babylon.module.d.ts 6.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @returns true if the loader can load the specified file
  1065. */
  1066. canLoad(extension: string): boolean;
  1067. /**
  1068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module "babylonjs/Engines/IPipelineContext" {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _getVertexShaderCode(): string | null;
  1100. /** @hidden */
  1101. _getFragmentShaderCode(): string | null;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module "babylonjs/Meshes/dataBuffer" {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. get underlyingResource(): any;
  1125. }
  1126. }
  1127. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1141. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1142. /** @hidden */
  1143. export interface ProcessingOptions {
  1144. defines: string[];
  1145. indexParameters: any;
  1146. isFragment: boolean;
  1147. shouldUseHighPrecisionShader: boolean;
  1148. supportsUniformBuffers: boolean;
  1149. shadersRepository: string;
  1150. includesShadersStore: {
  1151. [key: string]: string;
  1152. };
  1153. processor?: IShaderProcessor;
  1154. version: string;
  1155. platformName: string;
  1156. lookForClosingBracketForUniformBuffer?: boolean;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1160. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1186. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1187. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1188. /** @hidden */
  1189. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1190. process(preprocessors: {
  1191. [key: string]: string;
  1192. }, options: ProcessingOptions): string;
  1193. }
  1194. }
  1195. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1196. /** @hidden */
  1197. export class ShaderDefineExpression {
  1198. isTrue(preprocessors: {
  1199. [key: string]: string;
  1200. }): boolean;
  1201. private static _OperatorPriority;
  1202. private static _Stack;
  1203. static postfixToInfix(postfix: string[]): string;
  1204. static infixToPostfix(infix: string): string[];
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1208. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1209. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1210. /** @hidden */
  1211. export class ShaderCodeTestNode extends ShaderCodeNode {
  1212. testExpression: ShaderDefineExpression;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1222. define: string;
  1223. not: boolean;
  1224. constructor(define: string, not?: boolean);
  1225. isTrue(preprocessors: {
  1226. [key: string]: string;
  1227. }): boolean;
  1228. }
  1229. }
  1230. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1231. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1232. /** @hidden */
  1233. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1234. leftOperand: ShaderDefineExpression;
  1235. rightOperand: ShaderDefineExpression;
  1236. isTrue(preprocessors: {
  1237. [key: string]: string;
  1238. }): boolean;
  1239. }
  1240. }
  1241. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1242. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1243. /** @hidden */
  1244. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1256. define: string;
  1257. operand: string;
  1258. testValue: string;
  1259. constructor(define: string, operand: string, testValue: string);
  1260. isTrue(preprocessors: {
  1261. [key: string]: string;
  1262. }): boolean;
  1263. }
  1264. }
  1265. declare module "babylonjs/Offline/IOfflineProvider" {
  1266. /**
  1267. * Class used to enable access to offline support
  1268. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1269. */
  1270. export interface IOfflineProvider {
  1271. /**
  1272. * Gets a boolean indicating if scene must be saved in the database
  1273. */
  1274. enableSceneOffline: boolean;
  1275. /**
  1276. * Gets a boolean indicating if textures must be saved in the database
  1277. */
  1278. enableTexturesOffline: boolean;
  1279. /**
  1280. * Open the offline support and make it available
  1281. * @param successCallback defines the callback to call on success
  1282. * @param errorCallback defines the callback to call on error
  1283. */
  1284. open(successCallback: () => void, errorCallback: () => void): void;
  1285. /**
  1286. * Loads an image from the offline support
  1287. * @param url defines the url to load from
  1288. * @param image defines the target DOM image
  1289. */
  1290. loadImage(url: string, image: HTMLImageElement): void;
  1291. /**
  1292. * Loads a file from offline support
  1293. * @param url defines the URL to load from
  1294. * @param sceneLoaded defines a callback to call on success
  1295. * @param progressCallBack defines a callback to call when progress changed
  1296. * @param errorCallback defines a callback to call on error
  1297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1298. */
  1299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1300. }
  1301. }
  1302. declare module "babylonjs/Misc/filesInputStore" {
  1303. /**
  1304. * Class used to help managing file picking and drag'n'drop
  1305. * File Storage
  1306. */
  1307. export class FilesInputStore {
  1308. /**
  1309. * List of files ready to be loaded
  1310. */
  1311. static FilesToLoad: {
  1312. [key: string]: File;
  1313. };
  1314. }
  1315. }
  1316. declare module "babylonjs/Misc/retryStrategy" {
  1317. import { WebRequest } from "babylonjs/Misc/webRequest";
  1318. /**
  1319. * Class used to define a retry strategy when error happens while loading assets
  1320. */
  1321. export class RetryStrategy {
  1322. /**
  1323. * Function used to defines an exponential back off strategy
  1324. * @param maxRetries defines the maximum number of retries (3 by default)
  1325. * @param baseInterval defines the interval between retries
  1326. * @returns the strategy function to use
  1327. */
  1328. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/baseError" {
  1332. /**
  1333. * @ignore
  1334. * Application error to support additional information when loading a file
  1335. */
  1336. export abstract class BaseError extends Error {
  1337. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1338. }
  1339. }
  1340. declare module "babylonjs/Misc/fileTools" {
  1341. import { WebRequest } from "babylonjs/Misc/webRequest";
  1342. import { Nullable } from "babylonjs/types";
  1343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1344. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1345. import { BaseError } from "babylonjs/Misc/baseError";
  1346. /** @ignore */
  1347. export class LoadFileError extends BaseError {
  1348. request?: WebRequest;
  1349. file?: File;
  1350. /**
  1351. * Creates a new LoadFileError
  1352. * @param message defines the message of the error
  1353. * @param request defines the optional web request
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, object?: WebRequest | File);
  1357. }
  1358. /** @ignore */
  1359. export class RequestFileError extends BaseError {
  1360. request: WebRequest;
  1361. /**
  1362. * Creates a new LoadFileError
  1363. * @param message defines the message of the error
  1364. * @param request defines the optional web request
  1365. */
  1366. constructor(message: string, request: WebRequest);
  1367. }
  1368. /** @ignore */
  1369. export class ReadFileError extends BaseError {
  1370. file: File;
  1371. /**
  1372. * Creates a new ReadFileError
  1373. * @param message defines the message of the error
  1374. * @param file defines the optional file
  1375. */
  1376. constructor(message: string, file: File);
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export class FileTools {
  1382. /**
  1383. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1384. */
  1385. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1386. /**
  1387. * Gets or sets the base URL to use to load assets
  1388. */
  1389. static BaseUrl: string;
  1390. /**
  1391. * Default behaviour for cors in the application.
  1392. * It can be a string if the expected behavior is identical in the entire app.
  1393. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1394. */
  1395. static CorsBehavior: string | ((url: string | string[]) => string);
  1396. /**
  1397. * Gets or sets a function used to pre-process url before using them to load assets
  1398. */
  1399. static PreprocessUrl: (url: string) => string;
  1400. /**
  1401. * Removes unwanted characters from an url
  1402. * @param url defines the url to clean
  1403. * @returns the cleaned url
  1404. */
  1405. private static _CleanUrl;
  1406. /**
  1407. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1408. * @param url define the url we are trying
  1409. * @param element define the dom element where to configure the cors policy
  1410. */
  1411. static SetCorsBehavior(url: string | string[], element: {
  1412. crossOrigin: string | null;
  1413. }): void;
  1414. /**
  1415. * Loads an image as an HTMLImageElement.
  1416. * @param input url string, ArrayBuffer, or Blob to load
  1417. * @param onLoad callback called when the image successfully loads
  1418. * @param onError callback called when the image fails to load
  1419. * @param offlineProvider offline provider for caching
  1420. * @param mimeType optional mime type
  1421. * @returns the HTMLImageElement of the loaded image
  1422. */
  1423. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1424. /**
  1425. * Reads a file from a File object
  1426. * @param file defines the file to load
  1427. * @param onSuccess defines the callback to call when data is loaded
  1428. * @param onProgress defines the callback to call during loading process
  1429. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1430. * @param onError defines the callback to call when an error occurs
  1431. * @returns a file request object
  1432. */
  1433. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1434. /**
  1435. * Loads a file from a url
  1436. * @param url url to load
  1437. * @param onSuccess callback called when the file successfully loads
  1438. * @param onProgress callback called while file is loading (if the server supports this mode)
  1439. * @param offlineProvider defines the offline provider for caching
  1440. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1441. * @param onError callback called when the file fails to load
  1442. * @returns a file request object
  1443. */
  1444. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1445. /**
  1446. * Loads a file
  1447. * @param url url to load
  1448. * @param onSuccess callback called when the file successfully loads
  1449. * @param onProgress callback called while file is loading (if the server supports this mode)
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @param onOpened callback called when the web request is opened
  1453. * @returns a file request object
  1454. */
  1455. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1456. /**
  1457. * Checks if the loaded document was accessed via `file:`-Protocol.
  1458. * @returns boolean
  1459. */
  1460. static IsFileURL(): boolean;
  1461. }
  1462. }
  1463. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1464. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1465. import { WebRequest } from "babylonjs/Misc/webRequest";
  1466. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1467. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1468. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1469. /** @hidden */
  1470. export class ShaderProcessor {
  1471. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1472. private static _ProcessPrecision;
  1473. private static _ExtractOperation;
  1474. private static _BuildSubExpression;
  1475. private static _BuildExpression;
  1476. private static _MoveCursorWithinIf;
  1477. private static _MoveCursor;
  1478. private static _EvaluatePreProcessors;
  1479. private static _PreparePreProcessors;
  1480. private static _ProcessShaderConversion;
  1481. private static _ProcessIncludes;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. * @hidden
  1492. */
  1493. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1494. }
  1495. }
  1496. declare module "babylonjs/Maths/math.like" {
  1497. import { float, int, DeepImmutable } from "babylonjs/types";
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor4Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. a: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IColor3Like {
  1511. r: float;
  1512. g: float;
  1513. b: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector4Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. w: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector3Like {
  1528. x: float;
  1529. y: float;
  1530. z: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector2Like {
  1536. x: float;
  1537. y: float;
  1538. }
  1539. /**
  1540. * @hidden
  1541. */
  1542. export interface IMatrixLike {
  1543. toArray(): DeepImmutable<Float32Array>;
  1544. updateFlag: int;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IViewportLike {
  1550. x: float;
  1551. y: float;
  1552. width: float;
  1553. height: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IPlaneLike {
  1559. normal: IVector3Like;
  1560. d: float;
  1561. normalize(): void;
  1562. }
  1563. }
  1564. declare module "babylonjs/Materials/iEffectFallbacks" {
  1565. import { Effect } from "babylonjs/Materials/effect";
  1566. /**
  1567. * Interface used to define common properties for effect fallbacks
  1568. */
  1569. export interface IEffectFallbacks {
  1570. /**
  1571. * Removes the defines that should be removed when falling back.
  1572. * @param currentDefines defines the current define statements for the shader.
  1573. * @param effect defines the current effect we try to compile
  1574. * @returns The resulting defines with defines of the current rank removed.
  1575. */
  1576. reduce(currentDefines: string, effect: Effect): string;
  1577. /**
  1578. * Removes the fallback from the bound mesh.
  1579. */
  1580. unBindMesh(): void;
  1581. /**
  1582. * Checks to see if more fallbacks are still availible.
  1583. */
  1584. hasMoreFallbacks: boolean;
  1585. }
  1586. }
  1587. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1588. /**
  1589. * Class used to evalaute queries containing `and` and `or` operators
  1590. */
  1591. export class AndOrNotEvaluator {
  1592. /**
  1593. * Evaluate a query
  1594. * @param query defines the query to evaluate
  1595. * @param evaluateCallback defines the callback used to filter result
  1596. * @returns true if the query matches
  1597. */
  1598. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1599. private static _HandleParenthesisContent;
  1600. private static _SimplifyNegation;
  1601. }
  1602. }
  1603. declare module "babylonjs/Misc/tags" {
  1604. /**
  1605. * Class used to store custom tags
  1606. */
  1607. export class Tags {
  1608. /**
  1609. * Adds support for tags on the given object
  1610. * @param obj defines the object to use
  1611. */
  1612. static EnableFor(obj: any): void;
  1613. /**
  1614. * Removes tags support
  1615. * @param obj defines the object to use
  1616. */
  1617. static DisableFor(obj: any): void;
  1618. /**
  1619. * Gets a boolean indicating if the given object has tags
  1620. * @param obj defines the object to use
  1621. * @returns a boolean
  1622. */
  1623. static HasTags(obj: any): boolean;
  1624. /**
  1625. * Gets the tags available on a given object
  1626. * @param obj defines the object to use
  1627. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1628. * @returns the tags
  1629. */
  1630. static GetTags(obj: any, asString?: boolean): any;
  1631. /**
  1632. * Adds tags to an object
  1633. * @param obj defines the object to use
  1634. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1635. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1636. */
  1637. static AddTagsTo(obj: any, tagsString: string): void;
  1638. /**
  1639. * @hidden
  1640. */
  1641. static _AddTagTo(obj: any, tag: string): void;
  1642. /**
  1643. * Removes specific tags from a specific object
  1644. * @param obj defines the object to use
  1645. * @param tagsString defines the tags to remove
  1646. */
  1647. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _RemoveTagFrom(obj: any, tag: string): void;
  1652. /**
  1653. * Defines if tags hosted on an object match a given query
  1654. * @param obj defines the object to use
  1655. * @param tagsQuery defines the tag query
  1656. * @returns a boolean
  1657. */
  1658. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1659. }
  1660. }
  1661. declare module "babylonjs/Maths/math.scalar" {
  1662. /**
  1663. * Scalar computation library
  1664. */
  1665. export class Scalar {
  1666. /**
  1667. * Two pi constants convenient for computation.
  1668. */
  1669. static TwoPi: number;
  1670. /**
  1671. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. * @param a number
  1673. * @param b number
  1674. * @param epsilon (default = 1.401298E-45)
  1675. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1676. */
  1677. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1678. /**
  1679. * Returns a string : the upper case translation of the number i to hexadecimal.
  1680. * @param i number
  1681. * @returns the upper case translation of the number i to hexadecimal.
  1682. */
  1683. static ToHex(i: number): string;
  1684. /**
  1685. * Returns -1 if value is negative and +1 is value is positive.
  1686. * @param value the value
  1687. * @returns the value itself if it's equal to zero.
  1688. */
  1689. static Sign(value: number): number;
  1690. /**
  1691. * Returns the value itself if it's between min and max.
  1692. * Returns min if the value is lower than min.
  1693. * Returns max if the value is greater than max.
  1694. * @param value the value to clmap
  1695. * @param min the min value to clamp to (default: 0)
  1696. * @param max the max value to clamp to (default: 1)
  1697. * @returns the clamped value
  1698. */
  1699. static Clamp(value: number, min?: number, max?: number): number;
  1700. /**
  1701. * the log2 of value.
  1702. * @param value the value to compute log2 of
  1703. * @returns the log2 of value.
  1704. */
  1705. static Log2(value: number): number;
  1706. /**
  1707. * Loops the value, so that it is never larger than length and never smaller than 0.
  1708. *
  1709. * This is similar to the modulo operator but it works with floating point numbers.
  1710. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1711. * With t = 5 and length = 2.5, the result would be 0.0.
  1712. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1713. * @param value the value
  1714. * @param length the length
  1715. * @returns the looped value
  1716. */
  1717. static Repeat(value: number, length: number): number;
  1718. /**
  1719. * Normalize the value between 0.0 and 1.0 using min and max values
  1720. * @param value value to normalize
  1721. * @param min max to normalize between
  1722. * @param max min to normalize between
  1723. * @returns the normalized value
  1724. */
  1725. static Normalize(value: number, min: number, max: number): number;
  1726. /**
  1727. * Denormalize the value from 0.0 and 1.0 using min and max values
  1728. * @param normalized value to denormalize
  1729. * @param min max to denormalize between
  1730. * @param max min to denormalize between
  1731. * @returns the denormalized value
  1732. */
  1733. static Denormalize(normalized: number, min: number, max: number): number;
  1734. /**
  1735. * Calculates the shortest difference between two given angles given in degrees.
  1736. * @param current current angle in degrees
  1737. * @param target target angle in degrees
  1738. * @returns the delta
  1739. */
  1740. static DeltaAngle(current: number, target: number): number;
  1741. /**
  1742. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1743. * @param tx value
  1744. * @param length length
  1745. * @returns The returned value will move back and forth between 0 and length
  1746. */
  1747. static PingPong(tx: number, length: number): number;
  1748. /**
  1749. * Interpolates between min and max with smoothing at the limits.
  1750. *
  1751. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1752. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1753. * @param from from
  1754. * @param to to
  1755. * @param tx value
  1756. * @returns the smooth stepped value
  1757. */
  1758. static SmoothStep(from: number, to: number, tx: number): number;
  1759. /**
  1760. * Moves a value current towards target.
  1761. *
  1762. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1763. * Negative values of maxDelta pushes the value away from target.
  1764. * @param current current value
  1765. * @param target target value
  1766. * @param maxDelta max distance to move
  1767. * @returns resulting value
  1768. */
  1769. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1770. /**
  1771. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1772. *
  1773. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1774. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1775. * @param current current value
  1776. * @param target target value
  1777. * @param maxDelta max distance to move
  1778. * @returns resulting angle
  1779. */
  1780. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1781. /**
  1782. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static Lerp(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1791. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1792. * @param start start value
  1793. * @param end target value
  1794. * @param amount amount to lerp between
  1795. * @returns the lerped value
  1796. */
  1797. static LerpAngle(start: number, end: number, amount: number): number;
  1798. /**
  1799. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1800. * @param a start value
  1801. * @param b target value
  1802. * @param value value between a and b
  1803. * @returns the inverseLerp value
  1804. */
  1805. static InverseLerp(a: number, b: number, value: number): number;
  1806. /**
  1807. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1808. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1809. * @param value1 spline value
  1810. * @param tangent1 spline value
  1811. * @param value2 spline value
  1812. * @param tangent2 spline value
  1813. * @param amount input value
  1814. * @returns hermite result
  1815. */
  1816. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1817. /**
  1818. * Returns a random float number between and min and max values
  1819. * @param min min value of random
  1820. * @param max max value of random
  1821. * @returns random value
  1822. */
  1823. static RandomRange(min: number, max: number): number;
  1824. /**
  1825. * This function returns percentage of a number in a given range.
  1826. *
  1827. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1828. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1829. * @param number to convert to percentage
  1830. * @param min min range
  1831. * @param max max range
  1832. * @returns the percentage
  1833. */
  1834. static RangeToPercent(number: number, min: number, max: number): number;
  1835. /**
  1836. * This function returns number that corresponds to the percentage in a given range.
  1837. *
  1838. * PercentToRange(0.34,0,100) will return 34.
  1839. * @param percent to convert to number
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the number
  1843. */
  1844. static PercentToRange(percent: number, min: number, max: number): number;
  1845. /**
  1846. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1847. * @param angle The angle to normalize in radian.
  1848. * @return The converted angle.
  1849. */
  1850. static NormalizeRadians(angle: number): number;
  1851. }
  1852. }
  1853. declare module "babylonjs/Maths/math.constants" {
  1854. /**
  1855. * Constant used to convert a value to gamma space
  1856. * @ignorenaming
  1857. */
  1858. export const ToGammaSpace: number;
  1859. /**
  1860. * Constant used to convert a value to linear space
  1861. * @ignorenaming
  1862. */
  1863. export const ToLinearSpace = 2.2;
  1864. /**
  1865. * Constant used to define the minimal number value in Babylon.js
  1866. * @ignorenaming
  1867. */
  1868. let Epsilon: number;
  1869. export { Epsilon };
  1870. }
  1871. declare module "babylonjs/Maths/math.viewport" {
  1872. /**
  1873. * Class used to represent a viewport on screen
  1874. */
  1875. export class Viewport {
  1876. /** viewport left coordinate */
  1877. x: number;
  1878. /** viewport top coordinate */
  1879. y: number;
  1880. /**viewport width */
  1881. width: number;
  1882. /** viewport height */
  1883. height: number;
  1884. /**
  1885. * Creates a Viewport object located at (x, y) and sized (width, height)
  1886. * @param x defines viewport left coordinate
  1887. * @param y defines viewport top coordinate
  1888. * @param width defines the viewport width
  1889. * @param height defines the viewport height
  1890. */
  1891. constructor(
  1892. /** viewport left coordinate */
  1893. x: number,
  1894. /** viewport top coordinate */
  1895. y: number,
  1896. /**viewport width */
  1897. width: number,
  1898. /** viewport height */
  1899. height: number);
  1900. /**
  1901. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1902. * @param renderWidth defines the rendering width
  1903. * @param renderHeight defines the rendering height
  1904. * @returns a new Viewport
  1905. */
  1906. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1907. /**
  1908. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1909. * @param renderWidth defines the rendering width
  1910. * @param renderHeight defines the rendering height
  1911. * @param ref defines the target viewport
  1912. * @returns the current viewport
  1913. */
  1914. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1915. /**
  1916. * Returns a new Viewport copied from the current one
  1917. * @returns a new Viewport
  1918. */
  1919. clone(): Viewport;
  1920. }
  1921. }
  1922. declare module "babylonjs/Misc/arrayTools" {
  1923. /**
  1924. * Class containing a set of static utilities functions for arrays.
  1925. */
  1926. export class ArrayTools {
  1927. /**
  1928. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1929. * @param size the number of element to construct and put in the array
  1930. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1931. * @returns a new array filled with new objects
  1932. */
  1933. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1934. }
  1935. }
  1936. declare module "babylonjs/Maths/math.plane" {
  1937. import { DeepImmutable } from "babylonjs/types";
  1938. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1939. /**
  1940. * Represens a plane by the equation ax + by + cz + d = 0
  1941. */
  1942. export class Plane {
  1943. private static _TmpMatrix;
  1944. /**
  1945. * Normal of the plane (a,b,c)
  1946. */
  1947. normal: Vector3;
  1948. /**
  1949. * d component of the plane
  1950. */
  1951. d: number;
  1952. /**
  1953. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1954. * @param a a component of the plane
  1955. * @param b b component of the plane
  1956. * @param c c component of the plane
  1957. * @param d d component of the plane
  1958. */
  1959. constructor(a: number, b: number, c: number, d: number);
  1960. /**
  1961. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1962. */
  1963. asArray(): number[];
  1964. /**
  1965. * @returns a new plane copied from the current Plane.
  1966. */
  1967. clone(): Plane;
  1968. /**
  1969. * @returns the string "Plane".
  1970. */
  1971. getClassName(): string;
  1972. /**
  1973. * @returns the Plane hash code.
  1974. */
  1975. getHashCode(): number;
  1976. /**
  1977. * Normalize the current Plane in place.
  1978. * @returns the updated Plane.
  1979. */
  1980. normalize(): Plane;
  1981. /**
  1982. * Applies a transformation the plane and returns the result
  1983. * @param transformation the transformation matrix to be applied to the plane
  1984. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1985. */
  1986. transform(transformation: DeepImmutable<Matrix>): Plane;
  1987. /**
  1988. * Compute the dot product between the point and the plane normal
  1989. * @param point point to calculate the dot product with
  1990. * @returns the dot product (float) of the point coordinates and the plane normal.
  1991. */
  1992. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1993. /**
  1994. * Updates the current Plane from the plane defined by the three given points.
  1995. * @param point1 one of the points used to contruct the plane
  1996. * @param point2 one of the points used to contruct the plane
  1997. * @param point3 one of the points used to contruct the plane
  1998. * @returns the updated Plane.
  1999. */
  2000. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2001. /**
  2002. * Checks if the plane is facing a given direction
  2003. * @param direction the direction to check if the plane is facing
  2004. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2005. * @returns True is the vector "direction" is the same side than the plane normal.
  2006. */
  2007. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2008. /**
  2009. * Calculates the distance to a point
  2010. * @param point point to calculate distance to
  2011. * @returns the signed distance (float) from the given point to the Plane.
  2012. */
  2013. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2014. /**
  2015. * Creates a plane from an array
  2016. * @param array the array to create a plane from
  2017. * @returns a new Plane from the given array.
  2018. */
  2019. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2020. /**
  2021. * Creates a plane from three points
  2022. * @param point1 point used to create the plane
  2023. * @param point2 point used to create the plane
  2024. * @param point3 point used to create the plane
  2025. * @returns a new Plane defined by the three given points.
  2026. */
  2027. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2028. /**
  2029. * Creates a plane from an origin point and a normal
  2030. * @param origin origin of the plane to be constructed
  2031. * @param normal normal of the plane to be constructed
  2032. * @returns a new Plane the normal vector to this plane at the given origin point.
  2033. * Note : the vector "normal" is updated because normalized.
  2034. */
  2035. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Calculates the distance from a plane and a point
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @param point point to calculate distance to
  2041. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2042. */
  2043. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2044. }
  2045. }
  2046. declare module "babylonjs/Maths/math.vector" {
  2047. import { Viewport } from "babylonjs/Maths/math.viewport";
  2048. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2049. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2050. import { Plane } from "babylonjs/Maths/math.plane";
  2051. /**
  2052. * Class representing a vector containing 2 coordinates
  2053. */
  2054. export class Vector2 {
  2055. /** defines the first coordinate */
  2056. x: number;
  2057. /** defines the second coordinate */
  2058. y: number;
  2059. /**
  2060. * Creates a new Vector2 from the given x and y coordinates
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. */
  2064. constructor(
  2065. /** defines the first coordinate */
  2066. x?: number,
  2067. /** defines the second coordinate */
  2068. y?: number);
  2069. /**
  2070. * Gets a string with the Vector2 coordinates
  2071. * @returns a string with the Vector2 coordinates
  2072. */
  2073. toString(): string;
  2074. /**
  2075. * Gets class name
  2076. * @returns the string "Vector2"
  2077. */
  2078. getClassName(): string;
  2079. /**
  2080. * Gets current vector hash code
  2081. * @returns the Vector2 hash code as a number
  2082. */
  2083. getHashCode(): number;
  2084. /**
  2085. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2086. * @param array defines the source array
  2087. * @param index defines the offset in source array
  2088. * @returns the current Vector2
  2089. */
  2090. toArray(array: FloatArray, index?: number): Vector2;
  2091. /**
  2092. * Copy the current vector to an array
  2093. * @returns a new array with 2 elements: the Vector2 coordinates.
  2094. */
  2095. asArray(): number[];
  2096. /**
  2097. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2098. * @param source defines the source Vector2
  2099. * @returns the current updated Vector2
  2100. */
  2101. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2102. /**
  2103. * Sets the Vector2 coordinates with the given floats
  2104. * @param x defines the first coordinate
  2105. * @param y defines the second coordinate
  2106. * @returns the current updated Vector2
  2107. */
  2108. copyFromFloats(x: number, y: number): Vector2;
  2109. /**
  2110. * Sets the Vector2 coordinates with the given floats
  2111. * @param x defines the first coordinate
  2112. * @param y defines the second coordinate
  2113. * @returns the current updated Vector2
  2114. */
  2115. set(x: number, y: number): Vector2;
  2116. /**
  2117. * Add another vector with the current one
  2118. * @param otherVector defines the other vector
  2119. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2120. */
  2121. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2122. /**
  2123. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2124. * @param otherVector defines the other vector
  2125. * @param result defines the target vector
  2126. * @returns the unmodified current Vector2
  2127. */
  2128. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2129. /**
  2130. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2131. * @param otherVector defines the other vector
  2132. * @returns the current updated Vector2
  2133. */
  2134. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2135. /**
  2136. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2137. * @param otherVector defines the other vector
  2138. * @returns a new Vector2
  2139. */
  2140. addVector3(otherVector: Vector3): Vector2;
  2141. /**
  2142. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2143. * @param otherVector defines the other vector
  2144. * @returns a new Vector2
  2145. */
  2146. subtract(otherVector: Vector2): Vector2;
  2147. /**
  2148. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2149. * @param otherVector defines the other vector
  2150. * @param result defines the target vector
  2151. * @returns the unmodified current Vector2
  2152. */
  2153. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2154. /**
  2155. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2156. * @param otherVector defines the other vector
  2157. * @returns the current updated Vector2
  2158. */
  2159. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2160. /**
  2161. * Multiplies in place the current Vector2 coordinates by the given ones
  2162. * @param otherVector defines the other vector
  2163. * @returns the current updated Vector2
  2164. */
  2165. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2166. /**
  2167. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2168. * @param otherVector defines the other vector
  2169. * @returns a new Vector2
  2170. */
  2171. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2174. * @param otherVector defines the other vector
  2175. * @param result defines the target vector
  2176. * @returns the unmodified current Vector2
  2177. */
  2178. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2179. /**
  2180. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2181. * @param x defines the first coordinate
  2182. * @param y defines the second coordinate
  2183. * @returns a new Vector2
  2184. */
  2185. multiplyByFloats(x: number, y: number): Vector2;
  2186. /**
  2187. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2188. * @param otherVector defines the other vector
  2189. * @returns a new Vector2
  2190. */
  2191. divide(otherVector: Vector2): Vector2;
  2192. /**
  2193. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2194. * @param otherVector defines the other vector
  2195. * @param result defines the target vector
  2196. * @returns the unmodified current Vector2
  2197. */
  2198. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2199. /**
  2200. * Divides the current Vector2 coordinates by the given ones
  2201. * @param otherVector defines the other vector
  2202. * @returns the current updated Vector2
  2203. */
  2204. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 with current Vector2 negated coordinates
  2207. * @returns a new Vector2
  2208. */
  2209. negate(): Vector2;
  2210. /**
  2211. * Negate this vector in place
  2212. * @returns this
  2213. */
  2214. negateInPlace(): Vector2;
  2215. /**
  2216. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2217. * @param result defines the Vector3 object where to store the result
  2218. * @returns the current Vector2
  2219. */
  2220. negateToRef(result: Vector2): Vector2;
  2221. /**
  2222. * Multiply the Vector2 coordinates by scale
  2223. * @param scale defines the scaling factor
  2224. * @returns the current updated Vector2
  2225. */
  2226. scaleInPlace(scale: number): Vector2;
  2227. /**
  2228. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2229. * @param scale defines the scaling factor
  2230. * @returns a new Vector2
  2231. */
  2232. scale(scale: number): Vector2;
  2233. /**
  2234. * Scale the current Vector2 values by a factor to a given Vector2
  2235. * @param scale defines the scale factor
  2236. * @param result defines the Vector2 object where to store the result
  2237. * @returns the unmodified current Vector2
  2238. */
  2239. scaleToRef(scale: number, result: Vector2): Vector2;
  2240. /**
  2241. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2242. * @param scale defines the scale factor
  2243. * @param result defines the Vector2 object where to store the result
  2244. * @returns the unmodified current Vector2
  2245. */
  2246. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2247. /**
  2248. * Gets a boolean if two vectors are equals
  2249. * @param otherVector defines the other vector
  2250. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2251. */
  2252. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2253. /**
  2254. * Gets a boolean if two vectors are equals (using an epsilon value)
  2255. * @param otherVector defines the other vector
  2256. * @param epsilon defines the minimal distance to consider equality
  2257. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2258. */
  2259. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2260. /**
  2261. * Gets a new Vector2 from current Vector2 floored values
  2262. * @returns a new Vector2
  2263. */
  2264. floor(): Vector2;
  2265. /**
  2266. * Gets a new Vector2 from current Vector2 floored values
  2267. * @returns a new Vector2
  2268. */
  2269. fract(): Vector2;
  2270. /**
  2271. * Gets the length of the vector
  2272. * @returns the vector length (float)
  2273. */
  2274. length(): number;
  2275. /**
  2276. * Gets the vector squared length
  2277. * @returns the vector squared length (float)
  2278. */
  2279. lengthSquared(): number;
  2280. /**
  2281. * Normalize the vector
  2282. * @returns the current updated Vector2
  2283. */
  2284. normalize(): Vector2;
  2285. /**
  2286. * Gets a new Vector2 copied from the Vector2
  2287. * @returns a new Vector2
  2288. */
  2289. clone(): Vector2;
  2290. /**
  2291. * Gets a new Vector2(0, 0)
  2292. * @returns a new Vector2
  2293. */
  2294. static Zero(): Vector2;
  2295. /**
  2296. * Gets a new Vector2(1, 1)
  2297. * @returns a new Vector2
  2298. */
  2299. static One(): Vector2;
  2300. /**
  2301. * Gets a new Vector2 set from the given index element of the given array
  2302. * @param array defines the data source
  2303. * @param offset defines the offset in the data source
  2304. * @returns a new Vector2
  2305. */
  2306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2307. /**
  2308. * Sets "result" from the given index element of the given array
  2309. * @param array defines the data source
  2310. * @param offset defines the offset in the data source
  2311. * @param result defines the target vector
  2312. */
  2313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2314. /**
  2315. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2316. * @param value1 defines 1st point of control
  2317. * @param value2 defines 2nd point of control
  2318. * @param value3 defines 3rd point of control
  2319. * @param value4 defines 4th point of control
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * 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".
  2326. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2327. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2328. * @param value defines the value to clamp
  2329. * @param min defines the lower limit
  2330. * @param max defines the upper limit
  2331. * @returns a new Vector2
  2332. */
  2333. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2334. /**
  2335. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2336. * @param value1 defines the 1st control point
  2337. * @param tangent1 defines the outgoing tangent
  2338. * @param value2 defines the 2nd control point
  2339. * @param tangent2 defines the incoming tangent
  2340. * @param amount defines the interpolation factor
  2341. * @returns a new Vector2
  2342. */
  2343. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2344. /**
  2345. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2346. * @param start defines the start vector
  2347. * @param end defines the end vector
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Gets the dot product of the vector "left" and the vector "right"
  2354. * @param left defines first vector
  2355. * @param right defines second vector
  2356. * @returns the dot product (float)
  2357. */
  2358. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2359. /**
  2360. * Returns a new Vector2 equal to the normalized given vector
  2361. * @param vector defines the vector to normalize
  2362. * @returns a new Vector2
  2363. */
  2364. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2365. /**
  2366. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2367. * @param left defines 1st vector
  2368. * @param right defines 2nd vector
  2369. * @returns a new Vector2
  2370. */
  2371. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2372. /**
  2373. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2374. * @param left defines 1st vector
  2375. * @param right defines 2nd vector
  2376. * @returns a new Vector2
  2377. */
  2378. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2379. /**
  2380. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2381. * @param vector defines the vector to transform
  2382. * @param transformation defines the matrix to apply
  2383. * @returns a new Vector2
  2384. */
  2385. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2386. /**
  2387. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2388. * @param vector defines the vector to transform
  2389. * @param transformation defines the matrix to apply
  2390. * @param result defines the target vector
  2391. */
  2392. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2393. /**
  2394. * Determines if a given vector is included in a triangle
  2395. * @param p defines the vector to test
  2396. * @param p0 defines 1st triangle point
  2397. * @param p1 defines 2nd triangle point
  2398. * @param p2 defines 3rd triangle point
  2399. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2400. */
  2401. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2402. /**
  2403. * Gets the distance between the vectors "value1" and "value2"
  2404. * @param value1 defines first vector
  2405. * @param value2 defines second vector
  2406. * @returns the distance between vectors
  2407. */
  2408. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2409. /**
  2410. * Returns the squared distance between the vectors "value1" and "value2"
  2411. * @param value1 defines first vector
  2412. * @param value2 defines second vector
  2413. * @returns the squared distance between vectors
  2414. */
  2415. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2416. /**
  2417. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2418. * @param value1 defines first vector
  2419. * @param value2 defines second vector
  2420. * @returns a new Vector2
  2421. */
  2422. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2423. /**
  2424. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2425. * @param p defines the middle point
  2426. * @param segA defines one point of the segment
  2427. * @param segB defines the other point of the segment
  2428. * @returns the shortest distance
  2429. */
  2430. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2431. }
  2432. /**
  2433. * Class used to store (x,y,z) vector representation
  2434. * A Vector3 is the main object used in 3D geometry
  2435. * It can represent etiher the coordinates of a point the space, either a direction
  2436. * Reminder: js uses a left handed forward facing system
  2437. */
  2438. export class Vector3 {
  2439. /**
  2440. * Defines the first coordinates (on X axis)
  2441. */
  2442. x: number;
  2443. /**
  2444. * Defines the second coordinates (on Y axis)
  2445. */
  2446. y: number;
  2447. /**
  2448. * Defines the third coordinates (on Z axis)
  2449. */
  2450. z: number;
  2451. private static _UpReadOnly;
  2452. private static _ZeroReadOnly;
  2453. /**
  2454. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2455. * @param x defines the first coordinates (on X axis)
  2456. * @param y defines the second coordinates (on Y axis)
  2457. * @param z defines the third coordinates (on Z axis)
  2458. */
  2459. constructor(
  2460. /**
  2461. * Defines the first coordinates (on X axis)
  2462. */
  2463. x?: number,
  2464. /**
  2465. * Defines the second coordinates (on Y axis)
  2466. */
  2467. y?: number,
  2468. /**
  2469. * Defines the third coordinates (on Z axis)
  2470. */
  2471. z?: number);
  2472. /**
  2473. * Creates a string representation of the Vector3
  2474. * @returns a string with the Vector3 coordinates.
  2475. */
  2476. toString(): string;
  2477. /**
  2478. * Gets the class name
  2479. * @returns the string "Vector3"
  2480. */
  2481. getClassName(): string;
  2482. /**
  2483. * Creates the Vector3 hash code
  2484. * @returns a number which tends to be unique between Vector3 instances
  2485. */
  2486. getHashCode(): number;
  2487. /**
  2488. * Creates an array containing three elements : the coordinates of the Vector3
  2489. * @returns a new array of numbers
  2490. */
  2491. asArray(): number[];
  2492. /**
  2493. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2494. * @param array defines the destination array
  2495. * @param index defines the offset in the destination array
  2496. * @returns the current Vector3
  2497. */
  2498. toArray(array: FloatArray, index?: number): Vector3;
  2499. /**
  2500. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2501. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2502. */
  2503. toQuaternion(): Quaternion;
  2504. /**
  2505. * Adds the given vector to the current Vector3
  2506. * @param otherVector defines the second operand
  2507. * @returns the current updated Vector3
  2508. */
  2509. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Adds the given coordinates to the current Vector3
  2512. * @param x defines the x coordinate of the operand
  2513. * @param y defines the y coordinate of the operand
  2514. * @param z defines the z coordinate of the operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2518. /**
  2519. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the resulting Vector3
  2522. */
  2523. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Subtract the given vector from the current Vector3
  2533. * @param otherVector defines the second operand
  2534. * @returns the current updated Vector3
  2535. */
  2536. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2537. /**
  2538. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2539. * @param otherVector defines the second operand
  2540. * @returns the resulting Vector3
  2541. */
  2542. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Subtracts the given vector from the current Vector3 and stores the result in the 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. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the resulting Vector3
  2556. */
  2557. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2560. * @param x defines the x coordinate of the operand
  2561. * @param y defines the y coordinate of the operand
  2562. * @param z defines the z coordinate of the operand
  2563. * @param result defines the Vector3 object where to store the result
  2564. * @returns the current Vector3
  2565. */
  2566. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2567. /**
  2568. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2569. * @returns a new Vector3
  2570. */
  2571. negate(): Vector3;
  2572. /**
  2573. * Negate this vector in place
  2574. * @returns this
  2575. */
  2576. negateInPlace(): Vector3;
  2577. /**
  2578. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2579. * @param result defines the Vector3 object where to store the result
  2580. * @returns the current Vector3
  2581. */
  2582. negateToRef(result: Vector3): Vector3;
  2583. /**
  2584. * Multiplies the Vector3 coordinates by the float "scale"
  2585. * @param scale defines the multiplier factor
  2586. * @returns the current updated Vector3
  2587. */
  2588. scaleInPlace(scale: number): Vector3;
  2589. /**
  2590. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2591. * @param scale defines the multiplier factor
  2592. * @returns a new Vector3
  2593. */
  2594. scale(scale: number): Vector3;
  2595. /**
  2596. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2597. * @param scale defines the multiplier factor
  2598. * @param result defines the Vector3 object where to store the result
  2599. * @returns the current Vector3
  2600. */
  2601. scaleToRef(scale: number, result: Vector3): Vector3;
  2602. /**
  2603. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2604. * @param scale defines the scale factor
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the unmodified current Vector3
  2607. */
  2608. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2609. /**
  2610. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2611. * @param origin defines the origin of the projection ray
  2612. * @param plane defines the plane to project to
  2613. * @returns the projected vector3
  2614. */
  2615. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2616. /**
  2617. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2618. * @param origin defines the origin of the projection ray
  2619. * @param plane defines the plane to project to
  2620. * @param result defines the Vector3 where to store the result
  2621. */
  2622. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2623. /**
  2624. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2625. * @param otherVector defines the second operand
  2626. * @returns true if both vectors are equals
  2627. */
  2628. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2629. /**
  2630. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2631. * @param otherVector defines the second operand
  2632. * @param epsilon defines the minimal distance to define values as equals
  2633. * @returns true if both vectors are distant less than epsilon
  2634. */
  2635. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2636. /**
  2637. * Returns true if the current Vector3 coordinates equals the given floats
  2638. * @param x defines the x coordinate of the operand
  2639. * @param y defines the y coordinate of the operand
  2640. * @param z defines the z coordinate of the operand
  2641. * @returns true if both vectors are equals
  2642. */
  2643. equalsToFloats(x: number, y: number, z: number): boolean;
  2644. /**
  2645. * Multiplies the current Vector3 coordinates by the given ones
  2646. * @param otherVector defines the second operand
  2647. * @returns the current updated Vector3
  2648. */
  2649. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2650. /**
  2651. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2652. * @param otherVector defines the second operand
  2653. * @returns the new Vector3
  2654. */
  2655. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2658. * @param otherVector defines the second operand
  2659. * @param result defines the Vector3 object where to store the result
  2660. * @returns the current Vector3
  2661. */
  2662. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2663. /**
  2664. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2665. * @param x defines the x coordinate of the operand
  2666. * @param y defines the y coordinate of the operand
  2667. * @param z defines the z coordinate of the operand
  2668. * @returns the new Vector3
  2669. */
  2670. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2671. /**
  2672. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2673. * @param otherVector defines the second operand
  2674. * @returns the new Vector3
  2675. */
  2676. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2677. /**
  2678. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2679. * @param otherVector defines the second operand
  2680. * @param result defines the Vector3 object where to store the result
  2681. * @returns the current Vector3
  2682. */
  2683. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2684. /**
  2685. * Divides the current Vector3 coordinates by the given ones.
  2686. * @param otherVector defines the second operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. divideInPlace(otherVector: Vector3): Vector3;
  2690. /**
  2691. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2692. * @param other defines the second operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2696. /**
  2697. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2698. * @param other defines the second operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2702. /**
  2703. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns the current updated Vector3
  2708. */
  2709. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2710. /**
  2711. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the current updated Vector3
  2716. */
  2717. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2720. * Check if is non uniform within a certain amount of decimal places to account for this
  2721. * @param epsilon the amount the values can differ
  2722. * @returns if the the vector is non uniform to a certain number of decimal places
  2723. */
  2724. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2725. /**
  2726. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2727. */
  2728. get isNonUniform(): boolean;
  2729. /**
  2730. * Gets a new Vector3 from current Vector3 floored values
  2731. * @returns a new Vector3
  2732. */
  2733. floor(): Vector3;
  2734. /**
  2735. * Gets a new Vector3 from current Vector3 floored values
  2736. * @returns a new Vector3
  2737. */
  2738. fract(): Vector3;
  2739. /**
  2740. * Gets the length of the Vector3
  2741. * @returns the length of the Vector3
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Gets the squared length of the Vector3
  2746. * @returns squared length of the Vector3
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalize the current Vector3.
  2751. * Please note that this is an in place operation.
  2752. * @returns the current updated Vector3
  2753. */
  2754. normalize(): Vector3;
  2755. /**
  2756. * Reorders the x y z properties of the vector in place
  2757. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2758. * @returns the current updated vector
  2759. */
  2760. reorderInPlace(order: string): this;
  2761. /**
  2762. * Rotates the vector around 0,0,0 by a quaternion
  2763. * @param quaternion the rotation quaternion
  2764. * @param result vector to store the result
  2765. * @returns the resulting vector
  2766. */
  2767. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2768. /**
  2769. * Rotates a vector around a given point
  2770. * @param quaternion the rotation quaternion
  2771. * @param point the point to rotate around
  2772. * @param result vector to store the result
  2773. * @returns the resulting vector
  2774. */
  2775. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2776. /**
  2777. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2778. * The cross product is then orthogonal to both current and "other"
  2779. * @param other defines the right operand
  2780. * @returns the cross product
  2781. */
  2782. cross(other: Vector3): Vector3;
  2783. /**
  2784. * Normalize the current Vector3 with the given input length.
  2785. * Please note that this is an in place operation.
  2786. * @param len the length of the vector
  2787. * @returns the current updated Vector3
  2788. */
  2789. normalizeFromLength(len: number): Vector3;
  2790. /**
  2791. * Normalize the current Vector3 to a new vector
  2792. * @returns the new Vector3
  2793. */
  2794. normalizeToNew(): Vector3;
  2795. /**
  2796. * Normalize the current Vector3 to the reference
  2797. * @param reference define the Vector3 to update
  2798. * @returns the updated Vector3
  2799. */
  2800. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2801. /**
  2802. * Creates a new Vector3 copied from the current Vector3
  2803. * @returns the new Vector3
  2804. */
  2805. clone(): Vector3;
  2806. /**
  2807. * Copies the given vector coordinates to the current Vector3 ones
  2808. * @param source defines the source Vector3
  2809. * @returns the current updated Vector3
  2810. */
  2811. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2812. /**
  2813. * Copies the given floats to the current Vector3 coordinates
  2814. * @param x defines the x coordinate of the operand
  2815. * @param y defines the y coordinate of the operand
  2816. * @param z defines the z coordinate of the operand
  2817. * @returns the current updated Vector3
  2818. */
  2819. copyFromFloats(x: number, y: number, z: number): Vector3;
  2820. /**
  2821. * Copies the given floats to the current Vector3 coordinates
  2822. * @param x defines the x coordinate of the operand
  2823. * @param y defines the y coordinate of the operand
  2824. * @param z defines the z coordinate of the operand
  2825. * @returns the current updated Vector3
  2826. */
  2827. set(x: number, y: number, z: number): Vector3;
  2828. /**
  2829. * Copies the given float to the current Vector3 coordinates
  2830. * @param v defines the x, y and z coordinates of the operand
  2831. * @returns the current updated Vector3
  2832. */
  2833. setAll(v: number): Vector3;
  2834. /**
  2835. * Get the clip factor between two vectors
  2836. * @param vector0 defines the first operand
  2837. * @param vector1 defines the second operand
  2838. * @param axis defines the axis to use
  2839. * @param size defines the size along the axis
  2840. * @returns the clip factor
  2841. */
  2842. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2843. /**
  2844. * Get angle between two vectors
  2845. * @param vector0 angle between vector0 and vector1
  2846. * @param vector1 angle between vector0 and vector1
  2847. * @param normal direction of the normal
  2848. * @return the angle between vector0 and vector1
  2849. */
  2850. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2851. /**
  2852. * Returns a new Vector3 set from the index "offset" of the given array
  2853. * @param array defines the source array
  2854. * @param offset defines the offset in the source array
  2855. * @returns the new Vector3
  2856. */
  2857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2860. * @param array defines the source array
  2861. * @param offset defines the offset in the source array
  2862. * @returns the new Vector3
  2863. * @deprecated Please use FromArray instead.
  2864. */
  2865. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2866. /**
  2867. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2868. * @param array defines the source array
  2869. * @param offset defines the offset in the source array
  2870. * @param result defines the Vector3 where to store the result
  2871. */
  2872. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2873. /**
  2874. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2875. * @param array defines the source array
  2876. * @param offset defines the offset in the source array
  2877. * @param result defines the Vector3 where to store the result
  2878. * @deprecated Please use FromArrayToRef instead.
  2879. */
  2880. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2881. /**
  2882. * Sets the given vector "result" with the given floats.
  2883. * @param x defines the x coordinate of the source
  2884. * @param y defines the y coordinate of the source
  2885. * @param z defines the z coordinate of the source
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2891. * @returns a new empty Vector3
  2892. */
  2893. static Zero(): Vector3;
  2894. /**
  2895. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2896. * @returns a new unit Vector3
  2897. */
  2898. static One(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2901. * @returns a new up Vector3
  2902. */
  2903. static Up(): Vector3;
  2904. /**
  2905. * Gets a up Vector3 that must not be updated
  2906. */
  2907. static get UpReadOnly(): DeepImmutable<Vector3>;
  2908. /**
  2909. * Gets a zero Vector3 that must not be updated
  2910. */
  2911. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2912. /**
  2913. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2914. * @returns a new down Vector3
  2915. */
  2916. static Down(): Vector3;
  2917. /**
  2918. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2919. * @param rightHandedSystem is the scene right-handed (negative z)
  2920. * @returns a new forward Vector3
  2921. */
  2922. static Forward(rightHandedSystem?: boolean): Vector3;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2925. * @param rightHandedSystem is the scene right-handed (negative-z)
  2926. * @returns a new forward Vector3
  2927. */
  2928. static Backward(rightHandedSystem?: boolean): Vector3;
  2929. /**
  2930. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2931. * @returns a new right Vector3
  2932. */
  2933. static Right(): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2936. * @returns a new left Vector3
  2937. */
  2938. static Left(): Vector3;
  2939. /**
  2940. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2941. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2942. * @param vector defines the Vector3 to transform
  2943. * @param transformation defines the transformation matrix
  2944. * @returns the transformed Vector3
  2945. */
  2946. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2949. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2957. * This method computes tranformed coordinates only, not transformed direction vectors
  2958. * @param x define the x coordinate of the source vector
  2959. * @param y define the y coordinate of the source vector
  2960. * @param z define the z coordinate of the source vector
  2961. * @param transformation defines the transformation matrix
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2965. /**
  2966. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2967. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2968. * @param vector defines the Vector3 to transform
  2969. * @param transformation defines the transformation matrix
  2970. * @returns the new Vector3
  2971. */
  2972. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2973. /**
  2974. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2975. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @param result defines the Vector3 where to store the result
  2979. */
  2980. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2981. /**
  2982. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2983. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2984. * @param x define the x coordinate of the source vector
  2985. * @param y define the y coordinate of the source vector
  2986. * @param z define the z coordinate of the source vector
  2987. * @param transformation defines the transformation matrix
  2988. * @param result defines the Vector3 where to store the result
  2989. */
  2990. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2991. /**
  2992. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2993. * @param value1 defines the first control point
  2994. * @param value2 defines the second control point
  2995. * @param value3 defines the third control point
  2996. * @param value4 defines the fourth control point
  2997. * @param amount defines the amount on the spline to use
  2998. * @returns the new Vector3
  2999. */
  3000. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3001. /**
  3002. * 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"
  3003. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3004. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3005. * @param value defines the current value
  3006. * @param min defines the lower range value
  3007. * @param max defines the upper range value
  3008. * @returns the new Vector3
  3009. */
  3010. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * 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"
  3013. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3014. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3015. * @param value defines the current value
  3016. * @param min defines the lower range value
  3017. * @param max defines the upper range value
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3021. /**
  3022. * Checks if a given vector is inside a specific range
  3023. * @param v defines the vector to test
  3024. * @param min defines the minimum range
  3025. * @param max defines the maximum range
  3026. */
  3027. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3028. /**
  3029. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3030. * @param value1 defines the first control point
  3031. * @param tangent1 defines the first tangent vector
  3032. * @param value2 defines the second control point
  3033. * @param tangent2 defines the second tangent vector
  3034. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3035. * @returns the new Vector3
  3036. */
  3037. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3040. * @param start defines the start value
  3041. * @param end defines the end value
  3042. * @param amount max defines amount between both (between 0 and 1)
  3043. * @returns the new Vector3
  3044. */
  3045. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3046. /**
  3047. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3048. * @param start defines the start value
  3049. * @param end defines the end value
  3050. * @param amount max defines amount between both (between 0 and 1)
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3054. /**
  3055. * Returns the dot product (float) between the vectors "left" and "right"
  3056. * @param left defines the left operand
  3057. * @param right defines the right operand
  3058. * @returns the dot product
  3059. */
  3060. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3061. /**
  3062. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3063. * The cross product is then orthogonal to both "left" and "right"
  3064. * @param left defines the left operand
  3065. * @param right defines the right operand
  3066. * @returns the cross product
  3067. */
  3068. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3069. /**
  3070. * Sets the given vector "result" with the cross product of "left" and "right"
  3071. * The cross product is then orthogonal to both "left" and "right"
  3072. * @param left defines the left operand
  3073. * @param right defines the right operand
  3074. * @param result defines the Vector3 where to store the result
  3075. */
  3076. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3077. /**
  3078. * Returns a new Vector3 as the normalization of the given vector
  3079. * @param vector defines the Vector3 to normalize
  3080. * @returns the new Vector3
  3081. */
  3082. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3083. /**
  3084. * Sets the given vector "result" with the normalization of the given first vector
  3085. * @param vector defines the Vector3 to normalize
  3086. * @param result defines the Vector3 where to store the result
  3087. */
  3088. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3089. /**
  3090. * Project a Vector3 onto screen space
  3091. * @param vector defines the Vector3 to project
  3092. * @param world defines the world matrix to use
  3093. * @param transform defines the transform (view x projection) matrix to use
  3094. * @param viewport defines the screen viewport to use
  3095. * @returns the new Vector3
  3096. */
  3097. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3098. /** @hidden */
  3099. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3100. /**
  3101. * Unproject from screen space to object space
  3102. * @param source defines the screen space Vector3 to use
  3103. * @param viewportWidth defines the current width of the viewport
  3104. * @param viewportHeight defines the current height of the viewport
  3105. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3106. * @param transform defines the transform (view x projection) matrix to use
  3107. * @returns the new Vector3
  3108. */
  3109. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3110. /**
  3111. * Unproject from screen space to object space
  3112. * @param source defines the screen space Vector3 to use
  3113. * @param viewportWidth defines the current width of the viewport
  3114. * @param viewportHeight defines the current height of the viewport
  3115. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3116. * @param view defines the view matrix to use
  3117. * @param projection defines the projection matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @param result defines the Vector3 where to store the result
  3130. */
  3131. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param sourceX defines the screen space x coordinate to use
  3135. * @param sourceY defines the screen space y coordinate to use
  3136. * @param sourceZ defines the screen space z coordinate to use
  3137. * @param viewportWidth defines the current width of the viewport
  3138. * @param viewportHeight defines the current height of the viewport
  3139. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3140. * @param view defines the view matrix to use
  3141. * @param projection defines the projection matrix to use
  3142. * @param result defines the Vector3 where to store the result
  3143. */
  3144. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3145. /**
  3146. * Gets the minimal coordinate values between two Vector3
  3147. * @param left defines the first operand
  3148. * @param right defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Gets the maximal coordinate values between two Vector3
  3154. * @param left defines the first operand
  3155. * @param right defines the second operand
  3156. * @returns the new Vector3
  3157. */
  3158. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Returns the distance between the vectors "value1" and "value2"
  3161. * @param value1 defines the first operand
  3162. * @param value2 defines the second operand
  3163. * @returns the distance
  3164. */
  3165. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3166. /**
  3167. * Returns the squared distance between the vectors "value1" and "value2"
  3168. * @param value1 defines the first operand
  3169. * @param value2 defines the second operand
  3170. * @returns the squared distance
  3171. */
  3172. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3173. /**
  3174. * Returns a new Vector3 located at the center between "value1" and "value2"
  3175. * @param value1 defines the first operand
  3176. * @param value2 defines the second operand
  3177. * @returns the new Vector3
  3178. */
  3179. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3180. /**
  3181. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3182. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3183. * to something in order to rotate it from its local system to the given target system
  3184. * Note: axis1, axis2 and axis3 are normalized during this operation
  3185. * @param axis1 defines the first axis
  3186. * @param axis2 defines the second axis
  3187. * @param axis3 defines the third axis
  3188. * @returns a new Vector3
  3189. */
  3190. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3193. * @param axis1 defines the first axis
  3194. * @param axis2 defines the second axis
  3195. * @param axis3 defines the third axis
  3196. * @param ref defines the Vector3 where to store the result
  3197. */
  3198. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3199. }
  3200. /**
  3201. * Vector4 class created for EulerAngle class conversion to Quaternion
  3202. */
  3203. export class Vector4 {
  3204. /** x value of the vector */
  3205. x: number;
  3206. /** y value of the vector */
  3207. y: number;
  3208. /** z value of the vector */
  3209. z: number;
  3210. /** w value of the vector */
  3211. w: number;
  3212. /**
  3213. * Creates a Vector4 object from the given floats.
  3214. * @param x x value of the vector
  3215. * @param y y value of the vector
  3216. * @param z z value of the vector
  3217. * @param w w value of the vector
  3218. */
  3219. constructor(
  3220. /** x value of the vector */
  3221. x: number,
  3222. /** y value of the vector */
  3223. y: number,
  3224. /** z value of the vector */
  3225. z: number,
  3226. /** w value of the vector */
  3227. w: number);
  3228. /**
  3229. * Returns the string with the Vector4 coordinates.
  3230. * @returns a string containing all the vector values
  3231. */
  3232. toString(): string;
  3233. /**
  3234. * Returns the string "Vector4".
  3235. * @returns "Vector4"
  3236. */
  3237. getClassName(): string;
  3238. /**
  3239. * Returns the Vector4 hash code.
  3240. * @returns a unique hash code
  3241. */
  3242. getHashCode(): number;
  3243. /**
  3244. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3245. * @returns the resulting array
  3246. */
  3247. asArray(): number[];
  3248. /**
  3249. * Populates the given array from the given index with the Vector4 coordinates.
  3250. * @param array array to populate
  3251. * @param index index of the array to start at (default: 0)
  3252. * @returns the Vector4.
  3253. */
  3254. toArray(array: FloatArray, index?: number): Vector4;
  3255. /**
  3256. * Adds the given vector to the current Vector4.
  3257. * @param otherVector the vector to add
  3258. * @returns the updated Vector4.
  3259. */
  3260. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3261. /**
  3262. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3263. * @param otherVector the vector to add
  3264. * @returns the resulting vector
  3265. */
  3266. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3269. * @param otherVector the vector to add
  3270. * @param result the vector to store the result
  3271. * @returns the current Vector4.
  3272. */
  3273. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3274. /**
  3275. * Subtract in place the given vector from the current Vector4.
  3276. * @param otherVector the vector to subtract
  3277. * @returns the updated Vector4.
  3278. */
  3279. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3280. /**
  3281. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3282. * @param otherVector the vector to add
  3283. * @returns the new vector with the result
  3284. */
  3285. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3286. /**
  3287. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3288. * @param otherVector the vector to subtract
  3289. * @param result the vector to store the result
  3290. * @returns the current Vector4.
  3291. */
  3292. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3293. /**
  3294. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3295. */
  3296. /**
  3297. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3298. * @param x value to subtract
  3299. * @param y value to subtract
  3300. * @param z value to subtract
  3301. * @param w value to subtract
  3302. * @returns new vector containing the result
  3303. */
  3304. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3305. /**
  3306. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3307. * @param x value to subtract
  3308. * @param y value to subtract
  3309. * @param z value to subtract
  3310. * @param w value to subtract
  3311. * @param result the vector to store the result in
  3312. * @returns the current Vector4.
  3313. */
  3314. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3315. /**
  3316. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3317. * @returns a new vector with the negated values
  3318. */
  3319. negate(): Vector4;
  3320. /**
  3321. * Negate this vector in place
  3322. * @returns this
  3323. */
  3324. negateInPlace(): Vector4;
  3325. /**
  3326. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3327. * @param result defines the Vector3 object where to store the result
  3328. * @returns the current Vector4
  3329. */
  3330. negateToRef(result: Vector4): Vector4;
  3331. /**
  3332. * Multiplies the current Vector4 coordinates by scale (float).
  3333. * @param scale the number to scale with
  3334. * @returns the updated Vector4.
  3335. */
  3336. scaleInPlace(scale: number): Vector4;
  3337. /**
  3338. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3339. * @param scale the number to scale with
  3340. * @returns a new vector with the result
  3341. */
  3342. scale(scale: number): Vector4;
  3343. /**
  3344. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3345. * @param scale the number to scale with
  3346. * @param result a vector to store the result in
  3347. * @returns the current Vector4.
  3348. */
  3349. scaleToRef(scale: number, result: Vector4): Vector4;
  3350. /**
  3351. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3352. * @param scale defines the scale factor
  3353. * @param result defines the Vector4 object where to store the result
  3354. * @returns the unmodified current Vector4
  3355. */
  3356. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3357. /**
  3358. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3359. * @param otherVector the vector to compare against
  3360. * @returns true if they are equal
  3361. */
  3362. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3363. /**
  3364. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3365. * @param otherVector vector to compare against
  3366. * @param epsilon (Default: very small number)
  3367. * @returns true if they are equal
  3368. */
  3369. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3370. /**
  3371. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3372. * @param x x value to compare against
  3373. * @param y y value to compare against
  3374. * @param z z value to compare against
  3375. * @param w w value to compare against
  3376. * @returns true if equal
  3377. */
  3378. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3379. /**
  3380. * Multiplies in place the current Vector4 by the given one.
  3381. * @param otherVector vector to multiple with
  3382. * @returns the updated Vector4.
  3383. */
  3384. multiplyInPlace(otherVector: Vector4): Vector4;
  3385. /**
  3386. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3387. * @param otherVector vector to multiple with
  3388. * @returns resulting new vector
  3389. */
  3390. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3393. * @param otherVector vector to multiple with
  3394. * @param result vector to store the result
  3395. * @returns the current Vector4.
  3396. */
  3397. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3398. /**
  3399. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3400. * @param x x value multiply with
  3401. * @param y y value multiply with
  3402. * @param z z value multiply with
  3403. * @param w w value multiply with
  3404. * @returns resulting new vector
  3405. */
  3406. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3407. /**
  3408. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3409. * @param otherVector vector to devide with
  3410. * @returns resulting new vector
  3411. */
  3412. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3415. * @param otherVector vector to devide with
  3416. * @param result vector to store the result
  3417. * @returns the current Vector4.
  3418. */
  3419. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3420. /**
  3421. * Divides the current Vector3 coordinates by the given ones.
  3422. * @param otherVector vector to devide with
  3423. * @returns the updated Vector3.
  3424. */
  3425. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3428. * @param other defines the second operand
  3429. * @returns the current updated Vector4
  3430. */
  3431. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3434. * @param other defines the second operand
  3435. * @returns the current updated Vector4
  3436. */
  3437. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3438. /**
  3439. * Gets a new Vector4 from current Vector4 floored values
  3440. * @returns a new Vector4
  3441. */
  3442. floor(): Vector4;
  3443. /**
  3444. * Gets a new Vector4 from current Vector3 floored values
  3445. * @returns a new Vector4
  3446. */
  3447. fract(): Vector4;
  3448. /**
  3449. * Returns the Vector4 length (float).
  3450. * @returns the length
  3451. */
  3452. length(): number;
  3453. /**
  3454. * Returns the Vector4 squared length (float).
  3455. * @returns the length squared
  3456. */
  3457. lengthSquared(): number;
  3458. /**
  3459. * Normalizes in place the Vector4.
  3460. * @returns the updated Vector4.
  3461. */
  3462. normalize(): Vector4;
  3463. /**
  3464. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3465. * @returns this converted to a new vector3
  3466. */
  3467. toVector3(): Vector3;
  3468. /**
  3469. * Returns a new Vector4 copied from the current one.
  3470. * @returns the new cloned vector
  3471. */
  3472. clone(): Vector4;
  3473. /**
  3474. * Updates the current Vector4 with the given one coordinates.
  3475. * @param source the source vector to copy from
  3476. * @returns the updated Vector4.
  3477. */
  3478. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3479. /**
  3480. * Updates the current Vector4 coordinates with the given floats.
  3481. * @param x float to copy from
  3482. * @param y float to copy from
  3483. * @param z float to copy from
  3484. * @param w float to copy from
  3485. * @returns the updated Vector4.
  3486. */
  3487. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3488. /**
  3489. * Updates the current Vector4 coordinates with the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @returns the updated Vector4.
  3495. */
  3496. set(x: number, y: number, z: number, w: number): Vector4;
  3497. /**
  3498. * Copies the given float to the current Vector3 coordinates
  3499. * @param v defines the x, y, z and w coordinates of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. setAll(v: number): Vector4;
  3503. /**
  3504. * Returns a new Vector4 set from the starting index of the given array.
  3505. * @param array the array to pull values from
  3506. * @param offset the offset into the array to start at
  3507. * @returns the new vector
  3508. */
  3509. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3510. /**
  3511. * Updates the given vector "result" from the starting index of the given array.
  3512. * @param array the array to pull values from
  3513. * @param offset the offset into the array to start at
  3514. * @param result the vector to store the result in
  3515. */
  3516. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3517. /**
  3518. * Updates the given vector "result" from the starting index of the given Float32Array.
  3519. * @param array the array to pull values from
  3520. * @param offset the offset into the array to start at
  3521. * @param result the vector to store the result in
  3522. */
  3523. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3524. /**
  3525. * Updates the given vector "result" coordinates from the given floats.
  3526. * @param x float to set from
  3527. * @param y float to set from
  3528. * @param z float to set from
  3529. * @param w float to set from
  3530. * @param result the vector to the floats in
  3531. */
  3532. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3533. /**
  3534. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3535. * @returns the new vector
  3536. */
  3537. static Zero(): Vector4;
  3538. /**
  3539. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3540. * @returns the new vector
  3541. */
  3542. static One(): Vector4;
  3543. /**
  3544. * Returns a new normalized Vector4 from the given one.
  3545. * @param vector the vector to normalize
  3546. * @returns the vector
  3547. */
  3548. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3549. /**
  3550. * Updates the given vector "result" from the normalization of the given one.
  3551. * @param vector the vector to normalize
  3552. * @param result the vector to store the result in
  3553. */
  3554. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3555. /**
  3556. * Returns a vector with the minimum values from the left and right vectors
  3557. * @param left left vector to minimize
  3558. * @param right right vector to minimize
  3559. * @returns a new vector with the minimum of the left and right vector values
  3560. */
  3561. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a vector with the maximum values from the left and right vectors
  3564. * @param left left vector to maximize
  3565. * @param right right vector to maximize
  3566. * @returns a new vector with the maximum of the left and right vector values
  3567. */
  3568. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3569. /**
  3570. * Returns the distance (float) between the vectors "value1" and "value2".
  3571. * @param value1 value to calulate the distance between
  3572. * @param value2 value to calulate the distance between
  3573. * @return the distance between the two vectors
  3574. */
  3575. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3576. /**
  3577. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3578. * @param value1 value to calulate the distance between
  3579. * @param value2 value to calulate the distance between
  3580. * @return the distance between the two vectors squared
  3581. */
  3582. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3583. /**
  3584. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3585. * @param value1 value to calulate the center between
  3586. * @param value2 value to calulate the center between
  3587. * @return the center between the two vectors
  3588. */
  3589. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3590. /**
  3591. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3592. * This methods computes transformed normalized direction vectors only.
  3593. * @param vector the vector to transform
  3594. * @param transformation the transformation matrix to apply
  3595. * @returns the new vector
  3596. */
  3597. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3598. /**
  3599. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3600. * This methods computes transformed normalized direction vectors only.
  3601. * @param vector the vector to transform
  3602. * @param transformation the transformation matrix to apply
  3603. * @param result the vector to store the result in
  3604. */
  3605. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3606. /**
  3607. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3608. * This methods computes transformed normalized direction vectors only.
  3609. * @param x value to transform
  3610. * @param y value to transform
  3611. * @param z value to transform
  3612. * @param w value to transform
  3613. * @param transformation the transformation matrix to apply
  3614. * @param result the vector to store the results in
  3615. */
  3616. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3617. /**
  3618. * Creates a new Vector4 from a Vector3
  3619. * @param source defines the source data
  3620. * @param w defines the 4th component (default is 0)
  3621. * @returns a new Vector4
  3622. */
  3623. static FromVector3(source: Vector3, w?: number): Vector4;
  3624. }
  3625. /**
  3626. * Class used to store quaternion data
  3627. * @see https://en.wikipedia.org/wiki/Quaternion
  3628. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3629. */
  3630. export class Quaternion {
  3631. /** defines the first component (0 by default) */
  3632. x: number;
  3633. /** defines the second component (0 by default) */
  3634. y: number;
  3635. /** defines the third component (0 by default) */
  3636. z: number;
  3637. /** defines the fourth component (1.0 by default) */
  3638. w: number;
  3639. /**
  3640. * Creates a new Quaternion from the given floats
  3641. * @param x defines the first component (0 by default)
  3642. * @param y defines the second component (0 by default)
  3643. * @param z defines the third component (0 by default)
  3644. * @param w defines the fourth component (1.0 by default)
  3645. */
  3646. constructor(
  3647. /** defines the first component (0 by default) */
  3648. x?: number,
  3649. /** defines the second component (0 by default) */
  3650. y?: number,
  3651. /** defines the third component (0 by default) */
  3652. z?: number,
  3653. /** defines the fourth component (1.0 by default) */
  3654. w?: number);
  3655. /**
  3656. * Gets a string representation for the current quaternion
  3657. * @returns a string with the Quaternion coordinates
  3658. */
  3659. toString(): string;
  3660. /**
  3661. * Gets the class name of the quaternion
  3662. * @returns the string "Quaternion"
  3663. */
  3664. getClassName(): string;
  3665. /**
  3666. * Gets a hash code for this quaternion
  3667. * @returns the quaternion hash code
  3668. */
  3669. getHashCode(): number;
  3670. /**
  3671. * Copy the quaternion to an array
  3672. * @returns a new array populated with 4 elements from the quaternion coordinates
  3673. */
  3674. asArray(): number[];
  3675. /**
  3676. * Check if two quaternions are equals
  3677. * @param otherQuaternion defines the second operand
  3678. * @return true if the current quaternion and the given one coordinates are strictly equals
  3679. */
  3680. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3683. * @param otherQuaternion defines the other quaternion
  3684. * @param epsilon defines the minimal distance to consider equality
  3685. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3686. */
  3687. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3688. /**
  3689. * Clone the current quaternion
  3690. * @returns a new quaternion copied from the current one
  3691. */
  3692. clone(): Quaternion;
  3693. /**
  3694. * Copy a quaternion to the current one
  3695. * @param other defines the other quaternion
  3696. * @returns the updated current quaternion
  3697. */
  3698. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Updates the current quaternion with the given float coordinates
  3701. * @param x defines the x coordinate
  3702. * @param y defines the y coordinate
  3703. * @param z defines the z coordinate
  3704. * @param w defines the w coordinate
  3705. * @returns the updated current quaternion
  3706. */
  3707. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3708. /**
  3709. * Updates the current quaternion from the given float coordinates
  3710. * @param x defines the x coordinate
  3711. * @param y defines the y coordinate
  3712. * @param z defines the z coordinate
  3713. * @param w defines the w coordinate
  3714. * @returns the updated current quaternion
  3715. */
  3716. set(x: number, y: number, z: number, w: number): Quaternion;
  3717. /**
  3718. * Adds two quaternions
  3719. * @param other defines the second operand
  3720. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3721. */
  3722. add(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Add a quaternion to the current one
  3725. * @param other defines the quaternion to add
  3726. * @returns the current quaternion
  3727. */
  3728. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3729. /**
  3730. * Subtract two quaternions
  3731. * @param other defines the second operand
  3732. * @returns a new quaternion as the subtraction result of the given one from the current one
  3733. */
  3734. subtract(other: Quaternion): Quaternion;
  3735. /**
  3736. * Multiplies the current quaternion by a scale factor
  3737. * @param value defines the scale factor
  3738. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3739. */
  3740. scale(value: number): Quaternion;
  3741. /**
  3742. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3743. * @param scale defines the scale factor
  3744. * @param result defines the Quaternion object where to store the result
  3745. * @returns the unmodified current quaternion
  3746. */
  3747. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3748. /**
  3749. * Multiplies in place the current quaternion by a scale factor
  3750. * @param value defines the scale factor
  3751. * @returns the current modified quaternion
  3752. */
  3753. scaleInPlace(value: number): Quaternion;
  3754. /**
  3755. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3756. * @param scale defines the scale factor
  3757. * @param result defines the Quaternion object where to store the result
  3758. * @returns the unmodified current quaternion
  3759. */
  3760. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3761. /**
  3762. * Multiplies two quaternions
  3763. * @param q1 defines the second operand
  3764. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3765. */
  3766. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3767. /**
  3768. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3769. * @param q1 defines the second operand
  3770. * @param result defines the target quaternion
  3771. * @returns the current quaternion
  3772. */
  3773. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3774. /**
  3775. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3776. * @param q1 defines the second operand
  3777. * @returns the currentupdated quaternion
  3778. */
  3779. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3780. /**
  3781. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3782. * @param ref defines the target quaternion
  3783. * @returns the current quaternion
  3784. */
  3785. conjugateToRef(ref: Quaternion): Quaternion;
  3786. /**
  3787. * Conjugates in place (1-q) the current quaternion
  3788. * @returns the current updated quaternion
  3789. */
  3790. conjugateInPlace(): Quaternion;
  3791. /**
  3792. * Conjugates in place (1-q) the current quaternion
  3793. * @returns a new quaternion
  3794. */
  3795. conjugate(): Quaternion;
  3796. /**
  3797. * Gets length of current quaternion
  3798. * @returns the quaternion length (float)
  3799. */
  3800. length(): number;
  3801. /**
  3802. * Normalize in place the current quaternion
  3803. * @returns the current updated quaternion
  3804. */
  3805. normalize(): Quaternion;
  3806. /**
  3807. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3808. * @param order is a reserved parameter and is ignore for now
  3809. * @returns a new Vector3 containing the Euler angles
  3810. */
  3811. toEulerAngles(order?: string): Vector3;
  3812. /**
  3813. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3814. * @param result defines the vector which will be filled with the Euler angles
  3815. * @param order is a reserved parameter and is ignore for now
  3816. * @returns the current unchanged quaternion
  3817. */
  3818. toEulerAnglesToRef(result: Vector3): Quaternion;
  3819. /**
  3820. * Updates the given rotation matrix with the current quaternion values
  3821. * @param result defines the target matrix
  3822. * @returns the current unchanged quaternion
  3823. */
  3824. toRotationMatrix(result: Matrix): Quaternion;
  3825. /**
  3826. * Updates the current quaternion from the given rotation matrix values
  3827. * @param matrix defines the source matrix
  3828. * @returns the current updated quaternion
  3829. */
  3830. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3831. /**
  3832. * Creates a new quaternion from a rotation matrix
  3833. * @param matrix defines the source matrix
  3834. * @returns a new quaternion created from the given rotation matrix values
  3835. */
  3836. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3837. /**
  3838. * Updates the given quaternion with the given rotation matrix values
  3839. * @param matrix defines the source matrix
  3840. * @param result defines the target quaternion
  3841. */
  3842. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3843. /**
  3844. * Returns the dot product (float) between the quaternions "left" and "right"
  3845. * @param left defines the left operand
  3846. * @param right defines the right operand
  3847. * @returns the dot product
  3848. */
  3849. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3850. /**
  3851. * Checks if the two quaternions are close to each other
  3852. * @param quat0 defines the first quaternion to check
  3853. * @param quat1 defines the second quaternion to check
  3854. * @returns true if the two quaternions are close to each other
  3855. */
  3856. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3857. /**
  3858. * Creates an empty quaternion
  3859. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3860. */
  3861. static Zero(): Quaternion;
  3862. /**
  3863. * Inverse a given quaternion
  3864. * @param q defines the source quaternion
  3865. * @returns a new quaternion as the inverted current quaternion
  3866. */
  3867. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3868. /**
  3869. * Inverse a given quaternion
  3870. * @param q defines the source quaternion
  3871. * @param result the quaternion the result will be stored in
  3872. * @returns the result quaternion
  3873. */
  3874. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3875. /**
  3876. * Creates an identity quaternion
  3877. * @returns the identity quaternion
  3878. */
  3879. static Identity(): Quaternion;
  3880. /**
  3881. * Gets a boolean indicating if the given quaternion is identity
  3882. * @param quaternion defines the quaternion to check
  3883. * @returns true if the quaternion is identity
  3884. */
  3885. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3886. /**
  3887. * Creates a quaternion from a rotation around an axis
  3888. * @param axis defines the axis to use
  3889. * @param angle defines the angle to use
  3890. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3891. */
  3892. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3893. /**
  3894. * Creates a rotation around an axis and stores it into the given quaternion
  3895. * @param axis defines the axis to use
  3896. * @param angle defines the angle to use
  3897. * @param result defines the target quaternion
  3898. * @returns the target quaternion
  3899. */
  3900. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3901. /**
  3902. * Creates a new quaternion from data stored into an array
  3903. * @param array defines the data source
  3904. * @param offset defines the offset in the source array where the data starts
  3905. * @returns a new quaternion
  3906. */
  3907. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3908. /**
  3909. * Updates the given quaternion "result" from the starting index of the given array.
  3910. * @param array the array to pull values from
  3911. * @param offset the offset into the array to start at
  3912. * @param result the quaternion to store the result in
  3913. */
  3914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3915. /**
  3916. * Create a quaternion from Euler rotation angles
  3917. * @param x Pitch
  3918. * @param y Yaw
  3919. * @param z Roll
  3920. * @returns the new Quaternion
  3921. */
  3922. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3923. /**
  3924. * Updates a quaternion from Euler rotation angles
  3925. * @param x Pitch
  3926. * @param y Yaw
  3927. * @param z Roll
  3928. * @param result the quaternion to store the result
  3929. * @returns the updated quaternion
  3930. */
  3931. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3932. /**
  3933. * Create a quaternion from Euler rotation vector
  3934. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3935. * @returns the new Quaternion
  3936. */
  3937. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3938. /**
  3939. * Updates a quaternion from Euler rotation vector
  3940. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3941. * @param result the quaternion to store the result
  3942. * @returns the updated quaternion
  3943. */
  3944. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3945. /**
  3946. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3947. * @param yaw defines the rotation around Y axis
  3948. * @param pitch defines the rotation around X axis
  3949. * @param roll defines the rotation around Z axis
  3950. * @returns the new quaternion
  3951. */
  3952. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3953. /**
  3954. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3955. * @param yaw defines the rotation around Y axis
  3956. * @param pitch defines the rotation around X axis
  3957. * @param roll defines the rotation around Z axis
  3958. * @param result defines the target quaternion
  3959. */
  3960. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3961. /**
  3962. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3963. * @param alpha defines the rotation around first axis
  3964. * @param beta defines the rotation around second axis
  3965. * @param gamma defines the rotation around third axis
  3966. * @returns the new quaternion
  3967. */
  3968. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3971. * @param alpha defines the rotation around first axis
  3972. * @param beta defines the rotation around second axis
  3973. * @param gamma defines the rotation around third axis
  3974. * @param result defines the target quaternion
  3975. */
  3976. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3977. /**
  3978. * 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)
  3979. * @param axis1 defines the first axis
  3980. * @param axis2 defines the second axis
  3981. * @param axis3 defines the third axis
  3982. * @returns the new quaternion
  3983. */
  3984. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3985. /**
  3986. * 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
  3987. * @param axis1 defines the first axis
  3988. * @param axis2 defines the second axis
  3989. * @param axis3 defines the third axis
  3990. * @param ref defines the target quaternion
  3991. */
  3992. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3993. /**
  3994. * Interpolates between two quaternions
  3995. * @param left defines first quaternion
  3996. * @param right defines second quaternion
  3997. * @param amount defines the gradient to use
  3998. * @returns the new interpolated quaternion
  3999. */
  4000. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4001. /**
  4002. * Interpolates between two quaternions and stores it into a target quaternion
  4003. * @param left defines first quaternion
  4004. * @param right defines second quaternion
  4005. * @param amount defines the gradient to use
  4006. * @param result defines the target quaternion
  4007. */
  4008. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4009. /**
  4010. * Interpolate between two quaternions using Hermite interpolation
  4011. * @param value1 defines first quaternion
  4012. * @param tangent1 defines the incoming tangent
  4013. * @param value2 defines second quaternion
  4014. * @param tangent2 defines the outgoing tangent
  4015. * @param amount defines the target quaternion
  4016. * @returns the new interpolated quaternion
  4017. */
  4018. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4019. }
  4020. /**
  4021. * Class used to store matrix data (4x4)
  4022. */
  4023. export class Matrix {
  4024. private static _updateFlagSeed;
  4025. private static _identityReadOnly;
  4026. private _isIdentity;
  4027. private _isIdentityDirty;
  4028. private _isIdentity3x2;
  4029. private _isIdentity3x2Dirty;
  4030. /**
  4031. * Gets the update flag of the matrix which is an unique number for the matrix.
  4032. * It will be incremented every time the matrix data change.
  4033. * You can use it to speed the comparison between two versions of the same matrix.
  4034. */
  4035. updateFlag: number;
  4036. private readonly _m;
  4037. /**
  4038. * Gets the internal data of the matrix
  4039. */
  4040. get m(): DeepImmutable<Float32Array>;
  4041. /** @hidden */
  4042. _markAsUpdated(): void;
  4043. /** @hidden */
  4044. private _updateIdentityStatus;
  4045. /**
  4046. * Creates an empty matrix (filled with zeros)
  4047. */
  4048. constructor();
  4049. /**
  4050. * Check if the current matrix is identity
  4051. * @returns true is the matrix is the identity matrix
  4052. */
  4053. isIdentity(): boolean;
  4054. /**
  4055. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4056. * @returns true is the matrix is the identity matrix
  4057. */
  4058. isIdentityAs3x2(): boolean;
  4059. /**
  4060. * Gets the determinant of the matrix
  4061. * @returns the matrix determinant
  4062. */
  4063. determinant(): number;
  4064. /**
  4065. * Returns the matrix as a Float32Array
  4066. * @returns the matrix underlying array
  4067. */
  4068. toArray(): DeepImmutable<Float32Array>;
  4069. /**
  4070. * Returns the matrix as a Float32Array
  4071. * @returns the matrix underlying array.
  4072. */
  4073. asArray(): DeepImmutable<Float32Array>;
  4074. /**
  4075. * Inverts the current matrix in place
  4076. * @returns the current inverted matrix
  4077. */
  4078. invert(): Matrix;
  4079. /**
  4080. * Sets all the matrix elements to zero
  4081. * @returns the current matrix
  4082. */
  4083. reset(): Matrix;
  4084. /**
  4085. * Adds the current matrix with a second one
  4086. * @param other defines the matrix to add
  4087. * @returns a new matrix as the addition of the current matrix and the given one
  4088. */
  4089. add(other: DeepImmutable<Matrix>): Matrix;
  4090. /**
  4091. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4092. * @param other defines the matrix to add
  4093. * @param result defines the target matrix
  4094. * @returns the current matrix
  4095. */
  4096. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4097. /**
  4098. * Adds in place the given matrix to the current matrix
  4099. * @param other defines the second operand
  4100. * @returns the current updated matrix
  4101. */
  4102. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4103. /**
  4104. * Sets the given matrix to the current inverted Matrix
  4105. * @param other defines the target matrix
  4106. * @returns the unmodified current matrix
  4107. */
  4108. invertToRef(other: Matrix): Matrix;
  4109. /**
  4110. * add a value at the specified position in the current Matrix
  4111. * @param index the index of the value within the matrix. between 0 and 15.
  4112. * @param value the value to be added
  4113. * @returns the current updated matrix
  4114. */
  4115. addAtIndex(index: number, value: number): Matrix;
  4116. /**
  4117. * mutiply the specified position in the current Matrix by a value
  4118. * @param index the index of the value within the matrix. between 0 and 15.
  4119. * @param value the value to be added
  4120. * @returns the current updated matrix
  4121. */
  4122. multiplyAtIndex(index: number, value: number): Matrix;
  4123. /**
  4124. * Inserts the translation vector (using 3 floats) in the current matrix
  4125. * @param x defines the 1st component of the translation
  4126. * @param y defines the 2nd component of the translation
  4127. * @param z defines the 3rd component of the translation
  4128. * @returns the current updated matrix
  4129. */
  4130. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4131. /**
  4132. * Adds the translation vector (using 3 floats) in the current matrix
  4133. * @param x defines the 1st component of the translation
  4134. * @param y defines the 2nd component of the translation
  4135. * @param z defines the 3rd component of the translation
  4136. * @returns the current updated matrix
  4137. */
  4138. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4139. /**
  4140. * Inserts the translation vector in the current matrix
  4141. * @param vector3 defines the translation to insert
  4142. * @returns the current updated matrix
  4143. */
  4144. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4145. /**
  4146. * Gets the translation value of the current matrix
  4147. * @returns a new Vector3 as the extracted translation from the matrix
  4148. */
  4149. getTranslation(): Vector3;
  4150. /**
  4151. * Fill a Vector3 with the extracted translation from the matrix
  4152. * @param result defines the Vector3 where to store the translation
  4153. * @returns the current matrix
  4154. */
  4155. getTranslationToRef(result: Vector3): Matrix;
  4156. /**
  4157. * Remove rotation and scaling part from the matrix
  4158. * @returns the updated matrix
  4159. */
  4160. removeRotationAndScaling(): Matrix;
  4161. /**
  4162. * Multiply two matrices
  4163. * @param other defines the second operand
  4164. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4165. */
  4166. multiply(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Copy the current matrix from the given one
  4169. * @param other defines the source matrix
  4170. * @returns the current updated matrix
  4171. */
  4172. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4173. /**
  4174. * Populates the given array from the starting index with the current matrix values
  4175. * @param array defines the target array
  4176. * @param offset defines the offset in the target array where to start storing values
  4177. * @returns the current matrix
  4178. */
  4179. copyToArray(array: Float32Array, offset?: number): Matrix;
  4180. /**
  4181. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4182. * @param other defines the second operand
  4183. * @param result defines the matrix where to store the multiplication
  4184. * @returns the current matrix
  4185. */
  4186. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4187. /**
  4188. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4189. * @param other defines the second operand
  4190. * @param result defines the array where to store the multiplication
  4191. * @param offset defines the offset in the target array where to start storing values
  4192. * @returns the current matrix
  4193. */
  4194. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4195. /**
  4196. * Check equality between this matrix and a second one
  4197. * @param value defines the second matrix to compare
  4198. * @returns true is the current matrix and the given one values are strictly equal
  4199. */
  4200. equals(value: DeepImmutable<Matrix>): boolean;
  4201. /**
  4202. * Clone the current matrix
  4203. * @returns a new matrix from the current matrix
  4204. */
  4205. clone(): Matrix;
  4206. /**
  4207. * Returns the name of the current matrix class
  4208. * @returns the string "Matrix"
  4209. */
  4210. getClassName(): string;
  4211. /**
  4212. * Gets the hash code of the current matrix
  4213. * @returns the hash code
  4214. */
  4215. getHashCode(): number;
  4216. /**
  4217. * Decomposes the current Matrix into a translation, rotation and scaling components
  4218. * @param scale defines the scale vector3 given as a reference to update
  4219. * @param rotation defines the rotation quaternion given as a reference to update
  4220. * @param translation defines the translation vector3 given as a reference to update
  4221. * @returns true if operation was successful
  4222. */
  4223. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4224. /**
  4225. * Gets specific row of the matrix
  4226. * @param index defines the number of the row to get
  4227. * @returns the index-th row of the current matrix as a new Vector4
  4228. */
  4229. getRow(index: number): Nullable<Vector4>;
  4230. /**
  4231. * Sets the index-th row of the current matrix to the vector4 values
  4232. * @param index defines the number of the row to set
  4233. * @param row defines the target vector4
  4234. * @returns the updated current matrix
  4235. */
  4236. setRow(index: number, row: Vector4): Matrix;
  4237. /**
  4238. * Compute the transpose of the matrix
  4239. * @returns the new transposed matrix
  4240. */
  4241. transpose(): Matrix;
  4242. /**
  4243. * Compute the transpose of the matrix and store it in a given matrix
  4244. * @param result defines the target matrix
  4245. * @returns the current matrix
  4246. */
  4247. transposeToRef(result: Matrix): Matrix;
  4248. /**
  4249. * Sets the index-th row of the current matrix with the given 4 x float values
  4250. * @param index defines the row index
  4251. * @param x defines the x component to set
  4252. * @param y defines the y component to set
  4253. * @param z defines the z component to set
  4254. * @param w defines the w component to set
  4255. * @returns the updated current matrix
  4256. */
  4257. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4258. /**
  4259. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4260. * @param scale defines the scale factor
  4261. * @returns a new matrix
  4262. */
  4263. scale(scale: number): Matrix;
  4264. /**
  4265. * Scale the current matrix values by a factor to a given result matrix
  4266. * @param scale defines the scale factor
  4267. * @param result defines the matrix to store the result
  4268. * @returns the current matrix
  4269. */
  4270. scaleToRef(scale: number, result: Matrix): Matrix;
  4271. /**
  4272. * Scale the current matrix values by a factor and add the result to a given matrix
  4273. * @param scale defines the scale factor
  4274. * @param result defines the Matrix to store the result
  4275. * @returns the current matrix
  4276. */
  4277. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4278. /**
  4279. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4280. * @param ref matrix to store the result
  4281. */
  4282. toNormalMatrix(ref: Matrix): void;
  4283. /**
  4284. * Gets only rotation part of the current matrix
  4285. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4286. */
  4287. getRotationMatrix(): Matrix;
  4288. /**
  4289. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4290. * @param result defines the target matrix to store data to
  4291. * @returns the current matrix
  4292. */
  4293. getRotationMatrixToRef(result: Matrix): Matrix;
  4294. /**
  4295. * Toggles model matrix from being right handed to left handed in place and vice versa
  4296. */
  4297. toggleModelMatrixHandInPlace(): void;
  4298. /**
  4299. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4300. */
  4301. toggleProjectionMatrixHandInPlace(): void;
  4302. /**
  4303. * Creates a matrix from an array
  4304. * @param array defines the source array
  4305. * @param offset defines an offset in the source array
  4306. * @returns a new Matrix set from the starting index of the given array
  4307. */
  4308. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4309. /**
  4310. * Copy the content of an array into a given matrix
  4311. * @param array defines the source array
  4312. * @param offset defines an offset in the source array
  4313. * @param result defines the target matrix
  4314. */
  4315. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4316. /**
  4317. * Stores an array into a matrix after having multiplied each component by a given factor
  4318. * @param array defines the source array
  4319. * @param offset defines the offset in the source array
  4320. * @param scale defines the scaling factor
  4321. * @param result defines the target matrix
  4322. */
  4323. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4324. /**
  4325. * Gets an identity matrix that must not be updated
  4326. */
  4327. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4328. /**
  4329. * Stores a list of values (16) inside a given matrix
  4330. * @param initialM11 defines 1st value of 1st row
  4331. * @param initialM12 defines 2nd value of 1st row
  4332. * @param initialM13 defines 3rd value of 1st row
  4333. * @param initialM14 defines 4th value of 1st row
  4334. * @param initialM21 defines 1st value of 2nd row
  4335. * @param initialM22 defines 2nd value of 2nd row
  4336. * @param initialM23 defines 3rd value of 2nd row
  4337. * @param initialM24 defines 4th value of 2nd row
  4338. * @param initialM31 defines 1st value of 3rd row
  4339. * @param initialM32 defines 2nd value of 3rd row
  4340. * @param initialM33 defines 3rd value of 3rd row
  4341. * @param initialM34 defines 4th value of 3rd row
  4342. * @param initialM41 defines 1st value of 4th row
  4343. * @param initialM42 defines 2nd value of 4th row
  4344. * @param initialM43 defines 3rd value of 4th row
  4345. * @param initialM44 defines 4th value of 4th row
  4346. * @param result defines the target matrix
  4347. */
  4348. 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;
  4349. /**
  4350. * Creates new matrix from a list of values (16)
  4351. * @param initialM11 defines 1st value of 1st row
  4352. * @param initialM12 defines 2nd value of 1st row
  4353. * @param initialM13 defines 3rd value of 1st row
  4354. * @param initialM14 defines 4th value of 1st row
  4355. * @param initialM21 defines 1st value of 2nd row
  4356. * @param initialM22 defines 2nd value of 2nd row
  4357. * @param initialM23 defines 3rd value of 2nd row
  4358. * @param initialM24 defines 4th value of 2nd row
  4359. * @param initialM31 defines 1st value of 3rd row
  4360. * @param initialM32 defines 2nd value of 3rd row
  4361. * @param initialM33 defines 3rd value of 3rd row
  4362. * @param initialM34 defines 4th value of 3rd row
  4363. * @param initialM41 defines 1st value of 4th row
  4364. * @param initialM42 defines 2nd value of 4th row
  4365. * @param initialM43 defines 3rd value of 4th row
  4366. * @param initialM44 defines 4th value of 4th row
  4367. * @returns the new matrix
  4368. */
  4369. 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;
  4370. /**
  4371. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4372. * @param scale defines the scale vector3
  4373. * @param rotation defines the rotation quaternion
  4374. * @param translation defines the translation vector3
  4375. * @returns a new matrix
  4376. */
  4377. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4378. /**
  4379. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4380. * @param scale defines the scale vector3
  4381. * @param rotation defines the rotation quaternion
  4382. * @param translation defines the translation vector3
  4383. * @param result defines the target matrix
  4384. */
  4385. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4386. /**
  4387. * Creates a new identity matrix
  4388. * @returns a new identity matrix
  4389. */
  4390. static Identity(): Matrix;
  4391. /**
  4392. * Creates a new identity matrix and stores the result in a given matrix
  4393. * @param result defines the target matrix
  4394. */
  4395. static IdentityToRef(result: Matrix): void;
  4396. /**
  4397. * Creates a new zero matrix
  4398. * @returns a new zero matrix
  4399. */
  4400. static Zero(): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the X axis
  4403. * @param angle defines the angle (in radians) to use
  4404. * @return the new matrix
  4405. */
  4406. static RotationX(angle: number): Matrix;
  4407. /**
  4408. * Creates a new matrix as the invert of a given matrix
  4409. * @param source defines the source matrix
  4410. * @returns the new matrix
  4411. */
  4412. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4413. /**
  4414. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4415. * @param angle defines the angle (in radians) to use
  4416. * @param result defines the target matrix
  4417. */
  4418. static RotationXToRef(angle: number, result: Matrix): void;
  4419. /**
  4420. * Creates a new rotation matrix for "angle" radians around the Y axis
  4421. * @param angle defines the angle (in radians) to use
  4422. * @return the new matrix
  4423. */
  4424. static RotationY(angle: number): Matrix;
  4425. /**
  4426. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4427. * @param angle defines the angle (in radians) to use
  4428. * @param result defines the target matrix
  4429. */
  4430. static RotationYToRef(angle: number, result: Matrix): void;
  4431. /**
  4432. * Creates a new rotation matrix for "angle" radians around the Z axis
  4433. * @param angle defines the angle (in radians) to use
  4434. * @return the new matrix
  4435. */
  4436. static RotationZ(angle: number): Matrix;
  4437. /**
  4438. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4439. * @param angle defines the angle (in radians) to use
  4440. * @param result defines the target matrix
  4441. */
  4442. static RotationZToRef(angle: number, result: Matrix): void;
  4443. /**
  4444. * Creates a new rotation matrix for "angle" radians around the given axis
  4445. * @param axis defines the axis to use
  4446. * @param angle defines the angle (in radians) to use
  4447. * @return the new matrix
  4448. */
  4449. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4450. /**
  4451. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4452. * @param axis defines the axis to use
  4453. * @param angle defines the angle (in radians) to use
  4454. * @param result defines the target matrix
  4455. */
  4456. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4457. /**
  4458. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4459. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4460. * @param from defines the vector to align
  4461. * @param to defines the vector to align to
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4465. /**
  4466. * Creates a rotation matrix
  4467. * @param yaw defines the yaw angle in radians (Y axis)
  4468. * @param pitch defines the pitch angle in radians (X axis)
  4469. * @param roll defines the roll angle in radians (X axis)
  4470. * @returns the new rotation matrix
  4471. */
  4472. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4473. /**
  4474. * Creates a rotation matrix and stores it in a given matrix
  4475. * @param yaw defines the yaw angle in radians (Y axis)
  4476. * @param pitch defines the pitch angle in radians (X axis)
  4477. * @param roll defines the roll angle in radians (X axis)
  4478. * @param result defines the target matrix
  4479. */
  4480. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4481. /**
  4482. * Creates a scaling matrix
  4483. * @param x defines the scale factor on X axis
  4484. * @param y defines the scale factor on Y axis
  4485. * @param z defines the scale factor on Z axis
  4486. * @returns the new matrix
  4487. */
  4488. static Scaling(x: number, y: number, z: number): Matrix;
  4489. /**
  4490. * Creates a scaling matrix and stores it in a given matrix
  4491. * @param x defines the scale factor on X axis
  4492. * @param y defines the scale factor on Y axis
  4493. * @param z defines the scale factor on Z axis
  4494. * @param result defines the target matrix
  4495. */
  4496. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4497. /**
  4498. * Creates a translation matrix
  4499. * @param x defines the translation on X axis
  4500. * @param y defines the translation on Y axis
  4501. * @param z defines the translationon Z axis
  4502. * @returns the new matrix
  4503. */
  4504. static Translation(x: number, y: number, z: number): Matrix;
  4505. /**
  4506. * Creates a translation matrix and stores it in a given matrix
  4507. * @param x defines the translation on X axis
  4508. * @param y defines the translation on Y axis
  4509. * @param z defines the translationon Z axis
  4510. * @param result defines the target matrix
  4511. */
  4512. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4513. /**
  4514. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4515. * @param startValue defines the start value
  4516. * @param endValue defines the end value
  4517. * @param gradient defines the gradient factor
  4518. * @returns the new matrix
  4519. */
  4520. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4521. /**
  4522. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4523. * @param startValue defines the start value
  4524. * @param endValue defines the end value
  4525. * @param gradient defines the gradient factor
  4526. * @param result defines the Matrix object where to store data
  4527. */
  4528. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4529. /**
  4530. * Builds a new matrix whose values are computed by:
  4531. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4532. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4533. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4534. * @param startValue defines the first matrix
  4535. * @param endValue defines the second matrix
  4536. * @param gradient defines the gradient between the two matrices
  4537. * @returns the new matrix
  4538. */
  4539. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4540. /**
  4541. * Update a matrix to values which are computed by:
  4542. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4543. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4544. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4545. * @param startValue defines the first matrix
  4546. * @param endValue defines the second matrix
  4547. * @param gradient defines the gradient between the two matrices
  4548. * @param result defines the target matrix
  4549. */
  4550. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4551. /**
  4552. * 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"
  4553. * This function works in left handed mode
  4554. * @param eye defines the final position of the entity
  4555. * @param target defines where the entity should look at
  4556. * @param up defines the up vector for the entity
  4557. * @returns the new matrix
  4558. */
  4559. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4560. /**
  4561. * 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".
  4562. * This function works in left handed mode
  4563. * @param eye defines the final position of the entity
  4564. * @param target defines where the entity should look at
  4565. * @param up defines the up vector for the entity
  4566. * @param result defines the target matrix
  4567. */
  4568. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4569. /**
  4570. * 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"
  4571. * This function works in right handed mode
  4572. * @param eye defines the final position of the entity
  4573. * @param target defines where the entity should look at
  4574. * @param up defines the up vector for the entity
  4575. * @returns the new matrix
  4576. */
  4577. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4578. /**
  4579. * 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".
  4580. * This function works in right handed mode
  4581. * @param eye defines the final position of the entity
  4582. * @param target defines where the entity should look at
  4583. * @param up defines the up vector for the entity
  4584. * @param result defines the target matrix
  4585. */
  4586. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4587. /**
  4588. * Create a left-handed orthographic projection matrix
  4589. * @param width defines the viewport width
  4590. * @param height defines the viewport height
  4591. * @param znear defines the near clip plane
  4592. * @param zfar defines the far clip plane
  4593. * @returns a new matrix as a left-handed orthographic projection matrix
  4594. */
  4595. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4596. /**
  4597. * Store a left-handed orthographic projection to a given matrix
  4598. * @param width defines the viewport width
  4599. * @param height defines the viewport height
  4600. * @param znear defines the near clip plane
  4601. * @param zfar defines the far clip plane
  4602. * @param result defines the target matrix
  4603. */
  4604. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4605. /**
  4606. * Create a left-handed orthographic projection matrix
  4607. * @param left defines the viewport left coordinate
  4608. * @param right defines the viewport right coordinate
  4609. * @param bottom defines the viewport bottom coordinate
  4610. * @param top defines the viewport top coordinate
  4611. * @param znear defines the near clip plane
  4612. * @param zfar defines the far clip plane
  4613. * @returns a new matrix as a left-handed orthographic projection matrix
  4614. */
  4615. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4616. /**
  4617. * Stores a left-handed orthographic projection into a given matrix
  4618. * @param left defines the viewport left coordinate
  4619. * @param right defines the viewport right coordinate
  4620. * @param bottom defines the viewport bottom coordinate
  4621. * @param top defines the viewport top coordinate
  4622. * @param znear defines the near clip plane
  4623. * @param zfar defines the far clip plane
  4624. * @param result defines the target matrix
  4625. */
  4626. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4627. /**
  4628. * Creates a right-handed orthographic projection matrix
  4629. * @param left defines the viewport left coordinate
  4630. * @param right defines the viewport right coordinate
  4631. * @param bottom defines the viewport bottom coordinate
  4632. * @param top defines the viewport top coordinate
  4633. * @param znear defines the near clip plane
  4634. * @param zfar defines the far clip plane
  4635. * @returns a new matrix as a right-handed orthographic projection matrix
  4636. */
  4637. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4638. /**
  4639. * Stores a right-handed orthographic projection into a given matrix
  4640. * @param left defines the viewport left coordinate
  4641. * @param right defines the viewport right coordinate
  4642. * @param bottom defines the viewport bottom coordinate
  4643. * @param top defines the viewport top coordinate
  4644. * @param znear defines the near clip plane
  4645. * @param zfar defines the far clip plane
  4646. * @param result defines the target matrix
  4647. */
  4648. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4649. /**
  4650. * Creates a left-handed perspective projection matrix
  4651. * @param width defines the viewport width
  4652. * @param height defines the viewport height
  4653. * @param znear defines the near clip plane
  4654. * @param zfar defines the far clip plane
  4655. * @returns a new matrix as a left-handed perspective projection matrix
  4656. */
  4657. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4658. /**
  4659. * Creates a left-handed perspective projection matrix
  4660. * @param fov defines the horizontal field of view
  4661. * @param aspect defines the aspect ratio
  4662. * @param znear defines the near clip plane
  4663. * @param zfar defines the far clip plane
  4664. * @returns a new matrix as a left-handed perspective projection matrix
  4665. */
  4666. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4667. /**
  4668. * Stores a left-handed perspective projection into a given matrix
  4669. * @param fov defines the horizontal field of view
  4670. * @param aspect defines the aspect ratio
  4671. * @param znear defines the near clip plane
  4672. * @param zfar defines the far clip plane
  4673. * @param result defines the target matrix
  4674. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4675. */
  4676. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4677. /**
  4678. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4679. * @param fov defines the horizontal field of view
  4680. * @param aspect defines the aspect ratio
  4681. * @param znear defines the near clip plane
  4682. * @param zfar not used as infinity is used as far clip
  4683. * @param result defines the target matrix
  4684. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4685. */
  4686. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4687. /**
  4688. * Creates a right-handed perspective projection matrix
  4689. * @param fov defines the horizontal field of view
  4690. * @param aspect defines the aspect ratio
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @returns a new matrix as a right-handed perspective projection matrix
  4694. */
  4695. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4696. /**
  4697. * Stores a right-handed perspective projection into a given matrix
  4698. * @param fov defines the horizontal field of view
  4699. * @param aspect defines the aspect ratio
  4700. * @param znear defines the near clip plane
  4701. * @param zfar defines the far clip plane
  4702. * @param result defines the target matrix
  4703. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4704. */
  4705. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4706. /**
  4707. * Stores a right-handed perspective projection into a given matrix
  4708. * @param fov defines the horizontal field of view
  4709. * @param aspect defines the aspect ratio
  4710. * @param znear defines the near clip plane
  4711. * @param zfar not used as infinity is used as far clip
  4712. * @param result defines the target matrix
  4713. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4714. */
  4715. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4716. /**
  4717. * Stores a perspective projection for WebVR info a given matrix
  4718. * @param fov defines the field of view
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @param result defines the target matrix
  4722. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4723. */
  4724. static PerspectiveFovWebVRToRef(fov: {
  4725. upDegrees: number;
  4726. downDegrees: number;
  4727. leftDegrees: number;
  4728. rightDegrees: number;
  4729. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4730. /**
  4731. * Computes a complete transformation matrix
  4732. * @param viewport defines the viewport to use
  4733. * @param world defines the world matrix
  4734. * @param view defines the view matrix
  4735. * @param projection defines the projection matrix
  4736. * @param zmin defines the near clip plane
  4737. * @param zmax defines the far clip plane
  4738. * @returns the transformation matrix
  4739. */
  4740. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4741. /**
  4742. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4743. * @param matrix defines the matrix to use
  4744. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4745. */
  4746. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4747. /**
  4748. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4749. * @param matrix defines the matrix to use
  4750. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4751. */
  4752. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4753. /**
  4754. * Compute the transpose of a given matrix
  4755. * @param matrix defines the matrix to transpose
  4756. * @returns the new matrix
  4757. */
  4758. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4759. /**
  4760. * Compute the transpose of a matrix and store it in a target matrix
  4761. * @param matrix defines the matrix to transpose
  4762. * @param result defines the target matrix
  4763. */
  4764. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4765. /**
  4766. * Computes a reflection matrix from a plane
  4767. * @param plane defines the reflection plane
  4768. * @returns a new matrix
  4769. */
  4770. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4771. /**
  4772. * Computes a reflection matrix from a plane
  4773. * @param plane defines the reflection plane
  4774. * @param result defines the target matrix
  4775. */
  4776. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4777. /**
  4778. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4779. * @param xaxis defines the value of the 1st axis
  4780. * @param yaxis defines the value of the 2nd axis
  4781. * @param zaxis defines the value of the 3rd axis
  4782. * @param result defines the target matrix
  4783. */
  4784. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4785. /**
  4786. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4787. * @param quat defines the quaternion to use
  4788. * @param result defines the target matrix
  4789. */
  4790. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4791. }
  4792. /**
  4793. * @hidden
  4794. */
  4795. export class TmpVectors {
  4796. static Vector2: Vector2[];
  4797. static Vector3: Vector3[];
  4798. static Vector4: Vector4[];
  4799. static Quaternion: Quaternion[];
  4800. static Matrix: Matrix[];
  4801. }
  4802. }
  4803. declare module "babylonjs/Maths/math.path" {
  4804. import { DeepImmutable, Nullable } from "babylonjs/types";
  4805. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4806. /**
  4807. * Defines potential orientation for back face culling
  4808. */
  4809. export enum Orientation {
  4810. /**
  4811. * Clockwise
  4812. */
  4813. CW = 0,
  4814. /** Counter clockwise */
  4815. CCW = 1
  4816. }
  4817. /** Class used to represent a Bezier curve */
  4818. export class BezierCurve {
  4819. /**
  4820. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4821. * @param t defines the time
  4822. * @param x1 defines the left coordinate on X axis
  4823. * @param y1 defines the left coordinate on Y axis
  4824. * @param x2 defines the right coordinate on X axis
  4825. * @param y2 defines the right coordinate on Y axis
  4826. * @returns the interpolated value
  4827. */
  4828. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4829. }
  4830. /**
  4831. * Defines angle representation
  4832. */
  4833. export class Angle {
  4834. private _radians;
  4835. /**
  4836. * Creates an Angle object of "radians" radians (float).
  4837. * @param radians the angle in radians
  4838. */
  4839. constructor(radians: number);
  4840. /**
  4841. * Get value in degrees
  4842. * @returns the Angle value in degrees (float)
  4843. */
  4844. degrees(): number;
  4845. /**
  4846. * Get value in radians
  4847. * @returns the Angle value in radians (float)
  4848. */
  4849. radians(): number;
  4850. /**
  4851. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4852. * @param a defines first vector
  4853. * @param b defines second vector
  4854. * @returns a new Angle
  4855. */
  4856. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4857. /**
  4858. * Gets a new Angle object from the given float in radians
  4859. * @param radians defines the angle value in radians
  4860. * @returns a new Angle
  4861. */
  4862. static FromRadians(radians: number): Angle;
  4863. /**
  4864. * Gets a new Angle object from the given float in degrees
  4865. * @param degrees defines the angle value in degrees
  4866. * @returns a new Angle
  4867. */
  4868. static FromDegrees(degrees: number): Angle;
  4869. }
  4870. /**
  4871. * This represents an arc in a 2d space.
  4872. */
  4873. export class Arc2 {
  4874. /** Defines the start point of the arc */
  4875. startPoint: Vector2;
  4876. /** Defines the mid point of the arc */
  4877. midPoint: Vector2;
  4878. /** Defines the end point of the arc */
  4879. endPoint: Vector2;
  4880. /**
  4881. * Defines the center point of the arc.
  4882. */
  4883. centerPoint: Vector2;
  4884. /**
  4885. * Defines the radius of the arc.
  4886. */
  4887. radius: number;
  4888. /**
  4889. * Defines the angle of the arc (from mid point to end point).
  4890. */
  4891. angle: Angle;
  4892. /**
  4893. * Defines the start angle of the arc (from start point to middle point).
  4894. */
  4895. startAngle: Angle;
  4896. /**
  4897. * Defines the orientation of the arc (clock wise/counter clock wise).
  4898. */
  4899. orientation: Orientation;
  4900. /**
  4901. * Creates an Arc object from the three given points : start, middle and end.
  4902. * @param startPoint Defines the start point of the arc
  4903. * @param midPoint Defines the midlle point of the arc
  4904. * @param endPoint Defines the end point of the arc
  4905. */
  4906. constructor(
  4907. /** Defines the start point of the arc */
  4908. startPoint: Vector2,
  4909. /** Defines the mid point of the arc */
  4910. midPoint: Vector2,
  4911. /** Defines the end point of the arc */
  4912. endPoint: Vector2);
  4913. }
  4914. /**
  4915. * Represents a 2D path made up of multiple 2D points
  4916. */
  4917. export class Path2 {
  4918. private _points;
  4919. private _length;
  4920. /**
  4921. * If the path start and end point are the same
  4922. */
  4923. closed: boolean;
  4924. /**
  4925. * Creates a Path2 object from the starting 2D coordinates x and y.
  4926. * @param x the starting points x value
  4927. * @param y the starting points y value
  4928. */
  4929. constructor(x: number, y: number);
  4930. /**
  4931. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4932. * @param x the added points x value
  4933. * @param y the added points y value
  4934. * @returns the updated Path2.
  4935. */
  4936. addLineTo(x: number, y: number): Path2;
  4937. /**
  4938. * 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.
  4939. * @param midX middle point x value
  4940. * @param midY middle point y value
  4941. * @param endX end point x value
  4942. * @param endY end point y value
  4943. * @param numberOfSegments (default: 36)
  4944. * @returns the updated Path2.
  4945. */
  4946. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4947. /**
  4948. * Closes the Path2.
  4949. * @returns the Path2.
  4950. */
  4951. close(): Path2;
  4952. /**
  4953. * Gets the sum of the distance between each sequential point in the path
  4954. * @returns the Path2 total length (float).
  4955. */
  4956. length(): number;
  4957. /**
  4958. * Gets the points which construct the path
  4959. * @returns the Path2 internal array of points.
  4960. */
  4961. getPoints(): Vector2[];
  4962. /**
  4963. * Retreives the point at the distance aways from the starting point
  4964. * @param normalizedLengthPosition the length along the path to retreive the point from
  4965. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4966. */
  4967. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4968. /**
  4969. * Creates a new path starting from an x and y position
  4970. * @param x starting x value
  4971. * @param y starting y value
  4972. * @returns a new Path2 starting at the coordinates (x, y).
  4973. */
  4974. static StartingAt(x: number, y: number): Path2;
  4975. }
  4976. /**
  4977. * Represents a 3D path made up of multiple 3D points
  4978. */
  4979. export class Path3D {
  4980. /**
  4981. * an array of Vector3, the curve axis of the Path3D
  4982. */
  4983. path: Vector3[];
  4984. private _curve;
  4985. private _distances;
  4986. private _tangents;
  4987. private _normals;
  4988. private _binormals;
  4989. private _raw;
  4990. private _alignTangentsWithPath;
  4991. private readonly _pointAtData;
  4992. /**
  4993. * new Path3D(path, normal, raw)
  4994. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4995. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4996. * @param path an array of Vector3, the curve axis of the Path3D
  4997. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4998. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4999. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5000. */
  5001. constructor(
  5002. /**
  5003. * an array of Vector3, the curve axis of the Path3D
  5004. */
  5005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5006. /**
  5007. * Returns the Path3D array of successive Vector3 designing its curve.
  5008. * @returns the Path3D array of successive Vector3 designing its curve.
  5009. */
  5010. getCurve(): Vector3[];
  5011. /**
  5012. * Returns the Path3D array of successive Vector3 designing its curve.
  5013. * @returns the Path3D array of successive Vector3 designing its curve.
  5014. */
  5015. getPoints(): Vector3[];
  5016. /**
  5017. * @returns the computed length (float) of the path.
  5018. */
  5019. length(): number;
  5020. /**
  5021. * Returns an array populated with tangent vectors on each Path3D curve point.
  5022. * @returns an array populated with tangent vectors on each Path3D curve point.
  5023. */
  5024. getTangents(): Vector3[];
  5025. /**
  5026. * Returns an array populated with normal vectors on each Path3D curve point.
  5027. * @returns an array populated with normal vectors on each Path3D curve point.
  5028. */
  5029. getNormals(): Vector3[];
  5030. /**
  5031. * Returns an array populated with binormal vectors on each Path3D curve point.
  5032. * @returns an array populated with binormal vectors on each Path3D curve point.
  5033. */
  5034. getBinormals(): Vector3[];
  5035. /**
  5036. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5037. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5038. */
  5039. getDistances(): number[];
  5040. /**
  5041. * Returns an interpolated point along this path
  5042. * @param position the position of the point along this path, from 0.0 to 1.0
  5043. * @returns a new Vector3 as the point
  5044. */
  5045. getPointAt(position: number): Vector3;
  5046. /**
  5047. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5048. * @param position the position of the point along this path, from 0.0 to 1.0
  5049. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5050. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5051. */
  5052. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5053. /**
  5054. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5055. * @param position the position of the point along this path, from 0.0 to 1.0
  5056. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5057. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5058. */
  5059. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5060. /**
  5061. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5062. * @param position the position of the point along this path, from 0.0 to 1.0
  5063. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5064. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5065. */
  5066. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5067. /**
  5068. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5069. * @param position the position of the point along this path, from 0.0 to 1.0
  5070. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5071. */
  5072. getDistanceAt(position: number): number;
  5073. /**
  5074. * Returns the array index of the previous point of an interpolated point along this path
  5075. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5076. * @returns the array index
  5077. */
  5078. getPreviousPointIndexAt(position: number): number;
  5079. /**
  5080. * 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)
  5081. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5082. * @returns the sub position
  5083. */
  5084. getSubPositionAt(position: number): number;
  5085. /**
  5086. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5087. * @param target the vector of which to get the closest position to
  5088. * @returns the position of the closest virtual point on this path to the target vector
  5089. */
  5090. getClosestPositionTo(target: Vector3): number;
  5091. /**
  5092. * Returns a sub path (slice) of this path
  5093. * @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
  5094. * @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
  5095. * @returns a sub path (slice) of this path
  5096. */
  5097. slice(start?: number, end?: number): Path3D;
  5098. /**
  5099. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5100. * @param path path which all values are copied into the curves points
  5101. * @param firstNormal which should be projected onto the curve
  5102. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5103. * @returns the same object updated.
  5104. */
  5105. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5106. private _compute;
  5107. private _getFirstNonNullVector;
  5108. private _getLastNonNullVector;
  5109. private _normalVector;
  5110. /**
  5111. * Updates the point at data for an interpolated point along this curve
  5112. * @param position the position of the point along this curve, from 0.0 to 1.0
  5113. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5114. * @returns the (updated) point at data
  5115. */
  5116. private _updatePointAtData;
  5117. /**
  5118. * Updates the point at data from the specified parameters
  5119. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5120. * @param point the interpolated point
  5121. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5122. */
  5123. private _setPointAtData;
  5124. /**
  5125. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5126. */
  5127. private _updateInterpolationMatrix;
  5128. }
  5129. /**
  5130. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5131. * A Curve3 is designed from a series of successive Vector3.
  5132. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5133. */
  5134. export class Curve3 {
  5135. private _points;
  5136. private _length;
  5137. /**
  5138. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5139. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5140. * @param v1 (Vector3) the control point
  5141. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5142. * @param nbPoints (integer) the wanted number of points in the curve
  5143. * @returns the created Curve3
  5144. */
  5145. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5146. /**
  5147. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5148. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5149. * @param v1 (Vector3) the first control point
  5150. * @param v2 (Vector3) the second control point
  5151. * @param v3 (Vector3) the end point of the Cubic Bezier
  5152. * @param nbPoints (integer) the wanted number of points in the curve
  5153. * @returns the created Curve3
  5154. */
  5155. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5156. /**
  5157. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5158. * @param p1 (Vector3) the origin point of the Hermite Spline
  5159. * @param t1 (Vector3) the tangent vector at the origin point
  5160. * @param p2 (Vector3) the end point of the Hermite Spline
  5161. * @param t2 (Vector3) the tangent vector at the end point
  5162. * @param nbPoints (integer) the wanted number of points in the curve
  5163. * @returns the created Curve3
  5164. */
  5165. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5166. /**
  5167. * Returns a Curve3 object along a CatmullRom Spline curve :
  5168. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5169. * @param nbPoints (integer) the wanted number of points between each curve control points
  5170. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5171. * @returns the created Curve3
  5172. */
  5173. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5174. /**
  5175. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5176. * A Curve3 is designed from a series of successive Vector3.
  5177. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5178. * @param points points which make up the curve
  5179. */
  5180. constructor(points: Vector3[]);
  5181. /**
  5182. * @returns the Curve3 stored array of successive Vector3
  5183. */
  5184. getPoints(): Vector3[];
  5185. /**
  5186. * @returns the computed length (float) of the curve.
  5187. */
  5188. length(): number;
  5189. /**
  5190. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5191. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5192. * curveA and curveB keep unchanged.
  5193. * @param curve the curve to continue from this curve
  5194. * @returns the newly constructed curve
  5195. */
  5196. continue(curve: DeepImmutable<Curve3>): Curve3;
  5197. private _computeLength;
  5198. }
  5199. }
  5200. declare module "babylonjs/Animations/easing" {
  5201. /**
  5202. * This represents the main contract an easing function should follow.
  5203. * Easing functions are used throughout the animation system.
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export interface IEasingFunction {
  5207. /**
  5208. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5209. * of the easing function.
  5210. * The link below provides some of the most common examples of easing functions.
  5211. * @see https://easings.net/
  5212. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5213. * @returns the corresponding value on the curve defined by the easing function
  5214. */
  5215. ease(gradient: number): number;
  5216. }
  5217. /**
  5218. * Base class used for every default easing function.
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class EasingFunction implements IEasingFunction {
  5222. /**
  5223. * Interpolation follows the mathematical formula associated with the easing function.
  5224. */
  5225. static readonly EASINGMODE_EASEIN: number;
  5226. /**
  5227. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5228. */
  5229. static readonly EASINGMODE_EASEOUT: number;
  5230. /**
  5231. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5232. */
  5233. static readonly EASINGMODE_EASEINOUT: number;
  5234. private _easingMode;
  5235. /**
  5236. * Sets the easing mode of the current function.
  5237. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5238. */
  5239. setEasingMode(easingMode: number): void;
  5240. /**
  5241. * Gets the current easing mode.
  5242. * @returns the easing mode
  5243. */
  5244. getEasingMode(): number;
  5245. /**
  5246. * @hidden
  5247. */
  5248. easeInCore(gradient: number): number;
  5249. /**
  5250. * Given an input gradient between 0 and 1, this returns the corresponding value
  5251. * of the easing function.
  5252. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5253. * @returns the corresponding value on the curve defined by the easing function
  5254. */
  5255. ease(gradient: number): number;
  5256. }
  5257. /**
  5258. * Easing function with a circle shape (see link below).
  5259. * @see https://easings.net/#easeInCirc
  5260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5261. */
  5262. export class CircleEase extends EasingFunction implements IEasingFunction {
  5263. /** @hidden */
  5264. easeInCore(gradient: number): number;
  5265. }
  5266. /**
  5267. * Easing function with a ease back shape (see link below).
  5268. * @see https://easings.net/#easeInBack
  5269. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5270. */
  5271. export class BackEase extends EasingFunction implements IEasingFunction {
  5272. /** Defines the amplitude of the function */
  5273. amplitude: number;
  5274. /**
  5275. * Instantiates a back ease easing
  5276. * @see https://easings.net/#easeInBack
  5277. * @param amplitude Defines the amplitude of the function
  5278. */
  5279. constructor(
  5280. /** Defines the amplitude of the function */
  5281. amplitude?: number);
  5282. /** @hidden */
  5283. easeInCore(gradient: number): number;
  5284. }
  5285. /**
  5286. * Easing function with a bouncing shape (see link below).
  5287. * @see https://easings.net/#easeInBounce
  5288. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5289. */
  5290. export class BounceEase extends EasingFunction implements IEasingFunction {
  5291. /** Defines the number of bounces */
  5292. bounces: number;
  5293. /** Defines the amplitude of the bounce */
  5294. bounciness: number;
  5295. /**
  5296. * Instantiates a bounce easing
  5297. * @see https://easings.net/#easeInBounce
  5298. * @param bounces Defines the number of bounces
  5299. * @param bounciness Defines the amplitude of the bounce
  5300. */
  5301. constructor(
  5302. /** Defines the number of bounces */
  5303. bounces?: number,
  5304. /** Defines the amplitude of the bounce */
  5305. bounciness?: number);
  5306. /** @hidden */
  5307. easeInCore(gradient: number): number;
  5308. }
  5309. /**
  5310. * Easing function with a power of 3 shape (see link below).
  5311. * @see https://easings.net/#easeInCubic
  5312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5313. */
  5314. export class CubicEase extends EasingFunction implements IEasingFunction {
  5315. /** @hidden */
  5316. easeInCore(gradient: number): number;
  5317. }
  5318. /**
  5319. * Easing function with an elastic shape (see link below).
  5320. * @see https://easings.net/#easeInElastic
  5321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5322. */
  5323. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5324. /** Defines the number of oscillations*/
  5325. oscillations: number;
  5326. /** Defines the amplitude of the oscillations*/
  5327. springiness: number;
  5328. /**
  5329. * Instantiates an elastic easing function
  5330. * @see https://easings.net/#easeInElastic
  5331. * @param oscillations Defines the number of oscillations
  5332. * @param springiness Defines the amplitude of the oscillations
  5333. */
  5334. constructor(
  5335. /** Defines the number of oscillations*/
  5336. oscillations?: number,
  5337. /** Defines the amplitude of the oscillations*/
  5338. springiness?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with an exponential shape (see link below).
  5344. * @see https://easings.net/#easeInExpo
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5348. /** Defines the exponent of the function */
  5349. exponent: number;
  5350. /**
  5351. * Instantiates an exponential easing function
  5352. * @see https://easings.net/#easeInExpo
  5353. * @param exponent Defines the exponent of the function
  5354. */
  5355. constructor(
  5356. /** Defines the exponent of the function */
  5357. exponent?: number);
  5358. /** @hidden */
  5359. easeInCore(gradient: number): number;
  5360. }
  5361. /**
  5362. * Easing function with a power shape (see link below).
  5363. * @see https://easings.net/#easeInQuad
  5364. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5365. */
  5366. export class PowerEase extends EasingFunction implements IEasingFunction {
  5367. /** Defines the power of the function */
  5368. power: number;
  5369. /**
  5370. * Instantiates an power base easing function
  5371. * @see https://easings.net/#easeInQuad
  5372. * @param power Defines the power of the function
  5373. */
  5374. constructor(
  5375. /** Defines the power of the function */
  5376. power?: number);
  5377. /** @hidden */
  5378. easeInCore(gradient: number): number;
  5379. }
  5380. /**
  5381. * Easing function with a power of 2 shape (see link below).
  5382. * @see https://easings.net/#easeInQuad
  5383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5384. */
  5385. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5386. /** @hidden */
  5387. easeInCore(gradient: number): number;
  5388. }
  5389. /**
  5390. * Easing function with a power of 4 shape (see link below).
  5391. * @see https://easings.net/#easeInQuart
  5392. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5393. */
  5394. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5395. /** @hidden */
  5396. easeInCore(gradient: number): number;
  5397. }
  5398. /**
  5399. * Easing function with a power of 5 shape (see link below).
  5400. * @see https://easings.net/#easeInQuint
  5401. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5402. */
  5403. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5404. /** @hidden */
  5405. easeInCore(gradient: number): number;
  5406. }
  5407. /**
  5408. * Easing function with a sin shape (see link below).
  5409. * @see https://easings.net/#easeInSine
  5410. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5411. */
  5412. export class SineEase extends EasingFunction implements IEasingFunction {
  5413. /** @hidden */
  5414. easeInCore(gradient: number): number;
  5415. }
  5416. /**
  5417. * Easing function with a bezier shape (see link below).
  5418. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5420. */
  5421. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5422. /** Defines the x component of the start tangent in the bezier curve */
  5423. x1: number;
  5424. /** Defines the y component of the start tangent in the bezier curve */
  5425. y1: number;
  5426. /** Defines the x component of the end tangent in the bezier curve */
  5427. x2: number;
  5428. /** Defines the y component of the end tangent in the bezier curve */
  5429. y2: number;
  5430. /**
  5431. * Instantiates a bezier function
  5432. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5433. * @param x1 Defines the x component of the start tangent in the bezier curve
  5434. * @param y1 Defines the y component of the start tangent in the bezier curve
  5435. * @param x2 Defines the x component of the end tangent in the bezier curve
  5436. * @param y2 Defines the y component of the end tangent in the bezier curve
  5437. */
  5438. constructor(
  5439. /** Defines the x component of the start tangent in the bezier curve */
  5440. x1?: number,
  5441. /** Defines the y component of the start tangent in the bezier curve */
  5442. y1?: number,
  5443. /** Defines the x component of the end tangent in the bezier curve */
  5444. x2?: number,
  5445. /** Defines the y component of the end tangent in the bezier curve */
  5446. y2?: number);
  5447. /** @hidden */
  5448. easeInCore(gradient: number): number;
  5449. }
  5450. }
  5451. declare module "babylonjs/Maths/math.color" {
  5452. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to hold a RBG color
  5455. */
  5456. export class Color3 {
  5457. /**
  5458. * Defines the red component (between 0 and 1, default is 0)
  5459. */
  5460. r: number;
  5461. /**
  5462. * Defines the green component (between 0 and 1, default is 0)
  5463. */
  5464. g: number;
  5465. /**
  5466. * Defines the blue component (between 0 and 1, default is 0)
  5467. */
  5468. b: number;
  5469. /**
  5470. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5471. * @param r defines the red component (between 0 and 1, default is 0)
  5472. * @param g defines the green component (between 0 and 1, default is 0)
  5473. * @param b defines the blue component (between 0 and 1, default is 0)
  5474. */
  5475. constructor(
  5476. /**
  5477. * Defines the red component (between 0 and 1, default is 0)
  5478. */
  5479. r?: number,
  5480. /**
  5481. * Defines the green component (between 0 and 1, default is 0)
  5482. */
  5483. g?: number,
  5484. /**
  5485. * Defines the blue component (between 0 and 1, default is 0)
  5486. */
  5487. b?: number);
  5488. /**
  5489. * Creates a string with the Color3 current values
  5490. * @returns the string representation of the Color3 object
  5491. */
  5492. toString(): string;
  5493. /**
  5494. * Returns the string "Color3"
  5495. * @returns "Color3"
  5496. */
  5497. getClassName(): string;
  5498. /**
  5499. * Compute the Color3 hash code
  5500. * @returns an unique number that can be used to hash Color3 objects
  5501. */
  5502. getHashCode(): number;
  5503. /**
  5504. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5505. * @param array defines the array where to store the r,g,b components
  5506. * @param index defines an optional index in the target array to define where to start storing values
  5507. * @returns the current Color3 object
  5508. */
  5509. toArray(array: FloatArray, index?: number): Color3;
  5510. /**
  5511. * Returns a new Color4 object from the current Color3 and the given alpha
  5512. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5513. * @returns a new Color4 object
  5514. */
  5515. toColor4(alpha?: number): Color4;
  5516. /**
  5517. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5518. * @returns the new array
  5519. */
  5520. asArray(): number[];
  5521. /**
  5522. * Returns the luminance value
  5523. * @returns a float value
  5524. */
  5525. toLuminance(): number;
  5526. /**
  5527. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5528. * @param otherColor defines the second operand
  5529. * @returns the new Color3 object
  5530. */
  5531. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5532. /**
  5533. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5534. * @param otherColor defines the second operand
  5535. * @param result defines the Color3 object where to store the result
  5536. * @returns the current Color3
  5537. */
  5538. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5539. /**
  5540. * Determines equality between Color3 objects
  5541. * @param otherColor defines the second operand
  5542. * @returns true if the rgb values are equal to the given ones
  5543. */
  5544. equals(otherColor: DeepImmutable<Color3>): boolean;
  5545. /**
  5546. * Determines equality between the current Color3 object and a set of r,b,g values
  5547. * @param r defines the red component to check
  5548. * @param g defines the green component to check
  5549. * @param b defines the blue component to check
  5550. * @returns true if the rgb values are equal to the given ones
  5551. */
  5552. equalsFloats(r: number, g: number, b: number): boolean;
  5553. /**
  5554. * Multiplies in place each rgb value by scale
  5555. * @param scale defines the scaling factor
  5556. * @returns the updated Color3
  5557. */
  5558. scale(scale: number): Color3;
  5559. /**
  5560. * Multiplies the rgb values by scale and stores the result into "result"
  5561. * @param scale defines the scaling factor
  5562. * @param result defines the Color3 object where to store the result
  5563. * @returns the unmodified current Color3
  5564. */
  5565. scaleToRef(scale: number, result: Color3): Color3;
  5566. /**
  5567. * Scale the current Color3 values by a factor and add the result to a given Color3
  5568. * @param scale defines the scale factor
  5569. * @param result defines color to store the result into
  5570. * @returns the unmodified current Color3
  5571. */
  5572. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5573. /**
  5574. * Clamps the rgb values by the min and max values and stores the result into "result"
  5575. * @param min defines minimum clamping value (default is 0)
  5576. * @param max defines maximum clamping value (default is 1)
  5577. * @param result defines color to store the result into
  5578. * @returns the original Color3
  5579. */
  5580. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5581. /**
  5582. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5583. * @param otherColor defines the second operand
  5584. * @returns the new Color3
  5585. */
  5586. add(otherColor: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5589. * @param otherColor defines the second operand
  5590. * @param result defines Color3 object to store the result into
  5591. * @returns the unmodified current Color3
  5592. */
  5593. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5594. /**
  5595. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5596. * @param otherColor defines the second operand
  5597. * @returns the new Color3
  5598. */
  5599. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5600. /**
  5601. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5602. * @param otherColor defines the second operand
  5603. * @param result defines Color3 object to store the result into
  5604. * @returns the unmodified current Color3
  5605. */
  5606. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5607. /**
  5608. * Copy the current object
  5609. * @returns a new Color3 copied the current one
  5610. */
  5611. clone(): Color3;
  5612. /**
  5613. * Copies the rgb values from the source in the current Color3
  5614. * @param source defines the source Color3 object
  5615. * @returns the updated Color3 object
  5616. */
  5617. copyFrom(source: DeepImmutable<Color3>): Color3;
  5618. /**
  5619. * Updates the Color3 rgb values from the given floats
  5620. * @param r defines the red component to read from
  5621. * @param g defines the green component to read from
  5622. * @param b defines the blue component to read from
  5623. * @returns the current Color3 object
  5624. */
  5625. copyFromFloats(r: number, g: number, b: number): Color3;
  5626. /**
  5627. * Updates the Color3 rgb values from the given floats
  5628. * @param r defines the red component to read from
  5629. * @param g defines the green component to read from
  5630. * @param b defines the blue component to read from
  5631. * @returns the current Color3 object
  5632. */
  5633. set(r: number, g: number, b: number): Color3;
  5634. /**
  5635. * Compute the Color3 hexadecimal code as a string
  5636. * @returns a string containing the hexadecimal representation of the Color3 object
  5637. */
  5638. toHexString(): string;
  5639. /**
  5640. * Computes a new Color3 converted from the current one to linear space
  5641. * @returns a new Color3 object
  5642. */
  5643. toLinearSpace(): Color3;
  5644. /**
  5645. * Converts current color in rgb space to HSV values
  5646. * @returns a new color3 representing the HSV values
  5647. */
  5648. toHSV(): Color3;
  5649. /**
  5650. * Converts current color in rgb space to HSV values
  5651. * @param result defines the Color3 where to store the HSV values
  5652. */
  5653. toHSVToRef(result: Color3): void;
  5654. /**
  5655. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5656. * @param convertedColor defines the Color3 object where to store the linear space version
  5657. * @returns the unmodified Color3
  5658. */
  5659. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5660. /**
  5661. * Computes a new Color3 converted from the current one to gamma space
  5662. * @returns a new Color3 object
  5663. */
  5664. toGammaSpace(): Color3;
  5665. /**
  5666. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5667. * @param convertedColor defines the Color3 object where to store the gamma space version
  5668. * @returns the unmodified Color3
  5669. */
  5670. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5671. private static _BlackReadOnly;
  5672. /**
  5673. * Convert Hue, saturation and value to a Color3 (RGB)
  5674. * @param hue defines the hue
  5675. * @param saturation defines the saturation
  5676. * @param value defines the value
  5677. * @param result defines the Color3 where to store the RGB values
  5678. */
  5679. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5680. /**
  5681. * Creates a new Color3 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color3 object
  5684. */
  5685. static FromHexString(hex: string): Color3;
  5686. /**
  5687. * Creates a new Color3 from the starting index of the given array
  5688. * @param array defines the source array
  5689. * @param offset defines an offset in the source array
  5690. * @returns a new Color3 object
  5691. */
  5692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5693. /**
  5694. * Creates a new Color3 from integer values (< 256)
  5695. * @param r defines the red component to read from (value between 0 and 255)
  5696. * @param g defines the green component to read from (value between 0 and 255)
  5697. * @param b defines the blue component to read from (value between 0 and 255)
  5698. * @returns a new Color3 object
  5699. */
  5700. static FromInts(r: number, g: number, b: number): Color3;
  5701. /**
  5702. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5703. * @param start defines the start Color3 value
  5704. * @param end defines the end Color3 value
  5705. * @param amount defines the gradient value between start and end
  5706. * @returns a new Color3 object
  5707. */
  5708. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5709. /**
  5710. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5711. * @param left defines the start value
  5712. * @param right defines the end value
  5713. * @param amount defines the gradient factor
  5714. * @param result defines the Color3 object where to store the result
  5715. */
  5716. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5717. /**
  5718. * Returns a Color3 value containing a red color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Red(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a green color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Green(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a blue color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Blue(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a black color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Black(): Color3;
  5737. /**
  5738. * Gets a Color3 value containing a black color that must not be updated
  5739. */
  5740. static get BlackReadOnly(): DeepImmutable<Color3>;
  5741. /**
  5742. * Returns a Color3 value containing a white color
  5743. * @returns a new Color3 object
  5744. */
  5745. static White(): Color3;
  5746. /**
  5747. * Returns a Color3 value containing a purple color
  5748. * @returns a new Color3 object
  5749. */
  5750. static Purple(): Color3;
  5751. /**
  5752. * Returns a Color3 value containing a magenta color
  5753. * @returns a new Color3 object
  5754. */
  5755. static Magenta(): Color3;
  5756. /**
  5757. * Returns a Color3 value containing a yellow color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Yellow(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a gray color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Gray(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a teal color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Teal(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a random color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Random(): Color3;
  5776. }
  5777. /**
  5778. * Class used to hold a RBGA color
  5779. */
  5780. export class Color4 {
  5781. /**
  5782. * Defines the red component (between 0 and 1, default is 0)
  5783. */
  5784. r: number;
  5785. /**
  5786. * Defines the green component (between 0 and 1, default is 0)
  5787. */
  5788. g: number;
  5789. /**
  5790. * Defines the blue component (between 0 and 1, default is 0)
  5791. */
  5792. b: number;
  5793. /**
  5794. * Defines the alpha component (between 0 and 1, default is 1)
  5795. */
  5796. a: number;
  5797. /**
  5798. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5799. * @param r defines the red component (between 0 and 1, default is 0)
  5800. * @param g defines the green component (between 0 and 1, default is 0)
  5801. * @param b defines the blue component (between 0 and 1, default is 0)
  5802. * @param a defines the alpha component (between 0 and 1, default is 1)
  5803. */
  5804. constructor(
  5805. /**
  5806. * Defines the red component (between 0 and 1, default is 0)
  5807. */
  5808. r?: number,
  5809. /**
  5810. * Defines the green component (between 0 and 1, default is 0)
  5811. */
  5812. g?: number,
  5813. /**
  5814. * Defines the blue component (between 0 and 1, default is 0)
  5815. */
  5816. b?: number,
  5817. /**
  5818. * Defines the alpha component (between 0 and 1, default is 1)
  5819. */
  5820. a?: number);
  5821. /**
  5822. * Adds in place the given Color4 values to the current Color4 object
  5823. * @param right defines the second operand
  5824. * @returns the current updated Color4 object
  5825. */
  5826. addInPlace(right: DeepImmutable<Color4>): Color4;
  5827. /**
  5828. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5829. * @returns the new array
  5830. */
  5831. asArray(): number[];
  5832. /**
  5833. * Stores from the starting index in the given array the Color4 successive values
  5834. * @param array defines the array where to store the r,g,b components
  5835. * @param index defines an optional index in the target array to define where to start storing values
  5836. * @returns the current Color4 object
  5837. */
  5838. toArray(array: number[], index?: number): Color4;
  5839. /**
  5840. * Determines equality between Color4 objects
  5841. * @param otherColor defines the second operand
  5842. * @returns true if the rgba values are equal to the given ones
  5843. */
  5844. equals(otherColor: DeepImmutable<Color4>): boolean;
  5845. /**
  5846. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5847. * @param right defines the second operand
  5848. * @returns a new Color4 object
  5849. */
  5850. add(right: DeepImmutable<Color4>): Color4;
  5851. /**
  5852. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5853. * @param right defines the second operand
  5854. * @returns a new Color4 object
  5855. */
  5856. subtract(right: DeepImmutable<Color4>): Color4;
  5857. /**
  5858. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5859. * @param right defines the second operand
  5860. * @param result defines the Color4 object where to store the result
  5861. * @returns the current Color4 object
  5862. */
  5863. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5864. /**
  5865. * Creates a new Color4 with the current Color4 values multiplied by scale
  5866. * @param scale defines the scaling factor to apply
  5867. * @returns a new Color4 object
  5868. */
  5869. scale(scale: number): Color4;
  5870. /**
  5871. * Multiplies the current Color4 values by scale and stores the result in "result"
  5872. * @param scale defines the scaling factor to apply
  5873. * @param result defines the Color4 object where to store the result
  5874. * @returns the current unmodified Color4
  5875. */
  5876. scaleToRef(scale: number, result: Color4): Color4;
  5877. /**
  5878. * Scale the current Color4 values by a factor and add the result to a given Color4
  5879. * @param scale defines the scale factor
  5880. * @param result defines the Color4 object where to store the result
  5881. * @returns the unmodified current Color4
  5882. */
  5883. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5884. /**
  5885. * Clamps the rgb values by the min and max values and stores the result into "result"
  5886. * @param min defines minimum clamping value (default is 0)
  5887. * @param max defines maximum clamping value (default is 1)
  5888. * @param result defines color to store the result into.
  5889. * @returns the cuurent Color4
  5890. */
  5891. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5892. /**
  5893. * Multipy an Color4 value by another and return a new Color4 object
  5894. * @param color defines the Color4 value to multiply by
  5895. * @returns a new Color4 object
  5896. */
  5897. multiply(color: Color4): Color4;
  5898. /**
  5899. * Multipy a Color4 value by another and push the result in a reference value
  5900. * @param color defines the Color4 value to multiply by
  5901. * @param result defines the Color4 to fill the result in
  5902. * @returns the result Color4
  5903. */
  5904. multiplyToRef(color: Color4, result: Color4): Color4;
  5905. /**
  5906. * Creates a string with the Color4 current values
  5907. * @returns the string representation of the Color4 object
  5908. */
  5909. toString(): string;
  5910. /**
  5911. * Returns the string "Color4"
  5912. * @returns "Color4"
  5913. */
  5914. getClassName(): string;
  5915. /**
  5916. * Compute the Color4 hash code
  5917. * @returns an unique number that can be used to hash Color4 objects
  5918. */
  5919. getHashCode(): number;
  5920. /**
  5921. * Creates a new Color4 copied from the current one
  5922. * @returns a new Color4 object
  5923. */
  5924. clone(): Color4;
  5925. /**
  5926. * Copies the given Color4 values into the current one
  5927. * @param source defines the source Color4 object
  5928. * @returns the current updated Color4 object
  5929. */
  5930. copyFrom(source: Color4): Color4;
  5931. /**
  5932. * Copies the given float values into the current one
  5933. * @param r defines the red component to read from
  5934. * @param g defines the green component to read from
  5935. * @param b defines the blue component to read from
  5936. * @param a defines the alpha component to read from
  5937. * @returns the current updated Color4 object
  5938. */
  5939. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5940. /**
  5941. * Copies the given float values into the current one
  5942. * @param r defines the red component to read from
  5943. * @param g defines the green component to read from
  5944. * @param b defines the blue component to read from
  5945. * @param a defines the alpha component to read from
  5946. * @returns the current updated Color4 object
  5947. */
  5948. set(r: number, g: number, b: number, a: number): Color4;
  5949. /**
  5950. * Compute the Color4 hexadecimal code as a string
  5951. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5952. * @returns a string containing the hexadecimal representation of the Color4 object
  5953. */
  5954. toHexString(returnAsColor3?: boolean): string;
  5955. /**
  5956. * Computes a new Color4 converted from the current one to linear space
  5957. * @returns a new Color4 object
  5958. */
  5959. toLinearSpace(): Color4;
  5960. /**
  5961. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5962. * @param convertedColor defines the Color4 object where to store the linear space version
  5963. * @returns the unmodified Color4
  5964. */
  5965. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5966. /**
  5967. * Computes a new Color4 converted from the current one to gamma space
  5968. * @returns a new Color4 object
  5969. */
  5970. toGammaSpace(): Color4;
  5971. /**
  5972. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5973. * @param convertedColor defines the Color4 object where to store the gamma space version
  5974. * @returns the unmodified Color4
  5975. */
  5976. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5977. /**
  5978. * Creates a new Color4 from the string containing valid hexadecimal values
  5979. * @param hex defines a string containing valid hexadecimal values
  5980. * @returns a new Color4 object
  5981. */
  5982. static FromHexString(hex: string): Color4;
  5983. /**
  5984. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5985. * @param left defines the start value
  5986. * @param right defines the end value
  5987. * @param amount defines the gradient factor
  5988. * @returns a new Color4 object
  5989. */
  5990. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5991. /**
  5992. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5993. * @param left defines the start value
  5994. * @param right defines the end value
  5995. * @param amount defines the gradient factor
  5996. * @param result defines the Color4 object where to store data
  5997. */
  5998. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5999. /**
  6000. * Creates a new Color4 from a Color3 and an alpha value
  6001. * @param color3 defines the source Color3 to read from
  6002. * @param alpha defines the alpha component (1.0 by default)
  6003. * @returns a new Color4 object
  6004. */
  6005. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6006. /**
  6007. * Creates a new Color4 from the starting index element of the given array
  6008. * @param array defines the source array to read from
  6009. * @param offset defines the offset in the source array
  6010. * @returns a new Color4 object
  6011. */
  6012. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6013. /**
  6014. * Creates a new Color3 from integer values (< 256)
  6015. * @param r defines the red component to read from (value between 0 and 255)
  6016. * @param g defines the green component to read from (value between 0 and 255)
  6017. * @param b defines the blue component to read from (value between 0 and 255)
  6018. * @param a defines the alpha component to read from (value between 0 and 255)
  6019. * @returns a new Color3 object
  6020. */
  6021. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6022. /**
  6023. * Check the content of a given array and convert it to an array containing RGBA data
  6024. * If the original array was already containing count * 4 values then it is returned directly
  6025. * @param colors defines the array to check
  6026. * @param count defines the number of RGBA data to expect
  6027. * @returns an array containing count * 4 values (RGBA)
  6028. */
  6029. static CheckColors4(colors: number[], count: number): number[];
  6030. }
  6031. /**
  6032. * @hidden
  6033. */
  6034. export class TmpColors {
  6035. static Color3: Color3[];
  6036. static Color4: Color4[];
  6037. }
  6038. }
  6039. declare module "babylonjs/Animations/animationKey" {
  6040. /**
  6041. * Defines an interface which represents an animation key frame
  6042. */
  6043. export interface IAnimationKey {
  6044. /**
  6045. * Frame of the key frame
  6046. */
  6047. frame: number;
  6048. /**
  6049. * Value at the specifies key frame
  6050. */
  6051. value: any;
  6052. /**
  6053. * The input tangent for the cubic hermite spline
  6054. */
  6055. inTangent?: any;
  6056. /**
  6057. * The output tangent for the cubic hermite spline
  6058. */
  6059. outTangent?: any;
  6060. /**
  6061. * The animation interpolation type
  6062. */
  6063. interpolation?: AnimationKeyInterpolation;
  6064. }
  6065. /**
  6066. * Enum for the animation key frame interpolation type
  6067. */
  6068. export enum AnimationKeyInterpolation {
  6069. /**
  6070. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6071. */
  6072. STEP = 1
  6073. }
  6074. }
  6075. declare module "babylonjs/Animations/animationRange" {
  6076. /**
  6077. * Represents the range of an animation
  6078. */
  6079. export class AnimationRange {
  6080. /**The name of the animation range**/
  6081. name: string;
  6082. /**The starting frame of the animation */
  6083. from: number;
  6084. /**The ending frame of the animation*/
  6085. to: number;
  6086. /**
  6087. * Initializes the range of an animation
  6088. * @param name The name of the animation range
  6089. * @param from The starting frame of the animation
  6090. * @param to The ending frame of the animation
  6091. */
  6092. constructor(
  6093. /**The name of the animation range**/
  6094. name: string,
  6095. /**The starting frame of the animation */
  6096. from: number,
  6097. /**The ending frame of the animation*/
  6098. to: number);
  6099. /**
  6100. * Makes a copy of the animation range
  6101. * @returns A copy of the animation range
  6102. */
  6103. clone(): AnimationRange;
  6104. }
  6105. }
  6106. declare module "babylonjs/Animations/animationEvent" {
  6107. /**
  6108. * Composed of a frame, and an action function
  6109. */
  6110. export class AnimationEvent {
  6111. /** The frame for which the event is triggered **/
  6112. frame: number;
  6113. /** The event to perform when triggered **/
  6114. action: (currentFrame: number) => void;
  6115. /** Specifies if the event should be triggered only once**/
  6116. onlyOnce?: boolean | undefined;
  6117. /**
  6118. * Specifies if the animation event is done
  6119. */
  6120. isDone: boolean;
  6121. /**
  6122. * Initializes the animation event
  6123. * @param frame The frame for which the event is triggered
  6124. * @param action The event to perform when triggered
  6125. * @param onlyOnce Specifies if the event should be triggered only once
  6126. */
  6127. constructor(
  6128. /** The frame for which the event is triggered **/
  6129. frame: number,
  6130. /** The event to perform when triggered **/
  6131. action: (currentFrame: number) => void,
  6132. /** Specifies if the event should be triggered only once**/
  6133. onlyOnce?: boolean | undefined);
  6134. /** @hidden */
  6135. _clone(): AnimationEvent;
  6136. }
  6137. }
  6138. declare module "babylonjs/Behaviors/behavior" {
  6139. import { Nullable } from "babylonjs/types";
  6140. /**
  6141. * Interface used to define a behavior
  6142. */
  6143. export interface Behavior<T> {
  6144. /** gets or sets behavior's name */
  6145. name: string;
  6146. /**
  6147. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6148. */
  6149. init(): void;
  6150. /**
  6151. * Called when the behavior is attached to a target
  6152. * @param target defines the target where the behavior is attached to
  6153. */
  6154. attach(target: T): void;
  6155. /**
  6156. * Called when the behavior is detached from its target
  6157. */
  6158. detach(): void;
  6159. }
  6160. /**
  6161. * Interface implemented by classes supporting behaviors
  6162. */
  6163. export interface IBehaviorAware<T> {
  6164. /**
  6165. * Attach a behavior
  6166. * @param behavior defines the behavior to attach
  6167. * @returns the current host
  6168. */
  6169. addBehavior(behavior: Behavior<T>): T;
  6170. /**
  6171. * Remove a behavior from the current object
  6172. * @param behavior defines the behavior to detach
  6173. * @returns the current host
  6174. */
  6175. removeBehavior(behavior: Behavior<T>): T;
  6176. /**
  6177. * Gets a behavior using its name to search
  6178. * @param name defines the name to search
  6179. * @returns the behavior or null if not found
  6180. */
  6181. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6182. }
  6183. }
  6184. declare module "babylonjs/Misc/smartArray" {
  6185. /**
  6186. * Defines an array and its length.
  6187. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6188. */
  6189. export interface ISmartArrayLike<T> {
  6190. /**
  6191. * The data of the array.
  6192. */
  6193. data: Array<T>;
  6194. /**
  6195. * The active length of the array.
  6196. */
  6197. length: number;
  6198. }
  6199. /**
  6200. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6201. */
  6202. export class SmartArray<T> implements ISmartArrayLike<T> {
  6203. /**
  6204. * The full set of data from the array.
  6205. */
  6206. data: Array<T>;
  6207. /**
  6208. * The active length of the array.
  6209. */
  6210. length: number;
  6211. protected _id: number;
  6212. /**
  6213. * Instantiates a Smart Array.
  6214. * @param capacity defines the default capacity of the array.
  6215. */
  6216. constructor(capacity: number);
  6217. /**
  6218. * Pushes a value at the end of the active data.
  6219. * @param value defines the object to push in the array.
  6220. */
  6221. push(value: T): void;
  6222. /**
  6223. * Iterates over the active data and apply the lambda to them.
  6224. * @param func defines the action to apply on each value.
  6225. */
  6226. forEach(func: (content: T) => void): void;
  6227. /**
  6228. * Sorts the full sets of data.
  6229. * @param compareFn defines the comparison function to apply.
  6230. */
  6231. sort(compareFn: (a: T, b: T) => number): void;
  6232. /**
  6233. * Resets the active data to an empty array.
  6234. */
  6235. reset(): void;
  6236. /**
  6237. * Releases all the data from the array as well as the array.
  6238. */
  6239. dispose(): void;
  6240. /**
  6241. * Concats the active data with a given array.
  6242. * @param array defines the data to concatenate with.
  6243. */
  6244. concat(array: any): void;
  6245. /**
  6246. * Returns the position of a value in the active data.
  6247. * @param value defines the value to find the index for
  6248. * @returns the index if found in the active data otherwise -1
  6249. */
  6250. indexOf(value: T): number;
  6251. /**
  6252. * Returns whether an element is part of the active data.
  6253. * @param value defines the value to look for
  6254. * @returns true if found in the active data otherwise false
  6255. */
  6256. contains(value: T): boolean;
  6257. private static _GlobalId;
  6258. }
  6259. /**
  6260. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6261. * The data in this array can only be present once
  6262. */
  6263. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6264. private _duplicateId;
  6265. /**
  6266. * Pushes a value at the end of the active data.
  6267. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6268. * @param value defines the object to push in the array.
  6269. */
  6270. push(value: T): void;
  6271. /**
  6272. * Pushes a value at the end of the active data.
  6273. * If the data is already present, it won t be added again
  6274. * @param value defines the object to push in the array.
  6275. * @returns true if added false if it was already present
  6276. */
  6277. pushNoDuplicate(value: T): boolean;
  6278. /**
  6279. * Resets the active data to an empty array.
  6280. */
  6281. reset(): void;
  6282. /**
  6283. * Concats the active data with a given array.
  6284. * This ensures no dupplicate will be present in the result.
  6285. * @param array defines the data to concatenate with.
  6286. */
  6287. concatWithNoDuplicate(array: any): void;
  6288. }
  6289. }
  6290. declare module "babylonjs/Cameras/cameraInputsManager" {
  6291. import { Nullable } from "babylonjs/types";
  6292. import { Camera } from "babylonjs/Cameras/camera";
  6293. /**
  6294. * @ignore
  6295. * This is a list of all the different input types that are available in the application.
  6296. * Fo instance: ArcRotateCameraGamepadInput...
  6297. */
  6298. export var CameraInputTypes: {};
  6299. /**
  6300. * This is the contract to implement in order to create a new input class.
  6301. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6302. */
  6303. export interface ICameraInput<TCamera extends Camera> {
  6304. /**
  6305. * Defines the camera the input is attached to.
  6306. */
  6307. camera: Nullable<TCamera>;
  6308. /**
  6309. * Gets the class name of the current intput.
  6310. * @returns the class name
  6311. */
  6312. getClassName(): string;
  6313. /**
  6314. * Get the friendly name associated with the input class.
  6315. * @returns the input friendly name
  6316. */
  6317. getSimpleName(): string;
  6318. /**
  6319. * Attach the input controls to a specific dom element to get the input from.
  6320. * @param element Defines the element the controls should be listened from
  6321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6322. */
  6323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6324. /**
  6325. * Detach the current controls from the specified dom element.
  6326. * @param element Defines the element to stop listening the inputs from
  6327. */
  6328. detachControl(element: Nullable<HTMLElement>): void;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs?: () => void;
  6334. }
  6335. /**
  6336. * Represents a map of input types to input instance or input index to input instance.
  6337. */
  6338. export interface CameraInputsMap<TCamera extends Camera> {
  6339. /**
  6340. * Accessor to the input by input type.
  6341. */
  6342. [name: string]: ICameraInput<TCamera>;
  6343. /**
  6344. * Accessor to the input by input index.
  6345. */
  6346. [idx: number]: ICameraInput<TCamera>;
  6347. }
  6348. /**
  6349. * This represents the input manager used within a camera.
  6350. * It helps dealing with all the different kind of input attached to a camera.
  6351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6352. */
  6353. export class CameraInputsManager<TCamera extends Camera> {
  6354. /**
  6355. * Defines the list of inputs attahed to the camera.
  6356. */
  6357. attached: CameraInputsMap<TCamera>;
  6358. /**
  6359. * Defines the dom element the camera is collecting inputs from.
  6360. * This is null if the controls have not been attached.
  6361. */
  6362. attachedElement: Nullable<HTMLElement>;
  6363. /**
  6364. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6365. */
  6366. noPreventDefault: boolean;
  6367. /**
  6368. * Defined the camera the input manager belongs to.
  6369. */
  6370. camera: TCamera;
  6371. /**
  6372. * Update the current camera state depending on the inputs that have been used this frame.
  6373. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6374. */
  6375. checkInputs: () => void;
  6376. /**
  6377. * Instantiate a new Camera Input Manager.
  6378. * @param camera Defines the camera the input manager blongs to
  6379. */
  6380. constructor(camera: TCamera);
  6381. /**
  6382. * Add an input method to a camera
  6383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6384. * @param input camera input method
  6385. */
  6386. add(input: ICameraInput<TCamera>): void;
  6387. /**
  6388. * Remove a specific input method from a camera
  6389. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6390. * @param inputToRemove camera input method
  6391. */
  6392. remove(inputToRemove: ICameraInput<TCamera>): void;
  6393. /**
  6394. * Remove a specific input type from a camera
  6395. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6396. * @param inputType the type of the input to remove
  6397. */
  6398. removeByType(inputType: string): void;
  6399. private _addCheckInputs;
  6400. /**
  6401. * Attach the input controls to the currently attached dom element to listen the events from.
  6402. * @param input Defines the input to attach
  6403. */
  6404. attachInput(input: ICameraInput<TCamera>): void;
  6405. /**
  6406. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6407. * @param element Defines the dom element to collect the events from
  6408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6409. */
  6410. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6411. /**
  6412. * Detach the current manager inputs controls from a specific dom element.
  6413. * @param element Defines the dom element to collect the events from
  6414. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6415. */
  6416. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6417. /**
  6418. * Rebuild the dynamic inputCheck function from the current list of
  6419. * defined inputs in the manager.
  6420. */
  6421. rebuildInputCheck(): void;
  6422. /**
  6423. * Remove all attached input methods from a camera
  6424. */
  6425. clear(): void;
  6426. /**
  6427. * Serialize the current input manager attached to a camera.
  6428. * This ensures than once parsed,
  6429. * the input associated to the camera will be identical to the current ones
  6430. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6431. */
  6432. serialize(serializedCamera: any): void;
  6433. /**
  6434. * Parses an input manager serialized JSON to restore the previous list of inputs
  6435. * and states associated to a camera.
  6436. * @param parsedCamera Defines the JSON to parse
  6437. */
  6438. parse(parsedCamera: any): void;
  6439. }
  6440. }
  6441. declare module "babylonjs/Meshes/buffer" {
  6442. import { Nullable, DataArray } from "babylonjs/types";
  6443. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6444. /**
  6445. * Class used to store data that will be store in GPU memory
  6446. */
  6447. export class Buffer {
  6448. private _engine;
  6449. private _buffer;
  6450. /** @hidden */
  6451. _data: Nullable<DataArray>;
  6452. private _updatable;
  6453. private _instanced;
  6454. private _divisor;
  6455. /**
  6456. * Gets the byte stride.
  6457. */
  6458. readonly byteStride: number;
  6459. /**
  6460. * Constructor
  6461. * @param engine the engine
  6462. * @param data the data to use for this buffer
  6463. * @param updatable whether the data is updatable
  6464. * @param stride the stride (optional)
  6465. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6466. * @param instanced whether the buffer is instanced (optional)
  6467. * @param useBytes set to true if the stride in in bytes (optional)
  6468. * @param divisor sets an optional divisor for instances (1 by default)
  6469. */
  6470. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6471. /**
  6472. * Create a new VertexBuffer based on the current buffer
  6473. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6474. * @param offset defines offset in the buffer (0 by default)
  6475. * @param size defines the size in floats of attributes (position is 3 for instance)
  6476. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6477. * @param instanced defines if the vertex buffer contains indexed data
  6478. * @param useBytes defines if the offset and stride are in bytes *
  6479. * @param divisor sets an optional divisor for instances (1 by default)
  6480. * @returns the new vertex buffer
  6481. */
  6482. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6483. /**
  6484. * Gets a boolean indicating if the Buffer is updatable?
  6485. * @returns true if the buffer is updatable
  6486. */
  6487. isUpdatable(): boolean;
  6488. /**
  6489. * Gets current buffer's data
  6490. * @returns a DataArray or null
  6491. */
  6492. getData(): Nullable<DataArray>;
  6493. /**
  6494. * Gets underlying native buffer
  6495. * @returns underlying native buffer
  6496. */
  6497. getBuffer(): Nullable<DataBuffer>;
  6498. /**
  6499. * Gets the stride in float32 units (i.e. byte stride / 4).
  6500. * May not be an integer if the byte stride is not divisible by 4.
  6501. * @returns the stride in float32 units
  6502. * @deprecated Please use byteStride instead.
  6503. */
  6504. getStrideSize(): number;
  6505. /**
  6506. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6507. * @param data defines the data to store
  6508. */
  6509. create(data?: Nullable<DataArray>): void;
  6510. /** @hidden */
  6511. _rebuild(): void;
  6512. /**
  6513. * Update current buffer data
  6514. * @param data defines the data to store
  6515. */
  6516. update(data: DataArray): void;
  6517. /**
  6518. * Updates the data directly.
  6519. * @param data the new data
  6520. * @param offset the new offset
  6521. * @param vertexCount the vertex count (optional)
  6522. * @param useBytes set to true if the offset is in bytes
  6523. */
  6524. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6525. /**
  6526. * Release all resources
  6527. */
  6528. dispose(): void;
  6529. }
  6530. /**
  6531. * Specialized buffer used to store vertex data
  6532. */
  6533. export class VertexBuffer {
  6534. /** @hidden */
  6535. _buffer: Buffer;
  6536. private _kind;
  6537. private _size;
  6538. private _ownsBuffer;
  6539. private _instanced;
  6540. private _instanceDivisor;
  6541. /**
  6542. * The byte type.
  6543. */
  6544. static readonly BYTE: number;
  6545. /**
  6546. * The unsigned byte type.
  6547. */
  6548. static readonly UNSIGNED_BYTE: number;
  6549. /**
  6550. * The short type.
  6551. */
  6552. static readonly SHORT: number;
  6553. /**
  6554. * The unsigned short type.
  6555. */
  6556. static readonly UNSIGNED_SHORT: number;
  6557. /**
  6558. * The integer type.
  6559. */
  6560. static readonly INT: number;
  6561. /**
  6562. * The unsigned integer type.
  6563. */
  6564. static readonly UNSIGNED_INT: number;
  6565. /**
  6566. * The float type.
  6567. */
  6568. static readonly FLOAT: number;
  6569. /**
  6570. * Gets or sets the instance divisor when in instanced mode
  6571. */
  6572. get instanceDivisor(): number;
  6573. set instanceDivisor(value: number);
  6574. /**
  6575. * Gets the byte stride.
  6576. */
  6577. readonly byteStride: number;
  6578. /**
  6579. * Gets the byte offset.
  6580. */
  6581. readonly byteOffset: number;
  6582. /**
  6583. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6584. */
  6585. readonly normalized: boolean;
  6586. /**
  6587. * Gets the data type of each component in the array.
  6588. */
  6589. readonly type: number;
  6590. /**
  6591. * Constructor
  6592. * @param engine the engine
  6593. * @param data the data to use for this vertex buffer
  6594. * @param kind the vertex buffer kind
  6595. * @param updatable whether the data is updatable
  6596. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6597. * @param stride the stride (optional)
  6598. * @param instanced whether the buffer is instanced (optional)
  6599. * @param offset the offset of the data (optional)
  6600. * @param size the number of components (optional)
  6601. * @param type the type of the component (optional)
  6602. * @param normalized whether the data contains normalized data (optional)
  6603. * @param useBytes set to true if stride and offset are in bytes (optional)
  6604. * @param divisor defines the instance divisor to use (1 by default)
  6605. */
  6606. 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);
  6607. /** @hidden */
  6608. _rebuild(): void;
  6609. /**
  6610. * Returns the kind of the VertexBuffer (string)
  6611. * @returns a string
  6612. */
  6613. getKind(): string;
  6614. /**
  6615. * Gets a boolean indicating if the VertexBuffer is updatable?
  6616. * @returns true if the buffer is updatable
  6617. */
  6618. isUpdatable(): boolean;
  6619. /**
  6620. * Gets current buffer's data
  6621. * @returns a DataArray or null
  6622. */
  6623. getData(): Nullable<DataArray>;
  6624. /**
  6625. * Gets underlying native buffer
  6626. * @returns underlying native buffer
  6627. */
  6628. getBuffer(): Nullable<DataBuffer>;
  6629. /**
  6630. * Gets the stride in float32 units (i.e. byte stride / 4).
  6631. * May not be an integer if the byte stride is not divisible by 4.
  6632. * @returns the stride in float32 units
  6633. * @deprecated Please use byteStride instead.
  6634. */
  6635. getStrideSize(): number;
  6636. /**
  6637. * Returns the offset as a multiple of the type byte length.
  6638. * @returns the offset in bytes
  6639. * @deprecated Please use byteOffset instead.
  6640. */
  6641. getOffset(): number;
  6642. /**
  6643. * Returns the number of components per vertex attribute (integer)
  6644. * @returns the size in float
  6645. */
  6646. getSize(): number;
  6647. /**
  6648. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6649. * @returns true if this buffer is instanced
  6650. */
  6651. getIsInstanced(): boolean;
  6652. /**
  6653. * Returns the instancing divisor, zero for non-instanced (integer).
  6654. * @returns a number
  6655. */
  6656. getInstanceDivisor(): number;
  6657. /**
  6658. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6659. * @param data defines the data to store
  6660. */
  6661. create(data?: DataArray): void;
  6662. /**
  6663. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6664. * This function will create a new buffer if the current one is not updatable
  6665. * @param data defines the data to store
  6666. */
  6667. update(data: DataArray): void;
  6668. /**
  6669. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6670. * Returns the directly updated WebGLBuffer.
  6671. * @param data the new data
  6672. * @param offset the new offset
  6673. * @param useBytes set to true if the offset is in bytes
  6674. */
  6675. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6676. /**
  6677. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6678. */
  6679. dispose(): void;
  6680. /**
  6681. * Enumerates each value of this vertex buffer as numbers.
  6682. * @param count the number of values to enumerate
  6683. * @param callback the callback function called for each value
  6684. */
  6685. forEach(count: number, callback: (value: number, index: number) => void): void;
  6686. /**
  6687. * Positions
  6688. */
  6689. static readonly PositionKind: string;
  6690. /**
  6691. * Normals
  6692. */
  6693. static readonly NormalKind: string;
  6694. /**
  6695. * Tangents
  6696. */
  6697. static readonly TangentKind: string;
  6698. /**
  6699. * Texture coordinates
  6700. */
  6701. static readonly UVKind: string;
  6702. /**
  6703. * Texture coordinates 2
  6704. */
  6705. static readonly UV2Kind: string;
  6706. /**
  6707. * Texture coordinates 3
  6708. */
  6709. static readonly UV3Kind: string;
  6710. /**
  6711. * Texture coordinates 4
  6712. */
  6713. static readonly UV4Kind: string;
  6714. /**
  6715. * Texture coordinates 5
  6716. */
  6717. static readonly UV5Kind: string;
  6718. /**
  6719. * Texture coordinates 6
  6720. */
  6721. static readonly UV6Kind: string;
  6722. /**
  6723. * Colors
  6724. */
  6725. static readonly ColorKind: string;
  6726. /**
  6727. * Matrix indices (for bones)
  6728. */
  6729. static readonly MatricesIndicesKind: string;
  6730. /**
  6731. * Matrix weights (for bones)
  6732. */
  6733. static readonly MatricesWeightsKind: string;
  6734. /**
  6735. * Additional matrix indices (for bones)
  6736. */
  6737. static readonly MatricesIndicesExtraKind: string;
  6738. /**
  6739. * Additional matrix weights (for bones)
  6740. */
  6741. static readonly MatricesWeightsExtraKind: string;
  6742. /**
  6743. * Deduces the stride given a kind.
  6744. * @param kind The kind string to deduce
  6745. * @returns The deduced stride
  6746. */
  6747. static DeduceStride(kind: string): number;
  6748. /**
  6749. * Gets the byte length of the given type.
  6750. * @param type the type
  6751. * @returns the number of bytes
  6752. */
  6753. static GetTypeByteLength(type: number): number;
  6754. /**
  6755. * Enumerates each value of the given parameters as numbers.
  6756. * @param data the data to enumerate
  6757. * @param byteOffset the byte offset of the data
  6758. * @param byteStride the byte stride of the data
  6759. * @param componentCount the number of components per element
  6760. * @param componentType the type of the component
  6761. * @param count the number of values to enumerate
  6762. * @param normalized whether the data is normalized
  6763. * @param callback the callback function called for each value
  6764. */
  6765. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6766. private static _GetFloatValue;
  6767. }
  6768. }
  6769. declare module "babylonjs/Collisions/intersectionInfo" {
  6770. import { Nullable } from "babylonjs/types";
  6771. /**
  6772. * @hidden
  6773. */
  6774. export class IntersectionInfo {
  6775. bu: Nullable<number>;
  6776. bv: Nullable<number>;
  6777. distance: number;
  6778. faceId: number;
  6779. subMeshId: number;
  6780. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6781. }
  6782. }
  6783. declare module "babylonjs/Culling/boundingSphere" {
  6784. import { DeepImmutable } from "babylonjs/types";
  6785. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6786. import { Plane } from "babylonjs/Maths/math.plane";
  6787. /**
  6788. * Class used to store bounding sphere information
  6789. */
  6790. export class BoundingSphere {
  6791. /**
  6792. * Gets the center of the bounding sphere in local space
  6793. */
  6794. readonly center: Vector3;
  6795. /**
  6796. * Radius of the bounding sphere in local space
  6797. */
  6798. radius: number;
  6799. /**
  6800. * Gets the center of the bounding sphere in world space
  6801. */
  6802. readonly centerWorld: Vector3;
  6803. /**
  6804. * Radius of the bounding sphere in world space
  6805. */
  6806. radiusWorld: number;
  6807. /**
  6808. * Gets the minimum vector in local space
  6809. */
  6810. readonly minimum: Vector3;
  6811. /**
  6812. * Gets the maximum vector in local space
  6813. */
  6814. readonly maximum: Vector3;
  6815. private _worldMatrix;
  6816. private static readonly TmpVector3;
  6817. /**
  6818. * Creates a new bounding sphere
  6819. * @param min defines the minimum vector (in local space)
  6820. * @param max defines the maximum vector (in local space)
  6821. * @param worldMatrix defines the new world matrix
  6822. */
  6823. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6824. /**
  6825. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6826. * @param min defines the new minimum vector (in local space)
  6827. * @param max defines the new maximum vector (in local space)
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6831. /**
  6832. * Scale the current bounding sphere by applying a scale factor
  6833. * @param factor defines the scale factor to apply
  6834. * @returns the current bounding box
  6835. */
  6836. scale(factor: number): BoundingSphere;
  6837. /**
  6838. * Gets the world matrix of the bounding box
  6839. * @returns a matrix
  6840. */
  6841. getWorldMatrix(): DeepImmutable<Matrix>;
  6842. /** @hidden */
  6843. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6844. /**
  6845. * Tests if the bounding sphere is intersecting the frustum planes
  6846. * @param frustumPlanes defines the frustum planes to test
  6847. * @returns true if there is an intersection
  6848. */
  6849. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6850. /**
  6851. * Tests if the bounding sphere center is in between the frustum planes.
  6852. * Used for optimistic fast inclusion.
  6853. * @param frustumPlanes defines the frustum planes to test
  6854. * @returns true if the sphere center is in between the frustum planes
  6855. */
  6856. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6857. /**
  6858. * Tests if a point is inside the bounding sphere
  6859. * @param point defines the point to test
  6860. * @returns true if the point is inside the bounding sphere
  6861. */
  6862. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6863. /**
  6864. * Checks if two sphere intersct
  6865. * @param sphere0 sphere 0
  6866. * @param sphere1 sphere 1
  6867. * @returns true if the speres intersect
  6868. */
  6869. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6870. }
  6871. }
  6872. declare module "babylonjs/Culling/boundingBox" {
  6873. import { DeepImmutable } from "babylonjs/types";
  6874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6875. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6876. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6877. import { Plane } from "babylonjs/Maths/math.plane";
  6878. /**
  6879. * Class used to store bounding box information
  6880. */
  6881. export class BoundingBox implements ICullable {
  6882. /**
  6883. * Gets the 8 vectors representing the bounding box in local space
  6884. */
  6885. readonly vectors: Vector3[];
  6886. /**
  6887. * Gets the center of the bounding box in local space
  6888. */
  6889. readonly center: Vector3;
  6890. /**
  6891. * Gets the center of the bounding box in world space
  6892. */
  6893. readonly centerWorld: Vector3;
  6894. /**
  6895. * Gets the extend size in local space
  6896. */
  6897. readonly extendSize: Vector3;
  6898. /**
  6899. * Gets the extend size in world space
  6900. */
  6901. readonly extendSizeWorld: Vector3;
  6902. /**
  6903. * Gets the OBB (object bounding box) directions
  6904. */
  6905. readonly directions: Vector3[];
  6906. /**
  6907. * Gets the 8 vectors representing the bounding box in world space
  6908. */
  6909. readonly vectorsWorld: Vector3[];
  6910. /**
  6911. * Gets the minimum vector in world space
  6912. */
  6913. readonly minimumWorld: Vector3;
  6914. /**
  6915. * Gets the maximum vector in world space
  6916. */
  6917. readonly maximumWorld: Vector3;
  6918. /**
  6919. * Gets the minimum vector in local space
  6920. */
  6921. readonly minimum: Vector3;
  6922. /**
  6923. * Gets the maximum vector in local space
  6924. */
  6925. readonly maximum: Vector3;
  6926. private _worldMatrix;
  6927. private static readonly TmpVector3;
  6928. /**
  6929. * @hidden
  6930. */
  6931. _tag: number;
  6932. /**
  6933. * Creates a new bounding box
  6934. * @param min defines the minimum vector (in local space)
  6935. * @param max defines the maximum vector (in local space)
  6936. * @param worldMatrix defines the new world matrix
  6937. */
  6938. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6939. /**
  6940. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6941. * @param min defines the new minimum vector (in local space)
  6942. * @param max defines the new maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6946. /**
  6947. * Scale the current bounding box by applying a scale factor
  6948. * @param factor defines the scale factor to apply
  6949. * @returns the current bounding box
  6950. */
  6951. scale(factor: number): BoundingBox;
  6952. /**
  6953. * Gets the world matrix of the bounding box
  6954. * @returns a matrix
  6955. */
  6956. getWorldMatrix(): DeepImmutable<Matrix>;
  6957. /** @hidden */
  6958. _update(world: DeepImmutable<Matrix>): void;
  6959. /**
  6960. * Tests if the bounding box is intersecting the frustum planes
  6961. * @param frustumPlanes defines the frustum planes to test
  6962. * @returns true if there is an intersection
  6963. */
  6964. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6965. /**
  6966. * Tests if the bounding box is entirely inside the frustum planes
  6967. * @param frustumPlanes defines the frustum planes to test
  6968. * @returns true if there is an inclusion
  6969. */
  6970. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6971. /**
  6972. * Tests if a point is inside the bounding box
  6973. * @param point defines the point to test
  6974. * @returns true if the point is inside the bounding box
  6975. */
  6976. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6977. /**
  6978. * Tests if the bounding box intersects with a bounding sphere
  6979. * @param sphere defines the sphere to test
  6980. * @returns true if there is an intersection
  6981. */
  6982. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6983. /**
  6984. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6985. * @param min defines the min vector to use
  6986. * @param max defines the max vector to use
  6987. * @returns true if there is an intersection
  6988. */
  6989. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6990. /**
  6991. * Tests if two bounding boxes are intersections
  6992. * @param box0 defines the first box to test
  6993. * @param box1 defines the second box to test
  6994. * @returns true if there is an intersection
  6995. */
  6996. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6997. /**
  6998. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6999. * @param minPoint defines the minimum vector of the bounding box
  7000. * @param maxPoint defines the maximum vector of the bounding box
  7001. * @param sphereCenter defines the sphere center
  7002. * @param sphereRadius defines the sphere radius
  7003. * @returns true if there is an intersection
  7004. */
  7005. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7006. /**
  7007. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7008. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7009. * @param frustumPlanes defines the frustum planes to test
  7010. * @return true if there is an inclusion
  7011. */
  7012. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7013. /**
  7014. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7015. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7016. * @param frustumPlanes defines the frustum planes to test
  7017. * @return true if there is an intersection
  7018. */
  7019. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7020. }
  7021. }
  7022. declare module "babylonjs/Collisions/collider" {
  7023. import { Nullable, IndicesArray } from "babylonjs/types";
  7024. import { Vector3 } from "babylonjs/Maths/math.vector";
  7025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7026. import { Plane } from "babylonjs/Maths/math.plane";
  7027. /** @hidden */
  7028. export class Collider {
  7029. /** Define if a collision was found */
  7030. collisionFound: boolean;
  7031. /**
  7032. * Define last intersection point in local space
  7033. */
  7034. intersectionPoint: Vector3;
  7035. /**
  7036. * Define last collided mesh
  7037. */
  7038. collidedMesh: Nullable<AbstractMesh>;
  7039. private _collisionPoint;
  7040. private _planeIntersectionPoint;
  7041. private _tempVector;
  7042. private _tempVector2;
  7043. private _tempVector3;
  7044. private _tempVector4;
  7045. private _edge;
  7046. private _baseToVertex;
  7047. private _destinationPoint;
  7048. private _slidePlaneNormal;
  7049. private _displacementVector;
  7050. /** @hidden */
  7051. _radius: Vector3;
  7052. /** @hidden */
  7053. _retry: number;
  7054. private _velocity;
  7055. private _basePoint;
  7056. private _epsilon;
  7057. /** @hidden */
  7058. _velocityWorldLength: number;
  7059. /** @hidden */
  7060. _basePointWorld: Vector3;
  7061. private _velocityWorld;
  7062. private _normalizedVelocity;
  7063. /** @hidden */
  7064. _initialVelocity: Vector3;
  7065. /** @hidden */
  7066. _initialPosition: Vector3;
  7067. private _nearestDistance;
  7068. private _collisionMask;
  7069. get collisionMask(): number;
  7070. set collisionMask(mask: number);
  7071. /**
  7072. * Gets the plane normal used to compute the sliding response (in local space)
  7073. */
  7074. get slidePlaneNormal(): Vector3;
  7075. /** @hidden */
  7076. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7077. /** @hidden */
  7078. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7079. /** @hidden */
  7080. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7081. /** @hidden */
  7082. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7083. /** @hidden */
  7084. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7085. /** @hidden */
  7086. _getResponse(pos: Vector3, vel: Vector3): void;
  7087. }
  7088. }
  7089. declare module "babylonjs/Culling/boundingInfo" {
  7090. import { DeepImmutable } from "babylonjs/types";
  7091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7092. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7093. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7094. import { Plane } from "babylonjs/Maths/math.plane";
  7095. import { Collider } from "babylonjs/Collisions/collider";
  7096. /**
  7097. * Interface for cullable objects
  7098. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7099. */
  7100. export interface ICullable {
  7101. /**
  7102. * Checks if the object or part of the object is in the frustum
  7103. * @param frustumPlanes Camera near/planes
  7104. * @returns true if the object is in frustum otherwise false
  7105. */
  7106. isInFrustum(frustumPlanes: Plane[]): boolean;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7114. }
  7115. /**
  7116. * Info for a bounding data of a mesh
  7117. */
  7118. export class BoundingInfo implements ICullable {
  7119. /**
  7120. * Bounding box for the mesh
  7121. */
  7122. readonly boundingBox: BoundingBox;
  7123. /**
  7124. * Bounding sphere for the mesh
  7125. */
  7126. readonly boundingSphere: BoundingSphere;
  7127. private _isLocked;
  7128. private static readonly TmpVector3;
  7129. /**
  7130. * Constructs bounding info
  7131. * @param minimum min vector of the bounding box/sphere
  7132. * @param maximum max vector of the bounding box/sphere
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7136. /**
  7137. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7138. * @param min defines the new minimum vector (in local space)
  7139. * @param max defines the new maximum vector (in local space)
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7143. /**
  7144. * min vector of the bounding box/sphere
  7145. */
  7146. get minimum(): Vector3;
  7147. /**
  7148. * max vector of the bounding box/sphere
  7149. */
  7150. get maximum(): Vector3;
  7151. /**
  7152. * If the info is locked and won't be updated to avoid perf overhead
  7153. */
  7154. get isLocked(): boolean;
  7155. set isLocked(value: boolean);
  7156. /**
  7157. * Updates the bounding sphere and box
  7158. * @param world world matrix to be used to update
  7159. */
  7160. update(world: DeepImmutable<Matrix>): void;
  7161. /**
  7162. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7163. * @param center New center of the bounding info
  7164. * @param extend New extend of the bounding info
  7165. * @returns the current bounding info
  7166. */
  7167. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7168. /**
  7169. * Scale the current bounding info by applying a scale factor
  7170. * @param factor defines the scale factor to apply
  7171. * @returns the current bounding info
  7172. */
  7173. scale(factor: number): BoundingInfo;
  7174. /**
  7175. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7176. * @param frustumPlanes defines the frustum to test
  7177. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7178. * @returns true if the bounding info is in the frustum planes
  7179. */
  7180. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7181. /**
  7182. * Gets the world distance between the min and max points of the bounding box
  7183. */
  7184. get diagonalLength(): number;
  7185. /**
  7186. * Checks if a cullable object (mesh...) is in the camera frustum
  7187. * Unlike isInFrustum this cheks the full bounding box
  7188. * @param frustumPlanes Camera near/planes
  7189. * @returns true if the object is in frustum otherwise false
  7190. */
  7191. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. /** @hidden */
  7193. _checkCollision(collider: Collider): boolean;
  7194. /**
  7195. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7196. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7197. * @param point the point to check intersection with
  7198. * @returns if the point intersects
  7199. */
  7200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7201. /**
  7202. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7203. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7204. * @param boundingInfo the bounding info to check intersection with
  7205. * @param precise if the intersection should be done using OBB
  7206. * @returns if the bounding info intersects
  7207. */
  7208. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7209. }
  7210. }
  7211. declare module "babylonjs/Maths/math.functions" {
  7212. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7213. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7214. /**
  7215. * Extracts minimum and maximum values from a list of indexed positions
  7216. * @param positions defines the positions to use
  7217. * @param indices defines the indices to the positions
  7218. * @param indexStart defines the start index
  7219. * @param indexCount defines the end index
  7220. * @param bias defines bias value to add to the result
  7221. * @return minimum and maximum values
  7222. */
  7223. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7224. minimum: Vector3;
  7225. maximum: Vector3;
  7226. };
  7227. /**
  7228. * Extracts minimum and maximum values from a list of positions
  7229. * @param positions defines the positions to use
  7230. * @param start defines the start index in the positions array
  7231. * @param count defines the number of positions to handle
  7232. * @param bias defines bias value to add to the result
  7233. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7234. * @return minimum and maximum values
  7235. */
  7236. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7237. minimum: Vector3;
  7238. maximum: Vector3;
  7239. };
  7240. }
  7241. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7242. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7243. /** @hidden */
  7244. export class WebGLDataBuffer extends DataBuffer {
  7245. private _buffer;
  7246. constructor(resource: WebGLBuffer);
  7247. get underlyingResource(): any;
  7248. }
  7249. }
  7250. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7252. import { Nullable } from "babylonjs/types";
  7253. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7254. /** @hidden */
  7255. export class WebGLPipelineContext implements IPipelineContext {
  7256. engine: ThinEngine;
  7257. program: Nullable<WebGLProgram>;
  7258. context?: WebGLRenderingContext;
  7259. vertexShader?: WebGLShader;
  7260. fragmentShader?: WebGLShader;
  7261. isParallelCompiled: boolean;
  7262. onCompiled?: () => void;
  7263. transformFeedback?: WebGLTransformFeedback | null;
  7264. vertexCompilationError: Nullable<string>;
  7265. fragmentCompilationError: Nullable<string>;
  7266. programLinkError: Nullable<string>;
  7267. programValidationError: Nullable<string>;
  7268. get isAsync(): boolean;
  7269. get isReady(): boolean;
  7270. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7271. _getVertexShaderCode(): string | null;
  7272. _getFragmentShaderCode(): string | null;
  7273. }
  7274. }
  7275. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7276. import { FloatArray, Nullable } from "babylonjs/types";
  7277. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7278. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7279. module "babylonjs/Engines/thinEngine" {
  7280. interface ThinEngine {
  7281. /**
  7282. * Create an uniform buffer
  7283. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7284. * @param elements defines the content of the uniform buffer
  7285. * @returns the webGL uniform buffer
  7286. */
  7287. createUniformBuffer(elements: FloatArray): DataBuffer;
  7288. /**
  7289. * Create a dynamic uniform buffer
  7290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7291. * @param elements defines the content of the uniform buffer
  7292. * @returns the webGL uniform buffer
  7293. */
  7294. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7295. /**
  7296. * Update an existing uniform buffer
  7297. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7298. * @param uniformBuffer defines the target uniform buffer
  7299. * @param elements defines the content to update
  7300. * @param offset defines the offset in the uniform buffer where update should start
  7301. * @param count defines the size of the data to update
  7302. */
  7303. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7304. /**
  7305. * Bind an uniform buffer to the current webGL context
  7306. * @param buffer defines the buffer to bind
  7307. */
  7308. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7309. /**
  7310. * Bind a buffer to the current webGL context at a given location
  7311. * @param buffer defines the buffer to bind
  7312. * @param location defines the index where to bind the buffer
  7313. */
  7314. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7315. /**
  7316. * Bind a specific block at a given index in a specific shader program
  7317. * @param pipelineContext defines the pipeline context to use
  7318. * @param blockName defines the block name
  7319. * @param index defines the index where to bind the block
  7320. */
  7321. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7322. }
  7323. }
  7324. }
  7325. declare module "babylonjs/Materials/uniformBuffer" {
  7326. import { Nullable, FloatArray } from "babylonjs/types";
  7327. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7328. import { Engine } from "babylonjs/Engines/engine";
  7329. import { Effect } from "babylonjs/Materials/effect";
  7330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7331. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7332. import { Color3 } from "babylonjs/Maths/math.color";
  7333. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7334. /**
  7335. * Uniform buffer objects.
  7336. *
  7337. * Handles blocks of uniform on the GPU.
  7338. *
  7339. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7340. *
  7341. * For more information, please refer to :
  7342. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7343. */
  7344. export class UniformBuffer {
  7345. private _engine;
  7346. private _buffer;
  7347. private _data;
  7348. private _bufferData;
  7349. private _dynamic?;
  7350. private _uniformLocations;
  7351. private _uniformSizes;
  7352. private _uniformLocationPointer;
  7353. private _needSync;
  7354. private _noUBO;
  7355. private _currentEffect;
  7356. /** @hidden */
  7357. _alreadyBound: boolean;
  7358. private static _MAX_UNIFORM_SIZE;
  7359. private static _tempBuffer;
  7360. /**
  7361. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7362. * This is dynamic to allow compat with webgl 1 and 2.
  7363. * You will need to pass the name of the uniform as well as the value.
  7364. */
  7365. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7366. /**
  7367. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7368. * This is dynamic to allow compat with webgl 1 and 2.
  7369. * You will need to pass the name of the uniform as well as the value.
  7370. */
  7371. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7372. /**
  7373. * Lambda to Update a single float in a uniform buffer.
  7374. * This is dynamic to allow compat with webgl 1 and 2.
  7375. * You will need to pass the name of the uniform as well as the value.
  7376. */
  7377. updateFloat: (name: string, x: number) => void;
  7378. /**
  7379. * Lambda to Update a vec2 of float in a uniform buffer.
  7380. * This is dynamic to allow compat with webgl 1 and 2.
  7381. * You will need to pass the name of the uniform as well as the value.
  7382. */
  7383. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7384. /**
  7385. * Lambda to Update a vec3 of float in a uniform buffer.
  7386. * This is dynamic to allow compat with webgl 1 and 2.
  7387. * You will need to pass the name of the uniform as well as the value.
  7388. */
  7389. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7390. /**
  7391. * Lambda to Update a vec4 of float in a uniform buffer.
  7392. * This is dynamic to allow compat with webgl 1 and 2.
  7393. * You will need to pass the name of the uniform as well as the value.
  7394. */
  7395. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7396. /**
  7397. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7398. * This is dynamic to allow compat with webgl 1 and 2.
  7399. * You will need to pass the name of the uniform as well as the value.
  7400. */
  7401. updateMatrix: (name: string, mat: Matrix) => void;
  7402. /**
  7403. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7404. * This is dynamic to allow compat with webgl 1 and 2.
  7405. * You will need to pass the name of the uniform as well as the value.
  7406. */
  7407. updateVector3: (name: string, vector: Vector3) => void;
  7408. /**
  7409. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7410. * This is dynamic to allow compat with webgl 1 and 2.
  7411. * You will need to pass the name of the uniform as well as the value.
  7412. */
  7413. updateVector4: (name: string, vector: Vector4) => void;
  7414. /**
  7415. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7416. * This is dynamic to allow compat with webgl 1 and 2.
  7417. * You will need to pass the name of the uniform as well as the value.
  7418. */
  7419. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7420. /**
  7421. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7422. * This is dynamic to allow compat with webgl 1 and 2.
  7423. * You will need to pass the name of the uniform as well as the value.
  7424. */
  7425. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7426. /**
  7427. * Instantiates a new Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. * @param engine Define the engine the buffer is associated with
  7436. * @param data Define the data contained in the buffer
  7437. * @param dynamic Define if the buffer is updatable
  7438. */
  7439. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7440. /**
  7441. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7442. * or just falling back on setUniformXXX calls.
  7443. */
  7444. get useUbo(): boolean;
  7445. /**
  7446. * Indicates if the WebGL underlying uniform buffer is in sync
  7447. * with the javascript cache data.
  7448. */
  7449. get isSync(): boolean;
  7450. /**
  7451. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7452. * Also, a dynamic UniformBuffer will disable cache verification and always
  7453. * update the underlying WebGL uniform buffer to the GPU.
  7454. * @returns if Dynamic, otherwise false
  7455. */
  7456. isDynamic(): boolean;
  7457. /**
  7458. * The data cache on JS side.
  7459. * @returns the underlying data as a float array
  7460. */
  7461. getData(): Float32Array;
  7462. /**
  7463. * The underlying WebGL Uniform buffer.
  7464. * @returns the webgl buffer
  7465. */
  7466. getBuffer(): Nullable<DataBuffer>;
  7467. /**
  7468. * std140 layout specifies how to align data within an UBO structure.
  7469. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7470. * for specs.
  7471. */
  7472. private _fillAlignment;
  7473. /**
  7474. * Adds an uniform in the buffer.
  7475. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7476. * for the layout to be correct !
  7477. * @param name Name of the uniform, as used in the uniform block in the shader.
  7478. * @param size Data size, or data directly.
  7479. */
  7480. addUniform(name: string, size: number | number[]): void;
  7481. /**
  7482. * Adds a Matrix 4x4 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. * @param mat A 4x4 matrix.
  7485. */
  7486. addMatrix(name: string, mat: Matrix): void;
  7487. /**
  7488. * Adds a vec2 to the uniform buffer.
  7489. * @param name Name of the uniform, as used in the uniform block in the shader.
  7490. * @param x Define the x component value of the vec2
  7491. * @param y Define the y component value of the vec2
  7492. */
  7493. addFloat2(name: string, x: number, y: number): void;
  7494. /**
  7495. * Adds a vec3 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. * @param x Define the x component value of the vec3
  7498. * @param y Define the y component value of the vec3
  7499. * @param z Define the z component value of the vec3
  7500. */
  7501. addFloat3(name: string, x: number, y: number, z: number): void;
  7502. /**
  7503. * Adds a vec3 to the uniform buffer.
  7504. * @param name Name of the uniform, as used in the uniform block in the shader.
  7505. * @param color Define the vec3 from a Color
  7506. */
  7507. addColor3(name: string, color: Color3): void;
  7508. /**
  7509. * Adds a vec4 to the uniform buffer.
  7510. * @param name Name of the uniform, as used in the uniform block in the shader.
  7511. * @param color Define the rgb components from a Color
  7512. * @param alpha Define the a component of the vec4
  7513. */
  7514. addColor4(name: string, color: Color3, alpha: number): void;
  7515. /**
  7516. * Adds a vec3 to the uniform buffer.
  7517. * @param name Name of the uniform, as used in the uniform block in the shader.
  7518. * @param vector Define the vec3 components from a Vector
  7519. */
  7520. addVector3(name: string, vector: Vector3): void;
  7521. /**
  7522. * Adds a Matrix 3x3 to the uniform buffer.
  7523. * @param name Name of the uniform, as used in the uniform block in the shader.
  7524. */
  7525. addMatrix3x3(name: string): void;
  7526. /**
  7527. * Adds a Matrix 2x2 to the uniform buffer.
  7528. * @param name Name of the uniform, as used in the uniform block in the shader.
  7529. */
  7530. addMatrix2x2(name: string): void;
  7531. /**
  7532. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7533. */
  7534. create(): void;
  7535. /** @hidden */
  7536. _rebuild(): void;
  7537. /**
  7538. * Updates the WebGL Uniform Buffer on the GPU.
  7539. * If the `dynamic` flag is set to true, no cache comparison is done.
  7540. * Otherwise, the buffer will be updated only if the cache differs.
  7541. */
  7542. update(): void;
  7543. /**
  7544. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7545. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7546. * @param data Define the flattened data
  7547. * @param size Define the size of the data.
  7548. */
  7549. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7550. private _valueCache;
  7551. private _cacheMatrix;
  7552. private _updateMatrix3x3ForUniform;
  7553. private _updateMatrix3x3ForEffect;
  7554. private _updateMatrix2x2ForEffect;
  7555. private _updateMatrix2x2ForUniform;
  7556. private _updateFloatForEffect;
  7557. private _updateFloatForUniform;
  7558. private _updateFloat2ForEffect;
  7559. private _updateFloat2ForUniform;
  7560. private _updateFloat3ForEffect;
  7561. private _updateFloat3ForUniform;
  7562. private _updateFloat4ForEffect;
  7563. private _updateFloat4ForUniform;
  7564. private _updateMatrixForEffect;
  7565. private _updateMatrixForUniform;
  7566. private _updateVector3ForEffect;
  7567. private _updateVector3ForUniform;
  7568. private _updateVector4ForEffect;
  7569. private _updateVector4ForUniform;
  7570. private _updateColor3ForEffect;
  7571. private _updateColor3ForUniform;
  7572. private _updateColor4ForEffect;
  7573. private _updateColor4ForUniform;
  7574. /**
  7575. * Sets a sampler uniform on the effect.
  7576. * @param name Define the name of the sampler.
  7577. * @param texture Define the texture to set in the sampler
  7578. */
  7579. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7580. /**
  7581. * Directly updates the value of the uniform in the cache AND on the GPU.
  7582. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7583. * @param data Define the flattened data
  7584. */
  7585. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7586. /**
  7587. * Binds this uniform buffer to an effect.
  7588. * @param effect Define the effect to bind the buffer to
  7589. * @param name Name of the uniform block in the shader.
  7590. */
  7591. bindToEffect(effect: Effect, name: string): void;
  7592. /**
  7593. * Disposes the uniform buffer.
  7594. */
  7595. dispose(): void;
  7596. }
  7597. }
  7598. declare module "babylonjs/Misc/iInspectable" {
  7599. /**
  7600. * Enum that determines the text-wrapping mode to use.
  7601. */
  7602. export enum InspectableType {
  7603. /**
  7604. * Checkbox for booleans
  7605. */
  7606. Checkbox = 0,
  7607. /**
  7608. * Sliders for numbers
  7609. */
  7610. Slider = 1,
  7611. /**
  7612. * Vector3
  7613. */
  7614. Vector3 = 2,
  7615. /**
  7616. * Quaternions
  7617. */
  7618. Quaternion = 3,
  7619. /**
  7620. * Color3
  7621. */
  7622. Color3 = 4,
  7623. /**
  7624. * String
  7625. */
  7626. String = 5
  7627. }
  7628. /**
  7629. * Interface used to define custom inspectable properties.
  7630. * This interface is used by the inspector to display custom property grids
  7631. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7632. */
  7633. export interface IInspectable {
  7634. /**
  7635. * Gets the label to display
  7636. */
  7637. label: string;
  7638. /**
  7639. * Gets the name of the property to edit
  7640. */
  7641. propertyName: string;
  7642. /**
  7643. * Gets the type of the editor to use
  7644. */
  7645. type: InspectableType;
  7646. /**
  7647. * Gets the minimum value of the property when using in "slider" mode
  7648. */
  7649. min?: number;
  7650. /**
  7651. * Gets the maximum value of the property when using in "slider" mode
  7652. */
  7653. max?: number;
  7654. /**
  7655. * Gets the setp to use when using in "slider" mode
  7656. */
  7657. step?: number;
  7658. }
  7659. }
  7660. declare module "babylonjs/Misc/timingTools" {
  7661. /**
  7662. * Class used to provide helper for timing
  7663. */
  7664. export class TimingTools {
  7665. /**
  7666. * Polyfill for setImmediate
  7667. * @param action defines the action to execute after the current execution block
  7668. */
  7669. static SetImmediate(action: () => void): void;
  7670. }
  7671. }
  7672. declare module "babylonjs/Misc/instantiationTools" {
  7673. /**
  7674. * Class used to enable instatition of objects by class name
  7675. */
  7676. export class InstantiationTools {
  7677. /**
  7678. * Use this object to register external classes like custom textures or material
  7679. * to allow the laoders to instantiate them
  7680. */
  7681. static RegisteredExternalClasses: {
  7682. [key: string]: Object;
  7683. };
  7684. /**
  7685. * Tries to instantiate a new object from a given class name
  7686. * @param className defines the class name to instantiate
  7687. * @returns the new object or null if the system was not able to do the instantiation
  7688. */
  7689. static Instantiate(className: string): any;
  7690. }
  7691. }
  7692. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7693. /**
  7694. * Define options used to create a depth texture
  7695. */
  7696. export class DepthTextureCreationOptions {
  7697. /** Specifies whether or not a stencil should be allocated in the texture */
  7698. generateStencil?: boolean;
  7699. /** Specifies whether or not bilinear filtering is enable on the texture */
  7700. bilinearFiltering?: boolean;
  7701. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7702. comparisonFunction?: number;
  7703. /** Specifies if the created texture is a cube texture */
  7704. isCube?: boolean;
  7705. }
  7706. }
  7707. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7709. import { Nullable } from "babylonjs/types";
  7710. import { Scene } from "babylonjs/scene";
  7711. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7712. module "babylonjs/Engines/thinEngine" {
  7713. interface ThinEngine {
  7714. /**
  7715. * Creates a depth stencil cube texture.
  7716. * This is only available in WebGL 2.
  7717. * @param size The size of face edge in the cube texture.
  7718. * @param options The options defining the cube texture.
  7719. * @returns The cube texture
  7720. */
  7721. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7722. /**
  7723. * Creates a cube texture
  7724. * @param rootUrl defines the url where the files to load is located
  7725. * @param scene defines the current scene
  7726. * @param files defines the list of files to load (1 per face)
  7727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7728. * @param onLoad defines an optional callback raised when the texture is loaded
  7729. * @param onError defines an optional callback raised if there is an issue to load the texture
  7730. * @param format defines the format of the data
  7731. * @param forcedExtension defines the extension to use to pick the right loader
  7732. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7735. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7736. * @returns the cube texture as an InternalTexture
  7737. */
  7738. 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;
  7739. /**
  7740. * Creates a cube texture
  7741. * @param rootUrl defines the url where the files to load is located
  7742. * @param scene defines the current scene
  7743. * @param files defines the list of files to load (1 per face)
  7744. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7745. * @param onLoad defines an optional callback raised when the texture is loaded
  7746. * @param onError defines an optional callback raised if there is an issue to load the texture
  7747. * @param format defines the format of the data
  7748. * @param forcedExtension defines the extension to use to pick the right loader
  7749. * @returns the cube texture as an InternalTexture
  7750. */
  7751. 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;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @returns the cube texture as an InternalTexture
  7766. */
  7767. 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;
  7768. /** @hidden */
  7769. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7770. /** @hidden */
  7771. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7772. /** @hidden */
  7773. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7774. /** @hidden */
  7775. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7776. /**
  7777. * @hidden
  7778. */
  7779. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7780. }
  7781. }
  7782. }
  7783. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7784. import { Nullable } from "babylonjs/types";
  7785. import { Scene } from "babylonjs/scene";
  7786. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7788. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7789. import { Observable } from "babylonjs/Misc/observable";
  7790. /**
  7791. * Class for creating a cube texture
  7792. */
  7793. export class CubeTexture extends BaseTexture {
  7794. private _delayedOnLoad;
  7795. /**
  7796. * Observable triggered once the texture has been loaded.
  7797. */
  7798. onLoadObservable: Observable<CubeTexture>;
  7799. /**
  7800. * The url of the texture
  7801. */
  7802. url: string;
  7803. /**
  7804. * Gets or sets the center of the bounding box associated with the cube texture.
  7805. * It must define where the camera used to render the texture was set
  7806. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7807. */
  7808. boundingBoxPosition: Vector3;
  7809. private _boundingBoxSize;
  7810. /**
  7811. * Gets or sets the size of the bounding box associated with the cube texture
  7812. * When defined, the cubemap will switch to local mode
  7813. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7814. * @example https://www.babylonjs-playground.com/#RNASML
  7815. */
  7816. set boundingBoxSize(value: Vector3);
  7817. /**
  7818. * Returns the bounding box size
  7819. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7820. */
  7821. get boundingBoxSize(): Vector3;
  7822. protected _rotationY: number;
  7823. /**
  7824. * Sets texture matrix rotation angle around Y axis in radians.
  7825. */
  7826. set rotationY(value: number);
  7827. /**
  7828. * Gets texture matrix rotation angle around Y axis radians.
  7829. */
  7830. get rotationY(): number;
  7831. /**
  7832. * Are mip maps generated for this texture or not.
  7833. */
  7834. get noMipmap(): boolean;
  7835. private _noMipmap;
  7836. private _files;
  7837. protected _forcedExtension: Nullable<string>;
  7838. private _extensions;
  7839. private _textureMatrix;
  7840. private _format;
  7841. private _createPolynomials;
  7842. /** @hidden */
  7843. _prefiltered: boolean;
  7844. /**
  7845. * Creates a cube texture from an array of image urls
  7846. * @param files defines an array of image urls
  7847. * @param scene defines the hosting scene
  7848. * @param noMipmap specifies if mip maps are not used
  7849. * @returns a cube texture
  7850. */
  7851. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7852. /**
  7853. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7854. * @param url defines the url of the prefiltered texture
  7855. * @param scene defines the scene the texture is attached to
  7856. * @param forcedExtension defines the extension of the file if different from the url
  7857. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7858. * @return the prefiltered texture
  7859. */
  7860. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7861. /**
  7862. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7863. * as prefiltered data.
  7864. * @param rootUrl defines the url of the texture or the root name of the six images
  7865. * @param scene defines the scene the texture is attached to
  7866. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7867. * @param noMipmap defines if mipmaps should be created or not
  7868. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7869. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7870. * @param onError defines a callback triggered in case of error during load
  7871. * @param format defines the internal format to use for the texture once loaded
  7872. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7873. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7874. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7875. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7876. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7877. * @return the cube texture
  7878. */
  7879. 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);
  7880. /**
  7881. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7882. */
  7883. get isPrefiltered(): boolean;
  7884. /**
  7885. * Get the current class name of the texture useful for serialization or dynamic coding.
  7886. * @returns "CubeTexture"
  7887. */
  7888. getClassName(): string;
  7889. /**
  7890. * Update the url (and optional buffer) of this texture if url was null during construction.
  7891. * @param url the url of the texture
  7892. * @param forcedExtension defines the extension to use
  7893. * @param onLoad callback called when the texture is loaded (defaults to null)
  7894. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7895. */
  7896. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7897. /**
  7898. * Delays loading of the cube texture
  7899. * @param forcedExtension defines the extension to use
  7900. */
  7901. delayLoad(forcedExtension?: string): void;
  7902. /**
  7903. * Returns the reflection texture matrix
  7904. * @returns the reflection texture matrix
  7905. */
  7906. getReflectionTextureMatrix(): Matrix;
  7907. /**
  7908. * Sets the reflection texture matrix
  7909. * @param value Reflection texture matrix
  7910. */
  7911. setReflectionTextureMatrix(value: Matrix): void;
  7912. /**
  7913. * Parses text to create a cube texture
  7914. * @param parsedTexture define the serialized text to read from
  7915. * @param scene defines the hosting scene
  7916. * @param rootUrl defines the root url of the cube texture
  7917. * @returns a cube texture
  7918. */
  7919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7920. /**
  7921. * Makes a clone, or deep copy, of the cube texture
  7922. * @returns a new cube texture
  7923. */
  7924. clone(): CubeTexture;
  7925. }
  7926. }
  7927. declare module "babylonjs/Materials/materialDefines" {
  7928. /**
  7929. * Manages the defines for the Material
  7930. */
  7931. export class MaterialDefines {
  7932. /** @hidden */
  7933. protected _keys: string[];
  7934. private _isDirty;
  7935. /** @hidden */
  7936. _renderId: number;
  7937. /** @hidden */
  7938. _areLightsDirty: boolean;
  7939. /** @hidden */
  7940. _areLightsDisposed: boolean;
  7941. /** @hidden */
  7942. _areAttributesDirty: boolean;
  7943. /** @hidden */
  7944. _areTexturesDirty: boolean;
  7945. /** @hidden */
  7946. _areFresnelDirty: boolean;
  7947. /** @hidden */
  7948. _areMiscDirty: boolean;
  7949. /** @hidden */
  7950. _areImageProcessingDirty: boolean;
  7951. /** @hidden */
  7952. _normals: boolean;
  7953. /** @hidden */
  7954. _uvs: boolean;
  7955. /** @hidden */
  7956. _needNormals: boolean;
  7957. /** @hidden */
  7958. _needUVs: boolean;
  7959. [id: string]: any;
  7960. /**
  7961. * Specifies if the material needs to be re-calculated
  7962. */
  7963. get isDirty(): boolean;
  7964. /**
  7965. * Marks the material to indicate that it has been re-calculated
  7966. */
  7967. markAsProcessed(): void;
  7968. /**
  7969. * Marks the material to indicate that it needs to be re-calculated
  7970. */
  7971. markAsUnprocessed(): void;
  7972. /**
  7973. * Marks the material to indicate all of its defines need to be re-calculated
  7974. */
  7975. markAllAsDirty(): void;
  7976. /**
  7977. * Marks the material to indicate that image processing needs to be re-calculated
  7978. */
  7979. markAsImageProcessingDirty(): void;
  7980. /**
  7981. * Marks the material to indicate the lights need to be re-calculated
  7982. * @param disposed Defines whether the light is dirty due to dispose or not
  7983. */
  7984. markAsLightDirty(disposed?: boolean): void;
  7985. /**
  7986. * Marks the attribute state as changed
  7987. */
  7988. markAsAttributesDirty(): void;
  7989. /**
  7990. * Marks the texture state as changed
  7991. */
  7992. markAsTexturesDirty(): void;
  7993. /**
  7994. * Marks the fresnel state as changed
  7995. */
  7996. markAsFresnelDirty(): void;
  7997. /**
  7998. * Marks the misc state as changed
  7999. */
  8000. markAsMiscDirty(): void;
  8001. /**
  8002. * Rebuilds the material defines
  8003. */
  8004. rebuild(): void;
  8005. /**
  8006. * Specifies if two material defines are equal
  8007. * @param other - A material define instance to compare to
  8008. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8009. */
  8010. isEqual(other: MaterialDefines): boolean;
  8011. /**
  8012. * Clones this instance's defines to another instance
  8013. * @param other - material defines to clone values to
  8014. */
  8015. cloneTo(other: MaterialDefines): void;
  8016. /**
  8017. * Resets the material define values
  8018. */
  8019. reset(): void;
  8020. /**
  8021. * Converts the material define values to a string
  8022. * @returns - String of material define information
  8023. */
  8024. toString(): string;
  8025. }
  8026. }
  8027. declare module "babylonjs/Materials/colorCurves" {
  8028. import { Effect } from "babylonjs/Materials/effect";
  8029. /**
  8030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8032. * 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;
  8033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8034. */
  8035. export class ColorCurves {
  8036. private _dirty;
  8037. private _tempColor;
  8038. private _globalCurve;
  8039. private _highlightsCurve;
  8040. private _midtonesCurve;
  8041. private _shadowsCurve;
  8042. private _positiveCurve;
  8043. private _negativeCurve;
  8044. private _globalHue;
  8045. private _globalDensity;
  8046. private _globalSaturation;
  8047. private _globalExposure;
  8048. /**
  8049. * Gets the global Hue value.
  8050. * 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).
  8051. */
  8052. get globalHue(): number;
  8053. /**
  8054. * Sets the global Hue value.
  8055. * 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).
  8056. */
  8057. set globalHue(value: number);
  8058. /**
  8059. * Gets the global Density value.
  8060. * 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.
  8061. * Values less than zero provide a filter of opposite hue.
  8062. */
  8063. get globalDensity(): number;
  8064. /**
  8065. * Sets the global Density value.
  8066. * 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.
  8067. * Values less than zero provide a filter of opposite hue.
  8068. */
  8069. set globalDensity(value: number);
  8070. /**
  8071. * Gets the global Saturation value.
  8072. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8073. */
  8074. get globalSaturation(): number;
  8075. /**
  8076. * Sets the global Saturation value.
  8077. * 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.
  8078. */
  8079. set globalSaturation(value: number);
  8080. /**
  8081. * Gets the global Exposure value.
  8082. * 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.
  8083. */
  8084. get globalExposure(): number;
  8085. /**
  8086. * Sets the global Exposure value.
  8087. * 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.
  8088. */
  8089. set globalExposure(value: number);
  8090. private _highlightsHue;
  8091. private _highlightsDensity;
  8092. private _highlightsSaturation;
  8093. private _highlightsExposure;
  8094. /**
  8095. * Gets the highlights Hue value.
  8096. * 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).
  8097. */
  8098. get highlightsHue(): number;
  8099. /**
  8100. * Sets the highlights Hue value.
  8101. * 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).
  8102. */
  8103. set highlightsHue(value: number);
  8104. /**
  8105. * Gets the highlights Density value.
  8106. * 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.
  8107. * Values less than zero provide a filter of opposite hue.
  8108. */
  8109. get highlightsDensity(): number;
  8110. /**
  8111. * Sets the highlights Density value.
  8112. * 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.
  8113. * Values less than zero provide a filter of opposite hue.
  8114. */
  8115. set highlightsDensity(value: number);
  8116. /**
  8117. * Gets the highlights Saturation value.
  8118. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8119. */
  8120. get highlightsSaturation(): number;
  8121. /**
  8122. * Sets the highlights Saturation value.
  8123. * 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.
  8124. */
  8125. set highlightsSaturation(value: number);
  8126. /**
  8127. * Gets the highlights Exposure value.
  8128. * 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.
  8129. */
  8130. get highlightsExposure(): number;
  8131. /**
  8132. * Sets the highlights Exposure value.
  8133. * 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.
  8134. */
  8135. set highlightsExposure(value: number);
  8136. private _midtonesHue;
  8137. private _midtonesDensity;
  8138. private _midtonesSaturation;
  8139. private _midtonesExposure;
  8140. /**
  8141. * Gets the midtones Hue value.
  8142. * 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).
  8143. */
  8144. get midtonesHue(): number;
  8145. /**
  8146. * Sets the midtones Hue value.
  8147. * 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).
  8148. */
  8149. set midtonesHue(value: number);
  8150. /**
  8151. * Gets the midtones Density value.
  8152. * 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.
  8153. * Values less than zero provide a filter of opposite hue.
  8154. */
  8155. get midtonesDensity(): number;
  8156. /**
  8157. * Sets the midtones Density value.
  8158. * 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.
  8159. * Values less than zero provide a filter of opposite hue.
  8160. */
  8161. set midtonesDensity(value: number);
  8162. /**
  8163. * Gets the midtones Saturation value.
  8164. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8165. */
  8166. get midtonesSaturation(): number;
  8167. /**
  8168. * Sets the midtones Saturation value.
  8169. * 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.
  8170. */
  8171. set midtonesSaturation(value: number);
  8172. /**
  8173. * Gets the midtones Exposure value.
  8174. * 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.
  8175. */
  8176. get midtonesExposure(): number;
  8177. /**
  8178. * Sets the midtones Exposure value.
  8179. * 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.
  8180. */
  8181. set midtonesExposure(value: number);
  8182. private _shadowsHue;
  8183. private _shadowsDensity;
  8184. private _shadowsSaturation;
  8185. private _shadowsExposure;
  8186. /**
  8187. * Gets the shadows Hue value.
  8188. * 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).
  8189. */
  8190. get shadowsHue(): number;
  8191. /**
  8192. * Sets the shadows Hue value.
  8193. * 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).
  8194. */
  8195. set shadowsHue(value: number);
  8196. /**
  8197. * Gets the shadows Density value.
  8198. * 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.
  8199. * Values less than zero provide a filter of opposite hue.
  8200. */
  8201. get shadowsDensity(): number;
  8202. /**
  8203. * Sets the shadows Density value.
  8204. * 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.
  8205. * Values less than zero provide a filter of opposite hue.
  8206. */
  8207. set shadowsDensity(value: number);
  8208. /**
  8209. * Gets the shadows Saturation value.
  8210. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8211. */
  8212. get shadowsSaturation(): number;
  8213. /**
  8214. * Sets the shadows Saturation value.
  8215. * 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.
  8216. */
  8217. set shadowsSaturation(value: number);
  8218. /**
  8219. * Gets the shadows Exposure value.
  8220. * 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.
  8221. */
  8222. get shadowsExposure(): number;
  8223. /**
  8224. * Sets the shadows Exposure value.
  8225. * 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.
  8226. */
  8227. set shadowsExposure(value: number);
  8228. /**
  8229. * Returns the class name
  8230. * @returns The class name
  8231. */
  8232. getClassName(): string;
  8233. /**
  8234. * Binds the color curves to the shader.
  8235. * @param colorCurves The color curve to bind
  8236. * @param effect The effect to bind to
  8237. * @param positiveUniform The positive uniform shader parameter
  8238. * @param neutralUniform The neutral uniform shader parameter
  8239. * @param negativeUniform The negative uniform shader parameter
  8240. */
  8241. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8242. /**
  8243. * Prepare the list of uniforms associated with the ColorCurves effects.
  8244. * @param uniformsList The list of uniforms used in the effect
  8245. */
  8246. static PrepareUniforms(uniformsList: string[]): void;
  8247. /**
  8248. * Returns color grading data based on a hue, density, saturation and exposure value.
  8249. * @param filterHue The hue of the color filter.
  8250. * @param filterDensity The density of the color filter.
  8251. * @param saturation The saturation.
  8252. * @param exposure The exposure.
  8253. * @param result The result data container.
  8254. */
  8255. private getColorGradingDataToRef;
  8256. /**
  8257. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8258. * @param value The input slider value in range [-100,100].
  8259. * @returns Adjusted value.
  8260. */
  8261. private static applyColorGradingSliderNonlinear;
  8262. /**
  8263. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8264. * @param hue The hue (H) input.
  8265. * @param saturation The saturation (S) input.
  8266. * @param brightness The brightness (B) input.
  8267. * @result An RGBA color represented as Vector4.
  8268. */
  8269. private static fromHSBToRef;
  8270. /**
  8271. * Returns a value clamped between min and max
  8272. * @param value The value to clamp
  8273. * @param min The minimum of value
  8274. * @param max The maximum of value
  8275. * @returns The clamped value.
  8276. */
  8277. private static clamp;
  8278. /**
  8279. * Clones the current color curve instance.
  8280. * @return The cloned curves
  8281. */
  8282. clone(): ColorCurves;
  8283. /**
  8284. * Serializes the current color curve instance to a json representation.
  8285. * @return a JSON representation
  8286. */
  8287. serialize(): any;
  8288. /**
  8289. * Parses the color curve from a json representation.
  8290. * @param source the JSON source to parse
  8291. * @return The parsed curves
  8292. */
  8293. static Parse(source: any): ColorCurves;
  8294. }
  8295. }
  8296. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8297. import { Observable } from "babylonjs/Misc/observable";
  8298. import { Nullable } from "babylonjs/types";
  8299. import { Color4 } from "babylonjs/Maths/math.color";
  8300. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8301. import { Effect } from "babylonjs/Materials/effect";
  8302. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8303. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8304. /**
  8305. * Interface to follow in your material defines to integrate easily the
  8306. * Image proccessing functions.
  8307. * @hidden
  8308. */
  8309. export interface IImageProcessingConfigurationDefines {
  8310. IMAGEPROCESSING: boolean;
  8311. VIGNETTE: boolean;
  8312. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8313. VIGNETTEBLENDMODEOPAQUE: boolean;
  8314. TONEMAPPING: boolean;
  8315. TONEMAPPING_ACES: boolean;
  8316. CONTRAST: boolean;
  8317. EXPOSURE: boolean;
  8318. COLORCURVES: boolean;
  8319. COLORGRADING: boolean;
  8320. COLORGRADING3D: boolean;
  8321. SAMPLER3DGREENDEPTH: boolean;
  8322. SAMPLER3DBGRMAP: boolean;
  8323. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8324. }
  8325. /**
  8326. * @hidden
  8327. */
  8328. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8329. IMAGEPROCESSING: boolean;
  8330. VIGNETTE: boolean;
  8331. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8332. VIGNETTEBLENDMODEOPAQUE: boolean;
  8333. TONEMAPPING: boolean;
  8334. TONEMAPPING_ACES: boolean;
  8335. CONTRAST: boolean;
  8336. COLORCURVES: boolean;
  8337. COLORGRADING: boolean;
  8338. COLORGRADING3D: boolean;
  8339. SAMPLER3DGREENDEPTH: boolean;
  8340. SAMPLER3DBGRMAP: boolean;
  8341. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8342. EXPOSURE: boolean;
  8343. constructor();
  8344. }
  8345. /**
  8346. * This groups together the common properties used for image processing either in direct forward pass
  8347. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8348. * or not.
  8349. */
  8350. export class ImageProcessingConfiguration {
  8351. /**
  8352. * Default tone mapping applied in BabylonJS.
  8353. */
  8354. static readonly TONEMAPPING_STANDARD: number;
  8355. /**
  8356. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8357. * to other engines rendering to increase portability.
  8358. */
  8359. static readonly TONEMAPPING_ACES: number;
  8360. /**
  8361. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8362. */
  8363. colorCurves: Nullable<ColorCurves>;
  8364. private _colorCurvesEnabled;
  8365. /**
  8366. * Gets wether the color curves effect is enabled.
  8367. */
  8368. get colorCurvesEnabled(): boolean;
  8369. /**
  8370. * Sets wether the color curves effect is enabled.
  8371. */
  8372. set colorCurvesEnabled(value: boolean);
  8373. private _colorGradingTexture;
  8374. /**
  8375. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8376. */
  8377. get colorGradingTexture(): Nullable<BaseTexture>;
  8378. /**
  8379. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8380. */
  8381. set colorGradingTexture(value: Nullable<BaseTexture>);
  8382. private _colorGradingEnabled;
  8383. /**
  8384. * Gets wether the color grading effect is enabled.
  8385. */
  8386. get colorGradingEnabled(): boolean;
  8387. /**
  8388. * Sets wether the color grading effect is enabled.
  8389. */
  8390. set colorGradingEnabled(value: boolean);
  8391. private _colorGradingWithGreenDepth;
  8392. /**
  8393. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8394. */
  8395. get colorGradingWithGreenDepth(): boolean;
  8396. /**
  8397. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8398. */
  8399. set colorGradingWithGreenDepth(value: boolean);
  8400. private _colorGradingBGR;
  8401. /**
  8402. * Gets wether the color grading texture contains BGR values.
  8403. */
  8404. get colorGradingBGR(): boolean;
  8405. /**
  8406. * Sets wether the color grading texture contains BGR values.
  8407. */
  8408. set colorGradingBGR(value: boolean);
  8409. /** @hidden */
  8410. _exposure: number;
  8411. /**
  8412. * Gets the Exposure used in the effect.
  8413. */
  8414. get exposure(): number;
  8415. /**
  8416. * Sets the Exposure used in the effect.
  8417. */
  8418. set exposure(value: number);
  8419. private _toneMappingEnabled;
  8420. /**
  8421. * Gets wether the tone mapping effect is enabled.
  8422. */
  8423. get toneMappingEnabled(): boolean;
  8424. /**
  8425. * Sets wether the tone mapping effect is enabled.
  8426. */
  8427. set toneMappingEnabled(value: boolean);
  8428. private _toneMappingType;
  8429. /**
  8430. * Gets the type of tone mapping effect.
  8431. */
  8432. get toneMappingType(): number;
  8433. /**
  8434. * Sets the type of tone mapping effect used in BabylonJS.
  8435. */
  8436. set toneMappingType(value: number);
  8437. protected _contrast: number;
  8438. /**
  8439. * Gets the contrast used in the effect.
  8440. */
  8441. get contrast(): number;
  8442. /**
  8443. * Sets the contrast used in the effect.
  8444. */
  8445. set contrast(value: number);
  8446. /**
  8447. * Vignette stretch size.
  8448. */
  8449. vignetteStretch: number;
  8450. /**
  8451. * Vignette centre X Offset.
  8452. */
  8453. vignetteCentreX: number;
  8454. /**
  8455. * Vignette centre Y Offset.
  8456. */
  8457. vignetteCentreY: number;
  8458. /**
  8459. * Vignette weight or intensity of the vignette effect.
  8460. */
  8461. vignetteWeight: number;
  8462. /**
  8463. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8464. * if vignetteEnabled is set to true.
  8465. */
  8466. vignetteColor: Color4;
  8467. /**
  8468. * Camera field of view used by the Vignette effect.
  8469. */
  8470. vignetteCameraFov: number;
  8471. private _vignetteBlendMode;
  8472. /**
  8473. * Gets the vignette blend mode allowing different kind of effect.
  8474. */
  8475. get vignetteBlendMode(): number;
  8476. /**
  8477. * Sets the vignette blend mode allowing different kind of effect.
  8478. */
  8479. set vignetteBlendMode(value: number);
  8480. private _vignetteEnabled;
  8481. /**
  8482. * Gets wether the vignette effect is enabled.
  8483. */
  8484. get vignetteEnabled(): boolean;
  8485. /**
  8486. * Sets wether the vignette effect is enabled.
  8487. */
  8488. set vignetteEnabled(value: boolean);
  8489. private _applyByPostProcess;
  8490. /**
  8491. * Gets wether the image processing is applied through a post process or not.
  8492. */
  8493. get applyByPostProcess(): boolean;
  8494. /**
  8495. * Sets wether the image processing is applied through a post process or not.
  8496. */
  8497. set applyByPostProcess(value: boolean);
  8498. private _isEnabled;
  8499. /**
  8500. * Gets wether the image processing is enabled or not.
  8501. */
  8502. get isEnabled(): boolean;
  8503. /**
  8504. * Sets wether the image processing is enabled or not.
  8505. */
  8506. set isEnabled(value: boolean);
  8507. /**
  8508. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8509. */
  8510. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8511. /**
  8512. * Method called each time the image processing information changes requires to recompile the effect.
  8513. */
  8514. protected _updateParameters(): void;
  8515. /**
  8516. * Gets the current class name.
  8517. * @return "ImageProcessingConfiguration"
  8518. */
  8519. getClassName(): string;
  8520. /**
  8521. * Prepare the list of uniforms associated with the Image Processing effects.
  8522. * @param uniforms The list of uniforms used in the effect
  8523. * @param defines the list of defines currently in use
  8524. */
  8525. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8526. /**
  8527. * Prepare the list of samplers associated with the Image Processing effects.
  8528. * @param samplersList The list of uniforms used in the effect
  8529. * @param defines the list of defines currently in use
  8530. */
  8531. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8532. /**
  8533. * Prepare the list of defines associated to the shader.
  8534. * @param defines the list of defines to complete
  8535. * @param forPostProcess Define if we are currently in post process mode or not
  8536. */
  8537. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8538. /**
  8539. * Returns true if all the image processing information are ready.
  8540. * @returns True if ready, otherwise, false
  8541. */
  8542. isReady(): boolean;
  8543. /**
  8544. * Binds the image processing to the shader.
  8545. * @param effect The effect to bind to
  8546. * @param overrideAspectRatio Override the aspect ratio of the effect
  8547. */
  8548. bind(effect: Effect, overrideAspectRatio?: number): void;
  8549. /**
  8550. * Clones the current image processing instance.
  8551. * @return The cloned image processing
  8552. */
  8553. clone(): ImageProcessingConfiguration;
  8554. /**
  8555. * Serializes the current image processing instance to a json representation.
  8556. * @return a JSON representation
  8557. */
  8558. serialize(): any;
  8559. /**
  8560. * Parses the image processing from a json representation.
  8561. * @param source the JSON source to parse
  8562. * @return The parsed image processing
  8563. */
  8564. static Parse(source: any): ImageProcessingConfiguration;
  8565. private static _VIGNETTEMODE_MULTIPLY;
  8566. private static _VIGNETTEMODE_OPAQUE;
  8567. /**
  8568. * Used to apply the vignette as a mix with the pixel color.
  8569. */
  8570. static get VIGNETTEMODE_MULTIPLY(): number;
  8571. /**
  8572. * Used to apply the vignette as a replacement of the pixel color.
  8573. */
  8574. static get VIGNETTEMODE_OPAQUE(): number;
  8575. }
  8576. }
  8577. declare module "babylonjs/Shaders/postprocess.vertex" {
  8578. /** @hidden */
  8579. export var postprocessVertexShader: {
  8580. name: string;
  8581. shader: string;
  8582. };
  8583. }
  8584. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8585. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8586. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8587. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8588. module "babylonjs/Engines/thinEngine" {
  8589. interface ThinEngine {
  8590. /**
  8591. * Creates a new render target texture
  8592. * @param size defines the size of the texture
  8593. * @param options defines the options used to create the texture
  8594. * @returns a new render target texture stored in an InternalTexture
  8595. */
  8596. createRenderTargetTexture(size: number | {
  8597. width: number;
  8598. height: number;
  8599. layers?: number;
  8600. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8601. /**
  8602. * Creates a depth stencil texture.
  8603. * This is only available in WebGL 2 or with the depth texture extension available.
  8604. * @param size The size of face edge in the texture.
  8605. * @param options The options defining the texture.
  8606. * @returns The texture
  8607. */
  8608. createDepthStencilTexture(size: number | {
  8609. width: number;
  8610. height: number;
  8611. layers?: number;
  8612. }, options: DepthTextureCreationOptions): InternalTexture;
  8613. /** @hidden */
  8614. _createDepthStencilTexture(size: number | {
  8615. width: number;
  8616. height: number;
  8617. layers?: number;
  8618. }, options: DepthTextureCreationOptions): InternalTexture;
  8619. }
  8620. }
  8621. }
  8622. declare module "babylonjs/Maths/math.axis" {
  8623. import { Vector3 } from "babylonjs/Maths/math.vector";
  8624. /** Defines supported spaces */
  8625. export enum Space {
  8626. /** Local (object) space */
  8627. LOCAL = 0,
  8628. /** World space */
  8629. WORLD = 1,
  8630. /** Bone space */
  8631. BONE = 2
  8632. }
  8633. /** Defines the 3 main axes */
  8634. export class Axis {
  8635. /** X axis */
  8636. static X: Vector3;
  8637. /** Y axis */
  8638. static Y: Vector3;
  8639. /** Z axis */
  8640. static Z: Vector3;
  8641. }
  8642. }
  8643. declare module "babylonjs/Cameras/targetCamera" {
  8644. import { Nullable } from "babylonjs/types";
  8645. import { Camera } from "babylonjs/Cameras/camera";
  8646. import { Scene } from "babylonjs/scene";
  8647. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8648. /**
  8649. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8650. * This is the base of the follow, arc rotate cameras and Free camera
  8651. * @see http://doc.babylonjs.com/features/cameras
  8652. */
  8653. export class TargetCamera extends Camera {
  8654. private static _RigCamTransformMatrix;
  8655. private static _TargetTransformMatrix;
  8656. private static _TargetFocalPoint;
  8657. /**
  8658. * Define the current direction the camera is moving to
  8659. */
  8660. cameraDirection: Vector3;
  8661. /**
  8662. * Define the current rotation the camera is rotating to
  8663. */
  8664. cameraRotation: Vector2;
  8665. /**
  8666. * When set, the up vector of the camera will be updated by the rotation of the camera
  8667. */
  8668. updateUpVectorFromRotation: boolean;
  8669. private _tmpQuaternion;
  8670. /**
  8671. * Define the current rotation of the camera
  8672. */
  8673. rotation: Vector3;
  8674. /**
  8675. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8676. */
  8677. rotationQuaternion: Quaternion;
  8678. /**
  8679. * Define the current speed of the camera
  8680. */
  8681. speed: number;
  8682. /**
  8683. * Add constraint to the camera to prevent it to move freely in all directions and
  8684. * around all axis.
  8685. */
  8686. noRotationConstraint: boolean;
  8687. /**
  8688. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8689. * panning
  8690. */
  8691. invertRotation: boolean;
  8692. /**
  8693. * Speed multiplier for inverse camera panning
  8694. */
  8695. inverseRotationSpeed: number;
  8696. /**
  8697. * Define the current target of the camera as an object or a position.
  8698. */
  8699. lockedTarget: any;
  8700. /** @hidden */
  8701. _currentTarget: Vector3;
  8702. /** @hidden */
  8703. _initialFocalDistance: number;
  8704. /** @hidden */
  8705. _viewMatrix: Matrix;
  8706. /** @hidden */
  8707. _camMatrix: Matrix;
  8708. /** @hidden */
  8709. _cameraTransformMatrix: Matrix;
  8710. /** @hidden */
  8711. _cameraRotationMatrix: Matrix;
  8712. /** @hidden */
  8713. _referencePoint: Vector3;
  8714. /** @hidden */
  8715. _transformedReferencePoint: Vector3;
  8716. protected _globalCurrentTarget: Vector3;
  8717. protected _globalCurrentUpVector: Vector3;
  8718. /** @hidden */
  8719. _reset: () => void;
  8720. private _defaultUp;
  8721. /**
  8722. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8723. * This is the base of the follow, arc rotate cameras and Free camera
  8724. * @see http://doc.babylonjs.com/features/cameras
  8725. * @param name Defines the name of the camera in the scene
  8726. * @param position Defines the start position of the camera in the scene
  8727. * @param scene Defines the scene the camera belongs to
  8728. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8729. */
  8730. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8731. /**
  8732. * Gets the position in front of the camera at a given distance.
  8733. * @param distance The distance from the camera we want the position to be
  8734. * @returns the position
  8735. */
  8736. getFrontPosition(distance: number): Vector3;
  8737. /** @hidden */
  8738. _getLockedTargetPosition(): Nullable<Vector3>;
  8739. private _storedPosition;
  8740. private _storedRotation;
  8741. private _storedRotationQuaternion;
  8742. /**
  8743. * Store current camera state of the camera (fov, position, rotation, etc..)
  8744. * @returns the camera
  8745. */
  8746. storeState(): Camera;
  8747. /**
  8748. * Restored camera state. You must call storeState() first
  8749. * @returns whether it was successful or not
  8750. * @hidden
  8751. */
  8752. _restoreStateValues(): boolean;
  8753. /** @hidden */
  8754. _initCache(): void;
  8755. /** @hidden */
  8756. _updateCache(ignoreParentClass?: boolean): void;
  8757. /** @hidden */
  8758. _isSynchronizedViewMatrix(): boolean;
  8759. /** @hidden */
  8760. _computeLocalCameraSpeed(): number;
  8761. /**
  8762. * Defines the target the camera should look at.
  8763. * @param target Defines the new target as a Vector or a mesh
  8764. */
  8765. setTarget(target: Vector3): void;
  8766. /**
  8767. * Return the current target position of the camera. This value is expressed in local space.
  8768. * @returns the target position
  8769. */
  8770. getTarget(): Vector3;
  8771. /** @hidden */
  8772. _decideIfNeedsToMove(): boolean;
  8773. /** @hidden */
  8774. _updatePosition(): void;
  8775. /** @hidden */
  8776. _checkInputs(): void;
  8777. protected _updateCameraRotationMatrix(): void;
  8778. /**
  8779. * 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)
  8780. * @returns the current camera
  8781. */
  8782. private _rotateUpVectorWithCameraRotationMatrix;
  8783. private _cachedRotationZ;
  8784. private _cachedQuaternionRotationZ;
  8785. /** @hidden */
  8786. _getViewMatrix(): Matrix;
  8787. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8788. /**
  8789. * @hidden
  8790. */
  8791. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8792. /**
  8793. * @hidden
  8794. */
  8795. _updateRigCameras(): void;
  8796. private _getRigCamPositionAndTarget;
  8797. /**
  8798. * Gets the current object class name.
  8799. * @return the class name
  8800. */
  8801. getClassName(): string;
  8802. }
  8803. }
  8804. declare module "babylonjs/Events/keyboardEvents" {
  8805. /**
  8806. * Gather the list of keyboard event types as constants.
  8807. */
  8808. export class KeyboardEventTypes {
  8809. /**
  8810. * The keydown event is fired when a key becomes active (pressed).
  8811. */
  8812. static readonly KEYDOWN: number;
  8813. /**
  8814. * The keyup event is fired when a key has been released.
  8815. */
  8816. static readonly KEYUP: number;
  8817. }
  8818. /**
  8819. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8820. */
  8821. export class KeyboardInfo {
  8822. /**
  8823. * Defines the type of event (KeyboardEventTypes)
  8824. */
  8825. type: number;
  8826. /**
  8827. * Defines the related dom event
  8828. */
  8829. event: KeyboardEvent;
  8830. /**
  8831. * Instantiates a new keyboard info.
  8832. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8833. * @param type Defines the type of event (KeyboardEventTypes)
  8834. * @param event Defines the related dom event
  8835. */
  8836. constructor(
  8837. /**
  8838. * Defines the type of event (KeyboardEventTypes)
  8839. */
  8840. type: number,
  8841. /**
  8842. * Defines the related dom event
  8843. */
  8844. event: KeyboardEvent);
  8845. }
  8846. /**
  8847. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8848. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8849. */
  8850. export class KeyboardInfoPre extends KeyboardInfo {
  8851. /**
  8852. * Defines the type of event (KeyboardEventTypes)
  8853. */
  8854. type: number;
  8855. /**
  8856. * Defines the related dom event
  8857. */
  8858. event: KeyboardEvent;
  8859. /**
  8860. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8861. */
  8862. skipOnPointerObservable: boolean;
  8863. /**
  8864. * Instantiates a new keyboard pre info.
  8865. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8866. * @param type Defines the type of event (KeyboardEventTypes)
  8867. * @param event Defines the related dom event
  8868. */
  8869. constructor(
  8870. /**
  8871. * Defines the type of event (KeyboardEventTypes)
  8872. */
  8873. type: number,
  8874. /**
  8875. * Defines the related dom event
  8876. */
  8877. event: KeyboardEvent);
  8878. }
  8879. }
  8880. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8881. import { Nullable } from "babylonjs/types";
  8882. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8883. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8884. /**
  8885. * Manage the keyboard inputs to control the movement of a free camera.
  8886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8887. */
  8888. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8889. /**
  8890. * Defines the camera the input is attached to.
  8891. */
  8892. camera: FreeCamera;
  8893. /**
  8894. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8895. */
  8896. keysUp: number[];
  8897. /**
  8898. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8899. */
  8900. keysUpward: number[];
  8901. /**
  8902. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8903. */
  8904. keysDown: number[];
  8905. /**
  8906. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8907. */
  8908. keysDownward: number[];
  8909. /**
  8910. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8911. */
  8912. keysLeft: number[];
  8913. /**
  8914. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8915. */
  8916. keysRight: number[];
  8917. private _keys;
  8918. private _onCanvasBlurObserver;
  8919. private _onKeyboardObserver;
  8920. private _engine;
  8921. private _scene;
  8922. /**
  8923. * Attach the input controls to a specific dom element to get the input from.
  8924. * @param element Defines the element the controls should be listened from
  8925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8926. */
  8927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8928. /**
  8929. * Detach the current controls from the specified dom element.
  8930. * @param element Defines the element to stop listening the inputs from
  8931. */
  8932. detachControl(element: Nullable<HTMLElement>): void;
  8933. /**
  8934. * Update the current camera state depending on the inputs that have been used this frame.
  8935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8936. */
  8937. checkInputs(): void;
  8938. /**
  8939. * Gets the class name of the current intput.
  8940. * @returns the class name
  8941. */
  8942. getClassName(): string;
  8943. /** @hidden */
  8944. _onLostFocus(): void;
  8945. /**
  8946. * Get the friendly name associated with the input class.
  8947. * @returns the input friendly name
  8948. */
  8949. getSimpleName(): string;
  8950. }
  8951. }
  8952. declare module "babylonjs/Lights/shadowLight" {
  8953. import { Camera } from "babylonjs/Cameras/camera";
  8954. import { Scene } from "babylonjs/scene";
  8955. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8957. import { Light } from "babylonjs/Lights/light";
  8958. /**
  8959. * Interface describing all the common properties and methods a shadow light needs to implement.
  8960. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8961. * as well as binding the different shadow properties to the effects.
  8962. */
  8963. export interface IShadowLight extends Light {
  8964. /**
  8965. * The light id in the scene (used in scene.findLighById for instance)
  8966. */
  8967. id: string;
  8968. /**
  8969. * The position the shdow will be casted from.
  8970. */
  8971. position: Vector3;
  8972. /**
  8973. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8974. */
  8975. direction: Vector3;
  8976. /**
  8977. * The transformed position. Position of the light in world space taking parenting in account.
  8978. */
  8979. transformedPosition: Vector3;
  8980. /**
  8981. * The transformed direction. Direction of the light in world space taking parenting in account.
  8982. */
  8983. transformedDirection: Vector3;
  8984. /**
  8985. * The friendly name of the light in the scene.
  8986. */
  8987. name: string;
  8988. /**
  8989. * Defines the shadow projection clipping minimum z value.
  8990. */
  8991. shadowMinZ: number;
  8992. /**
  8993. * Defines the shadow projection clipping maximum z value.
  8994. */
  8995. shadowMaxZ: number;
  8996. /**
  8997. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8998. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8999. */
  9000. computeTransformedInformation(): boolean;
  9001. /**
  9002. * Gets the scene the light belongs to.
  9003. * @returns The scene
  9004. */
  9005. getScene(): Scene;
  9006. /**
  9007. * Callback defining a custom Projection Matrix Builder.
  9008. * This can be used to override the default projection matrix computation.
  9009. */
  9010. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9011. /**
  9012. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9013. * @param matrix The materix to updated with the projection information
  9014. * @param viewMatrix The transform matrix of the light
  9015. * @param renderList The list of mesh to render in the map
  9016. * @returns The current light
  9017. */
  9018. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9019. /**
  9020. * Gets the current depth scale used in ESM.
  9021. * @returns The scale
  9022. */
  9023. getDepthScale(): number;
  9024. /**
  9025. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9026. * @returns true if a cube texture needs to be use
  9027. */
  9028. needCube(): boolean;
  9029. /**
  9030. * Detects if the projection matrix requires to be recomputed this frame.
  9031. * @returns true if it requires to be recomputed otherwise, false.
  9032. */
  9033. needProjectionMatrixCompute(): boolean;
  9034. /**
  9035. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9036. */
  9037. forceProjectionMatrixCompute(): void;
  9038. /**
  9039. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9040. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9041. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9042. */
  9043. getShadowDirection(faceIndex?: number): Vector3;
  9044. /**
  9045. * Gets the minZ used for shadow according to both the scene and the light.
  9046. * @param activeCamera The camera we are returning the min for
  9047. * @returns the depth min z
  9048. */
  9049. getDepthMinZ(activeCamera: Camera): number;
  9050. /**
  9051. * Gets the maxZ used for shadow according to both the scene and the light.
  9052. * @param activeCamera The camera we are returning the max for
  9053. * @returns the depth max z
  9054. */
  9055. getDepthMaxZ(activeCamera: Camera): number;
  9056. }
  9057. /**
  9058. * Base implementation IShadowLight
  9059. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9060. */
  9061. export abstract class ShadowLight extends Light implements IShadowLight {
  9062. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9063. protected _position: Vector3;
  9064. protected _setPosition(value: Vector3): void;
  9065. /**
  9066. * Sets the position the shadow will be casted from. Also use as the light position for both
  9067. * point and spot lights.
  9068. */
  9069. get position(): Vector3;
  9070. /**
  9071. * Sets the position the shadow will be casted from. Also use as the light position for both
  9072. * point and spot lights.
  9073. */
  9074. set position(value: Vector3);
  9075. protected _direction: Vector3;
  9076. protected _setDirection(value: Vector3): void;
  9077. /**
  9078. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9079. * Also use as the light direction on spot and directional lights.
  9080. */
  9081. get direction(): Vector3;
  9082. /**
  9083. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9084. * Also use as the light direction on spot and directional lights.
  9085. */
  9086. set direction(value: Vector3);
  9087. protected _shadowMinZ: number;
  9088. /**
  9089. * Gets the shadow projection clipping minimum z value.
  9090. */
  9091. get shadowMinZ(): number;
  9092. /**
  9093. * Sets the shadow projection clipping minimum z value.
  9094. */
  9095. set shadowMinZ(value: number);
  9096. protected _shadowMaxZ: number;
  9097. /**
  9098. * Sets the shadow projection clipping maximum z value.
  9099. */
  9100. get shadowMaxZ(): number;
  9101. /**
  9102. * Gets the shadow projection clipping maximum z value.
  9103. */
  9104. set shadowMaxZ(value: number);
  9105. /**
  9106. * Callback defining a custom Projection Matrix Builder.
  9107. * This can be used to override the default projection matrix computation.
  9108. */
  9109. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9110. /**
  9111. * The transformed position. Position of the light in world space taking parenting in account.
  9112. */
  9113. transformedPosition: Vector3;
  9114. /**
  9115. * The transformed direction. Direction of the light in world space taking parenting in account.
  9116. */
  9117. transformedDirection: Vector3;
  9118. private _needProjectionMatrixCompute;
  9119. /**
  9120. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9121. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9122. */
  9123. computeTransformedInformation(): boolean;
  9124. /**
  9125. * Return the depth scale used for the shadow map.
  9126. * @returns the depth scale.
  9127. */
  9128. getDepthScale(): number;
  9129. /**
  9130. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9131. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9132. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9133. */
  9134. getShadowDirection(faceIndex?: number): Vector3;
  9135. /**
  9136. * Returns the ShadowLight absolute position in the World.
  9137. * @returns the position vector in world space
  9138. */
  9139. getAbsolutePosition(): Vector3;
  9140. /**
  9141. * Sets the ShadowLight direction toward the passed target.
  9142. * @param target The point to target in local space
  9143. * @returns the updated ShadowLight direction
  9144. */
  9145. setDirectionToTarget(target: Vector3): Vector3;
  9146. /**
  9147. * Returns the light rotation in euler definition.
  9148. * @returns the x y z rotation in local space.
  9149. */
  9150. getRotation(): Vector3;
  9151. /**
  9152. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9153. * @returns true if a cube texture needs to be use
  9154. */
  9155. needCube(): boolean;
  9156. /**
  9157. * Detects if the projection matrix requires to be recomputed this frame.
  9158. * @returns true if it requires to be recomputed otherwise, false.
  9159. */
  9160. needProjectionMatrixCompute(): boolean;
  9161. /**
  9162. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9163. */
  9164. forceProjectionMatrixCompute(): void;
  9165. /** @hidden */
  9166. _initCache(): void;
  9167. /** @hidden */
  9168. _isSynchronized(): boolean;
  9169. /**
  9170. * Computes the world matrix of the node
  9171. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9172. * @returns the world matrix
  9173. */
  9174. computeWorldMatrix(force?: boolean): Matrix;
  9175. /**
  9176. * Gets the minZ used for shadow according to both the scene and the light.
  9177. * @param activeCamera The camera we are returning the min for
  9178. * @returns the depth min z
  9179. */
  9180. getDepthMinZ(activeCamera: Camera): number;
  9181. /**
  9182. * Gets the maxZ used for shadow according to both the scene and the light.
  9183. * @param activeCamera The camera we are returning the max for
  9184. * @returns the depth max z
  9185. */
  9186. getDepthMaxZ(activeCamera: Camera): number;
  9187. /**
  9188. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9189. * @param matrix The materix to updated with the projection information
  9190. * @param viewMatrix The transform matrix of the light
  9191. * @param renderList The list of mesh to render in the map
  9192. * @returns The current light
  9193. */
  9194. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9195. }
  9196. }
  9197. declare module "babylonjs/Materials/effectFallbacks" {
  9198. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9199. import { Effect } from "babylonjs/Materials/effect";
  9200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9201. /**
  9202. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9203. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9204. */
  9205. export class EffectFallbacks implements IEffectFallbacks {
  9206. private _defines;
  9207. private _currentRank;
  9208. private _maxRank;
  9209. private _mesh;
  9210. /**
  9211. * Removes the fallback from the bound mesh.
  9212. */
  9213. unBindMesh(): void;
  9214. /**
  9215. * Adds a fallback on the specified property.
  9216. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9217. * @param define The name of the define in the shader
  9218. */
  9219. addFallback(rank: number, define: string): void;
  9220. /**
  9221. * Sets the mesh to use CPU skinning when needing to fallback.
  9222. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9223. * @param mesh The mesh to use the fallbacks.
  9224. */
  9225. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9226. /**
  9227. * Checks to see if more fallbacks are still availible.
  9228. */
  9229. get hasMoreFallbacks(): boolean;
  9230. /**
  9231. * Removes the defines that should be removed when falling back.
  9232. * @param currentDefines defines the current define statements for the shader.
  9233. * @param effect defines the current effect we try to compile
  9234. * @returns The resulting defines with defines of the current rank removed.
  9235. */
  9236. reduce(currentDefines: string, effect: Effect): string;
  9237. }
  9238. }
  9239. declare module "babylonjs/Materials/materialHelper" {
  9240. import { Nullable } from "babylonjs/types";
  9241. import { Scene } from "babylonjs/scene";
  9242. import { Engine } from "babylonjs/Engines/engine";
  9243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9244. import { Light } from "babylonjs/Lights/light";
  9245. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9246. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9248. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9249. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9250. /**
  9251. * "Static Class" containing the most commonly used helper while dealing with material for
  9252. * rendering purpose.
  9253. *
  9254. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9255. *
  9256. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9257. */
  9258. export class MaterialHelper {
  9259. /**
  9260. * Bind the current view position to an effect.
  9261. * @param effect The effect to be bound
  9262. * @param scene The scene the eyes position is used from
  9263. * @param variableName name of the shader variable that will hold the eye position
  9264. */
  9265. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  9266. /**
  9267. * Helps preparing the defines values about the UVs in used in the effect.
  9268. * UVs are shared as much as we can accross channels in the shaders.
  9269. * @param texture The texture we are preparing the UVs for
  9270. * @param defines The defines to update
  9271. * @param key The channel key "diffuse", "specular"... used in the shader
  9272. */
  9273. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9274. /**
  9275. * Binds a texture matrix value to its corrsponding uniform
  9276. * @param texture The texture to bind the matrix for
  9277. * @param uniformBuffer The uniform buffer receivin the data
  9278. * @param key The channel key "diffuse", "specular"... used in the shader
  9279. */
  9280. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9281. /**
  9282. * Gets the current status of the fog (should it be enabled?)
  9283. * @param mesh defines the mesh to evaluate for fog support
  9284. * @param scene defines the hosting scene
  9285. * @returns true if fog must be enabled
  9286. */
  9287. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9288. /**
  9289. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9290. * @param mesh defines the current mesh
  9291. * @param scene defines the current scene
  9292. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9293. * @param pointsCloud defines if point cloud rendering has to be turned on
  9294. * @param fogEnabled defines if fog has to be turned on
  9295. * @param alphaTest defines if alpha testing has to be turned on
  9296. * @param defines defines the current list of defines
  9297. */
  9298. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9299. /**
  9300. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9301. * @param scene defines the current scene
  9302. * @param engine defines the current engine
  9303. * @param defines specifies the list of active defines
  9304. * @param useInstances defines if instances have to be turned on
  9305. * @param useClipPlane defines if clip plane have to be turned on
  9306. */
  9307. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9308. /**
  9309. * Prepares the defines for bones
  9310. * @param mesh The mesh containing the geometry data we will draw
  9311. * @param defines The defines to update
  9312. */
  9313. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9314. /**
  9315. * Prepares the defines for morph targets
  9316. * @param mesh The mesh containing the geometry data we will draw
  9317. * @param defines The defines to update
  9318. */
  9319. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9320. /**
  9321. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9322. * @param mesh The mesh containing the geometry data we will draw
  9323. * @param defines The defines to update
  9324. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9325. * @param useBones Precise whether bones should be used or not (override mesh info)
  9326. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9327. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9328. * @returns false if defines are considered not dirty and have not been checked
  9329. */
  9330. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9331. /**
  9332. * Prepares the defines related to multiview
  9333. * @param scene The scene we are intending to draw
  9334. * @param defines The defines to update
  9335. */
  9336. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9337. /**
  9338. * Prepares the defines related to the light information passed in parameter
  9339. * @param scene The scene we are intending to draw
  9340. * @param mesh The mesh the effect is compiling for
  9341. * @param light The light the effect is compiling for
  9342. * @param lightIndex The index of the light
  9343. * @param defines The defines to update
  9344. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9345. * @param state Defines the current state regarding what is needed (normals, etc...)
  9346. */
  9347. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9348. needNormals: boolean;
  9349. needRebuild: boolean;
  9350. shadowEnabled: boolean;
  9351. specularEnabled: boolean;
  9352. lightmapMode: boolean;
  9353. }): void;
  9354. /**
  9355. * Prepares the defines related to the light information passed in parameter
  9356. * @param scene The scene we are intending to draw
  9357. * @param mesh The mesh the effect is compiling for
  9358. * @param defines The defines to update
  9359. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9360. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9361. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9362. * @returns true if normals will be required for the rest of the effect
  9363. */
  9364. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9365. /**
  9366. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9367. * @param lightIndex defines the light index
  9368. * @param uniformsList The uniform list
  9369. * @param samplersList The sampler list
  9370. * @param projectedLightTexture defines if projected texture must be used
  9371. * @param uniformBuffersList defines an optional list of uniform buffers
  9372. */
  9373. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9374. /**
  9375. * Prepares the uniforms and samplers list to be used in the effect
  9376. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9377. * @param samplersList The sampler list
  9378. * @param defines The defines helping in the list generation
  9379. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9380. */
  9381. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9382. /**
  9383. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9384. * @param defines The defines to update while falling back
  9385. * @param fallbacks The authorized effect fallbacks
  9386. * @param maxSimultaneousLights The maximum number of lights allowed
  9387. * @param rank the current rank of the Effect
  9388. * @returns The newly affected rank
  9389. */
  9390. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9391. private static _TmpMorphInfluencers;
  9392. /**
  9393. * Prepares the list of attributes required for morph targets according to the effect defines.
  9394. * @param attribs The current list of supported attribs
  9395. * @param mesh The mesh to prepare the morph targets attributes for
  9396. * @param influencers The number of influencers
  9397. */
  9398. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9399. /**
  9400. * Prepares the list of attributes required for morph targets according to the effect defines.
  9401. * @param attribs The current list of supported attribs
  9402. * @param mesh The mesh to prepare the morph targets attributes for
  9403. * @param defines The current Defines of the effect
  9404. */
  9405. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9406. /**
  9407. * Prepares the list of attributes required for bones according to the effect defines.
  9408. * @param attribs The current list of supported attribs
  9409. * @param mesh The mesh to prepare the bones attributes for
  9410. * @param defines The current Defines of the effect
  9411. * @param fallbacks The current efffect fallback strategy
  9412. */
  9413. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9414. /**
  9415. * Check and prepare the list of attributes required for instances according to the effect defines.
  9416. * @param attribs The current list of supported attribs
  9417. * @param defines The current MaterialDefines of the effect
  9418. */
  9419. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9420. /**
  9421. * Add the list of attributes required for instances to the attribs array.
  9422. * @param attribs The current list of supported attribs
  9423. */
  9424. static PushAttributesForInstances(attribs: string[]): void;
  9425. /**
  9426. * Binds the light information to the effect.
  9427. * @param light The light containing the generator
  9428. * @param effect The effect we are binding the data to
  9429. * @param lightIndex The light index in the effect used to render
  9430. */
  9431. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9432. /**
  9433. * Binds the lights information from the scene to the effect for the given mesh.
  9434. * @param light Light to bind
  9435. * @param lightIndex Light index
  9436. * @param scene The scene where the light belongs to
  9437. * @param effect The effect we are binding the data to
  9438. * @param useSpecular Defines if specular is supported
  9439. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9440. */
  9441. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9442. /**
  9443. * Binds the lights information from the scene to the effect for the given mesh.
  9444. * @param scene The scene the lights belongs to
  9445. * @param mesh The mesh we are binding the information to render
  9446. * @param effect The effect we are binding the data to
  9447. * @param defines The generated defines for the effect
  9448. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9449. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9450. */
  9451. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9452. private static _tempFogColor;
  9453. /**
  9454. * Binds the fog information from the scene to the effect for the given mesh.
  9455. * @param scene The scene the lights belongs to
  9456. * @param mesh The mesh we are binding the information to render
  9457. * @param effect The effect we are binding the data to
  9458. * @param linearSpace Defines if the fog effect is applied in linear space
  9459. */
  9460. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9461. /**
  9462. * Binds the bones information from the mesh to the effect.
  9463. * @param mesh The mesh we are binding the information to render
  9464. * @param effect The effect we are binding the data to
  9465. */
  9466. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9467. /**
  9468. * Binds the morph targets information from the mesh to the effect.
  9469. * @param abstractMesh The mesh we are binding the information to render
  9470. * @param effect The effect we are binding the data to
  9471. */
  9472. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9473. /**
  9474. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9475. * @param defines The generated defines used in the effect
  9476. * @param effect The effect we are binding the data to
  9477. * @param scene The scene we are willing to render with logarithmic scale for
  9478. */
  9479. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9480. /**
  9481. * Binds the clip plane information from the scene to the effect.
  9482. * @param scene The scene the clip plane information are extracted from
  9483. * @param effect The effect we are binding the data to
  9484. */
  9485. static BindClipPlane(effect: Effect, scene: Scene): void;
  9486. }
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9489. /** @hidden */
  9490. export var packingFunctions: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9496. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9497. /** @hidden */
  9498. export var shadowMapFragmentDeclaration: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9504. /** @hidden */
  9505. export var clipPlaneFragmentDeclaration: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9511. /** @hidden */
  9512. export var clipPlaneFragment: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9518. /** @hidden */
  9519. export var shadowMapFragment: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9525. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9528. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9529. /** @hidden */
  9530. export var shadowMapPixelShader: {
  9531. name: string;
  9532. shader: string;
  9533. };
  9534. }
  9535. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9536. /** @hidden */
  9537. export var bonesDeclaration: {
  9538. name: string;
  9539. shader: string;
  9540. };
  9541. }
  9542. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9543. /** @hidden */
  9544. export var morphTargetsVertexGlobalDeclaration: {
  9545. name: string;
  9546. shader: string;
  9547. };
  9548. }
  9549. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9550. /** @hidden */
  9551. export var morphTargetsVertexDeclaration: {
  9552. name: string;
  9553. shader: string;
  9554. };
  9555. }
  9556. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9557. /** @hidden */
  9558. export var instancesDeclaration: {
  9559. name: string;
  9560. shader: string;
  9561. };
  9562. }
  9563. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9564. /** @hidden */
  9565. export var helperFunctions: {
  9566. name: string;
  9567. shader: string;
  9568. };
  9569. }
  9570. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9571. /** @hidden */
  9572. export var shadowMapVertexDeclaration: {
  9573. name: string;
  9574. shader: string;
  9575. };
  9576. }
  9577. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9578. /** @hidden */
  9579. export var clipPlaneVertexDeclaration: {
  9580. name: string;
  9581. shader: string;
  9582. };
  9583. }
  9584. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9585. /** @hidden */
  9586. export var morphTargetsVertex: {
  9587. name: string;
  9588. shader: string;
  9589. };
  9590. }
  9591. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9592. /** @hidden */
  9593. export var instancesVertex: {
  9594. name: string;
  9595. shader: string;
  9596. };
  9597. }
  9598. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9599. /** @hidden */
  9600. export var bonesVertex: {
  9601. name: string;
  9602. shader: string;
  9603. };
  9604. }
  9605. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9606. /** @hidden */
  9607. export var shadowMapVertexNormalBias: {
  9608. name: string;
  9609. shader: string;
  9610. };
  9611. }
  9612. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9613. /** @hidden */
  9614. export var shadowMapVertexMetric: {
  9615. name: string;
  9616. shader: string;
  9617. };
  9618. }
  9619. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9620. /** @hidden */
  9621. export var clipPlaneVertex: {
  9622. name: string;
  9623. shader: string;
  9624. };
  9625. }
  9626. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9627. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9629. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9630. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9631. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9632. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9633. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9634. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9635. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9636. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9637. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9638. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9639. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9640. /** @hidden */
  9641. export var shadowMapVertexShader: {
  9642. name: string;
  9643. shader: string;
  9644. };
  9645. }
  9646. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9647. /** @hidden */
  9648. export var depthBoxBlurPixelShader: {
  9649. name: string;
  9650. shader: string;
  9651. };
  9652. }
  9653. declare module "babylonjs/Culling/ray" {
  9654. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9655. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9657. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9658. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9659. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9660. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9661. import { Plane } from "babylonjs/Maths/math.plane";
  9662. /**
  9663. * Class representing a ray with position and direction
  9664. */
  9665. export class Ray {
  9666. /** origin point */
  9667. origin: Vector3;
  9668. /** direction */
  9669. direction: Vector3;
  9670. /** length of the ray */
  9671. length: number;
  9672. private static readonly TmpVector3;
  9673. private _tmpRay;
  9674. /**
  9675. * Creates a new ray
  9676. * @param origin origin point
  9677. * @param direction direction
  9678. * @param length length of the ray
  9679. */
  9680. constructor(
  9681. /** origin point */
  9682. origin: Vector3,
  9683. /** direction */
  9684. direction: Vector3,
  9685. /** length of the ray */
  9686. length?: number);
  9687. /**
  9688. * Checks if the ray intersects a box
  9689. * This does not account for the ray lenght by design to improve perfs.
  9690. * @param minimum bound of the box
  9691. * @param maximum bound of the box
  9692. * @param intersectionTreshold extra extend to be added to the box in all direction
  9693. * @returns if the box was hit
  9694. */
  9695. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9696. /**
  9697. * Checks if the ray intersects a box
  9698. * This does not account for the ray lenght by design to improve perfs.
  9699. * @param box the bounding box to check
  9700. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9701. * @returns if the box was hit
  9702. */
  9703. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9704. /**
  9705. * If the ray hits a sphere
  9706. * @param sphere the bounding sphere to check
  9707. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9708. * @returns true if it hits the sphere
  9709. */
  9710. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9711. /**
  9712. * If the ray hits a triange
  9713. * @param vertex0 triangle vertex
  9714. * @param vertex1 triangle vertex
  9715. * @param vertex2 triangle vertex
  9716. * @returns intersection information if hit
  9717. */
  9718. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9719. /**
  9720. * Checks if ray intersects a plane
  9721. * @param plane the plane to check
  9722. * @returns the distance away it was hit
  9723. */
  9724. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9725. /**
  9726. * Calculate the intercept of a ray on a given axis
  9727. * @param axis to check 'x' | 'y' | 'z'
  9728. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9729. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9730. */
  9731. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9732. /**
  9733. * Checks if ray intersects a mesh
  9734. * @param mesh the mesh to check
  9735. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9736. * @returns picking info of the intersecton
  9737. */
  9738. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9739. /**
  9740. * Checks if ray intersects a mesh
  9741. * @param meshes the meshes to check
  9742. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9743. * @param results array to store result in
  9744. * @returns Array of picking infos
  9745. */
  9746. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9747. private _comparePickingInfo;
  9748. private static smallnum;
  9749. private static rayl;
  9750. /**
  9751. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9752. * @param sega the first point of the segment to test the intersection against
  9753. * @param segb the second point of the segment to test the intersection against
  9754. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9755. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9756. */
  9757. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9758. /**
  9759. * Update the ray from viewport position
  9760. * @param x position
  9761. * @param y y position
  9762. * @param viewportWidth viewport width
  9763. * @param viewportHeight viewport height
  9764. * @param world world matrix
  9765. * @param view view matrix
  9766. * @param projection projection matrix
  9767. * @returns this ray updated
  9768. */
  9769. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9770. /**
  9771. * Creates a ray with origin and direction of 0,0,0
  9772. * @returns the new ray
  9773. */
  9774. static Zero(): Ray;
  9775. /**
  9776. * Creates a new ray from screen space and viewport
  9777. * @param x position
  9778. * @param y y position
  9779. * @param viewportWidth viewport width
  9780. * @param viewportHeight viewport height
  9781. * @param world world matrix
  9782. * @param view view matrix
  9783. * @param projection projection matrix
  9784. * @returns new ray
  9785. */
  9786. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9787. /**
  9788. * 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
  9789. * transformed to the given world matrix.
  9790. * @param origin The origin point
  9791. * @param end The end point
  9792. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9793. * @returns the new ray
  9794. */
  9795. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9796. /**
  9797. * Transforms a ray by a matrix
  9798. * @param ray ray to transform
  9799. * @param matrix matrix to apply
  9800. * @returns the resulting new ray
  9801. */
  9802. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9803. /**
  9804. * Transforms a ray by a matrix
  9805. * @param ray ray to transform
  9806. * @param matrix matrix to apply
  9807. * @param result ray to store result in
  9808. */
  9809. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9810. /**
  9811. * Unproject a ray from screen space to object space
  9812. * @param sourceX defines the screen space x coordinate to use
  9813. * @param sourceY defines the screen space y coordinate to use
  9814. * @param viewportWidth defines the current width of the viewport
  9815. * @param viewportHeight defines the current height of the viewport
  9816. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9817. * @param view defines the view matrix to use
  9818. * @param projection defines the projection matrix to use
  9819. */
  9820. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9821. }
  9822. /**
  9823. * Type used to define predicate used to select faces when a mesh intersection is detected
  9824. */
  9825. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9826. module "babylonjs/scene" {
  9827. interface Scene {
  9828. /** @hidden */
  9829. _tempPickingRay: Nullable<Ray>;
  9830. /** @hidden */
  9831. _cachedRayForTransform: Ray;
  9832. /** @hidden */
  9833. _pickWithRayInverseMatrix: Matrix;
  9834. /** @hidden */
  9835. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9836. /** @hidden */
  9837. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9838. }
  9839. }
  9840. }
  9841. declare module "babylonjs/sceneComponent" {
  9842. import { Scene } from "babylonjs/scene";
  9843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9844. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9845. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9846. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9847. import { Nullable } from "babylonjs/types";
  9848. import { Camera } from "babylonjs/Cameras/camera";
  9849. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9850. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9851. import { AbstractScene } from "babylonjs/abstractScene";
  9852. import { Mesh } from "babylonjs/Meshes/mesh";
  9853. /**
  9854. * Groups all the scene component constants in one place to ease maintenance.
  9855. * @hidden
  9856. */
  9857. export class SceneComponentConstants {
  9858. static readonly NAME_EFFECTLAYER: string;
  9859. static readonly NAME_LAYER: string;
  9860. static readonly NAME_LENSFLARESYSTEM: string;
  9861. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9862. static readonly NAME_PARTICLESYSTEM: string;
  9863. static readonly NAME_GAMEPAD: string;
  9864. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9865. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9866. static readonly NAME_DEPTHRENDERER: string;
  9867. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9868. static readonly NAME_SPRITE: string;
  9869. static readonly NAME_OUTLINERENDERER: string;
  9870. static readonly NAME_PROCEDURALTEXTURE: string;
  9871. static readonly NAME_SHADOWGENERATOR: string;
  9872. static readonly NAME_OCTREE: string;
  9873. static readonly NAME_PHYSICSENGINE: string;
  9874. static readonly NAME_AUDIO: string;
  9875. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9876. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9877. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9878. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9879. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9880. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9881. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9882. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9883. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9884. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9885. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9886. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9887. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9888. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9889. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9890. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9891. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9892. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9893. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9894. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9895. static readonly STEP_AFTERRENDER_AUDIO: number;
  9896. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9897. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9898. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9899. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9900. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9901. static readonly STEP_POINTERMOVE_SPRITE: number;
  9902. static readonly STEP_POINTERDOWN_SPRITE: number;
  9903. static readonly STEP_POINTERUP_SPRITE: number;
  9904. }
  9905. /**
  9906. * This represents a scene component.
  9907. *
  9908. * This is used to decouple the dependency the scene is having on the different workloads like
  9909. * layers, post processes...
  9910. */
  9911. export interface ISceneComponent {
  9912. /**
  9913. * The name of the component. Each component must have a unique name.
  9914. */
  9915. name: string;
  9916. /**
  9917. * The scene the component belongs to.
  9918. */
  9919. scene: Scene;
  9920. /**
  9921. * Register the component to one instance of a scene.
  9922. */
  9923. register(): void;
  9924. /**
  9925. * Rebuilds the elements related to this component in case of
  9926. * context lost for instance.
  9927. */
  9928. rebuild(): void;
  9929. /**
  9930. * Disposes the component and the associated ressources.
  9931. */
  9932. dispose(): void;
  9933. }
  9934. /**
  9935. * This represents a SERIALIZABLE scene component.
  9936. *
  9937. * This extends Scene Component to add Serialization methods on top.
  9938. */
  9939. export interface ISceneSerializableComponent extends ISceneComponent {
  9940. /**
  9941. * Adds all the elements from the container to the scene
  9942. * @param container the container holding the elements
  9943. */
  9944. addFromContainer(container: AbstractScene): void;
  9945. /**
  9946. * Removes all the elements in the container from the scene
  9947. * @param container contains the elements to remove
  9948. * @param dispose if the removed element should be disposed (default: false)
  9949. */
  9950. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9951. /**
  9952. * Serializes the component data to the specified json object
  9953. * @param serializationObject The object to serialize to
  9954. */
  9955. serialize(serializationObject: any): void;
  9956. }
  9957. /**
  9958. * Strong typing of a Mesh related stage step action
  9959. */
  9960. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9961. /**
  9962. * Strong typing of a Evaluate Sub Mesh related stage step action
  9963. */
  9964. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9965. /**
  9966. * Strong typing of a Active Mesh related stage step action
  9967. */
  9968. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9969. /**
  9970. * Strong typing of a Camera related stage step action
  9971. */
  9972. export type CameraStageAction = (camera: Camera) => void;
  9973. /**
  9974. * Strong typing of a Camera Frame buffer related stage step action
  9975. */
  9976. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9977. /**
  9978. * Strong typing of a Render Target related stage step action
  9979. */
  9980. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9981. /**
  9982. * Strong typing of a RenderingGroup related stage step action
  9983. */
  9984. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9985. /**
  9986. * Strong typing of a Mesh Render related stage step action
  9987. */
  9988. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9989. /**
  9990. * Strong typing of a simple stage step action
  9991. */
  9992. export type SimpleStageAction = () => void;
  9993. /**
  9994. * Strong typing of a render target action.
  9995. */
  9996. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9997. /**
  9998. * Strong typing of a pointer move action.
  9999. */
  10000. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10001. /**
  10002. * Strong typing of a pointer up/down action.
  10003. */
  10004. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10005. /**
  10006. * Representation of a stage in the scene (Basically a list of ordered steps)
  10007. * @hidden
  10008. */
  10009. export class Stage<T extends Function> extends Array<{
  10010. index: number;
  10011. component: ISceneComponent;
  10012. action: T;
  10013. }> {
  10014. /**
  10015. * Hide ctor from the rest of the world.
  10016. * @param items The items to add.
  10017. */
  10018. private constructor();
  10019. /**
  10020. * Creates a new Stage.
  10021. * @returns A new instance of a Stage
  10022. */
  10023. static Create<T extends Function>(): Stage<T>;
  10024. /**
  10025. * Registers a step in an ordered way in the targeted stage.
  10026. * @param index Defines the position to register the step in
  10027. * @param component Defines the component attached to the step
  10028. * @param action Defines the action to launch during the step
  10029. */
  10030. registerStep(index: number, component: ISceneComponent, action: T): void;
  10031. /**
  10032. * Clears all the steps from the stage.
  10033. */
  10034. clear(): void;
  10035. }
  10036. }
  10037. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10038. import { Nullable } from "babylonjs/types";
  10039. import { Observable } from "babylonjs/Misc/observable";
  10040. import { Scene } from "babylonjs/scene";
  10041. import { Sprite } from "babylonjs/Sprites/sprite";
  10042. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10043. import { Ray } from "babylonjs/Culling/ray";
  10044. import { Camera } from "babylonjs/Cameras/camera";
  10045. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10046. import { ISceneComponent } from "babylonjs/sceneComponent";
  10047. module "babylonjs/scene" {
  10048. interface Scene {
  10049. /** @hidden */
  10050. _pointerOverSprite: Nullable<Sprite>;
  10051. /** @hidden */
  10052. _pickedDownSprite: Nullable<Sprite>;
  10053. /** @hidden */
  10054. _tempSpritePickingRay: Nullable<Ray>;
  10055. /**
  10056. * All of the sprite managers added to this scene
  10057. * @see http://doc.babylonjs.com/babylon101/sprites
  10058. */
  10059. spriteManagers: Array<ISpriteManager>;
  10060. /**
  10061. * An event triggered when sprites rendering is about to start
  10062. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10063. */
  10064. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10065. /**
  10066. * An event triggered when sprites rendering is done
  10067. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10068. */
  10069. onAfterSpritesRenderingObservable: Observable<Scene>;
  10070. /** @hidden */
  10071. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10072. /** Launch a ray to try to pick a sprite in the scene
  10073. * @param x position on screen
  10074. * @param y position on screen
  10075. * @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
  10076. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10077. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10078. * @returns a PickingInfo
  10079. */
  10080. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10081. /** Use the given ray to pick a sprite in the scene
  10082. * @param ray The ray (in world space) to use to pick meshes
  10083. * @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
  10084. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10085. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10086. * @returns a PickingInfo
  10087. */
  10088. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10089. /** @hidden */
  10090. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10091. /** Launch a ray to try to pick sprites in the scene
  10092. * @param x position on screen
  10093. * @param y position on screen
  10094. * @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
  10095. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10096. * @returns a PickingInfo array
  10097. */
  10098. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10099. /** Use the given ray to pick sprites in the scene
  10100. * @param ray The ray (in world space) to use to pick meshes
  10101. * @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
  10102. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10103. * @returns a PickingInfo array
  10104. */
  10105. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10106. /**
  10107. * Force the sprite under the pointer
  10108. * @param sprite defines the sprite to use
  10109. */
  10110. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10111. /**
  10112. * Gets the sprite under the pointer
  10113. * @returns a Sprite or null if no sprite is under the pointer
  10114. */
  10115. getPointerOverSprite(): Nullable<Sprite>;
  10116. }
  10117. }
  10118. /**
  10119. * Defines the sprite scene component responsible to manage sprites
  10120. * in a given scene.
  10121. */
  10122. export class SpriteSceneComponent implements ISceneComponent {
  10123. /**
  10124. * The component name helpfull to identify the component in the list of scene components.
  10125. */
  10126. readonly name: string;
  10127. /**
  10128. * The scene the component belongs to.
  10129. */
  10130. scene: Scene;
  10131. /** @hidden */
  10132. private _spritePredicate;
  10133. /**
  10134. * Creates a new instance of the component for the given scene
  10135. * @param scene Defines the scene to register the component in
  10136. */
  10137. constructor(scene: Scene);
  10138. /**
  10139. * Registers the component in a given scene
  10140. */
  10141. register(): void;
  10142. /**
  10143. * Rebuilds the elements related to this component in case of
  10144. * context lost for instance.
  10145. */
  10146. rebuild(): void;
  10147. /**
  10148. * Disposes the component and the associated ressources.
  10149. */
  10150. dispose(): void;
  10151. private _pickSpriteButKeepRay;
  10152. private _pointerMove;
  10153. private _pointerDown;
  10154. private _pointerUp;
  10155. }
  10156. }
  10157. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10158. /** @hidden */
  10159. export var fogFragmentDeclaration: {
  10160. name: string;
  10161. shader: string;
  10162. };
  10163. }
  10164. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10165. /** @hidden */
  10166. export var fogFragment: {
  10167. name: string;
  10168. shader: string;
  10169. };
  10170. }
  10171. declare module "babylonjs/Shaders/sprites.fragment" {
  10172. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10173. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10174. /** @hidden */
  10175. export var spritesPixelShader: {
  10176. name: string;
  10177. shader: string;
  10178. };
  10179. }
  10180. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10181. /** @hidden */
  10182. export var fogVertexDeclaration: {
  10183. name: string;
  10184. shader: string;
  10185. };
  10186. }
  10187. declare module "babylonjs/Shaders/sprites.vertex" {
  10188. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10189. /** @hidden */
  10190. export var spritesVertexShader: {
  10191. name: string;
  10192. shader: string;
  10193. };
  10194. }
  10195. declare module "babylonjs/Sprites/spriteManager" {
  10196. import { IDisposable, Scene } from "babylonjs/scene";
  10197. import { Nullable } from "babylonjs/types";
  10198. import { Observable } from "babylonjs/Misc/observable";
  10199. import { Sprite } from "babylonjs/Sprites/sprite";
  10200. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10201. import { Camera } from "babylonjs/Cameras/camera";
  10202. import { Texture } from "babylonjs/Materials/Textures/texture";
  10203. import "babylonjs/Shaders/sprites.fragment";
  10204. import "babylonjs/Shaders/sprites.vertex";
  10205. import { Ray } from "babylonjs/Culling/ray";
  10206. /**
  10207. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10208. */
  10209. export interface ISpriteManager extends IDisposable {
  10210. /**
  10211. * Restricts the camera to viewing objects with the same layerMask.
  10212. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10213. */
  10214. layerMask: number;
  10215. /**
  10216. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10217. */
  10218. isPickable: boolean;
  10219. /**
  10220. * Specifies the rendering group id for this mesh (0 by default)
  10221. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10222. */
  10223. renderingGroupId: number;
  10224. /**
  10225. * Defines the list of sprites managed by the manager.
  10226. */
  10227. sprites: Array<Sprite>;
  10228. /**
  10229. * Tests the intersection of a sprite with a specific ray.
  10230. * @param ray The ray we are sending to test the collision
  10231. * @param camera The camera space we are sending rays in
  10232. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10233. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10234. * @returns picking info or null.
  10235. */
  10236. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10237. /**
  10238. * Intersects the sprites with a ray
  10239. * @param ray defines the ray to intersect with
  10240. * @param camera defines the current active camera
  10241. * @param predicate defines a predicate used to select candidate sprites
  10242. * @returns null if no hit or a PickingInfo array
  10243. */
  10244. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10245. /**
  10246. * Renders the list of sprites on screen.
  10247. */
  10248. render(): void;
  10249. }
  10250. /**
  10251. * Class used to manage multiple sprites on the same spritesheet
  10252. * @see http://doc.babylonjs.com/babylon101/sprites
  10253. */
  10254. export class SpriteManager implements ISpriteManager {
  10255. /** defines the manager's name */
  10256. name: string;
  10257. /** Gets the list of sprites */
  10258. sprites: Sprite[];
  10259. /** Gets or sets the rendering group id (0 by default) */
  10260. renderingGroupId: number;
  10261. /** Gets or sets camera layer mask */
  10262. layerMask: number;
  10263. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10264. fogEnabled: boolean;
  10265. /** Gets or sets a boolean indicating if the sprites are pickable */
  10266. isPickable: boolean;
  10267. /** Defines the default width of a cell in the spritesheet */
  10268. cellWidth: number;
  10269. /** Defines the default height of a cell in the spritesheet */
  10270. cellHeight: number;
  10271. /** Associative array from JSON sprite data file */
  10272. private _cellData;
  10273. /** Array of sprite names from JSON sprite data file */
  10274. private _spriteMap;
  10275. /** True when packed cell data from JSON file is ready*/
  10276. private _packedAndReady;
  10277. private _textureContent;
  10278. /**
  10279. * An event triggered when the manager is disposed.
  10280. */
  10281. onDisposeObservable: Observable<SpriteManager>;
  10282. private _onDisposeObserver;
  10283. /**
  10284. * Callback called when the manager is disposed
  10285. */
  10286. set onDispose(callback: () => void);
  10287. private _capacity;
  10288. private _fromPacked;
  10289. private _spriteTexture;
  10290. private _epsilon;
  10291. private _scene;
  10292. private _vertexData;
  10293. private _buffer;
  10294. private _vertexBuffers;
  10295. private _indexBuffer;
  10296. private _effectBase;
  10297. private _effectFog;
  10298. /**
  10299. * Gets or sets the spritesheet texture
  10300. */
  10301. get texture(): Texture;
  10302. set texture(value: Texture);
  10303. private _blendMode;
  10304. /**
  10305. * Blend mode use to render the particle, it can be any of
  10306. * the static Constants.ALPHA_x properties provided in this class.
  10307. * Default value is Constants.ALPHA_COMBINE
  10308. */
  10309. get blendMode(): number;
  10310. set blendMode(blendMode: number);
  10311. /** Disables writing to the depth buffer when rendering the sprites.
  10312. * It can be handy to disable depth writing when using textures without alpha channel
  10313. * and setting some specific blend modes.
  10314. */
  10315. disableDepthWrite: boolean;
  10316. /**
  10317. * Creates a new sprite manager
  10318. * @param name defines the manager's name
  10319. * @param imgUrl defines the sprite sheet url
  10320. * @param capacity defines the maximum allowed number of sprites
  10321. * @param cellSize defines the size of a sprite cell
  10322. * @param scene defines the hosting scene
  10323. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10324. * @param samplingMode defines the smapling mode to use with spritesheet
  10325. * @param fromPacked set to false; do not alter
  10326. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10327. */
  10328. constructor(
  10329. /** defines the manager's name */
  10330. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10331. private _makePacked;
  10332. private _appendSpriteVertex;
  10333. private _checkTextureAlpha;
  10334. /**
  10335. * Intersects the sprites with a ray
  10336. * @param ray defines the ray to intersect with
  10337. * @param camera defines the current active camera
  10338. * @param predicate defines a predicate used to select candidate sprites
  10339. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10340. * @returns null if no hit or a PickingInfo
  10341. */
  10342. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10343. /**
  10344. * Intersects the sprites with a ray
  10345. * @param ray defines the ray to intersect with
  10346. * @param camera defines the current active camera
  10347. * @param predicate defines a predicate used to select candidate sprites
  10348. * @returns null if no hit or a PickingInfo array
  10349. */
  10350. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10351. /**
  10352. * Render all child sprites
  10353. */
  10354. render(): void;
  10355. /**
  10356. * Release associated resources
  10357. */
  10358. dispose(): void;
  10359. }
  10360. }
  10361. declare module "babylonjs/Misc/gradients" {
  10362. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10363. /** Interface used by value gradients (color, factor, ...) */
  10364. export interface IValueGradient {
  10365. /**
  10366. * Gets or sets the gradient value (between 0 and 1)
  10367. */
  10368. gradient: number;
  10369. }
  10370. /** Class used to store color4 gradient */
  10371. export class ColorGradient implements IValueGradient {
  10372. /**
  10373. * Gets or sets the gradient value (between 0 and 1)
  10374. */
  10375. gradient: number;
  10376. /**
  10377. * Gets or sets first associated color
  10378. */
  10379. color1: Color4;
  10380. /**
  10381. * Gets or sets second associated color
  10382. */
  10383. color2?: Color4 | undefined;
  10384. /**
  10385. * Creates a new color4 gradient
  10386. * @param gradient gets or sets the gradient value (between 0 and 1)
  10387. * @param color1 gets or sets first associated color
  10388. * @param color2 gets or sets first second color
  10389. */
  10390. constructor(
  10391. /**
  10392. * Gets or sets the gradient value (between 0 and 1)
  10393. */
  10394. gradient: number,
  10395. /**
  10396. * Gets or sets first associated color
  10397. */
  10398. color1: Color4,
  10399. /**
  10400. * Gets or sets second associated color
  10401. */
  10402. color2?: Color4 | undefined);
  10403. /**
  10404. * Will get a color picked randomly between color1 and color2.
  10405. * If color2 is undefined then color1 will be used
  10406. * @param result defines the target Color4 to store the result in
  10407. */
  10408. getColorToRef(result: Color4): void;
  10409. }
  10410. /** Class used to store color 3 gradient */
  10411. export class Color3Gradient implements IValueGradient {
  10412. /**
  10413. * Gets or sets the gradient value (between 0 and 1)
  10414. */
  10415. gradient: number;
  10416. /**
  10417. * Gets or sets the associated color
  10418. */
  10419. color: Color3;
  10420. /**
  10421. * Creates a new color3 gradient
  10422. * @param gradient gets or sets the gradient value (between 0 and 1)
  10423. * @param color gets or sets associated color
  10424. */
  10425. constructor(
  10426. /**
  10427. * Gets or sets the gradient value (between 0 and 1)
  10428. */
  10429. gradient: number,
  10430. /**
  10431. * Gets or sets the associated color
  10432. */
  10433. color: Color3);
  10434. }
  10435. /** Class used to store factor gradient */
  10436. export class FactorGradient implements IValueGradient {
  10437. /**
  10438. * Gets or sets the gradient value (between 0 and 1)
  10439. */
  10440. gradient: number;
  10441. /**
  10442. * Gets or sets first associated factor
  10443. */
  10444. factor1: number;
  10445. /**
  10446. * Gets or sets second associated factor
  10447. */
  10448. factor2?: number | undefined;
  10449. /**
  10450. * Creates a new factor gradient
  10451. * @param gradient gets or sets the gradient value (between 0 and 1)
  10452. * @param factor1 gets or sets first associated factor
  10453. * @param factor2 gets or sets second associated factor
  10454. */
  10455. constructor(
  10456. /**
  10457. * Gets or sets the gradient value (between 0 and 1)
  10458. */
  10459. gradient: number,
  10460. /**
  10461. * Gets or sets first associated factor
  10462. */
  10463. factor1: number,
  10464. /**
  10465. * Gets or sets second associated factor
  10466. */
  10467. factor2?: number | undefined);
  10468. /**
  10469. * Will get a number picked randomly between factor1 and factor2.
  10470. * If factor2 is undefined then factor1 will be used
  10471. * @returns the picked number
  10472. */
  10473. getFactor(): number;
  10474. }
  10475. /**
  10476. * Helper used to simplify some generic gradient tasks
  10477. */
  10478. export class GradientHelper {
  10479. /**
  10480. * Gets the current gradient from an array of IValueGradient
  10481. * @param ratio defines the current ratio to get
  10482. * @param gradients defines the array of IValueGradient
  10483. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10484. */
  10485. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10486. }
  10487. }
  10488. declare module "babylonjs/Maths/math.size" {
  10489. /**
  10490. * Interface for the size containing width and height
  10491. */
  10492. export interface ISize {
  10493. /**
  10494. * Width
  10495. */
  10496. width: number;
  10497. /**
  10498. * Heighht
  10499. */
  10500. height: number;
  10501. }
  10502. /**
  10503. * Size containing widht and height
  10504. */
  10505. export class Size implements ISize {
  10506. /**
  10507. * Width
  10508. */
  10509. width: number;
  10510. /**
  10511. * Height
  10512. */
  10513. height: number;
  10514. /**
  10515. * Creates a Size object from the given width and height (floats).
  10516. * @param width width of the new size
  10517. * @param height height of the new size
  10518. */
  10519. constructor(width: number, height: number);
  10520. /**
  10521. * Returns a string with the Size width and height
  10522. * @returns a string with the Size width and height
  10523. */
  10524. toString(): string;
  10525. /**
  10526. * "Size"
  10527. * @returns the string "Size"
  10528. */
  10529. getClassName(): string;
  10530. /**
  10531. * Returns the Size hash code.
  10532. * @returns a hash code for a unique width and height
  10533. */
  10534. getHashCode(): number;
  10535. /**
  10536. * Updates the current size from the given one.
  10537. * @param src the given size
  10538. */
  10539. copyFrom(src: Size): void;
  10540. /**
  10541. * Updates in place the current Size from the given floats.
  10542. * @param width width of the new size
  10543. * @param height height of the new size
  10544. * @returns the updated Size.
  10545. */
  10546. copyFromFloats(width: number, height: number): Size;
  10547. /**
  10548. * Updates in place the current Size from the given floats.
  10549. * @param width width to set
  10550. * @param height height to set
  10551. * @returns the updated Size.
  10552. */
  10553. set(width: number, height: number): Size;
  10554. /**
  10555. * Multiplies the width and height by numbers
  10556. * @param w factor to multiple the width by
  10557. * @param h factor to multiple the height by
  10558. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10559. */
  10560. multiplyByFloats(w: number, h: number): Size;
  10561. /**
  10562. * Clones the size
  10563. * @returns a new Size copied from the given one.
  10564. */
  10565. clone(): Size;
  10566. /**
  10567. * True if the current Size and the given one width and height are strictly equal.
  10568. * @param other the other size to compare against
  10569. * @returns True if the current Size and the given one width and height are strictly equal.
  10570. */
  10571. equals(other: Size): boolean;
  10572. /**
  10573. * The surface of the Size : width * height (float).
  10574. */
  10575. get surface(): number;
  10576. /**
  10577. * Create a new size of zero
  10578. * @returns a new Size set to (0.0, 0.0)
  10579. */
  10580. static Zero(): Size;
  10581. /**
  10582. * Sums the width and height of two sizes
  10583. * @param otherSize size to add to this size
  10584. * @returns a new Size set as the addition result of the current Size and the given one.
  10585. */
  10586. add(otherSize: Size): Size;
  10587. /**
  10588. * Subtracts the width and height of two
  10589. * @param otherSize size to subtract to this size
  10590. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10591. */
  10592. subtract(otherSize: Size): Size;
  10593. /**
  10594. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10595. * @param start starting size to lerp between
  10596. * @param end end size to lerp between
  10597. * @param amount amount to lerp between the start and end values
  10598. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10599. */
  10600. static Lerp(start: Size, end: Size, amount: number): Size;
  10601. }
  10602. }
  10603. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10604. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10605. import { Nullable } from "babylonjs/types";
  10606. module "babylonjs/Engines/thinEngine" {
  10607. interface ThinEngine {
  10608. /**
  10609. * Creates a dynamic texture
  10610. * @param width defines the width of the texture
  10611. * @param height defines the height of the texture
  10612. * @param generateMipMaps defines if the engine should generate the mip levels
  10613. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10614. * @returns the dynamic texture inside an InternalTexture
  10615. */
  10616. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10617. /**
  10618. * Update the content of a dynamic texture
  10619. * @param texture defines the texture to update
  10620. * @param canvas defines the canvas containing the source
  10621. * @param invertY defines if data must be stored with Y axis inverted
  10622. * @param premulAlpha defines if alpha is stored as premultiplied
  10623. * @param format defines the format of the data
  10624. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10625. */
  10626. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10627. }
  10628. }
  10629. }
  10630. declare module "babylonjs/Misc/canvasGenerator" {
  10631. /**
  10632. * Helper class used to generate a canvas to manipulate images
  10633. */
  10634. export class CanvasGenerator {
  10635. /**
  10636. * Create a new canvas (or offscreen canvas depending on the context)
  10637. * @param width defines the expected width
  10638. * @param height defines the expected height
  10639. * @return a new canvas or offscreen canvas
  10640. */
  10641. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10642. }
  10643. }
  10644. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10645. import { Scene } from "babylonjs/scene";
  10646. import { Texture } from "babylonjs/Materials/Textures/texture";
  10647. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10648. /**
  10649. * A class extending Texture allowing drawing on a texture
  10650. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10651. */
  10652. export class DynamicTexture extends Texture {
  10653. private _generateMipMaps;
  10654. private _canvas;
  10655. private _context;
  10656. private _engine;
  10657. /**
  10658. * Creates a DynamicTexture
  10659. * @param name defines the name of the texture
  10660. * @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
  10661. * @param scene defines the scene where you want the texture
  10662. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10663. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10664. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10665. */
  10666. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10667. /**
  10668. * Get the current class name of the texture useful for serialization or dynamic coding.
  10669. * @returns "DynamicTexture"
  10670. */
  10671. getClassName(): string;
  10672. /**
  10673. * Gets the current state of canRescale
  10674. */
  10675. get canRescale(): boolean;
  10676. private _recreate;
  10677. /**
  10678. * Scales the texture
  10679. * @param ratio the scale factor to apply to both width and height
  10680. */
  10681. scale(ratio: number): void;
  10682. /**
  10683. * Resizes the texture
  10684. * @param width the new width
  10685. * @param height the new height
  10686. */
  10687. scaleTo(width: number, height: number): void;
  10688. /**
  10689. * Gets the context of the canvas used by the texture
  10690. * @returns the canvas context of the dynamic texture
  10691. */
  10692. getContext(): CanvasRenderingContext2D;
  10693. /**
  10694. * Clears the texture
  10695. */
  10696. clear(): void;
  10697. /**
  10698. * Updates the texture
  10699. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10700. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10701. */
  10702. update(invertY?: boolean, premulAlpha?: boolean): void;
  10703. /**
  10704. * Draws text onto the texture
  10705. * @param text defines the text to be drawn
  10706. * @param x defines the placement of the text from the left
  10707. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10708. * @param font defines the font to be used with font-style, font-size, font-name
  10709. * @param color defines the color used for the text
  10710. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10711. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10712. * @param update defines whether texture is immediately update (default is true)
  10713. */
  10714. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10715. /**
  10716. * Clones the texture
  10717. * @returns the clone of the texture.
  10718. */
  10719. clone(): DynamicTexture;
  10720. /**
  10721. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10722. * @returns a serialized dynamic texture object
  10723. */
  10724. serialize(): any;
  10725. /** @hidden */
  10726. _rebuild(): void;
  10727. }
  10728. }
  10729. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10730. import { Nullable } from "babylonjs/types";
  10731. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10732. import { Scene } from "babylonjs/scene";
  10733. module "babylonjs/Engines/thinEngine" {
  10734. interface ThinEngine {
  10735. /**
  10736. * Creates a raw texture
  10737. * @param data defines the data to store in the texture
  10738. * @param width defines the width of the texture
  10739. * @param height defines the height of the texture
  10740. * @param format defines the format of the data
  10741. * @param generateMipMaps defines if the engine should generate the mip levels
  10742. * @param invertY defines if data must be stored with Y axis inverted
  10743. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10744. * @param compression defines the compression used (null by default)
  10745. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10746. * @returns the raw texture inside an InternalTexture
  10747. */
  10748. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10749. /**
  10750. * Update a raw texture
  10751. * @param texture defines the texture to update
  10752. * @param data defines the data to store in the texture
  10753. * @param format defines the format of the data
  10754. * @param invertY defines if data must be stored with Y axis inverted
  10755. */
  10756. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10757. /**
  10758. * Update a raw texture
  10759. * @param texture defines the texture to update
  10760. * @param data defines the data to store in the texture
  10761. * @param format defines the format of the data
  10762. * @param invertY defines if data must be stored with Y axis inverted
  10763. * @param compression defines the compression used (null by default)
  10764. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10765. */
  10766. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10767. /**
  10768. * Creates a new raw cube texture
  10769. * @param data defines the array of data to use to create each face
  10770. * @param size defines the size of the textures
  10771. * @param format defines the format of the data
  10772. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10773. * @param generateMipMaps defines if the engine should generate the mip levels
  10774. * @param invertY defines if data must be stored with Y axis inverted
  10775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10776. * @param compression defines the compression used (null by default)
  10777. * @returns the cube texture as an InternalTexture
  10778. */
  10779. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10780. /**
  10781. * Update a raw cube texture
  10782. * @param texture defines the texture to udpdate
  10783. * @param data defines the data to store
  10784. * @param format defines the data format
  10785. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10786. * @param invertY defines if data must be stored with Y axis inverted
  10787. */
  10788. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10789. /**
  10790. * Update a raw cube texture
  10791. * @param texture defines the texture to udpdate
  10792. * @param data defines the data to store
  10793. * @param format defines the data format
  10794. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10795. * @param invertY defines if data must be stored with Y axis inverted
  10796. * @param compression defines the compression used (null by default)
  10797. */
  10798. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10799. /**
  10800. * Update a raw cube texture
  10801. * @param texture defines the texture to udpdate
  10802. * @param data defines the data to store
  10803. * @param format defines the data format
  10804. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10805. * @param invertY defines if data must be stored with Y axis inverted
  10806. * @param compression defines the compression used (null by default)
  10807. * @param level defines which level of the texture to update
  10808. */
  10809. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10810. /**
  10811. * Creates a new raw cube texture from a specified url
  10812. * @param url defines the url where the data is located
  10813. * @param scene defines the current scene
  10814. * @param size defines the size of the textures
  10815. * @param format defines the format of the data
  10816. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10817. * @param noMipmap defines if the engine should avoid generating the mip levels
  10818. * @param callback defines a callback used to extract texture data from loaded data
  10819. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10820. * @param onLoad defines a callback called when texture is loaded
  10821. * @param onError defines a callback called if there is an error
  10822. * @returns the cube texture as an InternalTexture
  10823. */
  10824. 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;
  10825. /**
  10826. * Creates a new raw cube texture from a specified url
  10827. * @param url defines the url where the data is located
  10828. * @param scene defines the current scene
  10829. * @param size defines the size of the textures
  10830. * @param format defines the format of the data
  10831. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10832. * @param noMipmap defines if the engine should avoid generating the mip levels
  10833. * @param callback defines a callback used to extract texture data from loaded data
  10834. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10835. * @param onLoad defines a callback called when texture is loaded
  10836. * @param onError defines a callback called if there is an error
  10837. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10838. * @param invertY defines if data must be stored with Y axis inverted
  10839. * @returns the cube texture as an InternalTexture
  10840. */
  10841. 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;
  10842. /**
  10843. * Creates a new raw 3D texture
  10844. * @param data defines the data used to create the texture
  10845. * @param width defines the width of the texture
  10846. * @param height defines the height of the texture
  10847. * @param depth defines the depth of the texture
  10848. * @param format defines the format of the texture
  10849. * @param generateMipMaps defines if the engine must generate mip levels
  10850. * @param invertY defines if data must be stored with Y axis inverted
  10851. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10852. * @param compression defines the compressed used (can be null)
  10853. * @param textureType defines the compressed used (can be null)
  10854. * @returns a new raw 3D texture (stored in an InternalTexture)
  10855. */
  10856. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10857. /**
  10858. * Update a raw 3D texture
  10859. * @param texture defines the texture to update
  10860. * @param data defines the data to store
  10861. * @param format defines the data format
  10862. * @param invertY defines if data must be stored with Y axis inverted
  10863. */
  10864. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10865. /**
  10866. * Update a raw 3D texture
  10867. * @param texture defines the texture to update
  10868. * @param data defines the data to store
  10869. * @param format defines the data format
  10870. * @param invertY defines if data must be stored with Y axis inverted
  10871. * @param compression defines the used compression (can be null)
  10872. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10873. */
  10874. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10875. /**
  10876. * Creates a new raw 2D array texture
  10877. * @param data defines the data used to create the texture
  10878. * @param width defines the width of the texture
  10879. * @param height defines the height of the texture
  10880. * @param depth defines the number of layers of the texture
  10881. * @param format defines the format of the texture
  10882. * @param generateMipMaps defines if the engine must generate mip levels
  10883. * @param invertY defines if data must be stored with Y axis inverted
  10884. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10885. * @param compression defines the compressed used (can be null)
  10886. * @param textureType defines the compressed used (can be null)
  10887. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10888. */
  10889. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10890. /**
  10891. * Update a raw 2D array texture
  10892. * @param texture defines the texture to update
  10893. * @param data defines the data to store
  10894. * @param format defines the data format
  10895. * @param invertY defines if data must be stored with Y axis inverted
  10896. */
  10897. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10898. /**
  10899. * Update a raw 2D array texture
  10900. * @param texture defines the texture to update
  10901. * @param data defines the data to store
  10902. * @param format defines the data format
  10903. * @param invertY defines if data must be stored with Y axis inverted
  10904. * @param compression defines the used compression (can be null)
  10905. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10906. */
  10907. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10908. }
  10909. }
  10910. }
  10911. declare module "babylonjs/Materials/Textures/rawTexture" {
  10912. import { Scene } from "babylonjs/scene";
  10913. import { Texture } from "babylonjs/Materials/Textures/texture";
  10914. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10915. /**
  10916. * Raw texture can help creating a texture directly from an array of data.
  10917. * This can be super useful if you either get the data from an uncompressed source or
  10918. * if you wish to create your texture pixel by pixel.
  10919. */
  10920. export class RawTexture extends Texture {
  10921. /**
  10922. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10923. */
  10924. format: number;
  10925. private _engine;
  10926. /**
  10927. * Instantiates a new RawTexture.
  10928. * Raw texture can help creating a texture directly from an array of data.
  10929. * This can be super useful if you either get the data from an uncompressed source or
  10930. * if you wish to create your texture pixel by pixel.
  10931. * @param data define the array of data to use to create the texture
  10932. * @param width define the width of the texture
  10933. * @param height define the height of the texture
  10934. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10935. * @param scene define the scene the texture belongs to
  10936. * @param generateMipMaps define whether mip maps should be generated or not
  10937. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10938. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10939. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10940. */
  10941. constructor(data: ArrayBufferView, width: number, height: number,
  10942. /**
  10943. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10944. */
  10945. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10946. /**
  10947. * Updates the texture underlying data.
  10948. * @param data Define the new data of the texture
  10949. */
  10950. update(data: ArrayBufferView): void;
  10951. /**
  10952. * Creates a luminance texture from some data.
  10953. * @param data Define the texture data
  10954. * @param width Define the width of the texture
  10955. * @param height Define the height of the texture
  10956. * @param scene Define the scene the texture belongs to
  10957. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10958. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10959. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10960. * @returns the luminance texture
  10961. */
  10962. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10963. /**
  10964. * Creates a luminance alpha texture from some data.
  10965. * @param data Define the texture data
  10966. * @param width Define the width of the texture
  10967. * @param height Define the height of the texture
  10968. * @param scene Define the scene the texture belongs to
  10969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10972. * @returns the luminance alpha texture
  10973. */
  10974. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10975. /**
  10976. * Creates an alpha texture from some data.
  10977. * @param data Define the texture data
  10978. * @param width Define the width of the texture
  10979. * @param height Define the height of the texture
  10980. * @param scene Define the scene the texture belongs to
  10981. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10982. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10983. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10984. * @returns the alpha texture
  10985. */
  10986. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10987. /**
  10988. * Creates a RGB texture from some data.
  10989. * @param data Define the texture data
  10990. * @param width Define the width of the texture
  10991. * @param height Define the height of the texture
  10992. * @param scene Define the scene the texture belongs to
  10993. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10996. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10997. * @returns the RGB alpha texture
  10998. */
  10999. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11000. /**
  11001. * Creates a RGBA texture from some data.
  11002. * @param data Define the texture data
  11003. * @param width Define the width of the texture
  11004. * @param height Define the height of the texture
  11005. * @param scene Define the scene the texture belongs to
  11006. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11007. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11008. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11009. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11010. * @returns the RGBA texture
  11011. */
  11012. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11013. /**
  11014. * Creates a R texture from some data.
  11015. * @param data Define the texture data
  11016. * @param width Define the width of the texture
  11017. * @param height Define the height of the texture
  11018. * @param scene Define the scene the texture belongs to
  11019. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11020. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11021. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11022. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11023. * @returns the R texture
  11024. */
  11025. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11026. }
  11027. }
  11028. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11029. import { Scene } from "babylonjs/scene";
  11030. import { ISceneComponent } from "babylonjs/sceneComponent";
  11031. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11032. module "babylonjs/abstractScene" {
  11033. interface AbstractScene {
  11034. /**
  11035. * The list of procedural textures added to the scene
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11037. */
  11038. proceduralTextures: Array<ProceduralTexture>;
  11039. }
  11040. }
  11041. /**
  11042. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11043. * in a given scene.
  11044. */
  11045. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11046. /**
  11047. * The component name helpfull to identify the component in the list of scene components.
  11048. */
  11049. readonly name: string;
  11050. /**
  11051. * The scene the component belongs to.
  11052. */
  11053. scene: Scene;
  11054. /**
  11055. * Creates a new instance of the component for the given scene
  11056. * @param scene Defines the scene to register the component in
  11057. */
  11058. constructor(scene: Scene);
  11059. /**
  11060. * Registers the component in a given scene
  11061. */
  11062. register(): void;
  11063. /**
  11064. * Rebuilds the elements related to this component in case of
  11065. * context lost for instance.
  11066. */
  11067. rebuild(): void;
  11068. /**
  11069. * Disposes the component and the associated ressources.
  11070. */
  11071. dispose(): void;
  11072. private _beforeClear;
  11073. }
  11074. }
  11075. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11077. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11078. module "babylonjs/Engines/thinEngine" {
  11079. interface ThinEngine {
  11080. /**
  11081. * Creates a new render target cube texture
  11082. * @param size defines the size of the texture
  11083. * @param options defines the options used to create the texture
  11084. * @returns a new render target cube texture stored in an InternalTexture
  11085. */
  11086. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11087. }
  11088. }
  11089. }
  11090. declare module "babylonjs/Shaders/procedural.vertex" {
  11091. /** @hidden */
  11092. export var proceduralVertexShader: {
  11093. name: string;
  11094. shader: string;
  11095. };
  11096. }
  11097. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11098. import { Observable } from "babylonjs/Misc/observable";
  11099. import { Nullable } from "babylonjs/types";
  11100. import { Scene } from "babylonjs/scene";
  11101. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11102. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11103. import { Effect } from "babylonjs/Materials/effect";
  11104. import { Texture } from "babylonjs/Materials/Textures/texture";
  11105. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11106. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11107. import "babylonjs/Shaders/procedural.vertex";
  11108. /**
  11109. * 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.
  11110. * This is the base class of any Procedural texture and contains most of the shareable code.
  11111. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11112. */
  11113. export class ProceduralTexture extends Texture {
  11114. isCube: boolean;
  11115. /**
  11116. * Define if the texture is enabled or not (disabled texture will not render)
  11117. */
  11118. isEnabled: boolean;
  11119. /**
  11120. * Define if the texture must be cleared before rendering (default is true)
  11121. */
  11122. autoClear: boolean;
  11123. /**
  11124. * Callback called when the texture is generated
  11125. */
  11126. onGenerated: () => void;
  11127. /**
  11128. * Event raised when the texture is generated
  11129. */
  11130. onGeneratedObservable: Observable<ProceduralTexture>;
  11131. /** @hidden */
  11132. _generateMipMaps: boolean;
  11133. /** @hidden **/
  11134. _effect: Effect;
  11135. /** @hidden */
  11136. _textures: {
  11137. [key: string]: Texture;
  11138. };
  11139. /** @hidden */
  11140. protected _fallbackTexture: Nullable<Texture>;
  11141. private _size;
  11142. private _currentRefreshId;
  11143. private _frameId;
  11144. private _refreshRate;
  11145. private _vertexBuffers;
  11146. private _indexBuffer;
  11147. private _uniforms;
  11148. private _samplers;
  11149. private _fragment;
  11150. private _floats;
  11151. private _ints;
  11152. private _floatsArrays;
  11153. private _colors3;
  11154. private _colors4;
  11155. private _vectors2;
  11156. private _vectors3;
  11157. private _matrices;
  11158. private _fallbackTextureUsed;
  11159. private _engine;
  11160. private _cachedDefines;
  11161. private _contentUpdateId;
  11162. private _contentData;
  11163. /**
  11164. * Instantiates a new procedural texture.
  11165. * 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.
  11166. * This is the base class of any Procedural texture and contains most of the shareable code.
  11167. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11168. * @param name Define the name of the texture
  11169. * @param size Define the size of the texture to create
  11170. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11171. * @param scene Define the scene the texture belongs to
  11172. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11173. * @param generateMipMaps Define if the texture should creates mip maps or not
  11174. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11175. */
  11176. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11177. /**
  11178. * The effect that is created when initializing the post process.
  11179. * @returns The created effect corresponding the the postprocess.
  11180. */
  11181. getEffect(): Effect;
  11182. /**
  11183. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11184. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11185. */
  11186. getContent(): Nullable<ArrayBufferView>;
  11187. private _createIndexBuffer;
  11188. /** @hidden */
  11189. _rebuild(): void;
  11190. /**
  11191. * Resets the texture in order to recreate its associated resources.
  11192. * This can be called in case of context loss
  11193. */
  11194. reset(): void;
  11195. protected _getDefines(): string;
  11196. /**
  11197. * Is the texture ready to be used ? (rendered at least once)
  11198. * @returns true if ready, otherwise, false.
  11199. */
  11200. isReady(): boolean;
  11201. /**
  11202. * Resets the refresh counter of the texture and start bak from scratch.
  11203. * Could be useful to regenerate the texture if it is setup to render only once.
  11204. */
  11205. resetRefreshCounter(): void;
  11206. /**
  11207. * Set the fragment shader to use in order to render the texture.
  11208. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11209. */
  11210. setFragment(fragment: any): void;
  11211. /**
  11212. * Define the refresh rate of the texture or the rendering frequency.
  11213. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11214. */
  11215. get refreshRate(): number;
  11216. set refreshRate(value: number);
  11217. /** @hidden */
  11218. _shouldRender(): boolean;
  11219. /**
  11220. * Get the size the texture is rendering at.
  11221. * @returns the size (texture is always squared)
  11222. */
  11223. getRenderSize(): number;
  11224. /**
  11225. * Resize the texture to new value.
  11226. * @param size Define the new size the texture should have
  11227. * @param generateMipMaps Define whether the new texture should create mip maps
  11228. */
  11229. resize(size: number, generateMipMaps: boolean): void;
  11230. private _checkUniform;
  11231. /**
  11232. * Set a texture in the shader program used to render.
  11233. * @param name Define the name of the uniform samplers as defined in the shader
  11234. * @param texture Define the texture to bind to this sampler
  11235. * @return the texture itself allowing "fluent" like uniform updates
  11236. */
  11237. setTexture(name: string, texture: Texture): ProceduralTexture;
  11238. /**
  11239. * Set a float in the shader.
  11240. * @param name Define the name of the uniform as defined in the shader
  11241. * @param value Define the value to give to the uniform
  11242. * @return the texture itself allowing "fluent" like uniform updates
  11243. */
  11244. setFloat(name: string, value: number): ProceduralTexture;
  11245. /**
  11246. * Set a int in the shader.
  11247. * @param name Define the name of the uniform as defined in the shader
  11248. * @param value Define the value to give to the uniform
  11249. * @return the texture itself allowing "fluent" like uniform updates
  11250. */
  11251. setInt(name: string, value: number): ProceduralTexture;
  11252. /**
  11253. * Set an array of floats in the shader.
  11254. * @param name Define the name of the uniform as defined in the shader
  11255. * @param value Define the value to give to the uniform
  11256. * @return the texture itself allowing "fluent" like uniform updates
  11257. */
  11258. setFloats(name: string, value: number[]): ProceduralTexture;
  11259. /**
  11260. * Set a vec3 in the shader from a Color3.
  11261. * @param name Define the name of the uniform as defined in the shader
  11262. * @param value Define the value to give to the uniform
  11263. * @return the texture itself allowing "fluent" like uniform updates
  11264. */
  11265. setColor3(name: string, value: Color3): ProceduralTexture;
  11266. /**
  11267. * Set a vec4 in the shader from a Color4.
  11268. * @param name Define the name of the uniform as defined in the shader
  11269. * @param value Define the value to give to the uniform
  11270. * @return the texture itself allowing "fluent" like uniform updates
  11271. */
  11272. setColor4(name: string, value: Color4): ProceduralTexture;
  11273. /**
  11274. * Set a vec2 in the shader from a Vector2.
  11275. * @param name Define the name of the uniform as defined in the shader
  11276. * @param value Define the value to give to the uniform
  11277. * @return the texture itself allowing "fluent" like uniform updates
  11278. */
  11279. setVector2(name: string, value: Vector2): ProceduralTexture;
  11280. /**
  11281. * Set a vec3 in the shader from a Vector3.
  11282. * @param name Define the name of the uniform as defined in the shader
  11283. * @param value Define the value to give to the uniform
  11284. * @return the texture itself allowing "fluent" like uniform updates
  11285. */
  11286. setVector3(name: string, value: Vector3): ProceduralTexture;
  11287. /**
  11288. * Set a mat4 in the shader from a MAtrix.
  11289. * @param name Define the name of the uniform as defined in the shader
  11290. * @param value Define the value to give to the uniform
  11291. * @return the texture itself allowing "fluent" like uniform updates
  11292. */
  11293. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11294. /**
  11295. * Render the texture to its associated render target.
  11296. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11297. */
  11298. render(useCameraPostProcess?: boolean): void;
  11299. /**
  11300. * Clone the texture.
  11301. * @returns the cloned texture
  11302. */
  11303. clone(): ProceduralTexture;
  11304. /**
  11305. * Dispose the texture and release its asoociated resources.
  11306. */
  11307. dispose(): void;
  11308. }
  11309. }
  11310. declare module "babylonjs/Particles/baseParticleSystem" {
  11311. import { Nullable } from "babylonjs/types";
  11312. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11314. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11315. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11316. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11317. import { Scene } from "babylonjs/scene";
  11318. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11319. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11320. import { Texture } from "babylonjs/Materials/Textures/texture";
  11321. import { Color4 } from "babylonjs/Maths/math.color";
  11322. import { Animation } from "babylonjs/Animations/animation";
  11323. /**
  11324. * This represents the base class for particle system in Babylon.
  11325. * 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.
  11326. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11327. * @example https://doc.babylonjs.com/babylon101/particles
  11328. */
  11329. export class BaseParticleSystem {
  11330. /**
  11331. * Source color is added to the destination color without alpha affecting the result
  11332. */
  11333. static BLENDMODE_ONEONE: number;
  11334. /**
  11335. * Blend current color and particle color using particle’s alpha
  11336. */
  11337. static BLENDMODE_STANDARD: number;
  11338. /**
  11339. * Add current color and particle color multiplied by particle’s alpha
  11340. */
  11341. static BLENDMODE_ADD: number;
  11342. /**
  11343. * Multiply current color with particle color
  11344. */
  11345. static BLENDMODE_MULTIPLY: number;
  11346. /**
  11347. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11348. */
  11349. static BLENDMODE_MULTIPLYADD: number;
  11350. /**
  11351. * List of animations used by the particle system.
  11352. */
  11353. animations: Animation[];
  11354. /**
  11355. * Gets or sets the unique id of the particle system
  11356. */
  11357. uniqueId: number;
  11358. /**
  11359. * The id of the Particle system.
  11360. */
  11361. id: string;
  11362. /**
  11363. * The friendly name of the Particle system.
  11364. */
  11365. name: string;
  11366. /**
  11367. * Snippet ID if the particle system was created from the snippet server
  11368. */
  11369. snippetId: string;
  11370. /**
  11371. * The rendering group used by the Particle system to chose when to render.
  11372. */
  11373. renderingGroupId: number;
  11374. /**
  11375. * The emitter represents the Mesh or position we are attaching the particle system to.
  11376. */
  11377. emitter: Nullable<AbstractMesh | Vector3>;
  11378. /**
  11379. * The maximum number of particles to emit per frame
  11380. */
  11381. emitRate: number;
  11382. /**
  11383. * If you want to launch only a few particles at once, that can be done, as well.
  11384. */
  11385. manualEmitCount: number;
  11386. /**
  11387. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11388. */
  11389. updateSpeed: number;
  11390. /**
  11391. * The amount of time the particle system is running (depends of the overall update speed).
  11392. */
  11393. targetStopDuration: number;
  11394. /**
  11395. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11396. */
  11397. disposeOnStop: boolean;
  11398. /**
  11399. * Minimum power of emitting particles.
  11400. */
  11401. minEmitPower: number;
  11402. /**
  11403. * Maximum power of emitting particles.
  11404. */
  11405. maxEmitPower: number;
  11406. /**
  11407. * Minimum life time of emitting particles.
  11408. */
  11409. minLifeTime: number;
  11410. /**
  11411. * Maximum life time of emitting particles.
  11412. */
  11413. maxLifeTime: number;
  11414. /**
  11415. * Minimum Size of emitting particles.
  11416. */
  11417. minSize: number;
  11418. /**
  11419. * Maximum Size of emitting particles.
  11420. */
  11421. maxSize: number;
  11422. /**
  11423. * Minimum scale of emitting particles on X axis.
  11424. */
  11425. minScaleX: number;
  11426. /**
  11427. * Maximum scale of emitting particles on X axis.
  11428. */
  11429. maxScaleX: number;
  11430. /**
  11431. * Minimum scale of emitting particles on Y axis.
  11432. */
  11433. minScaleY: number;
  11434. /**
  11435. * Maximum scale of emitting particles on Y axis.
  11436. */
  11437. maxScaleY: number;
  11438. /**
  11439. * Gets or sets the minimal initial rotation in radians.
  11440. */
  11441. minInitialRotation: number;
  11442. /**
  11443. * Gets or sets the maximal initial rotation in radians.
  11444. */
  11445. maxInitialRotation: number;
  11446. /**
  11447. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11448. */
  11449. minAngularSpeed: number;
  11450. /**
  11451. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11452. */
  11453. maxAngularSpeed: number;
  11454. /**
  11455. * The texture used to render each particle. (this can be a spritesheet)
  11456. */
  11457. particleTexture: Nullable<Texture>;
  11458. /**
  11459. * The layer mask we are rendering the particles through.
  11460. */
  11461. layerMask: number;
  11462. /**
  11463. * This can help using your own shader to render the particle system.
  11464. * The according effect will be created
  11465. */
  11466. customShader: any;
  11467. /**
  11468. * By default particle system starts as soon as they are created. This prevents the
  11469. * automatic start to happen and let you decide when to start emitting particles.
  11470. */
  11471. preventAutoStart: boolean;
  11472. private _noiseTexture;
  11473. /**
  11474. * Gets or sets a texture used to add random noise to particle positions
  11475. */
  11476. get noiseTexture(): Nullable<ProceduralTexture>;
  11477. set noiseTexture(value: Nullable<ProceduralTexture>);
  11478. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11479. noiseStrength: Vector3;
  11480. /**
  11481. * Callback triggered when the particle animation is ending.
  11482. */
  11483. onAnimationEnd: Nullable<() => void>;
  11484. /**
  11485. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11486. */
  11487. blendMode: number;
  11488. /**
  11489. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11490. * to override the particles.
  11491. */
  11492. forceDepthWrite: boolean;
  11493. /** 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 */
  11494. preWarmCycles: number;
  11495. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11496. preWarmStepOffset: number;
  11497. /**
  11498. * 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)
  11499. */
  11500. spriteCellChangeSpeed: number;
  11501. /**
  11502. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11503. */
  11504. startSpriteCellID: number;
  11505. /**
  11506. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11507. */
  11508. endSpriteCellID: number;
  11509. /**
  11510. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11511. */
  11512. spriteCellWidth: number;
  11513. /**
  11514. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11515. */
  11516. spriteCellHeight: number;
  11517. /**
  11518. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11519. */
  11520. spriteRandomStartCell: boolean;
  11521. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11522. translationPivot: Vector2;
  11523. /** @hidden */
  11524. protected _isAnimationSheetEnabled: boolean;
  11525. /**
  11526. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11527. */
  11528. beginAnimationOnStart: boolean;
  11529. /**
  11530. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11531. */
  11532. beginAnimationFrom: number;
  11533. /**
  11534. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11535. */
  11536. beginAnimationTo: number;
  11537. /**
  11538. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11539. */
  11540. beginAnimationLoop: boolean;
  11541. /**
  11542. * Gets or sets a world offset applied to all particles
  11543. */
  11544. worldOffset: Vector3;
  11545. /**
  11546. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11547. */
  11548. get isAnimationSheetEnabled(): boolean;
  11549. set isAnimationSheetEnabled(value: boolean);
  11550. /**
  11551. * Get hosting scene
  11552. * @returns the scene
  11553. */
  11554. getScene(): Scene;
  11555. /**
  11556. * You can use gravity if you want to give an orientation to your particles.
  11557. */
  11558. gravity: Vector3;
  11559. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11560. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11561. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11562. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11563. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11564. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11565. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11566. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11567. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11568. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11569. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11570. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11571. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11572. /**
  11573. * Defines the delay in milliseconds before starting the system (0 by default)
  11574. */
  11575. startDelay: number;
  11576. /**
  11577. * Gets the current list of drag gradients.
  11578. * You must use addDragGradient and removeDragGradient to udpate this list
  11579. * @returns the list of drag gradients
  11580. */
  11581. getDragGradients(): Nullable<Array<FactorGradient>>;
  11582. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11583. limitVelocityDamping: number;
  11584. /**
  11585. * Gets the current list of limit velocity gradients.
  11586. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11587. * @returns the list of limit velocity gradients
  11588. */
  11589. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11590. /**
  11591. * Gets the current list of color gradients.
  11592. * You must use addColorGradient and removeColorGradient to udpate this list
  11593. * @returns the list of color gradients
  11594. */
  11595. getColorGradients(): Nullable<Array<ColorGradient>>;
  11596. /**
  11597. * Gets the current list of size gradients.
  11598. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11599. * @returns the list of size gradients
  11600. */
  11601. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11602. /**
  11603. * Gets the current list of color remap gradients.
  11604. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11605. * @returns the list of color remap gradients
  11606. */
  11607. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11608. /**
  11609. * Gets the current list of alpha remap gradients.
  11610. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11611. * @returns the list of alpha remap gradients
  11612. */
  11613. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11614. /**
  11615. * Gets the current list of life time gradients.
  11616. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11617. * @returns the list of life time gradients
  11618. */
  11619. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11620. /**
  11621. * Gets the current list of angular speed gradients.
  11622. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11623. * @returns the list of angular speed gradients
  11624. */
  11625. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11626. /**
  11627. * Gets the current list of velocity gradients.
  11628. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11629. * @returns the list of velocity gradients
  11630. */
  11631. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11632. /**
  11633. * Gets the current list of start size gradients.
  11634. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11635. * @returns the list of start size gradients
  11636. */
  11637. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11638. /**
  11639. * Gets the current list of emit rate gradients.
  11640. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11641. * @returns the list of emit rate gradients
  11642. */
  11643. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11644. /**
  11645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11646. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11647. */
  11648. get direction1(): Vector3;
  11649. set direction1(value: Vector3);
  11650. /**
  11651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11652. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11653. */
  11654. get direction2(): Vector3;
  11655. set direction2(value: Vector3);
  11656. /**
  11657. * 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.
  11658. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11659. */
  11660. get minEmitBox(): Vector3;
  11661. set minEmitBox(value: Vector3);
  11662. /**
  11663. * 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.
  11664. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11665. */
  11666. get maxEmitBox(): Vector3;
  11667. set maxEmitBox(value: Vector3);
  11668. /**
  11669. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11670. */
  11671. color1: Color4;
  11672. /**
  11673. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11674. */
  11675. color2: Color4;
  11676. /**
  11677. * Color the particle will have at the end of its lifetime
  11678. */
  11679. colorDead: Color4;
  11680. /**
  11681. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11682. */
  11683. textureMask: Color4;
  11684. /**
  11685. * The particle emitter type defines the emitter used by the particle system.
  11686. * It can be for example box, sphere, or cone...
  11687. */
  11688. particleEmitterType: IParticleEmitterType;
  11689. /** @hidden */
  11690. _isSubEmitter: boolean;
  11691. /**
  11692. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11693. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11694. */
  11695. billboardMode: number;
  11696. protected _isBillboardBased: boolean;
  11697. /**
  11698. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11699. */
  11700. get isBillboardBased(): boolean;
  11701. set isBillboardBased(value: boolean);
  11702. /**
  11703. * The scene the particle system belongs to.
  11704. */
  11705. protected _scene: Scene;
  11706. /**
  11707. * Local cache of defines for image processing.
  11708. */
  11709. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11710. /**
  11711. * Default configuration related to image processing available in the standard Material.
  11712. */
  11713. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11714. /**
  11715. * Gets the image processing configuration used either in this material.
  11716. */
  11717. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11718. /**
  11719. * Sets the Default image processing configuration used either in the this material.
  11720. *
  11721. * If sets to null, the scene one is in use.
  11722. */
  11723. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11724. /**
  11725. * Attaches a new image processing configuration to the Standard Material.
  11726. * @param configuration
  11727. */
  11728. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11729. /** @hidden */
  11730. protected _reset(): void;
  11731. /** @hidden */
  11732. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11733. /**
  11734. * Instantiates a particle system.
  11735. * 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.
  11736. * @param name The name of the particle system
  11737. */
  11738. constructor(name: string);
  11739. /**
  11740. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11741. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11742. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11743. * @returns the emitter
  11744. */
  11745. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11746. /**
  11747. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11748. * @param radius The radius of the hemisphere to emit from
  11749. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11750. * @returns the emitter
  11751. */
  11752. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11753. /**
  11754. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11755. * @param radius The radius of the sphere to emit from
  11756. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11757. * @returns the emitter
  11758. */
  11759. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11760. /**
  11761. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11762. * @param radius The radius of the sphere to emit from
  11763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11765. * @returns the emitter
  11766. */
  11767. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11768. /**
  11769. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11770. * @param radius The radius of the emission cylinder
  11771. * @param height The height of the emission cylinder
  11772. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11773. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11774. * @returns the emitter
  11775. */
  11776. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11777. /**
  11778. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11779. * @param radius The radius of the cylinder to emit from
  11780. * @param height The height of the emission cylinder
  11781. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11782. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11783. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11784. * @returns the emitter
  11785. */
  11786. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11787. /**
  11788. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11789. * @param radius The radius of the cone to emit from
  11790. * @param angle The base angle of the cone
  11791. * @returns the emitter
  11792. */
  11793. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11794. /**
  11795. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11796. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11797. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11798. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11799. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11800. * @returns the emitter
  11801. */
  11802. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11803. }
  11804. }
  11805. declare module "babylonjs/Particles/subEmitter" {
  11806. import { Scene } from "babylonjs/scene";
  11807. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11808. /**
  11809. * Type of sub emitter
  11810. */
  11811. export enum SubEmitterType {
  11812. /**
  11813. * Attached to the particle over it's lifetime
  11814. */
  11815. ATTACHED = 0,
  11816. /**
  11817. * Created when the particle dies
  11818. */
  11819. END = 1
  11820. }
  11821. /**
  11822. * Sub emitter class used to emit particles from an existing particle
  11823. */
  11824. export class SubEmitter {
  11825. /**
  11826. * the particle system to be used by the sub emitter
  11827. */
  11828. particleSystem: ParticleSystem;
  11829. /**
  11830. * Type of the submitter (Default: END)
  11831. */
  11832. type: SubEmitterType;
  11833. /**
  11834. * 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)
  11835. * Note: This only is supported when using an emitter of type Mesh
  11836. */
  11837. inheritDirection: boolean;
  11838. /**
  11839. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11840. */
  11841. inheritedVelocityAmount: number;
  11842. /**
  11843. * Creates a sub emitter
  11844. * @param particleSystem the particle system to be used by the sub emitter
  11845. */
  11846. constructor(
  11847. /**
  11848. * the particle system to be used by the sub emitter
  11849. */
  11850. particleSystem: ParticleSystem);
  11851. /**
  11852. * Clones the sub emitter
  11853. * @returns the cloned sub emitter
  11854. */
  11855. clone(): SubEmitter;
  11856. /**
  11857. * Serialize current object to a JSON object
  11858. * @returns the serialized object
  11859. */
  11860. serialize(): any;
  11861. /** @hidden */
  11862. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11863. /**
  11864. * Creates a new SubEmitter from a serialized JSON version
  11865. * @param serializationObject defines the JSON object to read from
  11866. * @param scene defines the hosting scene
  11867. * @param rootUrl defines the rootUrl for data loading
  11868. * @returns a new SubEmitter
  11869. */
  11870. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11871. /** Release associated resources */
  11872. dispose(): void;
  11873. }
  11874. }
  11875. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11876. /** @hidden */
  11877. export var imageProcessingDeclaration: {
  11878. name: string;
  11879. shader: string;
  11880. };
  11881. }
  11882. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11883. /** @hidden */
  11884. export var imageProcessingFunctions: {
  11885. name: string;
  11886. shader: string;
  11887. };
  11888. }
  11889. declare module "babylonjs/Shaders/particles.fragment" {
  11890. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11891. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11892. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11893. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11894. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11895. /** @hidden */
  11896. export var particlesPixelShader: {
  11897. name: string;
  11898. shader: string;
  11899. };
  11900. }
  11901. declare module "babylonjs/Shaders/particles.vertex" {
  11902. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11903. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11904. /** @hidden */
  11905. export var particlesVertexShader: {
  11906. name: string;
  11907. shader: string;
  11908. };
  11909. }
  11910. declare module "babylonjs/Particles/particleSystem" {
  11911. import { Nullable } from "babylonjs/types";
  11912. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11913. import { Observable } from "babylonjs/Misc/observable";
  11914. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11915. import { Effect } from "babylonjs/Materials/effect";
  11916. import { Scene, IDisposable } from "babylonjs/scene";
  11917. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11918. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11919. import { Particle } from "babylonjs/Particles/particle";
  11920. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11921. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11922. import "babylonjs/Shaders/particles.fragment";
  11923. import "babylonjs/Shaders/particles.vertex";
  11924. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11925. /**
  11926. * This represents a particle system in Babylon.
  11927. * 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.
  11928. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11929. * @example https://doc.babylonjs.com/babylon101/particles
  11930. */
  11931. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11932. /**
  11933. * Billboard mode will only apply to Y axis
  11934. */
  11935. static readonly BILLBOARDMODE_Y: number;
  11936. /**
  11937. * Billboard mode will apply to all axes
  11938. */
  11939. static readonly BILLBOARDMODE_ALL: number;
  11940. /**
  11941. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11942. */
  11943. static readonly BILLBOARDMODE_STRETCHED: number;
  11944. /**
  11945. * This function can be defined to provide custom update for active particles.
  11946. * This function will be called instead of regular update (age, position, color, etc.).
  11947. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11948. */
  11949. updateFunction: (particles: Particle[]) => void;
  11950. private _emitterWorldMatrix;
  11951. /**
  11952. * This function can be defined to specify initial direction for every new particle.
  11953. * It by default use the emitterType defined function
  11954. */
  11955. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11956. /**
  11957. * This function can be defined to specify initial position for every new particle.
  11958. * It by default use the emitterType defined function
  11959. */
  11960. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11961. /**
  11962. * @hidden
  11963. */
  11964. _inheritedVelocityOffset: Vector3;
  11965. /**
  11966. * An event triggered when the system is disposed
  11967. */
  11968. onDisposeObservable: Observable<ParticleSystem>;
  11969. private _onDisposeObserver;
  11970. /**
  11971. * Sets a callback that will be triggered when the system is disposed
  11972. */
  11973. set onDispose(callback: () => void);
  11974. private _particles;
  11975. private _epsilon;
  11976. private _capacity;
  11977. private _stockParticles;
  11978. private _newPartsExcess;
  11979. private _vertexData;
  11980. private _vertexBuffer;
  11981. private _vertexBuffers;
  11982. private _spriteBuffer;
  11983. private _indexBuffer;
  11984. private _effect;
  11985. private _customEffect;
  11986. private _cachedDefines;
  11987. private _scaledColorStep;
  11988. private _colorDiff;
  11989. private _scaledDirection;
  11990. private _scaledGravity;
  11991. private _currentRenderId;
  11992. private _alive;
  11993. private _useInstancing;
  11994. private _started;
  11995. private _stopped;
  11996. private _actualFrame;
  11997. private _scaledUpdateSpeed;
  11998. private _vertexBufferSize;
  11999. /** @hidden */
  12000. _currentEmitRateGradient: Nullable<FactorGradient>;
  12001. /** @hidden */
  12002. _currentEmitRate1: number;
  12003. /** @hidden */
  12004. _currentEmitRate2: number;
  12005. /** @hidden */
  12006. _currentStartSizeGradient: Nullable<FactorGradient>;
  12007. /** @hidden */
  12008. _currentStartSize1: number;
  12009. /** @hidden */
  12010. _currentStartSize2: number;
  12011. private readonly _rawTextureWidth;
  12012. private _rampGradientsTexture;
  12013. private _useRampGradients;
  12014. /** Gets or sets a boolean indicating that ramp gradients must be used
  12015. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12016. */
  12017. get useRampGradients(): boolean;
  12018. set useRampGradients(value: boolean);
  12019. /**
  12020. * 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.
  12021. * 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: [])
  12022. */
  12023. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12024. private _subEmitters;
  12025. /**
  12026. * @hidden
  12027. * If the particle systems emitter should be disposed when the particle system is disposed
  12028. */
  12029. _disposeEmitterOnDispose: boolean;
  12030. /**
  12031. * The current active Sub-systems, this property is used by the root particle system only.
  12032. */
  12033. activeSubSystems: Array<ParticleSystem>;
  12034. /**
  12035. * Specifies if the particles are updated in emitter local space or world space
  12036. */
  12037. isLocal: boolean;
  12038. private _rootParticleSystem;
  12039. /**
  12040. * Gets the current list of active particles
  12041. */
  12042. get particles(): Particle[];
  12043. /**
  12044. * Gets the number of particles active at the same time.
  12045. * @returns The number of active particles.
  12046. */
  12047. getActiveCount(): number;
  12048. /**
  12049. * Returns the string "ParticleSystem"
  12050. * @returns a string containing the class name
  12051. */
  12052. getClassName(): string;
  12053. /**
  12054. * Gets a boolean indicating that the system is stopping
  12055. * @returns true if the system is currently stopping
  12056. */
  12057. isStopping(): boolean;
  12058. /**
  12059. * Instantiates a particle system.
  12060. * 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.
  12061. * @param name The name of the particle system
  12062. * @param capacity The max number of particles alive at the same time
  12063. * @param scene The scene the particle system belongs to
  12064. * @param customEffect a custom effect used to change the way particles are rendered by default
  12065. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12066. * @param epsilon Offset used to render the particles
  12067. */
  12068. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12069. private _addFactorGradient;
  12070. private _removeFactorGradient;
  12071. /**
  12072. * Adds a new life time gradient
  12073. * @param gradient defines the gradient to use (between 0 and 1)
  12074. * @param factor defines the life time factor to affect to the specified gradient
  12075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12076. * @returns the current particle system
  12077. */
  12078. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12079. /**
  12080. * Remove a specific life time gradient
  12081. * @param gradient defines the gradient to remove
  12082. * @returns the current particle system
  12083. */
  12084. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12085. /**
  12086. * Adds a new size gradient
  12087. * @param gradient defines the gradient to use (between 0 and 1)
  12088. * @param factor defines the size factor to affect to the specified gradient
  12089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12090. * @returns the current particle system
  12091. */
  12092. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12093. /**
  12094. * Remove a specific size gradient
  12095. * @param gradient defines the gradient to remove
  12096. * @returns the current particle system
  12097. */
  12098. removeSizeGradient(gradient: number): IParticleSystem;
  12099. /**
  12100. * Adds a new color remap gradient
  12101. * @param gradient defines the gradient to use (between 0 and 1)
  12102. * @param min defines the color remap minimal range
  12103. * @param max defines the color remap maximal range
  12104. * @returns the current particle system
  12105. */
  12106. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12107. /**
  12108. * Remove a specific color remap gradient
  12109. * @param gradient defines the gradient to remove
  12110. * @returns the current particle system
  12111. */
  12112. removeColorRemapGradient(gradient: number): IParticleSystem;
  12113. /**
  12114. * Adds a new alpha remap gradient
  12115. * @param gradient defines the gradient to use (between 0 and 1)
  12116. * @param min defines the alpha remap minimal range
  12117. * @param max defines the alpha remap maximal range
  12118. * @returns the current particle system
  12119. */
  12120. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12121. /**
  12122. * Remove a specific alpha remap gradient
  12123. * @param gradient defines the gradient to remove
  12124. * @returns the current particle system
  12125. */
  12126. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12127. /**
  12128. * Adds a new angular speed gradient
  12129. * @param gradient defines the gradient to use (between 0 and 1)
  12130. * @param factor defines the angular speed to affect to the specified gradient
  12131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12132. * @returns the current particle system
  12133. */
  12134. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12135. /**
  12136. * Remove a specific angular speed gradient
  12137. * @param gradient defines the gradient to remove
  12138. * @returns the current particle system
  12139. */
  12140. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12141. /**
  12142. * Adds a new velocity gradient
  12143. * @param gradient defines the gradient to use (between 0 and 1)
  12144. * @param factor defines the velocity to affect to the specified gradient
  12145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12146. * @returns the current particle system
  12147. */
  12148. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12149. /**
  12150. * Remove a specific velocity gradient
  12151. * @param gradient defines the gradient to remove
  12152. * @returns the current particle system
  12153. */
  12154. removeVelocityGradient(gradient: number): IParticleSystem;
  12155. /**
  12156. * Adds a new limit velocity gradient
  12157. * @param gradient defines the gradient to use (between 0 and 1)
  12158. * @param factor defines the limit velocity value to affect to the specified gradient
  12159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12160. * @returns the current particle system
  12161. */
  12162. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12163. /**
  12164. * Remove a specific limit velocity gradient
  12165. * @param gradient defines the gradient to remove
  12166. * @returns the current particle system
  12167. */
  12168. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12169. /**
  12170. * Adds a new drag gradient
  12171. * @param gradient defines the gradient to use (between 0 and 1)
  12172. * @param factor defines the drag value to affect to the specified gradient
  12173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12174. * @returns the current particle system
  12175. */
  12176. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12177. /**
  12178. * Remove a specific drag gradient
  12179. * @param gradient defines the gradient to remove
  12180. * @returns the current particle system
  12181. */
  12182. removeDragGradient(gradient: number): IParticleSystem;
  12183. /**
  12184. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12185. * @param gradient defines the gradient to use (between 0 and 1)
  12186. * @param factor defines the emit rate value to affect to the specified gradient
  12187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12188. * @returns the current particle system
  12189. */
  12190. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12191. /**
  12192. * Remove a specific emit rate gradient
  12193. * @param gradient defines the gradient to remove
  12194. * @returns the current particle system
  12195. */
  12196. removeEmitRateGradient(gradient: number): IParticleSystem;
  12197. /**
  12198. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12199. * @param gradient defines the gradient to use (between 0 and 1)
  12200. * @param factor defines the start size value to affect to the specified gradient
  12201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12202. * @returns the current particle system
  12203. */
  12204. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12205. /**
  12206. * Remove a specific start size gradient
  12207. * @param gradient defines the gradient to remove
  12208. * @returns the current particle system
  12209. */
  12210. removeStartSizeGradient(gradient: number): IParticleSystem;
  12211. private _createRampGradientTexture;
  12212. /**
  12213. * Gets the current list of ramp gradients.
  12214. * You must use addRampGradient and removeRampGradient to udpate this list
  12215. * @returns the list of ramp gradients
  12216. */
  12217. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12218. /** Force the system to rebuild all gradients that need to be resync */
  12219. forceRefreshGradients(): void;
  12220. private _syncRampGradientTexture;
  12221. /**
  12222. * Adds a new ramp gradient used to remap particle colors
  12223. * @param gradient defines the gradient to use (between 0 and 1)
  12224. * @param color defines the color to affect to the specified gradient
  12225. * @returns the current particle system
  12226. */
  12227. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12228. /**
  12229. * Remove a specific ramp gradient
  12230. * @param gradient defines the gradient to remove
  12231. * @returns the current particle system
  12232. */
  12233. removeRampGradient(gradient: number): ParticleSystem;
  12234. /**
  12235. * Adds a new color gradient
  12236. * @param gradient defines the gradient to use (between 0 and 1)
  12237. * @param color1 defines the color to affect to the specified gradient
  12238. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12239. * @returns this particle system
  12240. */
  12241. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12242. /**
  12243. * Remove a specific color gradient
  12244. * @param gradient defines the gradient to remove
  12245. * @returns this particle system
  12246. */
  12247. removeColorGradient(gradient: number): IParticleSystem;
  12248. private _fetchR;
  12249. protected _reset(): void;
  12250. private _resetEffect;
  12251. private _createVertexBuffers;
  12252. private _createIndexBuffer;
  12253. /**
  12254. * Gets the maximum number of particles active at the same time.
  12255. * @returns The max number of active particles.
  12256. */
  12257. getCapacity(): number;
  12258. /**
  12259. * Gets whether there are still active particles in the system.
  12260. * @returns True if it is alive, otherwise false.
  12261. */
  12262. isAlive(): boolean;
  12263. /**
  12264. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12265. * @returns True if it has been started, otherwise false.
  12266. */
  12267. isStarted(): boolean;
  12268. private _prepareSubEmitterInternalArray;
  12269. /**
  12270. * Starts the particle system and begins to emit
  12271. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12272. */
  12273. start(delay?: number): void;
  12274. /**
  12275. * Stops the particle system.
  12276. * @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.
  12277. */
  12278. stop(stopSubEmitters?: boolean): void;
  12279. /**
  12280. * Remove all active particles
  12281. */
  12282. reset(): void;
  12283. /**
  12284. * @hidden (for internal use only)
  12285. */
  12286. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12287. /**
  12288. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12289. * Its lifetime will start back at 0.
  12290. */
  12291. recycleParticle: (particle: Particle) => void;
  12292. private _stopSubEmitters;
  12293. private _createParticle;
  12294. private _removeFromRoot;
  12295. private _emitFromParticle;
  12296. private _update;
  12297. /** @hidden */
  12298. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12299. /** @hidden */
  12300. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12301. /** @hidden */
  12302. private _getEffect;
  12303. /**
  12304. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12305. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12306. */
  12307. animate(preWarmOnly?: boolean): void;
  12308. private _appendParticleVertices;
  12309. /**
  12310. * Rebuilds the particle system.
  12311. */
  12312. rebuild(): void;
  12313. /**
  12314. * Is this system ready to be used/rendered
  12315. * @return true if the system is ready
  12316. */
  12317. isReady(): boolean;
  12318. private _render;
  12319. /**
  12320. * Renders the particle system in its current state.
  12321. * @returns the current number of particles
  12322. */
  12323. render(): number;
  12324. /**
  12325. * Disposes the particle system and free the associated resources
  12326. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12327. */
  12328. dispose(disposeTexture?: boolean): void;
  12329. /**
  12330. * Clones the particle system.
  12331. * @param name The name of the cloned object
  12332. * @param newEmitter The new emitter to use
  12333. * @returns the cloned particle system
  12334. */
  12335. clone(name: string, newEmitter: any): ParticleSystem;
  12336. /**
  12337. * Serializes the particle system to a JSON object
  12338. * @param serializeTexture defines if the texture must be serialized as well
  12339. * @returns the JSON object
  12340. */
  12341. serialize(serializeTexture?: boolean): any;
  12342. /** @hidden */
  12343. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12344. /** @hidden */
  12345. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12346. /**
  12347. * Parses a JSON object to create a particle system.
  12348. * @param parsedParticleSystem The JSON object to parse
  12349. * @param scene The scene to create the particle system in
  12350. * @param rootUrl The root url to use to load external dependencies like texture
  12351. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12352. * @returns the Parsed particle system
  12353. */
  12354. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12355. }
  12356. }
  12357. declare module "babylonjs/Particles/particle" {
  12358. import { Nullable } from "babylonjs/types";
  12359. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12360. import { Color4 } from "babylonjs/Maths/math.color";
  12361. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12362. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12363. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12364. /**
  12365. * A particle represents one of the element emitted by a particle system.
  12366. * This is mainly define by its coordinates, direction, velocity and age.
  12367. */
  12368. export class Particle {
  12369. /**
  12370. * The particle system the particle belongs to.
  12371. */
  12372. particleSystem: ParticleSystem;
  12373. private static _Count;
  12374. /**
  12375. * Unique ID of the particle
  12376. */
  12377. id: number;
  12378. /**
  12379. * The world position of the particle in the scene.
  12380. */
  12381. position: Vector3;
  12382. /**
  12383. * The world direction of the particle in the scene.
  12384. */
  12385. direction: Vector3;
  12386. /**
  12387. * The color of the particle.
  12388. */
  12389. color: Color4;
  12390. /**
  12391. * The color change of the particle per step.
  12392. */
  12393. colorStep: Color4;
  12394. /**
  12395. * Defines how long will the life of the particle be.
  12396. */
  12397. lifeTime: number;
  12398. /**
  12399. * The current age of the particle.
  12400. */
  12401. age: number;
  12402. /**
  12403. * The current size of the particle.
  12404. */
  12405. size: number;
  12406. /**
  12407. * The current scale of the particle.
  12408. */
  12409. scale: Vector2;
  12410. /**
  12411. * The current angle of the particle.
  12412. */
  12413. angle: number;
  12414. /**
  12415. * Defines how fast is the angle changing.
  12416. */
  12417. angularSpeed: number;
  12418. /**
  12419. * Defines the cell index used by the particle to be rendered from a sprite.
  12420. */
  12421. cellIndex: number;
  12422. /**
  12423. * The information required to support color remapping
  12424. */
  12425. remapData: Vector4;
  12426. /** @hidden */
  12427. _randomCellOffset?: number;
  12428. /** @hidden */
  12429. _initialDirection: Nullable<Vector3>;
  12430. /** @hidden */
  12431. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12432. /** @hidden */
  12433. _initialStartSpriteCellID: number;
  12434. /** @hidden */
  12435. _initialEndSpriteCellID: number;
  12436. /** @hidden */
  12437. _currentColorGradient: Nullable<ColorGradient>;
  12438. /** @hidden */
  12439. _currentColor1: Color4;
  12440. /** @hidden */
  12441. _currentColor2: Color4;
  12442. /** @hidden */
  12443. _currentSizeGradient: Nullable<FactorGradient>;
  12444. /** @hidden */
  12445. _currentSize1: number;
  12446. /** @hidden */
  12447. _currentSize2: number;
  12448. /** @hidden */
  12449. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12450. /** @hidden */
  12451. _currentAngularSpeed1: number;
  12452. /** @hidden */
  12453. _currentAngularSpeed2: number;
  12454. /** @hidden */
  12455. _currentVelocityGradient: Nullable<FactorGradient>;
  12456. /** @hidden */
  12457. _currentVelocity1: number;
  12458. /** @hidden */
  12459. _currentVelocity2: number;
  12460. /** @hidden */
  12461. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12462. /** @hidden */
  12463. _currentLimitVelocity1: number;
  12464. /** @hidden */
  12465. _currentLimitVelocity2: number;
  12466. /** @hidden */
  12467. _currentDragGradient: Nullable<FactorGradient>;
  12468. /** @hidden */
  12469. _currentDrag1: number;
  12470. /** @hidden */
  12471. _currentDrag2: number;
  12472. /** @hidden */
  12473. _randomNoiseCoordinates1: Vector3;
  12474. /** @hidden */
  12475. _randomNoiseCoordinates2: Vector3;
  12476. /** @hidden */
  12477. _localPosition?: Vector3;
  12478. /**
  12479. * Creates a new instance Particle
  12480. * @param particleSystem the particle system the particle belongs to
  12481. */
  12482. constructor(
  12483. /**
  12484. * The particle system the particle belongs to.
  12485. */
  12486. particleSystem: ParticleSystem);
  12487. private updateCellInfoFromSystem;
  12488. /**
  12489. * Defines how the sprite cell index is updated for the particle
  12490. */
  12491. updateCellIndex(): void;
  12492. /** @hidden */
  12493. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12494. /** @hidden */
  12495. _inheritParticleInfoToSubEmitters(): void;
  12496. /** @hidden */
  12497. _reset(): void;
  12498. /**
  12499. * Copy the properties of particle to another one.
  12500. * @param other the particle to copy the information to.
  12501. */
  12502. copyTo(other: Particle): void;
  12503. }
  12504. }
  12505. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12506. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12507. import { Effect } from "babylonjs/Materials/effect";
  12508. import { Particle } from "babylonjs/Particles/particle";
  12509. import { Scene } from "babylonjs/scene";
  12510. /**
  12511. * Particle emitter represents a volume emitting particles.
  12512. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12513. */
  12514. export interface IParticleEmitterType {
  12515. /**
  12516. * Called by the particle System when the direction is computed for the created particle.
  12517. * @param worldMatrix is the world matrix of the particle system
  12518. * @param directionToUpdate is the direction vector to update with the result
  12519. * @param particle is the particle we are computed the direction for
  12520. * @param isLocal defines if the direction should be set in local space
  12521. */
  12522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12523. /**
  12524. * Called by the particle System when the position is computed for the created particle.
  12525. * @param worldMatrix is the world matrix of the particle system
  12526. * @param positionToUpdate is the position vector to update with the result
  12527. * @param particle is the particle we are computed the position for
  12528. * @param isLocal defines if the position should be set in local space
  12529. */
  12530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12531. /**
  12532. * Clones the current emitter and returns a copy of it
  12533. * @returns the new emitter
  12534. */
  12535. clone(): IParticleEmitterType;
  12536. /**
  12537. * Called by the GPUParticleSystem to setup the update shader
  12538. * @param effect defines the update shader
  12539. */
  12540. applyToShader(effect: Effect): void;
  12541. /**
  12542. * Returns a string to use to update the GPU particles update shader
  12543. * @returns the effect defines string
  12544. */
  12545. getEffectDefines(): string;
  12546. /**
  12547. * Returns a string representing the class name
  12548. * @returns a string containing the class name
  12549. */
  12550. getClassName(): string;
  12551. /**
  12552. * Serializes the particle system to a JSON object.
  12553. * @returns the JSON object
  12554. */
  12555. serialize(): any;
  12556. /**
  12557. * Parse properties from a JSON object
  12558. * @param serializationObject defines the JSON object
  12559. * @param scene defines the hosting scene
  12560. */
  12561. parse(serializationObject: any, scene: Scene): void;
  12562. }
  12563. }
  12564. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12565. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12566. import { Effect } from "babylonjs/Materials/effect";
  12567. import { Particle } from "babylonjs/Particles/particle";
  12568. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12569. /**
  12570. * Particle emitter emitting particles from the inside of a box.
  12571. * It emits the particles randomly between 2 given directions.
  12572. */
  12573. export class BoxParticleEmitter implements IParticleEmitterType {
  12574. /**
  12575. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12576. */
  12577. direction1: Vector3;
  12578. /**
  12579. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12580. */
  12581. direction2: Vector3;
  12582. /**
  12583. * 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.
  12584. */
  12585. minEmitBox: Vector3;
  12586. /**
  12587. * 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.
  12588. */
  12589. maxEmitBox: Vector3;
  12590. /**
  12591. * Creates a new instance BoxParticleEmitter
  12592. */
  12593. constructor();
  12594. /**
  12595. * Called by the particle System when the direction is computed for the created particle.
  12596. * @param worldMatrix is the world matrix of the particle system
  12597. * @param directionToUpdate is the direction vector to update with the result
  12598. * @param particle is the particle we are computed the direction for
  12599. * @param isLocal defines if the direction should be set in local space
  12600. */
  12601. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12602. /**
  12603. * Called by the particle System when the position is computed for the created particle.
  12604. * @param worldMatrix is the world matrix of the particle system
  12605. * @param positionToUpdate is the position vector to update with the result
  12606. * @param particle is the particle we are computed the position for
  12607. * @param isLocal defines if the position should be set in local space
  12608. */
  12609. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12610. /**
  12611. * Clones the current emitter and returns a copy of it
  12612. * @returns the new emitter
  12613. */
  12614. clone(): BoxParticleEmitter;
  12615. /**
  12616. * Called by the GPUParticleSystem to setup the update shader
  12617. * @param effect defines the update shader
  12618. */
  12619. applyToShader(effect: Effect): void;
  12620. /**
  12621. * Returns a string to use to update the GPU particles update shader
  12622. * @returns a string containng the defines string
  12623. */
  12624. getEffectDefines(): string;
  12625. /**
  12626. * Returns the string "BoxParticleEmitter"
  12627. * @returns a string containing the class name
  12628. */
  12629. getClassName(): string;
  12630. /**
  12631. * Serializes the particle system to a JSON object.
  12632. * @returns the JSON object
  12633. */
  12634. serialize(): any;
  12635. /**
  12636. * Parse properties from a JSON object
  12637. * @param serializationObject defines the JSON object
  12638. */
  12639. parse(serializationObject: any): void;
  12640. }
  12641. }
  12642. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12643. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12644. import { Effect } from "babylonjs/Materials/effect";
  12645. import { Particle } from "babylonjs/Particles/particle";
  12646. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12647. /**
  12648. * Particle emitter emitting particles from the inside of a cone.
  12649. * It emits the particles alongside the cone volume from the base to the particle.
  12650. * The emission direction might be randomized.
  12651. */
  12652. export class ConeParticleEmitter implements IParticleEmitterType {
  12653. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12654. directionRandomizer: number;
  12655. private _radius;
  12656. private _angle;
  12657. private _height;
  12658. /**
  12659. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12660. */
  12661. radiusRange: number;
  12662. /**
  12663. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12664. */
  12665. heightRange: number;
  12666. /**
  12667. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12668. */
  12669. emitFromSpawnPointOnly: boolean;
  12670. /**
  12671. * Gets or sets the radius of the emission cone
  12672. */
  12673. get radius(): number;
  12674. set radius(value: number);
  12675. /**
  12676. * Gets or sets the angle of the emission cone
  12677. */
  12678. get angle(): number;
  12679. set angle(value: number);
  12680. private _buildHeight;
  12681. /**
  12682. * Creates a new instance ConeParticleEmitter
  12683. * @param radius the radius of the emission cone (1 by default)
  12684. * @param angle the cone base angle (PI by default)
  12685. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12686. */
  12687. constructor(radius?: number, angle?: number,
  12688. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12689. directionRandomizer?: number);
  12690. /**
  12691. * Called by the particle System when the direction is computed for the created particle.
  12692. * @param worldMatrix is the world matrix of the particle system
  12693. * @param directionToUpdate is the direction vector to update with the result
  12694. * @param particle is the particle we are computed the direction for
  12695. * @param isLocal defines if the direction should be set in local space
  12696. */
  12697. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12698. /**
  12699. * Called by the particle System when the position is computed for the created particle.
  12700. * @param worldMatrix is the world matrix of the particle system
  12701. * @param positionToUpdate is the position vector to update with the result
  12702. * @param particle is the particle we are computed the position for
  12703. * @param isLocal defines if the position should be set in local space
  12704. */
  12705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12706. /**
  12707. * Clones the current emitter and returns a copy of it
  12708. * @returns the new emitter
  12709. */
  12710. clone(): ConeParticleEmitter;
  12711. /**
  12712. * Called by the GPUParticleSystem to setup the update shader
  12713. * @param effect defines the update shader
  12714. */
  12715. applyToShader(effect: Effect): void;
  12716. /**
  12717. * Returns a string to use to update the GPU particles update shader
  12718. * @returns a string containng the defines string
  12719. */
  12720. getEffectDefines(): string;
  12721. /**
  12722. * Returns the string "ConeParticleEmitter"
  12723. * @returns a string containing the class name
  12724. */
  12725. getClassName(): string;
  12726. /**
  12727. * Serializes the particle system to a JSON object.
  12728. * @returns the JSON object
  12729. */
  12730. serialize(): any;
  12731. /**
  12732. * Parse properties from a JSON object
  12733. * @param serializationObject defines the JSON object
  12734. */
  12735. parse(serializationObject: any): void;
  12736. }
  12737. }
  12738. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12739. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12740. import { Effect } from "babylonjs/Materials/effect";
  12741. import { Particle } from "babylonjs/Particles/particle";
  12742. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12743. /**
  12744. * Particle emitter emitting particles from the inside of a cylinder.
  12745. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12746. */
  12747. export class CylinderParticleEmitter implements IParticleEmitterType {
  12748. /**
  12749. * The radius of the emission cylinder.
  12750. */
  12751. radius: number;
  12752. /**
  12753. * The height of the emission cylinder.
  12754. */
  12755. height: number;
  12756. /**
  12757. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12758. */
  12759. radiusRange: number;
  12760. /**
  12761. * How much to randomize the particle direction [0-1].
  12762. */
  12763. directionRandomizer: number;
  12764. /**
  12765. * Creates a new instance CylinderParticleEmitter
  12766. * @param radius the radius of the emission cylinder (1 by default)
  12767. * @param height the height of the emission cylinder (1 by default)
  12768. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12769. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12770. */
  12771. constructor(
  12772. /**
  12773. * The radius of the emission cylinder.
  12774. */
  12775. radius?: number,
  12776. /**
  12777. * The height of the emission cylinder.
  12778. */
  12779. height?: number,
  12780. /**
  12781. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12782. */
  12783. radiusRange?: number,
  12784. /**
  12785. * How much to randomize the particle direction [0-1].
  12786. */
  12787. directionRandomizer?: number);
  12788. /**
  12789. * Called by the particle System when the direction is computed for the created particle.
  12790. * @param worldMatrix is the world matrix of the particle system
  12791. * @param directionToUpdate is the direction vector to update with the result
  12792. * @param particle is the particle we are computed the direction for
  12793. * @param isLocal defines if the direction should be set in local space
  12794. */
  12795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12796. /**
  12797. * Called by the particle System when the position is computed for the created particle.
  12798. * @param worldMatrix is the world matrix of the particle system
  12799. * @param positionToUpdate is the position vector to update with the result
  12800. * @param particle is the particle we are computed the position for
  12801. * @param isLocal defines if the position should be set in local space
  12802. */
  12803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12804. /**
  12805. * Clones the current emitter and returns a copy of it
  12806. * @returns the new emitter
  12807. */
  12808. clone(): CylinderParticleEmitter;
  12809. /**
  12810. * Called by the GPUParticleSystem to setup the update shader
  12811. * @param effect defines the update shader
  12812. */
  12813. applyToShader(effect: Effect): void;
  12814. /**
  12815. * Returns a string to use to update the GPU particles update shader
  12816. * @returns a string containng the defines string
  12817. */
  12818. getEffectDefines(): string;
  12819. /**
  12820. * Returns the string "CylinderParticleEmitter"
  12821. * @returns a string containing the class name
  12822. */
  12823. getClassName(): string;
  12824. /**
  12825. * Serializes the particle system to a JSON object.
  12826. * @returns the JSON object
  12827. */
  12828. serialize(): any;
  12829. /**
  12830. * Parse properties from a JSON object
  12831. * @param serializationObject defines the JSON object
  12832. */
  12833. parse(serializationObject: any): void;
  12834. }
  12835. /**
  12836. * Particle emitter emitting particles from the inside of a cylinder.
  12837. * It emits the particles randomly between two vectors.
  12838. */
  12839. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12840. /**
  12841. * The min limit of the emission direction.
  12842. */
  12843. direction1: Vector3;
  12844. /**
  12845. * The max limit of the emission direction.
  12846. */
  12847. direction2: Vector3;
  12848. /**
  12849. * Creates a new instance CylinderDirectedParticleEmitter
  12850. * @param radius the radius of the emission cylinder (1 by default)
  12851. * @param height the height of the emission cylinder (1 by default)
  12852. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12853. * @param direction1 the min limit of the emission direction (up vector by default)
  12854. * @param direction2 the max limit of the emission direction (up vector by default)
  12855. */
  12856. constructor(radius?: number, height?: number, radiusRange?: number,
  12857. /**
  12858. * The min limit of the emission direction.
  12859. */
  12860. direction1?: Vector3,
  12861. /**
  12862. * The max limit of the emission direction.
  12863. */
  12864. direction2?: Vector3);
  12865. /**
  12866. * Called by the particle System when the direction is computed for the created particle.
  12867. * @param worldMatrix is the world matrix of the particle system
  12868. * @param directionToUpdate is the direction vector to update with the result
  12869. * @param particle is the particle we are computed the direction for
  12870. */
  12871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12872. /**
  12873. * Clones the current emitter and returns a copy of it
  12874. * @returns the new emitter
  12875. */
  12876. clone(): CylinderDirectedParticleEmitter;
  12877. /**
  12878. * Called by the GPUParticleSystem to setup the update shader
  12879. * @param effect defines the update shader
  12880. */
  12881. applyToShader(effect: Effect): void;
  12882. /**
  12883. * Returns a string to use to update the GPU particles update shader
  12884. * @returns a string containng the defines string
  12885. */
  12886. getEffectDefines(): string;
  12887. /**
  12888. * Returns the string "CylinderDirectedParticleEmitter"
  12889. * @returns a string containing the class name
  12890. */
  12891. getClassName(): string;
  12892. /**
  12893. * Serializes the particle system to a JSON object.
  12894. * @returns the JSON object
  12895. */
  12896. serialize(): any;
  12897. /**
  12898. * Parse properties from a JSON object
  12899. * @param serializationObject defines the JSON object
  12900. */
  12901. parse(serializationObject: any): void;
  12902. }
  12903. }
  12904. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12905. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12906. import { Effect } from "babylonjs/Materials/effect";
  12907. import { Particle } from "babylonjs/Particles/particle";
  12908. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12909. /**
  12910. * Particle emitter emitting particles from the inside of a hemisphere.
  12911. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12912. */
  12913. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12914. /**
  12915. * The radius of the emission hemisphere.
  12916. */
  12917. radius: number;
  12918. /**
  12919. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12920. */
  12921. radiusRange: number;
  12922. /**
  12923. * How much to randomize the particle direction [0-1].
  12924. */
  12925. directionRandomizer: number;
  12926. /**
  12927. * Creates a new instance HemisphericParticleEmitter
  12928. * @param radius the radius of the emission hemisphere (1 by default)
  12929. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12930. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12931. */
  12932. constructor(
  12933. /**
  12934. * The radius of the emission hemisphere.
  12935. */
  12936. radius?: number,
  12937. /**
  12938. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12939. */
  12940. radiusRange?: number,
  12941. /**
  12942. * How much to randomize the particle direction [0-1].
  12943. */
  12944. directionRandomizer?: number);
  12945. /**
  12946. * Called by the particle System when the direction is computed for the created particle.
  12947. * @param worldMatrix is the world matrix of the particle system
  12948. * @param directionToUpdate is the direction vector to update with the result
  12949. * @param particle is the particle we are computed the direction for
  12950. * @param isLocal defines if the direction should be set in local space
  12951. */
  12952. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12953. /**
  12954. * Called by the particle System when the position is computed for the created particle.
  12955. * @param worldMatrix is the world matrix of the particle system
  12956. * @param positionToUpdate is the position vector to update with the result
  12957. * @param particle is the particle we are computed the position for
  12958. * @param isLocal defines if the position should be set in local space
  12959. */
  12960. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12961. /**
  12962. * Clones the current emitter and returns a copy of it
  12963. * @returns the new emitter
  12964. */
  12965. clone(): HemisphericParticleEmitter;
  12966. /**
  12967. * Called by the GPUParticleSystem to setup the update shader
  12968. * @param effect defines the update shader
  12969. */
  12970. applyToShader(effect: Effect): void;
  12971. /**
  12972. * Returns a string to use to update the GPU particles update shader
  12973. * @returns a string containng the defines string
  12974. */
  12975. getEffectDefines(): string;
  12976. /**
  12977. * Returns the string "HemisphericParticleEmitter"
  12978. * @returns a string containing the class name
  12979. */
  12980. getClassName(): string;
  12981. /**
  12982. * Serializes the particle system to a JSON object.
  12983. * @returns the JSON object
  12984. */
  12985. serialize(): any;
  12986. /**
  12987. * Parse properties from a JSON object
  12988. * @param serializationObject defines the JSON object
  12989. */
  12990. parse(serializationObject: any): void;
  12991. }
  12992. }
  12993. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12994. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12995. import { Effect } from "babylonjs/Materials/effect";
  12996. import { Particle } from "babylonjs/Particles/particle";
  12997. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12998. /**
  12999. * Particle emitter emitting particles from a point.
  13000. * It emits the particles randomly between 2 given directions.
  13001. */
  13002. export class PointParticleEmitter implements IParticleEmitterType {
  13003. /**
  13004. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13005. */
  13006. direction1: Vector3;
  13007. /**
  13008. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13009. */
  13010. direction2: Vector3;
  13011. /**
  13012. * Creates a new instance PointParticleEmitter
  13013. */
  13014. constructor();
  13015. /**
  13016. * Called by the particle System when the direction is computed for the created particle.
  13017. * @param worldMatrix is the world matrix of the particle system
  13018. * @param directionToUpdate is the direction vector to update with the result
  13019. * @param particle is the particle we are computed the direction for
  13020. * @param isLocal defines if the direction should be set in local space
  13021. */
  13022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13023. /**
  13024. * Called by the particle System when the position is computed for the created particle.
  13025. * @param worldMatrix is the world matrix of the particle system
  13026. * @param positionToUpdate is the position vector to update with the result
  13027. * @param particle is the particle we are computed the position for
  13028. * @param isLocal defines if the position should be set in local space
  13029. */
  13030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13031. /**
  13032. * Clones the current emitter and returns a copy of it
  13033. * @returns the new emitter
  13034. */
  13035. clone(): PointParticleEmitter;
  13036. /**
  13037. * Called by the GPUParticleSystem to setup the update shader
  13038. * @param effect defines the update shader
  13039. */
  13040. applyToShader(effect: Effect): void;
  13041. /**
  13042. * Returns a string to use to update the GPU particles update shader
  13043. * @returns a string containng the defines string
  13044. */
  13045. getEffectDefines(): string;
  13046. /**
  13047. * Returns the string "PointParticleEmitter"
  13048. * @returns a string containing the class name
  13049. */
  13050. getClassName(): string;
  13051. /**
  13052. * Serializes the particle system to a JSON object.
  13053. * @returns the JSON object
  13054. */
  13055. serialize(): any;
  13056. /**
  13057. * Parse properties from a JSON object
  13058. * @param serializationObject defines the JSON object
  13059. */
  13060. parse(serializationObject: any): void;
  13061. }
  13062. }
  13063. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13064. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13065. import { Effect } from "babylonjs/Materials/effect";
  13066. import { Particle } from "babylonjs/Particles/particle";
  13067. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13068. /**
  13069. * Particle emitter emitting particles from the inside of a sphere.
  13070. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13071. */
  13072. export class SphereParticleEmitter implements IParticleEmitterType {
  13073. /**
  13074. * The radius of the emission sphere.
  13075. */
  13076. radius: number;
  13077. /**
  13078. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13079. */
  13080. radiusRange: number;
  13081. /**
  13082. * How much to randomize the particle direction [0-1].
  13083. */
  13084. directionRandomizer: number;
  13085. /**
  13086. * Creates a new instance SphereParticleEmitter
  13087. * @param radius the radius of the emission sphere (1 by default)
  13088. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13089. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13090. */
  13091. constructor(
  13092. /**
  13093. * The radius of the emission sphere.
  13094. */
  13095. radius?: number,
  13096. /**
  13097. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13098. */
  13099. radiusRange?: number,
  13100. /**
  13101. * How much to randomize the particle direction [0-1].
  13102. */
  13103. directionRandomizer?: number);
  13104. /**
  13105. * Called by the particle System when the direction is computed for the created particle.
  13106. * @param worldMatrix is the world matrix of the particle system
  13107. * @param directionToUpdate is the direction vector to update with the result
  13108. * @param particle is the particle we are computed the direction for
  13109. * @param isLocal defines if the direction should be set in local space
  13110. */
  13111. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13112. /**
  13113. * Called by the particle System when the position is computed for the created particle.
  13114. * @param worldMatrix is the world matrix of the particle system
  13115. * @param positionToUpdate is the position vector to update with the result
  13116. * @param particle is the particle we are computed the position for
  13117. * @param isLocal defines if the position should be set in local space
  13118. */
  13119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13120. /**
  13121. * Clones the current emitter and returns a copy of it
  13122. * @returns the new emitter
  13123. */
  13124. clone(): SphereParticleEmitter;
  13125. /**
  13126. * Called by the GPUParticleSystem to setup the update shader
  13127. * @param effect defines the update shader
  13128. */
  13129. applyToShader(effect: Effect): void;
  13130. /**
  13131. * Returns a string to use to update the GPU particles update shader
  13132. * @returns a string containng the defines string
  13133. */
  13134. getEffectDefines(): string;
  13135. /**
  13136. * Returns the string "SphereParticleEmitter"
  13137. * @returns a string containing the class name
  13138. */
  13139. getClassName(): string;
  13140. /**
  13141. * Serializes the particle system to a JSON object.
  13142. * @returns the JSON object
  13143. */
  13144. serialize(): any;
  13145. /**
  13146. * Parse properties from a JSON object
  13147. * @param serializationObject defines the JSON object
  13148. */
  13149. parse(serializationObject: any): void;
  13150. }
  13151. /**
  13152. * Particle emitter emitting particles from the inside of a sphere.
  13153. * It emits the particles randomly between two vectors.
  13154. */
  13155. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13156. /**
  13157. * The min limit of the emission direction.
  13158. */
  13159. direction1: Vector3;
  13160. /**
  13161. * The max limit of the emission direction.
  13162. */
  13163. direction2: Vector3;
  13164. /**
  13165. * Creates a new instance SphereDirectedParticleEmitter
  13166. * @param radius the radius of the emission sphere (1 by default)
  13167. * @param direction1 the min limit of the emission direction (up vector by default)
  13168. * @param direction2 the max limit of the emission direction (up vector by default)
  13169. */
  13170. constructor(radius?: number,
  13171. /**
  13172. * The min limit of the emission direction.
  13173. */
  13174. direction1?: Vector3,
  13175. /**
  13176. * The max limit of the emission direction.
  13177. */
  13178. direction2?: Vector3);
  13179. /**
  13180. * Called by the particle System when the direction is computed for the created particle.
  13181. * @param worldMatrix is the world matrix of the particle system
  13182. * @param directionToUpdate is the direction vector to update with the result
  13183. * @param particle is the particle we are computed the direction for
  13184. */
  13185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13186. /**
  13187. * Clones the current emitter and returns a copy of it
  13188. * @returns the new emitter
  13189. */
  13190. clone(): SphereDirectedParticleEmitter;
  13191. /**
  13192. * Called by the GPUParticleSystem to setup the update shader
  13193. * @param effect defines the update shader
  13194. */
  13195. applyToShader(effect: Effect): void;
  13196. /**
  13197. * Returns a string to use to update the GPU particles update shader
  13198. * @returns a string containng the defines string
  13199. */
  13200. getEffectDefines(): string;
  13201. /**
  13202. * Returns the string "SphereDirectedParticleEmitter"
  13203. * @returns a string containing the class name
  13204. */
  13205. getClassName(): string;
  13206. /**
  13207. * Serializes the particle system to a JSON object.
  13208. * @returns the JSON object
  13209. */
  13210. serialize(): any;
  13211. /**
  13212. * Parse properties from a JSON object
  13213. * @param serializationObject defines the JSON object
  13214. */
  13215. parse(serializationObject: any): void;
  13216. }
  13217. }
  13218. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13220. import { Effect } from "babylonjs/Materials/effect";
  13221. import { Particle } from "babylonjs/Particles/particle";
  13222. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13223. import { Nullable } from "babylonjs/types";
  13224. /**
  13225. * Particle emitter emitting particles from a custom list of positions.
  13226. */
  13227. export class CustomParticleEmitter implements IParticleEmitterType {
  13228. /**
  13229. * Gets or sets the position generator that will create the inital position of each particle.
  13230. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13231. */
  13232. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13233. /**
  13234. * Gets or sets the destination generator that will create the final destination of each particle.
  13235. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13236. */
  13237. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13238. /**
  13239. * Creates a new instance CustomParticleEmitter
  13240. */
  13241. constructor();
  13242. /**
  13243. * Called by the particle System when the direction is computed for the created particle.
  13244. * @param worldMatrix is the world matrix of the particle system
  13245. * @param directionToUpdate is the direction vector to update with the result
  13246. * @param particle is the particle we are computed the direction for
  13247. * @param isLocal defines if the direction should be set in local space
  13248. */
  13249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13250. /**
  13251. * Called by the particle System when the position is computed for the created particle.
  13252. * @param worldMatrix is the world matrix of the particle system
  13253. * @param positionToUpdate is the position vector to update with the result
  13254. * @param particle is the particle we are computed the position for
  13255. * @param isLocal defines if the position should be set in local space
  13256. */
  13257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13258. /**
  13259. * Clones the current emitter and returns a copy of it
  13260. * @returns the new emitter
  13261. */
  13262. clone(): CustomParticleEmitter;
  13263. /**
  13264. * Called by the GPUParticleSystem to setup the update shader
  13265. * @param effect defines the update shader
  13266. */
  13267. applyToShader(effect: Effect): void;
  13268. /**
  13269. * Returns a string to use to update the GPU particles update shader
  13270. * @returns a string containng the defines string
  13271. */
  13272. getEffectDefines(): string;
  13273. /**
  13274. * Returns the string "PointParticleEmitter"
  13275. * @returns a string containing the class name
  13276. */
  13277. getClassName(): string;
  13278. /**
  13279. * Serializes the particle system to a JSON object.
  13280. * @returns the JSON object
  13281. */
  13282. serialize(): any;
  13283. /**
  13284. * Parse properties from a JSON object
  13285. * @param serializationObject defines the JSON object
  13286. */
  13287. parse(serializationObject: any): void;
  13288. }
  13289. }
  13290. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13291. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13292. import { Effect } from "babylonjs/Materials/effect";
  13293. import { Particle } from "babylonjs/Particles/particle";
  13294. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13295. import { Nullable } from "babylonjs/types";
  13296. import { Scene } from "babylonjs/scene";
  13297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13298. /**
  13299. * Particle emitter emitting particles from the inside of a box.
  13300. * It emits the particles randomly between 2 given directions.
  13301. */
  13302. export class MeshParticleEmitter implements IParticleEmitterType {
  13303. private _indices;
  13304. private _positions;
  13305. private _normals;
  13306. private _storedNormal;
  13307. private _mesh;
  13308. /**
  13309. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13310. */
  13311. direction1: Vector3;
  13312. /**
  13313. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13314. */
  13315. direction2: Vector3;
  13316. /**
  13317. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13318. */
  13319. useMeshNormalsForDirection: boolean;
  13320. /** Defines the mesh to use as source */
  13321. get mesh(): Nullable<AbstractMesh>;
  13322. set mesh(value: Nullable<AbstractMesh>);
  13323. /**
  13324. * Creates a new instance MeshParticleEmitter
  13325. * @param mesh defines the mesh to use as source
  13326. */
  13327. constructor(mesh?: Nullable<AbstractMesh>);
  13328. /**
  13329. * Called by the particle System when the direction is computed for the created particle.
  13330. * @param worldMatrix is the world matrix of the particle system
  13331. * @param directionToUpdate is the direction vector to update with the result
  13332. * @param particle is the particle we are computed the direction for
  13333. * @param isLocal defines if the direction should be set in local space
  13334. */
  13335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13336. /**
  13337. * Called by the particle System when the position is computed for the created particle.
  13338. * @param worldMatrix is the world matrix of the particle system
  13339. * @param positionToUpdate is the position vector to update with the result
  13340. * @param particle is the particle we are computed the position for
  13341. * @param isLocal defines if the position should be set in local space
  13342. */
  13343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13344. /**
  13345. * Clones the current emitter and returns a copy of it
  13346. * @returns the new emitter
  13347. */
  13348. clone(): MeshParticleEmitter;
  13349. /**
  13350. * Called by the GPUParticleSystem to setup the update shader
  13351. * @param effect defines the update shader
  13352. */
  13353. applyToShader(effect: Effect): void;
  13354. /**
  13355. * Returns a string to use to update the GPU particles update shader
  13356. * @returns a string containng the defines string
  13357. */
  13358. getEffectDefines(): string;
  13359. /**
  13360. * Returns the string "BoxParticleEmitter"
  13361. * @returns a string containing the class name
  13362. */
  13363. getClassName(): string;
  13364. /**
  13365. * Serializes the particle system to a JSON object.
  13366. * @returns the JSON object
  13367. */
  13368. serialize(): any;
  13369. /**
  13370. * Parse properties from a JSON object
  13371. * @param serializationObject defines the JSON object
  13372. * @param scene defines the hosting scene
  13373. */
  13374. parse(serializationObject: any, scene: Scene): void;
  13375. }
  13376. }
  13377. declare module "babylonjs/Particles/EmitterTypes/index" {
  13378. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13379. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13380. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13381. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13382. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13383. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13384. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13385. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13386. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13387. }
  13388. declare module "babylonjs/Particles/IParticleSystem" {
  13389. import { Nullable } from "babylonjs/types";
  13390. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13391. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13394. import { Texture } from "babylonjs/Materials/Textures/texture";
  13395. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13396. import { Scene } from "babylonjs/scene";
  13397. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13398. import { Animation } from "babylonjs/Animations/animation";
  13399. /**
  13400. * Interface representing a particle system in Babylon.js.
  13401. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13402. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13403. */
  13404. export interface IParticleSystem {
  13405. /**
  13406. * List of animations used by the particle system.
  13407. */
  13408. animations: Animation[];
  13409. /**
  13410. * The id of the Particle system.
  13411. */
  13412. id: string;
  13413. /**
  13414. * The name of the Particle system.
  13415. */
  13416. name: string;
  13417. /**
  13418. * The emitter represents the Mesh or position we are attaching the particle system to.
  13419. */
  13420. emitter: Nullable<AbstractMesh | Vector3>;
  13421. /**
  13422. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13423. */
  13424. isBillboardBased: boolean;
  13425. /**
  13426. * The rendering group used by the Particle system to chose when to render.
  13427. */
  13428. renderingGroupId: number;
  13429. /**
  13430. * The layer mask we are rendering the particles through.
  13431. */
  13432. layerMask: number;
  13433. /**
  13434. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13435. */
  13436. updateSpeed: number;
  13437. /**
  13438. * The amount of time the particle system is running (depends of the overall update speed).
  13439. */
  13440. targetStopDuration: number;
  13441. /**
  13442. * The texture used to render each particle. (this can be a spritesheet)
  13443. */
  13444. particleTexture: Nullable<Texture>;
  13445. /**
  13446. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13447. */
  13448. blendMode: number;
  13449. /**
  13450. * Minimum life time of emitting particles.
  13451. */
  13452. minLifeTime: number;
  13453. /**
  13454. * Maximum life time of emitting particles.
  13455. */
  13456. maxLifeTime: number;
  13457. /**
  13458. * Minimum Size of emitting particles.
  13459. */
  13460. minSize: number;
  13461. /**
  13462. * Maximum Size of emitting particles.
  13463. */
  13464. maxSize: number;
  13465. /**
  13466. * Minimum scale of emitting particles on X axis.
  13467. */
  13468. minScaleX: number;
  13469. /**
  13470. * Maximum scale of emitting particles on X axis.
  13471. */
  13472. maxScaleX: number;
  13473. /**
  13474. * Minimum scale of emitting particles on Y axis.
  13475. */
  13476. minScaleY: number;
  13477. /**
  13478. * Maximum scale of emitting particles on Y axis.
  13479. */
  13480. maxScaleY: number;
  13481. /**
  13482. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13483. */
  13484. color1: Color4;
  13485. /**
  13486. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13487. */
  13488. color2: Color4;
  13489. /**
  13490. * Color the particle will have at the end of its lifetime.
  13491. */
  13492. colorDead: Color4;
  13493. /**
  13494. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13495. */
  13496. emitRate: number;
  13497. /**
  13498. * You can use gravity if you want to give an orientation to your particles.
  13499. */
  13500. gravity: Vector3;
  13501. /**
  13502. * Minimum power of emitting particles.
  13503. */
  13504. minEmitPower: number;
  13505. /**
  13506. * Maximum power of emitting particles.
  13507. */
  13508. maxEmitPower: number;
  13509. /**
  13510. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13511. */
  13512. minAngularSpeed: number;
  13513. /**
  13514. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13515. */
  13516. maxAngularSpeed: number;
  13517. /**
  13518. * Gets or sets the minimal initial rotation in radians.
  13519. */
  13520. minInitialRotation: number;
  13521. /**
  13522. * Gets or sets the maximal initial rotation in radians.
  13523. */
  13524. maxInitialRotation: number;
  13525. /**
  13526. * The particle emitter type defines the emitter used by the particle system.
  13527. * It can be for example box, sphere, or cone...
  13528. */
  13529. particleEmitterType: Nullable<IParticleEmitterType>;
  13530. /**
  13531. * Defines the delay in milliseconds before starting the system (0 by default)
  13532. */
  13533. startDelay: number;
  13534. /**
  13535. * 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
  13536. */
  13537. preWarmCycles: number;
  13538. /**
  13539. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13540. */
  13541. preWarmStepOffset: number;
  13542. /**
  13543. * 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)
  13544. */
  13545. spriteCellChangeSpeed: number;
  13546. /**
  13547. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13548. */
  13549. startSpriteCellID: number;
  13550. /**
  13551. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13552. */
  13553. endSpriteCellID: number;
  13554. /**
  13555. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13556. */
  13557. spriteCellWidth: number;
  13558. /**
  13559. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13560. */
  13561. spriteCellHeight: number;
  13562. /**
  13563. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13564. */
  13565. spriteRandomStartCell: boolean;
  13566. /**
  13567. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13568. */
  13569. isAnimationSheetEnabled: boolean;
  13570. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13571. translationPivot: Vector2;
  13572. /**
  13573. * Gets or sets a texture used to add random noise to particle positions
  13574. */
  13575. noiseTexture: Nullable<BaseTexture>;
  13576. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13577. noiseStrength: Vector3;
  13578. /**
  13579. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13580. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13581. */
  13582. billboardMode: number;
  13583. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13584. limitVelocityDamping: number;
  13585. /**
  13586. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13587. */
  13588. beginAnimationOnStart: boolean;
  13589. /**
  13590. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13591. */
  13592. beginAnimationFrom: number;
  13593. /**
  13594. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13595. */
  13596. beginAnimationTo: number;
  13597. /**
  13598. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13599. */
  13600. beginAnimationLoop: boolean;
  13601. /**
  13602. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13603. */
  13604. disposeOnStop: boolean;
  13605. /**
  13606. * Specifies if the particles are updated in emitter local space or world space
  13607. */
  13608. isLocal: boolean;
  13609. /** Snippet ID if the particle system was created from the snippet server */
  13610. snippetId: string;
  13611. /**
  13612. * Gets the maximum number of particles active at the same time.
  13613. * @returns The max number of active particles.
  13614. */
  13615. getCapacity(): number;
  13616. /**
  13617. * Gets the number of particles active at the same time.
  13618. * @returns The number of active particles.
  13619. */
  13620. getActiveCount(): number;
  13621. /**
  13622. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13623. * @returns True if it has been started, otherwise false.
  13624. */
  13625. isStarted(): boolean;
  13626. /**
  13627. * Animates the particle system for this frame.
  13628. */
  13629. animate(): void;
  13630. /**
  13631. * Renders the particle system in its current state.
  13632. * @returns the current number of particles
  13633. */
  13634. render(): number;
  13635. /**
  13636. * Dispose the particle system and frees its associated resources.
  13637. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13638. */
  13639. dispose(disposeTexture?: boolean): void;
  13640. /**
  13641. * Clones the particle system.
  13642. * @param name The name of the cloned object
  13643. * @param newEmitter The new emitter to use
  13644. * @returns the cloned particle system
  13645. */
  13646. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13647. /**
  13648. * Serializes the particle system to a JSON object
  13649. * @param serializeTexture defines if the texture must be serialized as well
  13650. * @returns the JSON object
  13651. */
  13652. serialize(serializeTexture: boolean): any;
  13653. /**
  13654. * Rebuild the particle system
  13655. */
  13656. rebuild(): void;
  13657. /** Force the system to rebuild all gradients that need to be resync */
  13658. forceRefreshGradients(): void;
  13659. /**
  13660. * Starts the particle system and begins to emit
  13661. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13662. */
  13663. start(delay?: number): void;
  13664. /**
  13665. * Stops the particle system.
  13666. */
  13667. stop(): void;
  13668. /**
  13669. * Remove all active particles
  13670. */
  13671. reset(): void;
  13672. /**
  13673. * Gets a boolean indicating that the system is stopping
  13674. * @returns true if the system is currently stopping
  13675. */
  13676. isStopping(): boolean;
  13677. /**
  13678. * Is this system ready to be used/rendered
  13679. * @return true if the system is ready
  13680. */
  13681. isReady(): boolean;
  13682. /**
  13683. * Returns the string "ParticleSystem"
  13684. * @returns a string containing the class name
  13685. */
  13686. getClassName(): string;
  13687. /**
  13688. * Adds a new color gradient
  13689. * @param gradient defines the gradient to use (between 0 and 1)
  13690. * @param color1 defines the color to affect to the specified gradient
  13691. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13692. * @returns the current particle system
  13693. */
  13694. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13695. /**
  13696. * Remove a specific color gradient
  13697. * @param gradient defines the gradient to remove
  13698. * @returns the current particle system
  13699. */
  13700. removeColorGradient(gradient: number): IParticleSystem;
  13701. /**
  13702. * Adds a new size gradient
  13703. * @param gradient defines the gradient to use (between 0 and 1)
  13704. * @param factor defines the size factor to affect to the specified gradient
  13705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13706. * @returns the current particle system
  13707. */
  13708. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13709. /**
  13710. * Remove a specific size gradient
  13711. * @param gradient defines the gradient to remove
  13712. * @returns the current particle system
  13713. */
  13714. removeSizeGradient(gradient: number): IParticleSystem;
  13715. /**
  13716. * Gets the current list of color gradients.
  13717. * You must use addColorGradient and removeColorGradient to udpate this list
  13718. * @returns the list of color gradients
  13719. */
  13720. getColorGradients(): Nullable<Array<ColorGradient>>;
  13721. /**
  13722. * Gets the current list of size gradients.
  13723. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13724. * @returns the list of size gradients
  13725. */
  13726. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13727. /**
  13728. * Gets the current list of angular speed gradients.
  13729. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13730. * @returns the list of angular speed gradients
  13731. */
  13732. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13733. /**
  13734. * Adds a new angular speed gradient
  13735. * @param gradient defines the gradient to use (between 0 and 1)
  13736. * @param factor defines the angular speed to affect to the specified gradient
  13737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13738. * @returns the current particle system
  13739. */
  13740. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13741. /**
  13742. * Remove a specific angular speed gradient
  13743. * @param gradient defines the gradient to remove
  13744. * @returns the current particle system
  13745. */
  13746. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13747. /**
  13748. * Gets the current list of velocity gradients.
  13749. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13750. * @returns the list of velocity gradients
  13751. */
  13752. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13753. /**
  13754. * Adds a new velocity gradient
  13755. * @param gradient defines the gradient to use (between 0 and 1)
  13756. * @param factor defines the velocity to affect to the specified gradient
  13757. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13758. * @returns the current particle system
  13759. */
  13760. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13761. /**
  13762. * Remove a specific velocity gradient
  13763. * @param gradient defines the gradient to remove
  13764. * @returns the current particle system
  13765. */
  13766. removeVelocityGradient(gradient: number): IParticleSystem;
  13767. /**
  13768. * Gets the current list of limit velocity gradients.
  13769. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13770. * @returns the list of limit velocity gradients
  13771. */
  13772. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13773. /**
  13774. * Adds a new limit velocity gradient
  13775. * @param gradient defines the gradient to use (between 0 and 1)
  13776. * @param factor defines the limit velocity to affect to the specified gradient
  13777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13778. * @returns the current particle system
  13779. */
  13780. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13781. /**
  13782. * Remove a specific limit velocity gradient
  13783. * @param gradient defines the gradient to remove
  13784. * @returns the current particle system
  13785. */
  13786. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13787. /**
  13788. * Adds a new drag gradient
  13789. * @param gradient defines the gradient to use (between 0 and 1)
  13790. * @param factor defines the drag to affect to the specified gradient
  13791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13792. * @returns the current particle system
  13793. */
  13794. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13795. /**
  13796. * Remove a specific drag gradient
  13797. * @param gradient defines the gradient to remove
  13798. * @returns the current particle system
  13799. */
  13800. removeDragGradient(gradient: number): IParticleSystem;
  13801. /**
  13802. * Gets the current list of drag gradients.
  13803. * You must use addDragGradient and removeDragGradient to udpate this list
  13804. * @returns the list of drag gradients
  13805. */
  13806. getDragGradients(): Nullable<Array<FactorGradient>>;
  13807. /**
  13808. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13809. * @param gradient defines the gradient to use (between 0 and 1)
  13810. * @param factor defines the emit rate to affect to the specified gradient
  13811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13812. * @returns the current particle system
  13813. */
  13814. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13815. /**
  13816. * Remove a specific emit rate gradient
  13817. * @param gradient defines the gradient to remove
  13818. * @returns the current particle system
  13819. */
  13820. removeEmitRateGradient(gradient: number): IParticleSystem;
  13821. /**
  13822. * Gets the current list of emit rate gradients.
  13823. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13824. * @returns the list of emit rate gradients
  13825. */
  13826. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13827. /**
  13828. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13829. * @param gradient defines the gradient to use (between 0 and 1)
  13830. * @param factor defines the start size to affect to the specified gradient
  13831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13832. * @returns the current particle system
  13833. */
  13834. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13835. /**
  13836. * Remove a specific start size gradient
  13837. * @param gradient defines the gradient to remove
  13838. * @returns the current particle system
  13839. */
  13840. removeStartSizeGradient(gradient: number): IParticleSystem;
  13841. /**
  13842. * Gets the current list of start size gradients.
  13843. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13844. * @returns the list of start size gradients
  13845. */
  13846. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13847. /**
  13848. * Adds a new life time gradient
  13849. * @param gradient defines the gradient to use (between 0 and 1)
  13850. * @param factor defines the life time factor to affect to the specified gradient
  13851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13852. * @returns the current particle system
  13853. */
  13854. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13855. /**
  13856. * Remove a specific life time gradient
  13857. * @param gradient defines the gradient to remove
  13858. * @returns the current particle system
  13859. */
  13860. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13861. /**
  13862. * Gets the current list of life time gradients.
  13863. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13864. * @returns the list of life time gradients
  13865. */
  13866. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13867. /**
  13868. * Gets the current list of color gradients.
  13869. * You must use addColorGradient and removeColorGradient to udpate this list
  13870. * @returns the list of color gradients
  13871. */
  13872. getColorGradients(): Nullable<Array<ColorGradient>>;
  13873. /**
  13874. * Adds a new ramp gradient used to remap particle colors
  13875. * @param gradient defines the gradient to use (between 0 and 1)
  13876. * @param color defines the color to affect to the specified gradient
  13877. * @returns the current particle system
  13878. */
  13879. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13880. /**
  13881. * Gets the current list of ramp gradients.
  13882. * You must use addRampGradient and removeRampGradient to udpate this list
  13883. * @returns the list of ramp gradients
  13884. */
  13885. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13886. /** Gets or sets a boolean indicating that ramp gradients must be used
  13887. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13888. */
  13889. useRampGradients: boolean;
  13890. /**
  13891. * Adds a new color remap gradient
  13892. * @param gradient defines the gradient to use (between 0 and 1)
  13893. * @param min defines the color remap minimal range
  13894. * @param max defines the color remap maximal range
  13895. * @returns the current particle system
  13896. */
  13897. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13898. /**
  13899. * Gets the current list of color remap gradients.
  13900. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13901. * @returns the list of color remap gradients
  13902. */
  13903. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13904. /**
  13905. * Adds a new alpha remap gradient
  13906. * @param gradient defines the gradient to use (between 0 and 1)
  13907. * @param min defines the alpha remap minimal range
  13908. * @param max defines the alpha remap maximal range
  13909. * @returns the current particle system
  13910. */
  13911. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13912. /**
  13913. * Gets the current list of alpha remap gradients.
  13914. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13915. * @returns the list of alpha remap gradients
  13916. */
  13917. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13918. /**
  13919. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13920. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13921. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13922. * @returns the emitter
  13923. */
  13924. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13925. /**
  13926. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13927. * @param radius The radius of the hemisphere to emit from
  13928. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13929. * @returns the emitter
  13930. */
  13931. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13932. /**
  13933. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13934. * @param radius The radius of the sphere to emit from
  13935. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13936. * @returns the emitter
  13937. */
  13938. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13939. /**
  13940. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13941. * @param radius The radius of the sphere to emit from
  13942. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13943. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13944. * @returns the emitter
  13945. */
  13946. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13947. /**
  13948. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13949. * @param radius The radius of the emission cylinder
  13950. * @param height The height of the emission cylinder
  13951. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13952. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13953. * @returns the emitter
  13954. */
  13955. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13956. /**
  13957. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13958. * @param radius The radius of the cylinder to emit from
  13959. * @param height The height of the emission cylinder
  13960. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13961. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13962. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13963. * @returns the emitter
  13964. */
  13965. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13966. /**
  13967. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13968. * @param radius The radius of the cone to emit from
  13969. * @param angle The base angle of the cone
  13970. * @returns the emitter
  13971. */
  13972. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13973. /**
  13974. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13975. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13976. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13977. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13978. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13979. * @returns the emitter
  13980. */
  13981. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13982. /**
  13983. * Get hosting scene
  13984. * @returns the scene
  13985. */
  13986. getScene(): Scene;
  13987. }
  13988. }
  13989. declare module "babylonjs/Meshes/transformNode" {
  13990. import { DeepImmutable } from "babylonjs/types";
  13991. import { Observable } from "babylonjs/Misc/observable";
  13992. import { Nullable } from "babylonjs/types";
  13993. import { Camera } from "babylonjs/Cameras/camera";
  13994. import { Scene } from "babylonjs/scene";
  13995. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13996. import { Node } from "babylonjs/node";
  13997. import { Bone } from "babylonjs/Bones/bone";
  13998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13999. import { Space } from "babylonjs/Maths/math.axis";
  14000. /**
  14001. * 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.
  14002. * @see https://doc.babylonjs.com/how_to/transformnode
  14003. */
  14004. export class TransformNode extends Node {
  14005. /**
  14006. * Object will not rotate to face the camera
  14007. */
  14008. static BILLBOARDMODE_NONE: number;
  14009. /**
  14010. * Object will rotate to face the camera but only on the x axis
  14011. */
  14012. static BILLBOARDMODE_X: number;
  14013. /**
  14014. * Object will rotate to face the camera but only on the y axis
  14015. */
  14016. static BILLBOARDMODE_Y: number;
  14017. /**
  14018. * Object will rotate to face the camera but only on the z axis
  14019. */
  14020. static BILLBOARDMODE_Z: number;
  14021. /**
  14022. * Object will rotate to face the camera
  14023. */
  14024. static BILLBOARDMODE_ALL: number;
  14025. /**
  14026. * Object will rotate to face the camera's position instead of orientation
  14027. */
  14028. static BILLBOARDMODE_USE_POSITION: number;
  14029. private _forward;
  14030. private _forwardInverted;
  14031. private _up;
  14032. private _right;
  14033. private _rightInverted;
  14034. private _position;
  14035. private _rotation;
  14036. private _rotationQuaternion;
  14037. protected _scaling: Vector3;
  14038. protected _isDirty: boolean;
  14039. private _transformToBoneReferal;
  14040. private _isAbsoluteSynced;
  14041. private _billboardMode;
  14042. /**
  14043. * Gets or sets the billboard mode. Default is 0.
  14044. *
  14045. * | Value | Type | Description |
  14046. * | --- | --- | --- |
  14047. * | 0 | BILLBOARDMODE_NONE | |
  14048. * | 1 | BILLBOARDMODE_X | |
  14049. * | 2 | BILLBOARDMODE_Y | |
  14050. * | 4 | BILLBOARDMODE_Z | |
  14051. * | 7 | BILLBOARDMODE_ALL | |
  14052. *
  14053. */
  14054. get billboardMode(): number;
  14055. set billboardMode(value: number);
  14056. private _preserveParentRotationForBillboard;
  14057. /**
  14058. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14059. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14060. */
  14061. get preserveParentRotationForBillboard(): boolean;
  14062. set preserveParentRotationForBillboard(value: boolean);
  14063. /**
  14064. * 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
  14065. */
  14066. scalingDeterminant: number;
  14067. private _infiniteDistance;
  14068. /**
  14069. * Gets or sets the distance of the object to max, often used by skybox
  14070. */
  14071. get infiniteDistance(): boolean;
  14072. set infiniteDistance(value: boolean);
  14073. /**
  14074. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14075. * By default the system will update normals to compensate
  14076. */
  14077. ignoreNonUniformScaling: boolean;
  14078. /**
  14079. * 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
  14080. */
  14081. reIntegrateRotationIntoRotationQuaternion: boolean;
  14082. /** @hidden */
  14083. _poseMatrix: Nullable<Matrix>;
  14084. /** @hidden */
  14085. _localMatrix: Matrix;
  14086. private _usePivotMatrix;
  14087. private _absolutePosition;
  14088. private _absoluteScaling;
  14089. private _absoluteRotationQuaternion;
  14090. private _pivotMatrix;
  14091. private _pivotMatrixInverse;
  14092. protected _postMultiplyPivotMatrix: boolean;
  14093. protected _isWorldMatrixFrozen: boolean;
  14094. /** @hidden */
  14095. _indexInSceneTransformNodesArray: number;
  14096. /**
  14097. * An event triggered after the world matrix is updated
  14098. */
  14099. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14100. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14101. /**
  14102. * Gets a string identifying the name of the class
  14103. * @returns "TransformNode" string
  14104. */
  14105. getClassName(): string;
  14106. /**
  14107. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14108. */
  14109. get position(): Vector3;
  14110. set position(newPosition: Vector3);
  14111. /**
  14112. * 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)).
  14113. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14114. */
  14115. get rotation(): Vector3;
  14116. set rotation(newRotation: Vector3);
  14117. /**
  14118. * 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)).
  14119. */
  14120. get scaling(): Vector3;
  14121. set scaling(newScaling: Vector3);
  14122. /**
  14123. * 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).
  14124. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14125. */
  14126. get rotationQuaternion(): Nullable<Quaternion>;
  14127. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14128. /**
  14129. * The forward direction of that transform in world space.
  14130. */
  14131. get forward(): Vector3;
  14132. /**
  14133. * The up direction of that transform in world space.
  14134. */
  14135. get up(): Vector3;
  14136. /**
  14137. * The right direction of that transform in world space.
  14138. */
  14139. get right(): Vector3;
  14140. /**
  14141. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14142. * @param matrix the matrix to copy the pose from
  14143. * @returns this TransformNode.
  14144. */
  14145. updatePoseMatrix(matrix: Matrix): TransformNode;
  14146. /**
  14147. * Returns the mesh Pose matrix.
  14148. * @returns the pose matrix
  14149. */
  14150. getPoseMatrix(): Matrix;
  14151. /** @hidden */
  14152. _isSynchronized(): boolean;
  14153. /** @hidden */
  14154. _initCache(): void;
  14155. /**
  14156. * Flag the transform node as dirty (Forcing it to update everything)
  14157. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14158. * @returns this transform node
  14159. */
  14160. markAsDirty(property: string): TransformNode;
  14161. /**
  14162. * Returns the current mesh absolute position.
  14163. * Returns a Vector3.
  14164. */
  14165. get absolutePosition(): Vector3;
  14166. /**
  14167. * Returns the current mesh absolute scaling.
  14168. * Returns a Vector3.
  14169. */
  14170. get absoluteScaling(): Vector3;
  14171. /**
  14172. * Returns the current mesh absolute rotation.
  14173. * Returns a Quaternion.
  14174. */
  14175. get absoluteRotationQuaternion(): Quaternion;
  14176. /**
  14177. * Sets a new matrix to apply before all other transformation
  14178. * @param matrix defines the transform matrix
  14179. * @returns the current TransformNode
  14180. */
  14181. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14182. /**
  14183. * Sets a new pivot matrix to the current node
  14184. * @param matrix defines the new pivot matrix to use
  14185. * @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
  14186. * @returns the current TransformNode
  14187. */
  14188. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14189. /**
  14190. * Returns the mesh pivot matrix.
  14191. * Default : Identity.
  14192. * @returns the matrix
  14193. */
  14194. getPivotMatrix(): Matrix;
  14195. /**
  14196. * Instantiate (when possible) or clone that node with its hierarchy
  14197. * @param newParent defines the new parent to use for the instance (or clone)
  14198. * @param options defines options to configure how copy is done
  14199. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14200. * @returns an instance (or a clone) of the current node with its hiearchy
  14201. */
  14202. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14203. doNotInstantiate: boolean;
  14204. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14205. /**
  14206. * Prevents the World matrix to be computed any longer
  14207. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14208. * @returns the TransformNode.
  14209. */
  14210. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14211. /**
  14212. * Allows back the World matrix computation.
  14213. * @returns the TransformNode.
  14214. */
  14215. unfreezeWorldMatrix(): this;
  14216. /**
  14217. * True if the World matrix has been frozen.
  14218. */
  14219. get isWorldMatrixFrozen(): boolean;
  14220. /**
  14221. * Retuns the mesh absolute position in the World.
  14222. * @returns a Vector3.
  14223. */
  14224. getAbsolutePosition(): Vector3;
  14225. /**
  14226. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14227. * @param absolutePosition the absolute position to set
  14228. * @returns the TransformNode.
  14229. */
  14230. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14231. /**
  14232. * Sets the mesh position in its local space.
  14233. * @param vector3 the position to set in localspace
  14234. * @returns the TransformNode.
  14235. */
  14236. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14237. /**
  14238. * Returns the mesh position in the local space from the current World matrix values.
  14239. * @returns a new Vector3.
  14240. */
  14241. getPositionExpressedInLocalSpace(): Vector3;
  14242. /**
  14243. * Translates the mesh along the passed Vector3 in its local space.
  14244. * @param vector3 the distance to translate in localspace
  14245. * @returns the TransformNode.
  14246. */
  14247. locallyTranslate(vector3: Vector3): TransformNode;
  14248. private static _lookAtVectorCache;
  14249. /**
  14250. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14251. * @param targetPoint the position (must be in same space as current mesh) to look at
  14252. * @param yawCor optional yaw (y-axis) correction in radians
  14253. * @param pitchCor optional pitch (x-axis) correction in radians
  14254. * @param rollCor optional roll (z-axis) correction in radians
  14255. * @param space the choosen space of the target
  14256. * @returns the TransformNode.
  14257. */
  14258. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14259. /**
  14260. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14261. * This Vector3 is expressed in the World space.
  14262. * @param localAxis axis to rotate
  14263. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14264. */
  14265. getDirection(localAxis: Vector3): Vector3;
  14266. /**
  14267. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14268. * localAxis is expressed in the mesh local space.
  14269. * result is computed in the Wordl space from the mesh World matrix.
  14270. * @param localAxis axis to rotate
  14271. * @param result the resulting transformnode
  14272. * @returns this TransformNode.
  14273. */
  14274. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14275. /**
  14276. * Sets this transform node rotation to the given local axis.
  14277. * @param localAxis the axis in local space
  14278. * @param yawCor optional yaw (y-axis) correction in radians
  14279. * @param pitchCor optional pitch (x-axis) correction in radians
  14280. * @param rollCor optional roll (z-axis) correction in radians
  14281. * @returns this TransformNode
  14282. */
  14283. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14284. /**
  14285. * Sets a new pivot point to the current node
  14286. * @param point defines the new pivot point to use
  14287. * @param space defines if the point is in world or local space (local by default)
  14288. * @returns the current TransformNode
  14289. */
  14290. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14291. /**
  14292. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14293. * @returns the pivot point
  14294. */
  14295. getPivotPoint(): Vector3;
  14296. /**
  14297. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14298. * @param result the vector3 to store the result
  14299. * @returns this TransformNode.
  14300. */
  14301. getPivotPointToRef(result: Vector3): TransformNode;
  14302. /**
  14303. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14304. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14305. */
  14306. getAbsolutePivotPoint(): Vector3;
  14307. /**
  14308. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14309. * @param result vector3 to store the result
  14310. * @returns this TransformNode.
  14311. */
  14312. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14313. /**
  14314. * Defines the passed node as the parent of the current node.
  14315. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14316. * @see https://doc.babylonjs.com/how_to/parenting
  14317. * @param node the node ot set as the parent
  14318. * @returns this TransformNode.
  14319. */
  14320. setParent(node: Nullable<Node>): TransformNode;
  14321. private _nonUniformScaling;
  14322. /**
  14323. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14324. */
  14325. get nonUniformScaling(): boolean;
  14326. /** @hidden */
  14327. _updateNonUniformScalingState(value: boolean): boolean;
  14328. /**
  14329. * Attach the current TransformNode to another TransformNode associated with a bone
  14330. * @param bone Bone affecting the TransformNode
  14331. * @param affectedTransformNode TransformNode associated with the bone
  14332. * @returns this object
  14333. */
  14334. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14335. /**
  14336. * Detach the transform node if its associated with a bone
  14337. * @returns this object
  14338. */
  14339. detachFromBone(): TransformNode;
  14340. private static _rotationAxisCache;
  14341. /**
  14342. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14343. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14344. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14345. * The passed axis is also normalized.
  14346. * @param axis the axis to rotate around
  14347. * @param amount the amount to rotate in radians
  14348. * @param space Space to rotate in (Default: local)
  14349. * @returns the TransformNode.
  14350. */
  14351. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14352. /**
  14353. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14354. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14355. * The passed axis is also normalized. .
  14356. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14357. * @param point the point to rotate around
  14358. * @param axis the axis to rotate around
  14359. * @param amount the amount to rotate in radians
  14360. * @returns the TransformNode
  14361. */
  14362. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14363. /**
  14364. * Translates the mesh along the axis vector for the passed distance in the given space.
  14365. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14366. * @param axis the axis to translate in
  14367. * @param distance the distance to translate
  14368. * @param space Space to rotate in (Default: local)
  14369. * @returns the TransformNode.
  14370. */
  14371. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14372. /**
  14373. * Adds a rotation step to the mesh current rotation.
  14374. * x, y, z are Euler angles expressed in radians.
  14375. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14376. * This means this rotation is made in the mesh local space only.
  14377. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14378. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14379. * ```javascript
  14380. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14381. * ```
  14382. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14383. * 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.
  14384. * @param x Rotation to add
  14385. * @param y Rotation to add
  14386. * @param z Rotation to add
  14387. * @returns the TransformNode.
  14388. */
  14389. addRotation(x: number, y: number, z: number): TransformNode;
  14390. /**
  14391. * @hidden
  14392. */
  14393. protected _getEffectiveParent(): Nullable<Node>;
  14394. /**
  14395. * Computes the world matrix of the node
  14396. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14397. * @returns the world matrix
  14398. */
  14399. computeWorldMatrix(force?: boolean): Matrix;
  14400. /**
  14401. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14402. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14403. */
  14404. resetLocalMatrix(independentOfChildren?: boolean): void;
  14405. protected _afterComputeWorldMatrix(): void;
  14406. /**
  14407. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14408. * @param func callback function to add
  14409. *
  14410. * @returns the TransformNode.
  14411. */
  14412. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14413. /**
  14414. * Removes a registered callback function.
  14415. * @param func callback function to remove
  14416. * @returns the TransformNode.
  14417. */
  14418. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14419. /**
  14420. * Gets the position of the current mesh in camera space
  14421. * @param camera defines the camera to use
  14422. * @returns a position
  14423. */
  14424. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14425. /**
  14426. * Returns the distance from the mesh to the active camera
  14427. * @param camera defines the camera to use
  14428. * @returns the distance
  14429. */
  14430. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14431. /**
  14432. * Clone the current transform node
  14433. * @param name Name of the new clone
  14434. * @param newParent New parent for the clone
  14435. * @param doNotCloneChildren Do not clone children hierarchy
  14436. * @returns the new transform node
  14437. */
  14438. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14439. /**
  14440. * Serializes the objects information.
  14441. * @param currentSerializationObject defines the object to serialize in
  14442. * @returns the serialized object
  14443. */
  14444. serialize(currentSerializationObject?: any): any;
  14445. /**
  14446. * Returns a new TransformNode object parsed from the source provided.
  14447. * @param parsedTransformNode is the source.
  14448. * @param scene the scne the object belongs to
  14449. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14450. * @returns a new TransformNode object parsed from the source provided.
  14451. */
  14452. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14453. /**
  14454. * Get all child-transformNodes of this node
  14455. * @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
  14456. * @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
  14457. * @returns an array of TransformNode
  14458. */
  14459. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14460. /**
  14461. * Releases resources associated with this transform node.
  14462. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14463. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14464. */
  14465. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14466. /**
  14467. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14468. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14469. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14470. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14471. * @returns the current mesh
  14472. */
  14473. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14474. private _syncAbsoluteScalingAndRotation;
  14475. }
  14476. }
  14477. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14478. /**
  14479. * Class used to override all child animations of a given target
  14480. */
  14481. export class AnimationPropertiesOverride {
  14482. /**
  14483. * Gets or sets a value indicating if animation blending must be used
  14484. */
  14485. enableBlending: boolean;
  14486. /**
  14487. * Gets or sets the blending speed to use when enableBlending is true
  14488. */
  14489. blendingSpeed: number;
  14490. /**
  14491. * Gets or sets the default loop mode to use
  14492. */
  14493. loopMode: number;
  14494. }
  14495. }
  14496. declare module "babylonjs/Bones/bone" {
  14497. import { Skeleton } from "babylonjs/Bones/skeleton";
  14498. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14499. import { Nullable } from "babylonjs/types";
  14500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14501. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14502. import { Node } from "babylonjs/node";
  14503. import { Space } from "babylonjs/Maths/math.axis";
  14504. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14505. /**
  14506. * Class used to store bone information
  14507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14508. */
  14509. export class Bone extends Node {
  14510. /**
  14511. * defines the bone name
  14512. */
  14513. name: string;
  14514. private static _tmpVecs;
  14515. private static _tmpQuat;
  14516. private static _tmpMats;
  14517. /**
  14518. * Gets the list of child bones
  14519. */
  14520. children: Bone[];
  14521. /** Gets the animations associated with this bone */
  14522. animations: import("babylonjs/Animations/animation").Animation[];
  14523. /**
  14524. * Gets or sets bone length
  14525. */
  14526. length: number;
  14527. /**
  14528. * @hidden Internal only
  14529. * Set this value to map this bone to a different index in the transform matrices
  14530. * Set this value to -1 to exclude the bone from the transform matrices
  14531. */
  14532. _index: Nullable<number>;
  14533. private _skeleton;
  14534. private _localMatrix;
  14535. private _restPose;
  14536. private _baseMatrix;
  14537. private _absoluteTransform;
  14538. private _invertedAbsoluteTransform;
  14539. private _parent;
  14540. private _scalingDeterminant;
  14541. private _worldTransform;
  14542. private _localScaling;
  14543. private _localRotation;
  14544. private _localPosition;
  14545. private _needToDecompose;
  14546. private _needToCompose;
  14547. /** @hidden */
  14548. _linkedTransformNode: Nullable<TransformNode>;
  14549. /** @hidden */
  14550. _waitingTransformNodeId: Nullable<string>;
  14551. /** @hidden */
  14552. get _matrix(): Matrix;
  14553. /** @hidden */
  14554. set _matrix(value: Matrix);
  14555. /**
  14556. * Create a new bone
  14557. * @param name defines the bone name
  14558. * @param skeleton defines the parent skeleton
  14559. * @param parentBone defines the parent (can be null if the bone is the root)
  14560. * @param localMatrix defines the local matrix
  14561. * @param restPose defines the rest pose matrix
  14562. * @param baseMatrix defines the base matrix
  14563. * @param index defines index of the bone in the hiearchy
  14564. */
  14565. constructor(
  14566. /**
  14567. * defines the bone name
  14568. */
  14569. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14570. /**
  14571. * Gets the current object class name.
  14572. * @return the class name
  14573. */
  14574. getClassName(): string;
  14575. /**
  14576. * Gets the parent skeleton
  14577. * @returns a skeleton
  14578. */
  14579. getSkeleton(): Skeleton;
  14580. /**
  14581. * Gets parent bone
  14582. * @returns a bone or null if the bone is the root of the bone hierarchy
  14583. */
  14584. getParent(): Nullable<Bone>;
  14585. /**
  14586. * Returns an array containing the root bones
  14587. * @returns an array containing the root bones
  14588. */
  14589. getChildren(): Array<Bone>;
  14590. /**
  14591. * Gets the node index in matrix array generated for rendering
  14592. * @returns the node index
  14593. */
  14594. getIndex(): number;
  14595. /**
  14596. * Sets the parent bone
  14597. * @param parent defines the parent (can be null if the bone is the root)
  14598. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14599. */
  14600. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14601. /**
  14602. * Gets the local matrix
  14603. * @returns a matrix
  14604. */
  14605. getLocalMatrix(): Matrix;
  14606. /**
  14607. * Gets the base matrix (initial matrix which remains unchanged)
  14608. * @returns a matrix
  14609. */
  14610. getBaseMatrix(): Matrix;
  14611. /**
  14612. * Gets the rest pose matrix
  14613. * @returns a matrix
  14614. */
  14615. getRestPose(): Matrix;
  14616. /**
  14617. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14618. */
  14619. getWorldMatrix(): Matrix;
  14620. /**
  14621. * Sets the local matrix to rest pose matrix
  14622. */
  14623. returnToRest(): void;
  14624. /**
  14625. * Gets the inverse of the absolute transform matrix.
  14626. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14627. * @returns a matrix
  14628. */
  14629. getInvertedAbsoluteTransform(): Matrix;
  14630. /**
  14631. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14632. * @returns a matrix
  14633. */
  14634. getAbsoluteTransform(): Matrix;
  14635. /**
  14636. * Links with the given transform node.
  14637. * The local matrix of this bone is copied from the transform node every frame.
  14638. * @param transformNode defines the transform node to link to
  14639. */
  14640. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14641. /**
  14642. * Gets the node used to drive the bone's transformation
  14643. * @returns a transform node or null
  14644. */
  14645. getTransformNode(): Nullable<TransformNode>;
  14646. /** Gets or sets current position (in local space) */
  14647. get position(): Vector3;
  14648. set position(newPosition: Vector3);
  14649. /** Gets or sets current rotation (in local space) */
  14650. get rotation(): Vector3;
  14651. set rotation(newRotation: Vector3);
  14652. /** Gets or sets current rotation quaternion (in local space) */
  14653. get rotationQuaternion(): Quaternion;
  14654. set rotationQuaternion(newRotation: Quaternion);
  14655. /** Gets or sets current scaling (in local space) */
  14656. get scaling(): Vector3;
  14657. set scaling(newScaling: Vector3);
  14658. /**
  14659. * Gets the animation properties override
  14660. */
  14661. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14662. private _decompose;
  14663. private _compose;
  14664. /**
  14665. * Update the base and local matrices
  14666. * @param matrix defines the new base or local matrix
  14667. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14668. * @param updateLocalMatrix defines if the local matrix should be updated
  14669. */
  14670. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14671. /** @hidden */
  14672. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14673. /**
  14674. * Flag the bone as dirty (Forcing it to update everything)
  14675. */
  14676. markAsDirty(): void;
  14677. /** @hidden */
  14678. _markAsDirtyAndCompose(): void;
  14679. private _markAsDirtyAndDecompose;
  14680. /**
  14681. * Translate the bone in local or world space
  14682. * @param vec The amount to translate the bone
  14683. * @param space The space that the translation is in
  14684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14685. */
  14686. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14687. /**
  14688. * Set the postion of the bone in local or world space
  14689. * @param position The position to set the bone
  14690. * @param space The space that the position is in
  14691. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14692. */
  14693. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14694. /**
  14695. * Set the absolute position of the bone (world space)
  14696. * @param position The position to set the bone
  14697. * @param mesh The mesh that this bone is attached to
  14698. */
  14699. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14700. /**
  14701. * Scale the bone on the x, y and z axes (in local space)
  14702. * @param x The amount to scale the bone on the x axis
  14703. * @param y The amount to scale the bone on the y axis
  14704. * @param z The amount to scale the bone on the z axis
  14705. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14706. */
  14707. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14708. /**
  14709. * Set the bone scaling in local space
  14710. * @param scale defines the scaling vector
  14711. */
  14712. setScale(scale: Vector3): void;
  14713. /**
  14714. * Gets the current scaling in local space
  14715. * @returns the current scaling vector
  14716. */
  14717. getScale(): Vector3;
  14718. /**
  14719. * Gets the current scaling in local space and stores it in a target vector
  14720. * @param result defines the target vector
  14721. */
  14722. getScaleToRef(result: Vector3): void;
  14723. /**
  14724. * Set the yaw, pitch, and roll of the bone in local or world space
  14725. * @param yaw The rotation of the bone on the y axis
  14726. * @param pitch The rotation of the bone on the x axis
  14727. * @param roll The rotation of the bone on the z axis
  14728. * @param space The space that the axes of rotation are in
  14729. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14730. */
  14731. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14732. /**
  14733. * Add a rotation to the bone on an axis in local or world space
  14734. * @param axis The axis to rotate the bone on
  14735. * @param amount The amount to rotate the bone
  14736. * @param space The space that the axis is in
  14737. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14738. */
  14739. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14740. /**
  14741. * Set the rotation of the bone to a particular axis angle in local or world space
  14742. * @param axis The axis to rotate the bone on
  14743. * @param angle The angle that the bone should be rotated to
  14744. * @param space The space that the axis is in
  14745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14746. */
  14747. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14748. /**
  14749. * Set the euler rotation of the bone in local of world space
  14750. * @param rotation The euler rotation that the bone should be set to
  14751. * @param space The space that the rotation is in
  14752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14753. */
  14754. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14755. /**
  14756. * Set the quaternion rotation of the bone in local of world space
  14757. * @param quat The quaternion rotation that the bone should be set to
  14758. * @param space The space that the rotation is in
  14759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14760. */
  14761. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14762. /**
  14763. * Set the rotation matrix of the bone in local of world space
  14764. * @param rotMat The rotation matrix that the bone should be set to
  14765. * @param space The space that the rotation is in
  14766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14767. */
  14768. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14769. private _rotateWithMatrix;
  14770. private _getNegativeRotationToRef;
  14771. /**
  14772. * Get the position of the bone in local or world space
  14773. * @param space The space that the returned position is in
  14774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14775. * @returns The position of the bone
  14776. */
  14777. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14778. /**
  14779. * Copy the position of the bone to a vector3 in local or world space
  14780. * @param space The space that the returned position is in
  14781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14782. * @param result The vector3 to copy the position to
  14783. */
  14784. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14785. /**
  14786. * Get the absolute position of the bone (world space)
  14787. * @param mesh The mesh that this bone is attached to
  14788. * @returns The absolute position of the bone
  14789. */
  14790. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14791. /**
  14792. * Copy the absolute position of the bone (world space) to the result param
  14793. * @param mesh The mesh that this bone is attached to
  14794. * @param result The vector3 to copy the absolute position to
  14795. */
  14796. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14797. /**
  14798. * Compute the absolute transforms of this bone and its children
  14799. */
  14800. computeAbsoluteTransforms(): void;
  14801. /**
  14802. * Get the world direction from an axis that is in the local space of the bone
  14803. * @param localAxis The local direction that is used to compute the world direction
  14804. * @param mesh The mesh that this bone is attached to
  14805. * @returns The world direction
  14806. */
  14807. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14808. /**
  14809. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14810. * @param localAxis The local direction that is used to compute the world direction
  14811. * @param mesh The mesh that this bone is attached to
  14812. * @param result The vector3 that the world direction will be copied to
  14813. */
  14814. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14815. /**
  14816. * Get the euler rotation of the bone in local or world space
  14817. * @param space The space that the rotation should be in
  14818. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14819. * @returns The euler rotation
  14820. */
  14821. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14822. /**
  14823. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14824. * @param space The space that the rotation should be in
  14825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14826. * @param result The vector3 that the rotation should be copied to
  14827. */
  14828. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14829. /**
  14830. * Get the quaternion rotation of the bone in either local or world space
  14831. * @param space The space that the rotation should be in
  14832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14833. * @returns The quaternion rotation
  14834. */
  14835. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14836. /**
  14837. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14838. * @param space The space that the rotation should be in
  14839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14840. * @param result The quaternion that the rotation should be copied to
  14841. */
  14842. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14843. /**
  14844. * Get the rotation matrix of the bone in local or world space
  14845. * @param space The space that the rotation should be in
  14846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14847. * @returns The rotation matrix
  14848. */
  14849. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14850. /**
  14851. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14852. * @param space The space that the rotation should be in
  14853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14854. * @param result The quaternion that the rotation should be copied to
  14855. */
  14856. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14857. /**
  14858. * Get the world position of a point that is in the local space of the bone
  14859. * @param position The local position
  14860. * @param mesh The mesh that this bone is attached to
  14861. * @returns The world position
  14862. */
  14863. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14864. /**
  14865. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14866. * @param position The local position
  14867. * @param mesh The mesh that this bone is attached to
  14868. * @param result The vector3 that the world position should be copied to
  14869. */
  14870. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14871. /**
  14872. * Get the local position of a point that is in world space
  14873. * @param position The world position
  14874. * @param mesh The mesh that this bone is attached to
  14875. * @returns The local position
  14876. */
  14877. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14878. /**
  14879. * Get the local position of a point that is in world space and copy it to the result param
  14880. * @param position The world position
  14881. * @param mesh The mesh that this bone is attached to
  14882. * @param result The vector3 that the local position should be copied to
  14883. */
  14884. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14885. }
  14886. }
  14887. declare module "babylonjs/Animations/runtimeAnimation" {
  14888. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14889. import { Animatable } from "babylonjs/Animations/animatable";
  14890. import { Scene } from "babylonjs/scene";
  14891. /**
  14892. * Defines a runtime animation
  14893. */
  14894. export class RuntimeAnimation {
  14895. private _events;
  14896. /**
  14897. * The current frame of the runtime animation
  14898. */
  14899. private _currentFrame;
  14900. /**
  14901. * The animation used by the runtime animation
  14902. */
  14903. private _animation;
  14904. /**
  14905. * The target of the runtime animation
  14906. */
  14907. private _target;
  14908. /**
  14909. * The initiating animatable
  14910. */
  14911. private _host;
  14912. /**
  14913. * The original value of the runtime animation
  14914. */
  14915. private _originalValue;
  14916. /**
  14917. * The original blend value of the runtime animation
  14918. */
  14919. private _originalBlendValue;
  14920. /**
  14921. * The offsets cache of the runtime animation
  14922. */
  14923. private _offsetsCache;
  14924. /**
  14925. * The high limits cache of the runtime animation
  14926. */
  14927. private _highLimitsCache;
  14928. /**
  14929. * Specifies if the runtime animation has been stopped
  14930. */
  14931. private _stopped;
  14932. /**
  14933. * The blending factor of the runtime animation
  14934. */
  14935. private _blendingFactor;
  14936. /**
  14937. * The BabylonJS scene
  14938. */
  14939. private _scene;
  14940. /**
  14941. * The current value of the runtime animation
  14942. */
  14943. private _currentValue;
  14944. /** @hidden */
  14945. _animationState: _IAnimationState;
  14946. /**
  14947. * The active target of the runtime animation
  14948. */
  14949. private _activeTargets;
  14950. private _currentActiveTarget;
  14951. private _directTarget;
  14952. /**
  14953. * The target path of the runtime animation
  14954. */
  14955. private _targetPath;
  14956. /**
  14957. * The weight of the runtime animation
  14958. */
  14959. private _weight;
  14960. /**
  14961. * The ratio offset of the runtime animation
  14962. */
  14963. private _ratioOffset;
  14964. /**
  14965. * The previous delay of the runtime animation
  14966. */
  14967. private _previousDelay;
  14968. /**
  14969. * The previous ratio of the runtime animation
  14970. */
  14971. private _previousRatio;
  14972. private _enableBlending;
  14973. private _keys;
  14974. private _minFrame;
  14975. private _maxFrame;
  14976. private _minValue;
  14977. private _maxValue;
  14978. private _targetIsArray;
  14979. /**
  14980. * Gets the current frame of the runtime animation
  14981. */
  14982. get currentFrame(): number;
  14983. /**
  14984. * Gets the weight of the runtime animation
  14985. */
  14986. get weight(): number;
  14987. /**
  14988. * Gets the current value of the runtime animation
  14989. */
  14990. get currentValue(): any;
  14991. /**
  14992. * Gets the target path of the runtime animation
  14993. */
  14994. get targetPath(): string;
  14995. /**
  14996. * Gets the actual target of the runtime animation
  14997. */
  14998. get target(): any;
  14999. /**
  15000. * Gets the additive state of the runtime animation
  15001. */
  15002. get isAdditive(): boolean;
  15003. /** @hidden */
  15004. _onLoop: () => void;
  15005. /**
  15006. * Create a new RuntimeAnimation object
  15007. * @param target defines the target of the animation
  15008. * @param animation defines the source animation object
  15009. * @param scene defines the hosting scene
  15010. * @param host defines the initiating Animatable
  15011. */
  15012. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15013. private _preparePath;
  15014. /**
  15015. * Gets the animation from the runtime animation
  15016. */
  15017. get animation(): Animation;
  15018. /**
  15019. * Resets the runtime animation to the beginning
  15020. * @param restoreOriginal defines whether to restore the target property to the original value
  15021. */
  15022. reset(restoreOriginal?: boolean): void;
  15023. /**
  15024. * Specifies if the runtime animation is stopped
  15025. * @returns Boolean specifying if the runtime animation is stopped
  15026. */
  15027. isStopped(): boolean;
  15028. /**
  15029. * Disposes of the runtime animation
  15030. */
  15031. dispose(): void;
  15032. /**
  15033. * Apply the interpolated value to the target
  15034. * @param currentValue defines the value computed by the animation
  15035. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15036. */
  15037. setValue(currentValue: any, weight: number): void;
  15038. private _getOriginalValues;
  15039. private _setValue;
  15040. /**
  15041. * Gets the loop pmode of the runtime animation
  15042. * @returns Loop Mode
  15043. */
  15044. private _getCorrectLoopMode;
  15045. /**
  15046. * Move the current animation to a given frame
  15047. * @param frame defines the frame to move to
  15048. */
  15049. goToFrame(frame: number): void;
  15050. /**
  15051. * @hidden Internal use only
  15052. */
  15053. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15054. /**
  15055. * Execute the current animation
  15056. * @param delay defines the delay to add to the current frame
  15057. * @param from defines the lower bound of the animation range
  15058. * @param to defines the upper bound of the animation range
  15059. * @param loop defines if the current animation must loop
  15060. * @param speedRatio defines the current speed ratio
  15061. * @param weight defines the weight of the animation (default is -1 so no weight)
  15062. * @param onLoop optional callback called when animation loops
  15063. * @returns a boolean indicating if the animation is running
  15064. */
  15065. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15066. }
  15067. }
  15068. declare module "babylonjs/Animations/animatable" {
  15069. import { Animation } from "babylonjs/Animations/animation";
  15070. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15071. import { Nullable } from "babylonjs/types";
  15072. import { Observable } from "babylonjs/Misc/observable";
  15073. import { Scene } from "babylonjs/scene";
  15074. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15075. import { Node } from "babylonjs/node";
  15076. /**
  15077. * Class used to store an actual running animation
  15078. */
  15079. export class Animatable {
  15080. /** defines the target object */
  15081. target: any;
  15082. /** defines the starting frame number (default is 0) */
  15083. fromFrame: number;
  15084. /** defines the ending frame number (default is 100) */
  15085. toFrame: number;
  15086. /** defines if the animation must loop (default is false) */
  15087. loopAnimation: boolean;
  15088. /** defines a callback to call when animation ends if it is not looping */
  15089. onAnimationEnd?: (() => void) | null | undefined;
  15090. /** defines a callback to call when animation loops */
  15091. onAnimationLoop?: (() => void) | null | undefined;
  15092. /** defines whether the animation should be evaluated additively */
  15093. isAdditive: boolean;
  15094. private _localDelayOffset;
  15095. private _pausedDelay;
  15096. private _runtimeAnimations;
  15097. private _paused;
  15098. private _scene;
  15099. private _speedRatio;
  15100. private _weight;
  15101. private _syncRoot;
  15102. /**
  15103. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15104. * This will only apply for non looping animation (default is true)
  15105. */
  15106. disposeOnEnd: boolean;
  15107. /**
  15108. * Gets a boolean indicating if the animation has started
  15109. */
  15110. animationStarted: boolean;
  15111. /**
  15112. * Observer raised when the animation ends
  15113. */
  15114. onAnimationEndObservable: Observable<Animatable>;
  15115. /**
  15116. * Observer raised when the animation loops
  15117. */
  15118. onAnimationLoopObservable: Observable<Animatable>;
  15119. /**
  15120. * Gets the root Animatable used to synchronize and normalize animations
  15121. */
  15122. get syncRoot(): Nullable<Animatable>;
  15123. /**
  15124. * Gets the current frame of the first RuntimeAnimation
  15125. * Used to synchronize Animatables
  15126. */
  15127. get masterFrame(): number;
  15128. /**
  15129. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15130. */
  15131. get weight(): number;
  15132. set weight(value: number);
  15133. /**
  15134. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15135. */
  15136. get speedRatio(): number;
  15137. set speedRatio(value: number);
  15138. /**
  15139. * Creates a new Animatable
  15140. * @param scene defines the hosting scene
  15141. * @param target defines the target object
  15142. * @param fromFrame defines the starting frame number (default is 0)
  15143. * @param toFrame defines the ending frame number (default is 100)
  15144. * @param loopAnimation defines if the animation must loop (default is false)
  15145. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15146. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15147. * @param animations defines a group of animation to add to the new Animatable
  15148. * @param onAnimationLoop defines a callback to call when animation loops
  15149. * @param isAdditive defines whether the animation should be evaluated additively
  15150. */
  15151. constructor(scene: Scene,
  15152. /** defines the target object */
  15153. target: any,
  15154. /** defines the starting frame number (default is 0) */
  15155. fromFrame?: number,
  15156. /** defines the ending frame number (default is 100) */
  15157. toFrame?: number,
  15158. /** defines if the animation must loop (default is false) */
  15159. loopAnimation?: boolean, speedRatio?: number,
  15160. /** defines a callback to call when animation ends if it is not looping */
  15161. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15162. /** defines a callback to call when animation loops */
  15163. onAnimationLoop?: (() => void) | null | undefined,
  15164. /** defines whether the animation should be evaluated additively */
  15165. isAdditive?: boolean);
  15166. /**
  15167. * Synchronize and normalize current Animatable with a source Animatable
  15168. * This is useful when using animation weights and when animations are not of the same length
  15169. * @param root defines the root Animatable to synchronize with
  15170. * @returns the current Animatable
  15171. */
  15172. syncWith(root: Animatable): Animatable;
  15173. /**
  15174. * Gets the list of runtime animations
  15175. * @returns an array of RuntimeAnimation
  15176. */
  15177. getAnimations(): RuntimeAnimation[];
  15178. /**
  15179. * Adds more animations to the current animatable
  15180. * @param target defines the target of the animations
  15181. * @param animations defines the new animations to add
  15182. */
  15183. appendAnimations(target: any, animations: Animation[]): void;
  15184. /**
  15185. * Gets the source animation for a specific property
  15186. * @param property defines the propertyu to look for
  15187. * @returns null or the source animation for the given property
  15188. */
  15189. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15190. /**
  15191. * Gets the runtime animation for a specific property
  15192. * @param property defines the propertyu to look for
  15193. * @returns null or the runtime animation for the given property
  15194. */
  15195. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15196. /**
  15197. * Resets the animatable to its original state
  15198. */
  15199. reset(): void;
  15200. /**
  15201. * Allows the animatable to blend with current running animations
  15202. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15203. * @param blendingSpeed defines the blending speed to use
  15204. */
  15205. enableBlending(blendingSpeed: number): void;
  15206. /**
  15207. * Disable animation blending
  15208. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15209. */
  15210. disableBlending(): void;
  15211. /**
  15212. * Jump directly to a given frame
  15213. * @param frame defines the frame to jump to
  15214. */
  15215. goToFrame(frame: number): void;
  15216. /**
  15217. * Pause the animation
  15218. */
  15219. pause(): void;
  15220. /**
  15221. * Restart the animation
  15222. */
  15223. restart(): void;
  15224. private _raiseOnAnimationEnd;
  15225. /**
  15226. * Stop and delete the current animation
  15227. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15228. * @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)
  15229. */
  15230. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15231. /**
  15232. * Wait asynchronously for the animation to end
  15233. * @returns a promise which will be fullfilled when the animation ends
  15234. */
  15235. waitAsync(): Promise<Animatable>;
  15236. /** @hidden */
  15237. _animate(delay: number): boolean;
  15238. }
  15239. module "babylonjs/scene" {
  15240. interface Scene {
  15241. /** @hidden */
  15242. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15243. /** @hidden */
  15244. _processLateAnimationBindingsForMatrices(holder: {
  15245. totalWeight: number;
  15246. totalAdditiveWeight: number;
  15247. animations: RuntimeAnimation[];
  15248. additiveAnimations: RuntimeAnimation[];
  15249. originalValue: Matrix;
  15250. }): any;
  15251. /** @hidden */
  15252. _processLateAnimationBindingsForQuaternions(holder: {
  15253. totalWeight: number;
  15254. totalAdditiveWeight: number;
  15255. animations: RuntimeAnimation[];
  15256. additiveAnimations: RuntimeAnimation[];
  15257. originalValue: Quaternion;
  15258. }, refQuaternion: Quaternion): Quaternion;
  15259. /** @hidden */
  15260. _processLateAnimationBindings(): void;
  15261. /**
  15262. * Will start the animation sequence of a given target
  15263. * @param target defines the target
  15264. * @param from defines from which frame should animation start
  15265. * @param to defines until which frame should animation run.
  15266. * @param weight defines the weight to apply to the animation (1.0 by default)
  15267. * @param loop defines if the animation loops
  15268. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15269. * @param onAnimationEnd defines the function to be executed when the animation ends
  15270. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15271. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15272. * @param onAnimationLoop defines the callback to call when an animation loops
  15273. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15274. * @returns the animatable object created for this animation
  15275. */
  15276. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15277. /**
  15278. * Will start the animation sequence of a given target
  15279. * @param target defines the target
  15280. * @param from defines from which frame should animation start
  15281. * @param to defines until which frame should animation run.
  15282. * @param loop defines if the animation loops
  15283. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15284. * @param onAnimationEnd defines the function to be executed when the animation ends
  15285. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15286. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15287. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15288. * @param onAnimationLoop defines the callback to call when an animation loops
  15289. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15290. * @returns the animatable object created for this animation
  15291. */
  15292. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15293. /**
  15294. * Will start the animation sequence of a given target and its hierarchy
  15295. * @param target defines the target
  15296. * @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.
  15297. * @param from defines from which frame should animation start
  15298. * @param to defines until which frame should animation run.
  15299. * @param loop defines if the animation loops
  15300. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15301. * @param onAnimationEnd defines the function to be executed when the animation ends
  15302. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15303. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15304. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15305. * @param onAnimationLoop defines the callback to call when an animation loops
  15306. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15307. * @returns the list of created animatables
  15308. */
  15309. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15310. /**
  15311. * Begin a new animation on a given node
  15312. * @param target defines the target where the animation will take place
  15313. * @param animations defines the list of animations to start
  15314. * @param from defines the initial value
  15315. * @param to defines the final value
  15316. * @param loop defines if you want animation to loop (off by default)
  15317. * @param speedRatio defines the speed ratio to apply to all animations
  15318. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15319. * @param onAnimationLoop defines the callback to call when an animation loops
  15320. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15321. * @returns the list of created animatables
  15322. */
  15323. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15324. /**
  15325. * Begin a new animation on a given node and its hierarchy
  15326. * @param target defines the root node where the animation will take place
  15327. * @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.
  15328. * @param animations defines the list of animations to start
  15329. * @param from defines the initial value
  15330. * @param to defines the final value
  15331. * @param loop defines if you want animation to loop (off by default)
  15332. * @param speedRatio defines the speed ratio to apply to all animations
  15333. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15334. * @param onAnimationLoop defines the callback to call when an animation loops
  15335. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15336. * @returns the list of animatables created for all nodes
  15337. */
  15338. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15339. /**
  15340. * Gets the animatable associated with a specific target
  15341. * @param target defines the target of the animatable
  15342. * @returns the required animatable if found
  15343. */
  15344. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15345. /**
  15346. * Gets all animatables associated with a given target
  15347. * @param target defines the target to look animatables for
  15348. * @returns an array of Animatables
  15349. */
  15350. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15351. /**
  15352. * Stops and removes all animations that have been applied to the scene
  15353. */
  15354. stopAllAnimations(): void;
  15355. /**
  15356. * Gets the current delta time used by animation engine
  15357. */
  15358. deltaTime: number;
  15359. }
  15360. }
  15361. module "babylonjs/Bones/bone" {
  15362. interface Bone {
  15363. /**
  15364. * Copy an animation range from another bone
  15365. * @param source defines the source bone
  15366. * @param rangeName defines the range name to copy
  15367. * @param frameOffset defines the frame offset
  15368. * @param rescaleAsRequired defines if rescaling must be applied if required
  15369. * @param skelDimensionsRatio defines the scaling ratio
  15370. * @returns true if operation was successful
  15371. */
  15372. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15373. }
  15374. }
  15375. }
  15376. declare module "babylonjs/Bones/skeleton" {
  15377. import { Bone } from "babylonjs/Bones/bone";
  15378. import { Observable } from "babylonjs/Misc/observable";
  15379. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15380. import { Scene } from "babylonjs/scene";
  15381. import { Nullable } from "babylonjs/types";
  15382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15383. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15384. import { Animatable } from "babylonjs/Animations/animatable";
  15385. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15386. import { Animation } from "babylonjs/Animations/animation";
  15387. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15388. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15389. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15390. /**
  15391. * Class used to handle skinning animations
  15392. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15393. */
  15394. export class Skeleton implements IAnimatable {
  15395. /** defines the skeleton name */
  15396. name: string;
  15397. /** defines the skeleton Id */
  15398. id: string;
  15399. /**
  15400. * Defines the list of child bones
  15401. */
  15402. bones: Bone[];
  15403. /**
  15404. * Defines an estimate of the dimension of the skeleton at rest
  15405. */
  15406. dimensionsAtRest: Vector3;
  15407. /**
  15408. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15409. */
  15410. needInitialSkinMatrix: boolean;
  15411. /**
  15412. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15413. */
  15414. overrideMesh: Nullable<AbstractMesh>;
  15415. /**
  15416. * Gets the list of animations attached to this skeleton
  15417. */
  15418. animations: Array<Animation>;
  15419. private _scene;
  15420. private _isDirty;
  15421. private _transformMatrices;
  15422. private _transformMatrixTexture;
  15423. private _meshesWithPoseMatrix;
  15424. private _animatables;
  15425. private _identity;
  15426. private _synchronizedWithMesh;
  15427. private _ranges;
  15428. private _lastAbsoluteTransformsUpdateId;
  15429. private _canUseTextureForBones;
  15430. private _uniqueId;
  15431. /** @hidden */
  15432. _numBonesWithLinkedTransformNode: number;
  15433. /** @hidden */
  15434. _hasWaitingData: Nullable<boolean>;
  15435. /**
  15436. * Specifies if the skeleton should be serialized
  15437. */
  15438. doNotSerialize: boolean;
  15439. private _useTextureToStoreBoneMatrices;
  15440. /**
  15441. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15442. * Please note that this option is not available if the hardware does not support it
  15443. */
  15444. get useTextureToStoreBoneMatrices(): boolean;
  15445. set useTextureToStoreBoneMatrices(value: boolean);
  15446. private _animationPropertiesOverride;
  15447. /**
  15448. * Gets or sets the animation properties override
  15449. */
  15450. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15451. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15452. /**
  15453. * List of inspectable custom properties (used by the Inspector)
  15454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15455. */
  15456. inspectableCustomProperties: IInspectable[];
  15457. /**
  15458. * An observable triggered before computing the skeleton's matrices
  15459. */
  15460. onBeforeComputeObservable: Observable<Skeleton>;
  15461. /**
  15462. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15463. */
  15464. get isUsingTextureForMatrices(): boolean;
  15465. /**
  15466. * Gets the unique ID of this skeleton
  15467. */
  15468. get uniqueId(): number;
  15469. /**
  15470. * Creates a new skeleton
  15471. * @param name defines the skeleton name
  15472. * @param id defines the skeleton Id
  15473. * @param scene defines the hosting scene
  15474. */
  15475. constructor(
  15476. /** defines the skeleton name */
  15477. name: string,
  15478. /** defines the skeleton Id */
  15479. id: string, scene: Scene);
  15480. /**
  15481. * Gets the current object class name.
  15482. * @return the class name
  15483. */
  15484. getClassName(): string;
  15485. /**
  15486. * Returns an array containing the root bones
  15487. * @returns an array containing the root bones
  15488. */
  15489. getChildren(): Array<Bone>;
  15490. /**
  15491. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15492. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15493. * @returns a Float32Array containing matrices data
  15494. */
  15495. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15496. /**
  15497. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15498. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15499. * @returns a raw texture containing the data
  15500. */
  15501. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15502. /**
  15503. * Gets the current hosting scene
  15504. * @returns a scene object
  15505. */
  15506. getScene(): Scene;
  15507. /**
  15508. * Gets a string representing the current skeleton data
  15509. * @param fullDetails defines a boolean indicating if we want a verbose version
  15510. * @returns a string representing the current skeleton data
  15511. */
  15512. toString(fullDetails?: boolean): string;
  15513. /**
  15514. * Get bone's index searching by name
  15515. * @param name defines bone's name to search for
  15516. * @return the indice of the bone. Returns -1 if not found
  15517. */
  15518. getBoneIndexByName(name: string): number;
  15519. /**
  15520. * Creater a new animation range
  15521. * @param name defines the name of the range
  15522. * @param from defines the start key
  15523. * @param to defines the end key
  15524. */
  15525. createAnimationRange(name: string, from: number, to: number): void;
  15526. /**
  15527. * Delete a specific animation range
  15528. * @param name defines the name of the range
  15529. * @param deleteFrames defines if frames must be removed as well
  15530. */
  15531. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15532. /**
  15533. * Gets a specific animation range
  15534. * @param name defines the name of the range to look for
  15535. * @returns the requested animation range or null if not found
  15536. */
  15537. getAnimationRange(name: string): Nullable<AnimationRange>;
  15538. /**
  15539. * Gets the list of all animation ranges defined on this skeleton
  15540. * @returns an array
  15541. */
  15542. getAnimationRanges(): Nullable<AnimationRange>[];
  15543. /**
  15544. * Copy animation range from a source skeleton.
  15545. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15546. * @param source defines the source skeleton
  15547. * @param name defines the name of the range to copy
  15548. * @param rescaleAsRequired defines if rescaling must be applied if required
  15549. * @returns true if operation was successful
  15550. */
  15551. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15552. /**
  15553. * Forces the skeleton to go to rest pose
  15554. */
  15555. returnToRest(): void;
  15556. private _getHighestAnimationFrame;
  15557. /**
  15558. * Begin a specific animation range
  15559. * @param name defines the name of the range to start
  15560. * @param loop defines if looping must be turned on (false by default)
  15561. * @param speedRatio defines the speed ratio to apply (1 by default)
  15562. * @param onAnimationEnd defines a callback which will be called when animation will end
  15563. * @returns a new animatable
  15564. */
  15565. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15566. /**
  15567. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15568. * @param skeleton defines the Skeleton containing the animation range to convert
  15569. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15570. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15571. * @returns the original skeleton
  15572. */
  15573. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15574. /** @hidden */
  15575. _markAsDirty(): void;
  15576. /** @hidden */
  15577. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15578. /** @hidden */
  15579. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15580. private _computeTransformMatrices;
  15581. /**
  15582. * Build all resources required to render a skeleton
  15583. */
  15584. prepare(): void;
  15585. /**
  15586. * Gets the list of animatables currently running for this skeleton
  15587. * @returns an array of animatables
  15588. */
  15589. getAnimatables(): IAnimatable[];
  15590. /**
  15591. * Clone the current skeleton
  15592. * @param name defines the name of the new skeleton
  15593. * @param id defines the id of the new skeleton
  15594. * @returns the new skeleton
  15595. */
  15596. clone(name: string, id?: string): Skeleton;
  15597. /**
  15598. * Enable animation blending for this skeleton
  15599. * @param blendingSpeed defines the blending speed to apply
  15600. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15601. */
  15602. enableBlending(blendingSpeed?: number): void;
  15603. /**
  15604. * Releases all resources associated with the current skeleton
  15605. */
  15606. dispose(): void;
  15607. /**
  15608. * Serialize the skeleton in a JSON object
  15609. * @returns a JSON object
  15610. */
  15611. serialize(): any;
  15612. /**
  15613. * Creates a new skeleton from serialized data
  15614. * @param parsedSkeleton defines the serialized data
  15615. * @param scene defines the hosting scene
  15616. * @returns a new skeleton
  15617. */
  15618. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15619. /**
  15620. * Compute all node absolute transforms
  15621. * @param forceUpdate defines if computation must be done even if cache is up to date
  15622. */
  15623. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15624. /**
  15625. * Gets the root pose matrix
  15626. * @returns a matrix
  15627. */
  15628. getPoseMatrix(): Nullable<Matrix>;
  15629. /**
  15630. * Sorts bones per internal index
  15631. */
  15632. sortBones(): void;
  15633. private _sortBones;
  15634. }
  15635. }
  15636. declare module "babylonjs/Meshes/instancedMesh" {
  15637. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15638. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15639. import { Camera } from "babylonjs/Cameras/camera";
  15640. import { Node } from "babylonjs/node";
  15641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15642. import { Mesh } from "babylonjs/Meshes/mesh";
  15643. import { Material } from "babylonjs/Materials/material";
  15644. import { Skeleton } from "babylonjs/Bones/skeleton";
  15645. import { Light } from "babylonjs/Lights/light";
  15646. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15647. /**
  15648. * Creates an instance based on a source mesh.
  15649. */
  15650. export class InstancedMesh extends AbstractMesh {
  15651. private _sourceMesh;
  15652. private _currentLOD;
  15653. /** @hidden */
  15654. _indexInSourceMeshInstanceArray: number;
  15655. constructor(name: string, source: Mesh);
  15656. /**
  15657. * Returns the string "InstancedMesh".
  15658. */
  15659. getClassName(): string;
  15660. /** Gets the list of lights affecting that mesh */
  15661. get lightSources(): Light[];
  15662. _resyncLightSources(): void;
  15663. _resyncLightSource(light: Light): void;
  15664. _removeLightSource(light: Light, dispose: boolean): void;
  15665. /**
  15666. * If the source mesh receives shadows
  15667. */
  15668. get receiveShadows(): boolean;
  15669. /**
  15670. * The material of the source mesh
  15671. */
  15672. get material(): Nullable<Material>;
  15673. /**
  15674. * Visibility of the source mesh
  15675. */
  15676. get visibility(): number;
  15677. /**
  15678. * Skeleton of the source mesh
  15679. */
  15680. get skeleton(): Nullable<Skeleton>;
  15681. /**
  15682. * Rendering ground id of the source mesh
  15683. */
  15684. get renderingGroupId(): number;
  15685. set renderingGroupId(value: number);
  15686. /**
  15687. * Returns the total number of vertices (integer).
  15688. */
  15689. getTotalVertices(): number;
  15690. /**
  15691. * Returns a positive integer : the total number of indices in this mesh geometry.
  15692. * @returns the numner of indices or zero if the mesh has no geometry.
  15693. */
  15694. getTotalIndices(): number;
  15695. /**
  15696. * The source mesh of the instance
  15697. */
  15698. get sourceMesh(): Mesh;
  15699. /**
  15700. * Is this node ready to be used/rendered
  15701. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15702. * @return {boolean} is it ready
  15703. */
  15704. isReady(completeCheck?: boolean): boolean;
  15705. /**
  15706. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15707. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15708. * @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.
  15709. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15710. */
  15711. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15712. /**
  15713. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15714. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15715. * The `data` are either a numeric array either a Float32Array.
  15716. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15717. * 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).
  15718. * Note that a new underlying VertexBuffer object is created each call.
  15719. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15720. *
  15721. * Possible `kind` values :
  15722. * - VertexBuffer.PositionKind
  15723. * - VertexBuffer.UVKind
  15724. * - VertexBuffer.UV2Kind
  15725. * - VertexBuffer.UV3Kind
  15726. * - VertexBuffer.UV4Kind
  15727. * - VertexBuffer.UV5Kind
  15728. * - VertexBuffer.UV6Kind
  15729. * - VertexBuffer.ColorKind
  15730. * - VertexBuffer.MatricesIndicesKind
  15731. * - VertexBuffer.MatricesIndicesExtraKind
  15732. * - VertexBuffer.MatricesWeightsKind
  15733. * - VertexBuffer.MatricesWeightsExtraKind
  15734. *
  15735. * Returns the Mesh.
  15736. */
  15737. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15738. /**
  15739. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15740. * If the mesh has no geometry, it is simply returned as it is.
  15741. * The `data` are either a numeric array either a Float32Array.
  15742. * No new underlying VertexBuffer object is created.
  15743. * 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.
  15744. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15745. *
  15746. * Possible `kind` values :
  15747. * - VertexBuffer.PositionKind
  15748. * - VertexBuffer.UVKind
  15749. * - VertexBuffer.UV2Kind
  15750. * - VertexBuffer.UV3Kind
  15751. * - VertexBuffer.UV4Kind
  15752. * - VertexBuffer.UV5Kind
  15753. * - VertexBuffer.UV6Kind
  15754. * - VertexBuffer.ColorKind
  15755. * - VertexBuffer.MatricesIndicesKind
  15756. * - VertexBuffer.MatricesIndicesExtraKind
  15757. * - VertexBuffer.MatricesWeightsKind
  15758. * - VertexBuffer.MatricesWeightsExtraKind
  15759. *
  15760. * Returns the Mesh.
  15761. */
  15762. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15763. /**
  15764. * Sets the mesh indices.
  15765. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15766. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15767. * This method creates a new index buffer each call.
  15768. * Returns the Mesh.
  15769. */
  15770. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15771. /**
  15772. * Boolean : True if the mesh owns the requested kind of data.
  15773. */
  15774. isVerticesDataPresent(kind: string): boolean;
  15775. /**
  15776. * Returns an array of indices (IndicesArray).
  15777. */
  15778. getIndices(): Nullable<IndicesArray>;
  15779. get _positions(): Nullable<Vector3[]>;
  15780. /**
  15781. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15782. * This means the mesh underlying bounding box and sphere are recomputed.
  15783. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15784. * @returns the current mesh
  15785. */
  15786. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15787. /** @hidden */
  15788. _preActivate(): InstancedMesh;
  15789. /** @hidden */
  15790. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15791. /** @hidden */
  15792. _postActivate(): void;
  15793. getWorldMatrix(): Matrix;
  15794. get isAnInstance(): boolean;
  15795. /**
  15796. * Returns the current associated LOD AbstractMesh.
  15797. */
  15798. getLOD(camera: Camera): AbstractMesh;
  15799. /** @hidden */
  15800. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15801. /** @hidden */
  15802. _syncSubMeshes(): InstancedMesh;
  15803. /** @hidden */
  15804. _generatePointsArray(): boolean;
  15805. /**
  15806. * Creates a new InstancedMesh from the current mesh.
  15807. * - name (string) : the cloned mesh name
  15808. * - newParent (optional Node) : the optional Node to parent the clone to.
  15809. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15810. *
  15811. * Returns the clone.
  15812. */
  15813. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15814. /**
  15815. * Disposes the InstancedMesh.
  15816. * Returns nothing.
  15817. */
  15818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15819. }
  15820. module "babylonjs/Meshes/mesh" {
  15821. interface Mesh {
  15822. /**
  15823. * Register a custom buffer that will be instanced
  15824. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15825. * @param kind defines the buffer kind
  15826. * @param stride defines the stride in floats
  15827. */
  15828. registerInstancedBuffer(kind: string, stride: number): void;
  15829. /** @hidden */
  15830. _userInstancedBuffersStorage: {
  15831. data: {
  15832. [key: string]: Float32Array;
  15833. };
  15834. sizes: {
  15835. [key: string]: number;
  15836. };
  15837. vertexBuffers: {
  15838. [key: string]: Nullable<VertexBuffer>;
  15839. };
  15840. strides: {
  15841. [key: string]: number;
  15842. };
  15843. };
  15844. }
  15845. }
  15846. module "babylonjs/Meshes/abstractMesh" {
  15847. interface AbstractMesh {
  15848. /**
  15849. * Object used to store instanced buffers defined by user
  15850. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15851. */
  15852. instancedBuffers: {
  15853. [key: string]: any;
  15854. };
  15855. }
  15856. }
  15857. }
  15858. declare module "babylonjs/Materials/shaderMaterial" {
  15859. import { Nullable } from "babylonjs/types";
  15860. import { Scene } from "babylonjs/scene";
  15861. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15863. import { Mesh } from "babylonjs/Meshes/mesh";
  15864. import { SubMesh, BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15866. import { Effect } from "babylonjs/Materials/effect";
  15867. import { Material } from "babylonjs/Materials/material";
  15868. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15869. /**
  15870. * Defines the options associated with the creation of a shader material.
  15871. */
  15872. export interface IShaderMaterialOptions {
  15873. /**
  15874. * Does the material work in alpha blend mode
  15875. */
  15876. needAlphaBlending: boolean;
  15877. /**
  15878. * Does the material work in alpha test mode
  15879. */
  15880. needAlphaTesting: boolean;
  15881. /**
  15882. * The list of attribute names used in the shader
  15883. */
  15884. attributes: string[];
  15885. /**
  15886. * The list of unifrom names used in the shader
  15887. */
  15888. uniforms: string[];
  15889. /**
  15890. * The list of UBO names used in the shader
  15891. */
  15892. uniformBuffers: string[];
  15893. /**
  15894. * The list of sampler names used in the shader
  15895. */
  15896. samplers: string[];
  15897. /**
  15898. * The list of defines used in the shader
  15899. */
  15900. defines: string[];
  15901. }
  15902. /**
  15903. * 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.
  15904. *
  15905. * This returned material effects how the mesh will look based on the code in the shaders.
  15906. *
  15907. * @see http://doc.babylonjs.com/how_to/shader_material
  15908. */
  15909. export class ShaderMaterial extends Material {
  15910. private _shaderPath;
  15911. private _options;
  15912. private _textures;
  15913. private _textureArrays;
  15914. private _floats;
  15915. private _ints;
  15916. private _floatsArrays;
  15917. private _colors3;
  15918. private _colors3Arrays;
  15919. private _colors4;
  15920. private _colors4Arrays;
  15921. private _vectors2;
  15922. private _vectors3;
  15923. private _vectors4;
  15924. private _matrices;
  15925. private _matrixArrays;
  15926. private _matrices3x3;
  15927. private _matrices2x2;
  15928. private _vectors2Arrays;
  15929. private _vectors3Arrays;
  15930. private _vectors4Arrays;
  15931. private _cachedWorldViewMatrix;
  15932. private _cachedWorldViewProjectionMatrix;
  15933. private _renderId;
  15934. private _multiview;
  15935. private _cachedDefines;
  15936. /**
  15937. * Instantiate a new shader material.
  15938. * 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.
  15939. * This returned material effects how the mesh will look based on the code in the shaders.
  15940. * @see http://doc.babylonjs.com/how_to/shader_material
  15941. * @param name Define the name of the material in the scene
  15942. * @param scene Define the scene the material belongs to
  15943. * @param shaderPath Defines the route to the shader code in one of three ways:
  15944. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15945. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15946. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15947. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15948. * @param options Define the options used to create the shader
  15949. */
  15950. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15951. /**
  15952. * Gets the shader path used to define the shader code
  15953. * It can be modified to trigger a new compilation
  15954. */
  15955. get shaderPath(): any;
  15956. /**
  15957. * Sets the shader path used to define the shader code
  15958. * It can be modified to trigger a new compilation
  15959. */
  15960. set shaderPath(shaderPath: any);
  15961. /**
  15962. * Gets the options used to compile the shader.
  15963. * They can be modified to trigger a new compilation
  15964. */
  15965. get options(): IShaderMaterialOptions;
  15966. /**
  15967. * Gets the current class name of the material e.g. "ShaderMaterial"
  15968. * Mainly use in serialization.
  15969. * @returns the class name
  15970. */
  15971. getClassName(): string;
  15972. /**
  15973. * Specifies if the material will require alpha blending
  15974. * @returns a boolean specifying if alpha blending is needed
  15975. */
  15976. needAlphaBlending(): boolean;
  15977. /**
  15978. * Specifies if this material should be rendered in alpha test mode
  15979. * @returns a boolean specifying if an alpha test is needed.
  15980. */
  15981. needAlphaTesting(): boolean;
  15982. private _checkUniform;
  15983. /**
  15984. * Set a texture in the shader.
  15985. * @param name Define the name of the uniform samplers as defined in the shader
  15986. * @param texture Define the texture to bind to this sampler
  15987. * @return the material itself allowing "fluent" like uniform updates
  15988. */
  15989. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15990. /**
  15991. * Set a texture array in the shader.
  15992. * @param name Define the name of the uniform sampler array as defined in the shader
  15993. * @param textures Define the list of textures to bind to this sampler
  15994. * @return the material itself allowing "fluent" like uniform updates
  15995. */
  15996. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15997. /**
  15998. * Set a float in the shader.
  15999. * @param name Define the name of the uniform as defined in the shader
  16000. * @param value Define the value to give to the uniform
  16001. * @return the material itself allowing "fluent" like uniform updates
  16002. */
  16003. setFloat(name: string, value: number): ShaderMaterial;
  16004. /**
  16005. * Set a int in the shader.
  16006. * @param name Define the name of the uniform as defined in the shader
  16007. * @param value Define the value to give to the uniform
  16008. * @return the material itself allowing "fluent" like uniform updates
  16009. */
  16010. setInt(name: string, value: number): ShaderMaterial;
  16011. /**
  16012. * Set an array of floats in the shader.
  16013. * @param name Define the name of the uniform as defined in the shader
  16014. * @param value Define the value to give to the uniform
  16015. * @return the material itself allowing "fluent" like uniform updates
  16016. */
  16017. setFloats(name: string, value: number[]): ShaderMaterial;
  16018. /**
  16019. * Set a vec3 in the shader from a Color3.
  16020. * @param name Define the name of the uniform as defined in the shader
  16021. * @param value Define the value to give to the uniform
  16022. * @return the material itself allowing "fluent" like uniform updates
  16023. */
  16024. setColor3(name: string, value: Color3): ShaderMaterial;
  16025. /**
  16026. * Set a vec3 array in the shader from a Color3 array.
  16027. * @param name Define the name of the uniform as defined in the shader
  16028. * @param value Define the value to give to the uniform
  16029. * @return the material itself allowing "fluent" like uniform updates
  16030. */
  16031. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16032. /**
  16033. * Set a vec4 in the shader from a Color4.
  16034. * @param name Define the name of the uniform as defined in the shader
  16035. * @param value Define the value to give to the uniform
  16036. * @return the material itself allowing "fluent" like uniform updates
  16037. */
  16038. setColor4(name: string, value: Color4): ShaderMaterial;
  16039. /**
  16040. * Set a vec4 array in the shader from a Color4 array.
  16041. * @param name Define the name of the uniform as defined in the shader
  16042. * @param value Define the value to give to the uniform
  16043. * @return the material itself allowing "fluent" like uniform updates
  16044. */
  16045. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16046. /**
  16047. * Set a vec2 in the shader from a Vector2.
  16048. * @param name Define the name of the uniform as defined in the shader
  16049. * @param value Define the value to give to the uniform
  16050. * @return the material itself allowing "fluent" like uniform updates
  16051. */
  16052. setVector2(name: string, value: Vector2): ShaderMaterial;
  16053. /**
  16054. * Set a vec3 in the shader from a Vector3.
  16055. * @param name Define the name of the uniform as defined in the shader
  16056. * @param value Define the value to give to the uniform
  16057. * @return the material itself allowing "fluent" like uniform updates
  16058. */
  16059. setVector3(name: string, value: Vector3): ShaderMaterial;
  16060. /**
  16061. * Set a vec4 in the shader from a Vector4.
  16062. * @param name Define the name of the uniform as defined in the shader
  16063. * @param value Define the value to give to the uniform
  16064. * @return the material itself allowing "fluent" like uniform updates
  16065. */
  16066. setVector4(name: string, value: Vector4): ShaderMaterial;
  16067. /**
  16068. * Set a mat4 in the shader from a Matrix.
  16069. * @param name Define the name of the uniform as defined in the shader
  16070. * @param value Define the value to give to the uniform
  16071. * @return the material itself allowing "fluent" like uniform updates
  16072. */
  16073. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16074. /**
  16075. * Set a float32Array in the shader from a matrix array.
  16076. * @param name Define the name of the uniform as defined in the shader
  16077. * @param value Define the value to give to the uniform
  16078. * @return the material itself allowing "fluent" like uniform updates
  16079. */
  16080. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16081. /**
  16082. * Set a mat3 in the shader from a Float32Array.
  16083. * @param name Define the name of the uniform as defined in the shader
  16084. * @param value Define the value to give to the uniform
  16085. * @return the material itself allowing "fluent" like uniform updates
  16086. */
  16087. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16088. /**
  16089. * Set a mat2 in the shader from a Float32Array.
  16090. * @param name Define the name of the uniform as defined in the shader
  16091. * @param value Define the value to give to the uniform
  16092. * @return the material itself allowing "fluent" like uniform updates
  16093. */
  16094. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16095. /**
  16096. * Set a vec2 array in the shader from a number array.
  16097. * @param name Define the name of the uniform as defined in the shader
  16098. * @param value Define the value to give to the uniform
  16099. * @return the material itself allowing "fluent" like uniform updates
  16100. */
  16101. setArray2(name: string, value: number[]): ShaderMaterial;
  16102. /**
  16103. * Set a vec3 array in the shader from a number array.
  16104. * @param name Define the name of the uniform as defined in the shader
  16105. * @param value Define the value to give to the uniform
  16106. * @return the material itself allowing "fluent" like uniform updates
  16107. */
  16108. setArray3(name: string, value: number[]): ShaderMaterial;
  16109. /**
  16110. * Set a vec4 array in the shader from a number array.
  16111. * @param name Define the name of the uniform as defined in the shader
  16112. * @param value Define the value to give to the uniform
  16113. * @return the material itself allowing "fluent" like uniform updates
  16114. */
  16115. setArray4(name: string, value: number[]): ShaderMaterial;
  16116. private _checkCache;
  16117. /**
  16118. * Specifies that the submesh is ready to be used
  16119. * @param mesh defines the mesh to check
  16120. * @param subMesh defines which submesh to check
  16121. * @param useInstances specifies that instances should be used
  16122. * @returns a boolean indicating that the submesh is ready or not
  16123. */
  16124. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16125. /**
  16126. * Checks if the material is ready to render the requested mesh
  16127. * @param mesh Define the mesh to render
  16128. * @param useInstances Define whether or not the material is used with instances
  16129. * @returns true if ready, otherwise false
  16130. */
  16131. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16132. /**
  16133. * Binds the world matrix to the material
  16134. * @param world defines the world transformation matrix
  16135. * @param effectOverride - If provided, use this effect instead of internal effect
  16136. */
  16137. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16138. /**
  16139. * Binds the submesh to this material by preparing the effect and shader to draw
  16140. * @param world defines the world transformation matrix
  16141. * @param mesh defines the mesh containing the submesh
  16142. * @param subMesh defines the submesh to bind the material to
  16143. */
  16144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16145. /**
  16146. * Binds the material to the mesh
  16147. * @param world defines the world transformation matrix
  16148. * @param mesh defines the mesh to bind the material to
  16149. * @param effectOverride - If provided, use this effect instead of internal effect
  16150. */
  16151. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16152. protected _afterBind(mesh?: Mesh): void;
  16153. /**
  16154. * Gets the active textures from the material
  16155. * @returns an array of textures
  16156. */
  16157. getActiveTextures(): BaseTexture[];
  16158. /**
  16159. * Specifies if the material uses a texture
  16160. * @param texture defines the texture to check against the material
  16161. * @returns a boolean specifying if the material uses the texture
  16162. */
  16163. hasTexture(texture: BaseTexture): boolean;
  16164. /**
  16165. * Makes a duplicate of the material, and gives it a new name
  16166. * @param name defines the new name for the duplicated material
  16167. * @returns the cloned material
  16168. */
  16169. clone(name: string): ShaderMaterial;
  16170. /**
  16171. * Disposes the material
  16172. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16173. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16174. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16175. */
  16176. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16177. /**
  16178. * Serializes this material in a JSON representation
  16179. * @returns the serialized material object
  16180. */
  16181. serialize(): any;
  16182. /**
  16183. * Creates a shader material from parsed shader material data
  16184. * @param source defines the JSON represnetation of the material
  16185. * @param scene defines the hosting scene
  16186. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16187. * @returns a new material
  16188. */
  16189. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16190. }
  16191. }
  16192. declare module "babylonjs/Shaders/color.fragment" {
  16193. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16194. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16195. /** @hidden */
  16196. export var colorPixelShader: {
  16197. name: string;
  16198. shader: string;
  16199. };
  16200. }
  16201. declare module "babylonjs/Shaders/color.vertex" {
  16202. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16203. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16204. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16205. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16206. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16207. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16208. /** @hidden */
  16209. export var colorVertexShader: {
  16210. name: string;
  16211. shader: string;
  16212. };
  16213. }
  16214. declare module "babylonjs/Meshes/linesMesh" {
  16215. import { Nullable } from "babylonjs/types";
  16216. import { Scene } from "babylonjs/scene";
  16217. import { Color3 } from "babylonjs/Maths/math.color";
  16218. import { Node } from "babylonjs/node";
  16219. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16220. import { Mesh } from "babylonjs/Meshes/mesh";
  16221. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16222. import { Effect } from "babylonjs/Materials/effect";
  16223. import { Material } from "babylonjs/Materials/material";
  16224. import "babylonjs/Shaders/color.fragment";
  16225. import "babylonjs/Shaders/color.vertex";
  16226. /**
  16227. * Line mesh
  16228. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16229. */
  16230. export class LinesMesh extends Mesh {
  16231. /**
  16232. * If vertex color should be applied to the mesh
  16233. */
  16234. readonly useVertexColor?: boolean | undefined;
  16235. /**
  16236. * If vertex alpha should be applied to the mesh
  16237. */
  16238. readonly useVertexAlpha?: boolean | undefined;
  16239. /**
  16240. * Color of the line (Default: White)
  16241. */
  16242. color: Color3;
  16243. /**
  16244. * Alpha of the line (Default: 1)
  16245. */
  16246. alpha: number;
  16247. /**
  16248. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16249. * This margin is expressed in world space coordinates, so its value may vary.
  16250. * Default value is 0.1
  16251. */
  16252. intersectionThreshold: number;
  16253. private _colorShader;
  16254. private color4;
  16255. /**
  16256. * Creates a new LinesMesh
  16257. * @param name defines the name
  16258. * @param scene defines the hosting scene
  16259. * @param parent defines the parent mesh if any
  16260. * @param source defines the optional source LinesMesh used to clone data from
  16261. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16262. * When false, achieved by calling a clone(), also passing False.
  16263. * This will make creation of children, recursive.
  16264. * @param useVertexColor defines if this LinesMesh supports vertex color
  16265. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16266. */
  16267. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16268. /**
  16269. * If vertex color should be applied to the mesh
  16270. */
  16271. useVertexColor?: boolean | undefined,
  16272. /**
  16273. * If vertex alpha should be applied to the mesh
  16274. */
  16275. useVertexAlpha?: boolean | undefined);
  16276. private _addClipPlaneDefine;
  16277. private _removeClipPlaneDefine;
  16278. isReady(): boolean;
  16279. /**
  16280. * Returns the string "LineMesh"
  16281. */
  16282. getClassName(): string;
  16283. /**
  16284. * @hidden
  16285. */
  16286. get material(): Material;
  16287. /**
  16288. * @hidden
  16289. */
  16290. set material(value: Material);
  16291. /**
  16292. * @hidden
  16293. */
  16294. get checkCollisions(): boolean;
  16295. /** @hidden */
  16296. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16297. /** @hidden */
  16298. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16299. /**
  16300. * Disposes of the line mesh
  16301. * @param doNotRecurse If children should be disposed
  16302. */
  16303. dispose(doNotRecurse?: boolean): void;
  16304. /**
  16305. * Returns a new LineMesh object cloned from the current one.
  16306. */
  16307. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16308. /**
  16309. * Creates a new InstancedLinesMesh object from the mesh model.
  16310. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16311. * @param name defines the name of the new instance
  16312. * @returns a new InstancedLinesMesh
  16313. */
  16314. createInstance(name: string): InstancedLinesMesh;
  16315. }
  16316. /**
  16317. * Creates an instance based on a source LinesMesh
  16318. */
  16319. export class InstancedLinesMesh extends InstancedMesh {
  16320. /**
  16321. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16322. * This margin is expressed in world space coordinates, so its value may vary.
  16323. * Initilized with the intersectionThreshold value of the source LinesMesh
  16324. */
  16325. intersectionThreshold: number;
  16326. constructor(name: string, source: LinesMesh);
  16327. /**
  16328. * Returns the string "InstancedLinesMesh".
  16329. */
  16330. getClassName(): string;
  16331. }
  16332. }
  16333. declare module "babylonjs/Shaders/line.fragment" {
  16334. /** @hidden */
  16335. export var linePixelShader: {
  16336. name: string;
  16337. shader: string;
  16338. };
  16339. }
  16340. declare module "babylonjs/Shaders/line.vertex" {
  16341. /** @hidden */
  16342. export var lineVertexShader: {
  16343. name: string;
  16344. shader: string;
  16345. };
  16346. }
  16347. declare module "babylonjs/Rendering/edgesRenderer" {
  16348. import { Nullable } from "babylonjs/types";
  16349. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16351. import { Vector3 } from "babylonjs/Maths/math.vector";
  16352. import { IDisposable } from "babylonjs/scene";
  16353. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16354. import "babylonjs/Shaders/line.fragment";
  16355. import "babylonjs/Shaders/line.vertex";
  16356. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16357. module "babylonjs/Meshes/abstractMesh" {
  16358. interface AbstractMesh {
  16359. /**
  16360. * Gets the edgesRenderer associated with the mesh
  16361. */
  16362. edgesRenderer: Nullable<EdgesRenderer>;
  16363. }
  16364. }
  16365. module "babylonjs/Meshes/linesMesh" {
  16366. interface LinesMesh {
  16367. /**
  16368. * Enables the edge rendering mode on the mesh.
  16369. * This mode makes the mesh edges visible
  16370. * @param epsilon defines the maximal distance between two angles to detect a face
  16371. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16372. * @returns the currentAbstractMesh
  16373. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16374. */
  16375. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16376. }
  16377. }
  16378. module "babylonjs/Meshes/linesMesh" {
  16379. interface InstancedLinesMesh {
  16380. /**
  16381. * Enables the edge rendering mode on the mesh.
  16382. * This mode makes the mesh edges visible
  16383. * @param epsilon defines the maximal distance between two angles to detect a face
  16384. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16385. * @returns the current InstancedLinesMesh
  16386. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16387. */
  16388. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16389. }
  16390. }
  16391. /**
  16392. * Defines the minimum contract an Edges renderer should follow.
  16393. */
  16394. export interface IEdgesRenderer extends IDisposable {
  16395. /**
  16396. * Gets or sets a boolean indicating if the edgesRenderer is active
  16397. */
  16398. isEnabled: boolean;
  16399. /**
  16400. * Renders the edges of the attached mesh,
  16401. */
  16402. render(): void;
  16403. /**
  16404. * Checks wether or not the edges renderer is ready to render.
  16405. * @return true if ready, otherwise false.
  16406. */
  16407. isReady(): boolean;
  16408. }
  16409. /**
  16410. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16411. */
  16412. export class EdgesRenderer implements IEdgesRenderer {
  16413. /**
  16414. * Define the size of the edges with an orthographic camera
  16415. */
  16416. edgesWidthScalerForOrthographic: number;
  16417. /**
  16418. * Define the size of the edges with a perspective camera
  16419. */
  16420. edgesWidthScalerForPerspective: number;
  16421. protected _source: AbstractMesh;
  16422. protected _linesPositions: number[];
  16423. protected _linesNormals: number[];
  16424. protected _linesIndices: number[];
  16425. protected _epsilon: number;
  16426. protected _indicesCount: number;
  16427. protected _lineShader: ShaderMaterial;
  16428. protected _ib: DataBuffer;
  16429. protected _buffers: {
  16430. [key: string]: Nullable<VertexBuffer>;
  16431. };
  16432. protected _checkVerticesInsteadOfIndices: boolean;
  16433. private _meshRebuildObserver;
  16434. private _meshDisposeObserver;
  16435. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16436. isEnabled: boolean;
  16437. /**
  16438. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16439. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16440. * @param source Mesh used to create edges
  16441. * @param epsilon sum of angles in adjacency to check for edge
  16442. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16443. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16444. */
  16445. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16446. protected _prepareRessources(): void;
  16447. /** @hidden */
  16448. _rebuild(): void;
  16449. /**
  16450. * Releases the required resources for the edges renderer
  16451. */
  16452. dispose(): void;
  16453. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16454. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16455. /**
  16456. * Checks if the pair of p0 and p1 is en edge
  16457. * @param faceIndex
  16458. * @param edge
  16459. * @param faceNormals
  16460. * @param p0
  16461. * @param p1
  16462. * @private
  16463. */
  16464. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16465. /**
  16466. * push line into the position, normal and index buffer
  16467. * @protected
  16468. */
  16469. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16470. /**
  16471. * Generates lines edges from adjacencjes
  16472. * @private
  16473. */
  16474. _generateEdgesLines(): void;
  16475. /**
  16476. * Checks wether or not the edges renderer is ready to render.
  16477. * @return true if ready, otherwise false.
  16478. */
  16479. isReady(): boolean;
  16480. /**
  16481. * Renders the edges of the attached mesh,
  16482. */
  16483. render(): void;
  16484. }
  16485. /**
  16486. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16487. */
  16488. export class LineEdgesRenderer extends EdgesRenderer {
  16489. /**
  16490. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16491. * @param source LineMesh used to generate edges
  16492. * @param epsilon not important (specified angle for edge detection)
  16493. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16494. */
  16495. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16496. /**
  16497. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16498. */
  16499. _generateEdgesLines(): void;
  16500. }
  16501. }
  16502. declare module "babylonjs/Rendering/renderingGroup" {
  16503. import { SmartArray } from "babylonjs/Misc/smartArray";
  16504. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16506. import { Nullable } from "babylonjs/types";
  16507. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16508. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16509. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16510. import { Material } from "babylonjs/Materials/material";
  16511. import { Scene } from "babylonjs/scene";
  16512. /**
  16513. * This represents the object necessary to create a rendering group.
  16514. * This is exclusively used and created by the rendering manager.
  16515. * To modify the behavior, you use the available helpers in your scene or meshes.
  16516. * @hidden
  16517. */
  16518. export class RenderingGroup {
  16519. index: number;
  16520. private static _zeroVector;
  16521. private _scene;
  16522. private _opaqueSubMeshes;
  16523. private _transparentSubMeshes;
  16524. private _alphaTestSubMeshes;
  16525. private _depthOnlySubMeshes;
  16526. private _particleSystems;
  16527. private _spriteManagers;
  16528. private _opaqueSortCompareFn;
  16529. private _alphaTestSortCompareFn;
  16530. private _transparentSortCompareFn;
  16531. private _renderOpaque;
  16532. private _renderAlphaTest;
  16533. private _renderTransparent;
  16534. /** @hidden */
  16535. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16536. onBeforeTransparentRendering: () => void;
  16537. /**
  16538. * Set the opaque sort comparison function.
  16539. * If null the sub meshes will be render in the order they were created
  16540. */
  16541. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16542. /**
  16543. * Set the alpha test sort comparison function.
  16544. * If null the sub meshes will be render in the order they were created
  16545. */
  16546. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16547. /**
  16548. * Set the transparent sort comparison function.
  16549. * If null the sub meshes will be render in the order they were created
  16550. */
  16551. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16552. /**
  16553. * Creates a new rendering group.
  16554. * @param index The rendering group index
  16555. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16556. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16557. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16558. */
  16559. 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>);
  16560. /**
  16561. * Render all the sub meshes contained in the group.
  16562. * @param customRenderFunction Used to override the default render behaviour of the group.
  16563. * @returns true if rendered some submeshes.
  16564. */
  16565. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16566. /**
  16567. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16568. * @param subMeshes The submeshes to render
  16569. */
  16570. private renderOpaqueSorted;
  16571. /**
  16572. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16573. * @param subMeshes The submeshes to render
  16574. */
  16575. private renderAlphaTestSorted;
  16576. /**
  16577. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16578. * @param subMeshes The submeshes to render
  16579. */
  16580. private renderTransparentSorted;
  16581. /**
  16582. * Renders the submeshes in a specified order.
  16583. * @param subMeshes The submeshes to sort before render
  16584. * @param sortCompareFn The comparison function use to sort
  16585. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16586. * @param transparent Specifies to activate blending if true
  16587. */
  16588. private static renderSorted;
  16589. /**
  16590. * Renders the submeshes in the order they were dispatched (no sort applied).
  16591. * @param subMeshes The submeshes to render
  16592. */
  16593. private static renderUnsorted;
  16594. /**
  16595. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16596. * are rendered back to front if in the same alpha index.
  16597. *
  16598. * @param a The first submesh
  16599. * @param b The second submesh
  16600. * @returns The result of the comparison
  16601. */
  16602. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16603. /**
  16604. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16605. * are rendered back to front.
  16606. *
  16607. * @param a The first submesh
  16608. * @param b The second submesh
  16609. * @returns The result of the comparison
  16610. */
  16611. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16612. /**
  16613. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16614. * are rendered front to back (prevent overdraw).
  16615. *
  16616. * @param a The first submesh
  16617. * @param b The second submesh
  16618. * @returns The result of the comparison
  16619. */
  16620. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16621. /**
  16622. * Resets the different lists of submeshes to prepare a new frame.
  16623. */
  16624. prepare(): void;
  16625. dispose(): void;
  16626. /**
  16627. * Inserts the submesh in its correct queue depending on its material.
  16628. * @param subMesh The submesh to dispatch
  16629. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16630. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16631. */
  16632. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16633. dispatchSprites(spriteManager: ISpriteManager): void;
  16634. dispatchParticles(particleSystem: IParticleSystem): void;
  16635. private _renderParticles;
  16636. private _renderSprites;
  16637. }
  16638. }
  16639. declare module "babylonjs/Rendering/renderingManager" {
  16640. import { Nullable } from "babylonjs/types";
  16641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16643. import { SmartArray } from "babylonjs/Misc/smartArray";
  16644. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16645. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16646. import { Material } from "babylonjs/Materials/material";
  16647. import { Scene } from "babylonjs/scene";
  16648. import { Camera } from "babylonjs/Cameras/camera";
  16649. /**
  16650. * Interface describing the different options available in the rendering manager
  16651. * regarding Auto Clear between groups.
  16652. */
  16653. export interface IRenderingManagerAutoClearSetup {
  16654. /**
  16655. * Defines whether or not autoclear is enable.
  16656. */
  16657. autoClear: boolean;
  16658. /**
  16659. * Defines whether or not to autoclear the depth buffer.
  16660. */
  16661. depth: boolean;
  16662. /**
  16663. * Defines whether or not to autoclear the stencil buffer.
  16664. */
  16665. stencil: boolean;
  16666. }
  16667. /**
  16668. * This class is used by the onRenderingGroupObservable
  16669. */
  16670. export class RenderingGroupInfo {
  16671. /**
  16672. * The Scene that being rendered
  16673. */
  16674. scene: Scene;
  16675. /**
  16676. * The camera currently used for the rendering pass
  16677. */
  16678. camera: Nullable<Camera>;
  16679. /**
  16680. * The ID of the renderingGroup being processed
  16681. */
  16682. renderingGroupId: number;
  16683. }
  16684. /**
  16685. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16686. * It is enable to manage the different groups as well as the different necessary sort functions.
  16687. * This should not be used directly aside of the few static configurations
  16688. */
  16689. export class RenderingManager {
  16690. /**
  16691. * The max id used for rendering groups (not included)
  16692. */
  16693. static MAX_RENDERINGGROUPS: number;
  16694. /**
  16695. * The min id used for rendering groups (included)
  16696. */
  16697. static MIN_RENDERINGGROUPS: number;
  16698. /**
  16699. * Used to globally prevent autoclearing scenes.
  16700. */
  16701. static AUTOCLEAR: boolean;
  16702. /**
  16703. * @hidden
  16704. */
  16705. _useSceneAutoClearSetup: boolean;
  16706. private _scene;
  16707. private _renderingGroups;
  16708. private _depthStencilBufferAlreadyCleaned;
  16709. private _autoClearDepthStencil;
  16710. private _customOpaqueSortCompareFn;
  16711. private _customAlphaTestSortCompareFn;
  16712. private _customTransparentSortCompareFn;
  16713. private _renderingGroupInfo;
  16714. /**
  16715. * Instantiates a new rendering group for a particular scene
  16716. * @param scene Defines the scene the groups belongs to
  16717. */
  16718. constructor(scene: Scene);
  16719. private _clearDepthStencilBuffer;
  16720. /**
  16721. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16722. * @hidden
  16723. */
  16724. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16725. /**
  16726. * Resets the different information of the group to prepare a new frame
  16727. * @hidden
  16728. */
  16729. reset(): void;
  16730. /**
  16731. * Dispose and release the group and its associated resources.
  16732. * @hidden
  16733. */
  16734. dispose(): void;
  16735. /**
  16736. * Clear the info related to rendering groups preventing retention points during dispose.
  16737. */
  16738. freeRenderingGroups(): void;
  16739. private _prepareRenderingGroup;
  16740. /**
  16741. * Add a sprite manager to the rendering manager in order to render it this frame.
  16742. * @param spriteManager Define the sprite manager to render
  16743. */
  16744. dispatchSprites(spriteManager: ISpriteManager): void;
  16745. /**
  16746. * Add a particle system to the rendering manager in order to render it this frame.
  16747. * @param particleSystem Define the particle system to render
  16748. */
  16749. dispatchParticles(particleSystem: IParticleSystem): void;
  16750. /**
  16751. * Add a submesh to the manager in order to render it this frame
  16752. * @param subMesh The submesh to dispatch
  16753. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16754. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16755. */
  16756. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16757. /**
  16758. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16759. * This allowed control for front to back rendering or reversly depending of the special needs.
  16760. *
  16761. * @param renderingGroupId The rendering group id corresponding to its index
  16762. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16763. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16764. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16765. */
  16766. 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;
  16767. /**
  16768. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16769. *
  16770. * @param renderingGroupId The rendering group id corresponding to its index
  16771. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16772. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16773. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16774. */
  16775. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16776. /**
  16777. * Gets the current auto clear configuration for one rendering group of the rendering
  16778. * manager.
  16779. * @param index the rendering group index to get the information for
  16780. * @returns The auto clear setup for the requested rendering group
  16781. */
  16782. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16783. }
  16784. }
  16785. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16786. import { SmartArray } from "babylonjs/Misc/smartArray";
  16787. import { Nullable } from "babylonjs/types";
  16788. import { Scene } from "babylonjs/scene";
  16789. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16790. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16792. import { Mesh } from "babylonjs/Meshes/mesh";
  16793. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16794. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16795. import { Effect } from "babylonjs/Materials/effect";
  16796. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16797. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16798. import "babylonjs/Shaders/shadowMap.fragment";
  16799. import "babylonjs/Shaders/shadowMap.vertex";
  16800. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16801. import { Observable } from "babylonjs/Misc/observable";
  16802. /**
  16803. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16804. */
  16805. export interface ICustomShaderOptions {
  16806. /**
  16807. * Gets or sets the custom shader name to use
  16808. */
  16809. shaderName: string;
  16810. /**
  16811. * The list of attribute names used in the shader
  16812. */
  16813. attributes?: string[];
  16814. /**
  16815. * The list of unifrom names used in the shader
  16816. */
  16817. uniforms?: string[];
  16818. /**
  16819. * The list of sampler names used in the shader
  16820. */
  16821. samplers?: string[];
  16822. /**
  16823. * The list of defines used in the shader
  16824. */
  16825. defines?: string[];
  16826. }
  16827. /**
  16828. * Interface to implement to create a shadow generator compatible with BJS.
  16829. */
  16830. export interface IShadowGenerator {
  16831. /**
  16832. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16833. * @returns The render target texture if present otherwise, null
  16834. */
  16835. getShadowMap(): Nullable<RenderTargetTexture>;
  16836. /**
  16837. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16838. * @param subMesh The submesh we want to render in the shadow map
  16839. * @param useInstances Defines wether will draw in the map using instances
  16840. * @returns true if ready otherwise, false
  16841. */
  16842. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16843. /**
  16844. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16845. * @param defines Defines of the material we want to update
  16846. * @param lightIndex Index of the light in the enabled light list of the material
  16847. */
  16848. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16849. /**
  16850. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16851. * defined in the generator but impacting the effect).
  16852. * It implies the unifroms available on the materials are the standard BJS ones.
  16853. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16854. * @param effect The effect we are binfing the information for
  16855. */
  16856. bindShadowLight(lightIndex: string, effect: Effect): void;
  16857. /**
  16858. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16859. * (eq to shadow prjection matrix * light transform matrix)
  16860. * @returns The transform matrix used to create the shadow map
  16861. */
  16862. getTransformMatrix(): Matrix;
  16863. /**
  16864. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16865. * Cube and 2D textures for instance.
  16866. */
  16867. recreateShadowMap(): void;
  16868. /**
  16869. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16870. * @param onCompiled Callback triggered at the and of the effects compilation
  16871. * @param options Sets of optional options forcing the compilation with different modes
  16872. */
  16873. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16874. useInstances: boolean;
  16875. }>): void;
  16876. /**
  16877. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16878. * @param options Sets of optional options forcing the compilation with different modes
  16879. * @returns A promise that resolves when the compilation completes
  16880. */
  16881. forceCompilationAsync(options?: Partial<{
  16882. useInstances: boolean;
  16883. }>): Promise<void>;
  16884. /**
  16885. * Serializes the shadow generator setup to a json object.
  16886. * @returns The serialized JSON object
  16887. */
  16888. serialize(): any;
  16889. /**
  16890. * Disposes the Shadow map and related Textures and effects.
  16891. */
  16892. dispose(): void;
  16893. }
  16894. /**
  16895. * Default implementation IShadowGenerator.
  16896. * This is the main object responsible of generating shadows in the framework.
  16897. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16898. */
  16899. export class ShadowGenerator implements IShadowGenerator {
  16900. /**
  16901. * Name of the shadow generator class
  16902. */
  16903. static CLASSNAME: string;
  16904. /**
  16905. * Shadow generator mode None: no filtering applied.
  16906. */
  16907. static readonly FILTER_NONE: number;
  16908. /**
  16909. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16910. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16911. */
  16912. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16913. /**
  16914. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16915. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16916. */
  16917. static readonly FILTER_POISSONSAMPLING: number;
  16918. /**
  16919. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16920. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16921. */
  16922. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16923. /**
  16924. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16925. * edge artifacts on steep falloff.
  16926. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16927. */
  16928. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16929. /**
  16930. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16931. * edge artifacts on steep falloff.
  16932. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16933. */
  16934. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16935. /**
  16936. * Shadow generator mode PCF: Percentage Closer Filtering
  16937. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16938. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16939. */
  16940. static readonly FILTER_PCF: number;
  16941. /**
  16942. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16943. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16944. * Contact Hardening
  16945. */
  16946. static readonly FILTER_PCSS: number;
  16947. /**
  16948. * Reserved for PCF and PCSS
  16949. * Highest Quality.
  16950. *
  16951. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16952. *
  16953. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16954. */
  16955. static readonly QUALITY_HIGH: number;
  16956. /**
  16957. * Reserved for PCF and PCSS
  16958. * Good tradeoff for quality/perf cross devices
  16959. *
  16960. * Execute PCF on a 3*3 kernel.
  16961. *
  16962. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16963. */
  16964. static readonly QUALITY_MEDIUM: number;
  16965. /**
  16966. * Reserved for PCF and PCSS
  16967. * The lowest quality but the fastest.
  16968. *
  16969. * Execute PCF on a 1*1 kernel.
  16970. *
  16971. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16972. */
  16973. static readonly QUALITY_LOW: number;
  16974. /** Gets or sets the custom shader name to use */
  16975. customShaderOptions: ICustomShaderOptions;
  16976. /**
  16977. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16978. */
  16979. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16980. /**
  16981. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16982. */
  16983. onAfterShadowMapRenderObservable: Observable<Effect>;
  16984. /**
  16985. * Observable triggered before a mesh is rendered in the shadow map.
  16986. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16987. */
  16988. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16989. /**
  16990. * Observable triggered after a mesh is rendered in the shadow map.
  16991. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16992. */
  16993. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16994. protected _bias: number;
  16995. /**
  16996. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16997. */
  16998. get bias(): number;
  16999. /**
  17000. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17001. */
  17002. set bias(bias: number);
  17003. protected _normalBias: number;
  17004. /**
  17005. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17006. */
  17007. get normalBias(): number;
  17008. /**
  17009. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17010. */
  17011. set normalBias(normalBias: number);
  17012. protected _blurBoxOffset: number;
  17013. /**
  17014. * Gets the blur box offset: offset applied during the blur pass.
  17015. * Only useful if useKernelBlur = false
  17016. */
  17017. get blurBoxOffset(): number;
  17018. /**
  17019. * Sets the blur box offset: offset applied during the blur pass.
  17020. * Only useful if useKernelBlur = false
  17021. */
  17022. set blurBoxOffset(value: number);
  17023. protected _blurScale: number;
  17024. /**
  17025. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17026. * 2 means half of the size.
  17027. */
  17028. get blurScale(): number;
  17029. /**
  17030. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17031. * 2 means half of the size.
  17032. */
  17033. set blurScale(value: number);
  17034. protected _blurKernel: number;
  17035. /**
  17036. * Gets the blur kernel: kernel size of the blur pass.
  17037. * Only useful if useKernelBlur = true
  17038. */
  17039. get blurKernel(): number;
  17040. /**
  17041. * Sets the blur kernel: kernel size of the blur pass.
  17042. * Only useful if useKernelBlur = true
  17043. */
  17044. set blurKernel(value: number);
  17045. protected _useKernelBlur: boolean;
  17046. /**
  17047. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17048. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17049. */
  17050. get useKernelBlur(): boolean;
  17051. /**
  17052. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17053. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17054. */
  17055. set useKernelBlur(value: boolean);
  17056. protected _depthScale: number;
  17057. /**
  17058. * Gets the depth scale used in ESM mode.
  17059. */
  17060. get depthScale(): number;
  17061. /**
  17062. * Sets the depth scale used in ESM mode.
  17063. * This can override the scale stored on the light.
  17064. */
  17065. set depthScale(value: number);
  17066. protected _validateFilter(filter: number): number;
  17067. protected _filter: number;
  17068. /**
  17069. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17070. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17071. */
  17072. get filter(): number;
  17073. /**
  17074. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17075. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17076. */
  17077. set filter(value: number);
  17078. /**
  17079. * Gets if the current filter is set to Poisson Sampling.
  17080. */
  17081. get usePoissonSampling(): boolean;
  17082. /**
  17083. * Sets the current filter to Poisson Sampling.
  17084. */
  17085. set usePoissonSampling(value: boolean);
  17086. /**
  17087. * Gets if the current filter is set to ESM.
  17088. */
  17089. get useExponentialShadowMap(): boolean;
  17090. /**
  17091. * Sets the current filter is to ESM.
  17092. */
  17093. set useExponentialShadowMap(value: boolean);
  17094. /**
  17095. * Gets if the current filter is set to filtered ESM.
  17096. */
  17097. get useBlurExponentialShadowMap(): boolean;
  17098. /**
  17099. * Gets if the current filter is set to filtered ESM.
  17100. */
  17101. set useBlurExponentialShadowMap(value: boolean);
  17102. /**
  17103. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17104. * exponential to prevent steep falloff artifacts).
  17105. */
  17106. get useCloseExponentialShadowMap(): boolean;
  17107. /**
  17108. * Sets the current filter to "close ESM" (using the inverse of the
  17109. * exponential to prevent steep falloff artifacts).
  17110. */
  17111. set useCloseExponentialShadowMap(value: boolean);
  17112. /**
  17113. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17114. * exponential to prevent steep falloff artifacts).
  17115. */
  17116. get useBlurCloseExponentialShadowMap(): boolean;
  17117. /**
  17118. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17119. * exponential to prevent steep falloff artifacts).
  17120. */
  17121. set useBlurCloseExponentialShadowMap(value: boolean);
  17122. /**
  17123. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17124. */
  17125. get usePercentageCloserFiltering(): boolean;
  17126. /**
  17127. * Sets the current filter to "PCF" (percentage closer filtering).
  17128. */
  17129. set usePercentageCloserFiltering(value: boolean);
  17130. protected _filteringQuality: number;
  17131. /**
  17132. * Gets the PCF or PCSS Quality.
  17133. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17134. */
  17135. get filteringQuality(): number;
  17136. /**
  17137. * Sets the PCF or PCSS Quality.
  17138. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17139. */
  17140. set filteringQuality(filteringQuality: number);
  17141. /**
  17142. * Gets if the current filter is set to "PCSS" (contact hardening).
  17143. */
  17144. get useContactHardeningShadow(): boolean;
  17145. /**
  17146. * Sets the current filter to "PCSS" (contact hardening).
  17147. */
  17148. set useContactHardeningShadow(value: boolean);
  17149. protected _contactHardeningLightSizeUVRatio: number;
  17150. /**
  17151. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17152. * Using a ratio helps keeping shape stability independently of the map size.
  17153. *
  17154. * It does not account for the light projection as it was having too much
  17155. * instability during the light setup or during light position changes.
  17156. *
  17157. * Only valid if useContactHardeningShadow is true.
  17158. */
  17159. get contactHardeningLightSizeUVRatio(): number;
  17160. /**
  17161. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17162. * Using a ratio helps keeping shape stability independently of the map size.
  17163. *
  17164. * It does not account for the light projection as it was having too much
  17165. * instability during the light setup or during light position changes.
  17166. *
  17167. * Only valid if useContactHardeningShadow is true.
  17168. */
  17169. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17170. protected _darkness: number;
  17171. /** Gets or sets the actual darkness of a shadow */
  17172. get darkness(): number;
  17173. set darkness(value: number);
  17174. /**
  17175. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17176. * 0 means strongest and 1 would means no shadow.
  17177. * @returns the darkness.
  17178. */
  17179. getDarkness(): number;
  17180. /**
  17181. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17182. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17183. * @returns the shadow generator allowing fluent coding.
  17184. */
  17185. setDarkness(darkness: number): ShadowGenerator;
  17186. protected _transparencyShadow: boolean;
  17187. /** Gets or sets the ability to have transparent shadow */
  17188. get transparencyShadow(): boolean;
  17189. set transparencyShadow(value: boolean);
  17190. /**
  17191. * Sets the ability to have transparent shadow (boolean).
  17192. * @param transparent True if transparent else False
  17193. * @returns the shadow generator allowing fluent coding
  17194. */
  17195. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17196. protected _shadowMap: Nullable<RenderTargetTexture>;
  17197. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17198. /**
  17199. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17200. * @returns The render target texture if present otherwise, null
  17201. */
  17202. getShadowMap(): Nullable<RenderTargetTexture>;
  17203. /**
  17204. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17205. * @returns The render target texture if the shadow map is present otherwise, null
  17206. */
  17207. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17208. /**
  17209. * Gets the class name of that object
  17210. * @returns "ShadowGenerator"
  17211. */
  17212. getClassName(): string;
  17213. /**
  17214. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17215. * @param mesh Mesh to add
  17216. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17217. * @returns the Shadow Generator itself
  17218. */
  17219. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17220. /**
  17221. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17222. * @param mesh Mesh to remove
  17223. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17224. * @returns the Shadow Generator itself
  17225. */
  17226. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17227. /**
  17228. * Controls the extent to which the shadows fade out at the edge of the frustum
  17229. */
  17230. frustumEdgeFalloff: number;
  17231. protected _light: IShadowLight;
  17232. /**
  17233. * Returns the associated light object.
  17234. * @returns the light generating the shadow
  17235. */
  17236. getLight(): IShadowLight;
  17237. /**
  17238. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17239. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17240. * It might on the other hand introduce peter panning.
  17241. */
  17242. forceBackFacesOnly: boolean;
  17243. protected _scene: Scene;
  17244. protected _lightDirection: Vector3;
  17245. protected _effect: Effect;
  17246. protected _viewMatrix: Matrix;
  17247. protected _projectionMatrix: Matrix;
  17248. protected _transformMatrix: Matrix;
  17249. protected _cachedPosition: Vector3;
  17250. protected _cachedDirection: Vector3;
  17251. protected _cachedDefines: string;
  17252. protected _currentRenderID: number;
  17253. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17254. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17255. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17256. protected _blurPostProcesses: PostProcess[];
  17257. protected _mapSize: number;
  17258. protected _currentFaceIndex: number;
  17259. protected _currentFaceIndexCache: number;
  17260. protected _textureType: number;
  17261. protected _defaultTextureMatrix: Matrix;
  17262. protected _storedUniqueId: Nullable<number>;
  17263. /** @hidden */
  17264. static _SceneComponentInitialization: (scene: Scene) => void;
  17265. /**
  17266. * Creates a ShadowGenerator object.
  17267. * A ShadowGenerator is the required tool to use the shadows.
  17268. * Each light casting shadows needs to use its own ShadowGenerator.
  17269. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17270. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17271. * @param light The light object generating the shadows.
  17272. * @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.
  17273. */
  17274. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17275. protected _initializeGenerator(): void;
  17276. protected _createTargetRenderTexture(): void;
  17277. protected _initializeShadowMap(): void;
  17278. protected _initializeBlurRTTAndPostProcesses(): void;
  17279. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17280. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17281. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17282. protected _applyFilterValues(): void;
  17283. /**
  17284. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17285. * @param onCompiled Callback triggered at the and of the effects compilation
  17286. * @param options Sets of optional options forcing the compilation with different modes
  17287. */
  17288. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17289. useInstances: boolean;
  17290. }>): void;
  17291. /**
  17292. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17293. * @param options Sets of optional options forcing the compilation with different modes
  17294. * @returns A promise that resolves when the compilation completes
  17295. */
  17296. forceCompilationAsync(options?: Partial<{
  17297. useInstances: boolean;
  17298. }>): Promise<void>;
  17299. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17300. private _prepareShadowDefines;
  17301. /**
  17302. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17303. * @param subMesh The submesh we want to render in the shadow map
  17304. * @param useInstances Defines wether will draw in the map using instances
  17305. * @returns true if ready otherwise, false
  17306. */
  17307. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17308. /**
  17309. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17310. * @param defines Defines of the material we want to update
  17311. * @param lightIndex Index of the light in the enabled light list of the material
  17312. */
  17313. prepareDefines(defines: any, lightIndex: number): void;
  17314. /**
  17315. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17316. * defined in the generator but impacting the effect).
  17317. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17318. * @param effect The effect we are binfing the information for
  17319. */
  17320. bindShadowLight(lightIndex: string, effect: Effect): void;
  17321. /**
  17322. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17323. * (eq to shadow prjection matrix * light transform matrix)
  17324. * @returns The transform matrix used to create the shadow map
  17325. */
  17326. getTransformMatrix(): Matrix;
  17327. /**
  17328. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17329. * Cube and 2D textures for instance.
  17330. */
  17331. recreateShadowMap(): void;
  17332. protected _disposeBlurPostProcesses(): void;
  17333. protected _disposeRTTandPostProcesses(): void;
  17334. /**
  17335. * Disposes the ShadowGenerator.
  17336. * Returns nothing.
  17337. */
  17338. dispose(): void;
  17339. /**
  17340. * Serializes the shadow generator setup to a json object.
  17341. * @returns The serialized JSON object
  17342. */
  17343. serialize(): any;
  17344. /**
  17345. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17346. * @param parsedShadowGenerator The JSON object to parse
  17347. * @param scene The scene to create the shadow map for
  17348. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17349. * @returns The parsed shadow generator
  17350. */
  17351. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17352. }
  17353. }
  17354. declare module "babylonjs/Lights/light" {
  17355. import { Nullable } from "babylonjs/types";
  17356. import { Scene } from "babylonjs/scene";
  17357. import { Vector3 } from "babylonjs/Maths/math.vector";
  17358. import { Color3 } from "babylonjs/Maths/math.color";
  17359. import { Node } from "babylonjs/node";
  17360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17361. import { Effect } from "babylonjs/Materials/effect";
  17362. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17363. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17364. /**
  17365. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17366. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17367. * 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.
  17368. */
  17369. export abstract class Light extends Node {
  17370. /**
  17371. * Falloff Default: light is falling off following the material specification:
  17372. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17373. */
  17374. static readonly FALLOFF_DEFAULT: number;
  17375. /**
  17376. * Falloff Physical: light is falling off following the inverse squared distance law.
  17377. */
  17378. static readonly FALLOFF_PHYSICAL: number;
  17379. /**
  17380. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17381. * to enhance interoperability with other engines.
  17382. */
  17383. static readonly FALLOFF_GLTF: number;
  17384. /**
  17385. * Falloff Standard: light is falling off like in the standard material
  17386. * to enhance interoperability with other materials.
  17387. */
  17388. static readonly FALLOFF_STANDARD: number;
  17389. /**
  17390. * If every light affecting the material is in this lightmapMode,
  17391. * material.lightmapTexture adds or multiplies
  17392. * (depends on material.useLightmapAsShadowmap)
  17393. * after every other light calculations.
  17394. */
  17395. static readonly LIGHTMAP_DEFAULT: number;
  17396. /**
  17397. * material.lightmapTexture as only diffuse lighting from this light
  17398. * adds only specular lighting from this light
  17399. * adds dynamic shadows
  17400. */
  17401. static readonly LIGHTMAP_SPECULAR: number;
  17402. /**
  17403. * material.lightmapTexture as only lighting
  17404. * no light calculation from this light
  17405. * only adds dynamic shadows from this light
  17406. */
  17407. static readonly LIGHTMAP_SHADOWSONLY: number;
  17408. /**
  17409. * Each light type uses the default quantity according to its type:
  17410. * point/spot lights use luminous intensity
  17411. * directional lights use illuminance
  17412. */
  17413. static readonly INTENSITYMODE_AUTOMATIC: number;
  17414. /**
  17415. * lumen (lm)
  17416. */
  17417. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17418. /**
  17419. * candela (lm/sr)
  17420. */
  17421. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17422. /**
  17423. * lux (lm/m^2)
  17424. */
  17425. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17426. /**
  17427. * nit (cd/m^2)
  17428. */
  17429. static readonly INTENSITYMODE_LUMINANCE: number;
  17430. /**
  17431. * Light type const id of the point light.
  17432. */
  17433. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17434. /**
  17435. * Light type const id of the directional light.
  17436. */
  17437. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17438. /**
  17439. * Light type const id of the spot light.
  17440. */
  17441. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17442. /**
  17443. * Light type const id of the hemispheric light.
  17444. */
  17445. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17446. /**
  17447. * Diffuse gives the basic color to an object.
  17448. */
  17449. diffuse: Color3;
  17450. /**
  17451. * Specular produces a highlight color on an object.
  17452. * Note: This is note affecting PBR materials.
  17453. */
  17454. specular: Color3;
  17455. /**
  17456. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17457. * falling off base on range or angle.
  17458. * This can be set to any values in Light.FALLOFF_x.
  17459. *
  17460. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17461. * other types of materials.
  17462. */
  17463. falloffType: number;
  17464. /**
  17465. * Strength of the light.
  17466. * Note: By default it is define in the framework own unit.
  17467. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17468. */
  17469. intensity: number;
  17470. private _range;
  17471. protected _inverseSquaredRange: number;
  17472. /**
  17473. * Defines how far from the source the light is impacting in scene units.
  17474. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17475. */
  17476. get range(): number;
  17477. /**
  17478. * Defines how far from the source the light is impacting in scene units.
  17479. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17480. */
  17481. set range(value: number);
  17482. /**
  17483. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17484. * of light.
  17485. */
  17486. private _photometricScale;
  17487. private _intensityMode;
  17488. /**
  17489. * Gets the photometric scale used to interpret the intensity.
  17490. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17491. */
  17492. get intensityMode(): number;
  17493. /**
  17494. * Sets the photometric scale used to interpret the intensity.
  17495. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17496. */
  17497. set intensityMode(value: number);
  17498. private _radius;
  17499. /**
  17500. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17501. */
  17502. get radius(): number;
  17503. /**
  17504. * sets the light radius used by PBR Materials to simulate soft area lights.
  17505. */
  17506. set radius(value: number);
  17507. private _renderPriority;
  17508. /**
  17509. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17510. * exceeding the number allowed of the materials.
  17511. */
  17512. renderPriority: number;
  17513. private _shadowEnabled;
  17514. /**
  17515. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17516. * the current shadow generator.
  17517. */
  17518. get shadowEnabled(): boolean;
  17519. /**
  17520. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17521. * the current shadow generator.
  17522. */
  17523. set shadowEnabled(value: boolean);
  17524. private _includedOnlyMeshes;
  17525. /**
  17526. * Gets the only meshes impacted by this light.
  17527. */
  17528. get includedOnlyMeshes(): AbstractMesh[];
  17529. /**
  17530. * Sets the only meshes impacted by this light.
  17531. */
  17532. set includedOnlyMeshes(value: AbstractMesh[]);
  17533. private _excludedMeshes;
  17534. /**
  17535. * Gets the meshes not impacted by this light.
  17536. */
  17537. get excludedMeshes(): AbstractMesh[];
  17538. /**
  17539. * Sets the meshes not impacted by this light.
  17540. */
  17541. set excludedMeshes(value: AbstractMesh[]);
  17542. private _excludeWithLayerMask;
  17543. /**
  17544. * Gets the layer id use to find what meshes are not impacted by the light.
  17545. * Inactive if 0
  17546. */
  17547. get excludeWithLayerMask(): number;
  17548. /**
  17549. * Sets the layer id use to find what meshes are not impacted by the light.
  17550. * Inactive if 0
  17551. */
  17552. set excludeWithLayerMask(value: number);
  17553. private _includeOnlyWithLayerMask;
  17554. /**
  17555. * Gets the layer id use to find what meshes are impacted by the light.
  17556. * Inactive if 0
  17557. */
  17558. get includeOnlyWithLayerMask(): number;
  17559. /**
  17560. * Sets the layer id use to find what meshes are impacted by the light.
  17561. * Inactive if 0
  17562. */
  17563. set includeOnlyWithLayerMask(value: number);
  17564. private _lightmapMode;
  17565. /**
  17566. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17567. */
  17568. get lightmapMode(): number;
  17569. /**
  17570. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17571. */
  17572. set lightmapMode(value: number);
  17573. /**
  17574. * Shadow generator associted to the light.
  17575. * @hidden Internal use only.
  17576. */
  17577. _shadowGenerator: Nullable<IShadowGenerator>;
  17578. /**
  17579. * @hidden Internal use only.
  17580. */
  17581. _excludedMeshesIds: string[];
  17582. /**
  17583. * @hidden Internal use only.
  17584. */
  17585. _includedOnlyMeshesIds: string[];
  17586. /**
  17587. * The current light unifom buffer.
  17588. * @hidden Internal use only.
  17589. */
  17590. _uniformBuffer: UniformBuffer;
  17591. /** @hidden */
  17592. _renderId: number;
  17593. /**
  17594. * Creates a Light object in the scene.
  17595. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17596. * @param name The firendly name of the light
  17597. * @param scene The scene the light belongs too
  17598. */
  17599. constructor(name: string, scene: Scene);
  17600. protected abstract _buildUniformLayout(): void;
  17601. /**
  17602. * Sets the passed Effect "effect" with the Light information.
  17603. * @param effect The effect to update
  17604. * @param lightIndex The index of the light in the effect to update
  17605. * @returns The light
  17606. */
  17607. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17608. /**
  17609. * Sets the passed Effect "effect" with the Light textures.
  17610. * @param effect The effect to update
  17611. * @param lightIndex The index of the light in the effect to update
  17612. * @returns The light
  17613. */
  17614. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17615. /**
  17616. * Binds the lights information from the scene to the effect for the given mesh.
  17617. * @param lightIndex Light index
  17618. * @param scene The scene where the light belongs to
  17619. * @param effect The effect we are binding the data to
  17620. * @param useSpecular Defines if specular is supported
  17621. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17622. */
  17623. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17624. /**
  17625. * Sets the passed Effect "effect" with the Light information.
  17626. * @param effect The effect to update
  17627. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17628. * @returns The light
  17629. */
  17630. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17631. /**
  17632. * Returns the string "Light".
  17633. * @returns the class name
  17634. */
  17635. getClassName(): string;
  17636. /** @hidden */
  17637. readonly _isLight: boolean;
  17638. /**
  17639. * Converts the light information to a readable string for debug purpose.
  17640. * @param fullDetails Supports for multiple levels of logging within scene loading
  17641. * @returns the human readable light info
  17642. */
  17643. toString(fullDetails?: boolean): string;
  17644. /** @hidden */
  17645. protected _syncParentEnabledState(): void;
  17646. /**
  17647. * Set the enabled state of this node.
  17648. * @param value - the new enabled state
  17649. */
  17650. setEnabled(value: boolean): void;
  17651. /**
  17652. * Returns the Light associated shadow generator if any.
  17653. * @return the associated shadow generator.
  17654. */
  17655. getShadowGenerator(): Nullable<IShadowGenerator>;
  17656. /**
  17657. * Returns a Vector3, the absolute light position in the World.
  17658. * @returns the world space position of the light
  17659. */
  17660. getAbsolutePosition(): Vector3;
  17661. /**
  17662. * Specifies if the light will affect the passed mesh.
  17663. * @param mesh The mesh to test against the light
  17664. * @return true the mesh is affected otherwise, false.
  17665. */
  17666. canAffectMesh(mesh: AbstractMesh): boolean;
  17667. /**
  17668. * Sort function to order lights for rendering.
  17669. * @param a First Light object to compare to second.
  17670. * @param b Second Light object to compare first.
  17671. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17672. */
  17673. static CompareLightsPriority(a: Light, b: Light): number;
  17674. /**
  17675. * Releases resources associated with this node.
  17676. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17677. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17678. */
  17679. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17680. /**
  17681. * Returns the light type ID (integer).
  17682. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17683. */
  17684. getTypeID(): number;
  17685. /**
  17686. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17687. * @returns the scaled intensity in intensity mode unit
  17688. */
  17689. getScaledIntensity(): number;
  17690. /**
  17691. * Returns a new Light object, named "name", from the current one.
  17692. * @param name The name of the cloned light
  17693. * @returns the new created light
  17694. */
  17695. clone(name: string): Nullable<Light>;
  17696. /**
  17697. * Serializes the current light into a Serialization object.
  17698. * @returns the serialized object.
  17699. */
  17700. serialize(): any;
  17701. /**
  17702. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17703. * This new light is named "name" and added to the passed scene.
  17704. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17705. * @param name The friendly name of the light
  17706. * @param scene The scene the new light will belong to
  17707. * @returns the constructor function
  17708. */
  17709. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17710. /**
  17711. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17712. * @param parsedLight The JSON representation of the light
  17713. * @param scene The scene to create the parsed light in
  17714. * @returns the created light after parsing
  17715. */
  17716. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17717. private _hookArrayForExcluded;
  17718. private _hookArrayForIncludedOnly;
  17719. private _resyncMeshes;
  17720. /**
  17721. * Forces the meshes to update their light related information in their rendering used effects
  17722. * @hidden Internal Use Only
  17723. */
  17724. _markMeshesAsLightDirty(): void;
  17725. /**
  17726. * Recomputes the cached photometric scale if needed.
  17727. */
  17728. private _computePhotometricScale;
  17729. /**
  17730. * Returns the Photometric Scale according to the light type and intensity mode.
  17731. */
  17732. private _getPhotometricScale;
  17733. /**
  17734. * Reorder the light in the scene according to their defined priority.
  17735. * @hidden Internal Use Only
  17736. */
  17737. _reorderLightsInScene(): void;
  17738. /**
  17739. * Prepares the list of defines specific to the light type.
  17740. * @param defines the list of defines
  17741. * @param lightIndex defines the index of the light for the effect
  17742. */
  17743. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17744. }
  17745. }
  17746. declare module "babylonjs/Actions/action" {
  17747. import { Observable } from "babylonjs/Misc/observable";
  17748. import { Condition } from "babylonjs/Actions/condition";
  17749. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17750. import { ActionManager } from "babylonjs/Actions/actionManager";
  17751. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17752. /**
  17753. * Interface used to define Action
  17754. */
  17755. export interface IAction {
  17756. /**
  17757. * Trigger for the action
  17758. */
  17759. trigger: number;
  17760. /** Options of the trigger */
  17761. triggerOptions: any;
  17762. /**
  17763. * Gets the trigger parameters
  17764. * @returns the trigger parameters
  17765. */
  17766. getTriggerParameter(): any;
  17767. /**
  17768. * Internal only - executes current action event
  17769. * @hidden
  17770. */
  17771. _executeCurrent(evt?: ActionEvent): void;
  17772. /**
  17773. * Serialize placeholder for child classes
  17774. * @param parent of child
  17775. * @returns the serialized object
  17776. */
  17777. serialize(parent: any): any;
  17778. /**
  17779. * Internal only
  17780. * @hidden
  17781. */
  17782. _prepare(): void;
  17783. /**
  17784. * Internal only - manager for action
  17785. * @hidden
  17786. */
  17787. _actionManager: AbstractActionManager;
  17788. /**
  17789. * Adds action to chain of actions, may be a DoNothingAction
  17790. * @param action defines the next action to execute
  17791. * @returns The action passed in
  17792. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17793. */
  17794. then(action: IAction): IAction;
  17795. }
  17796. /**
  17797. * The action to be carried out following a trigger
  17798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17799. */
  17800. export class Action implements IAction {
  17801. /** the trigger, with or without parameters, for the action */
  17802. triggerOptions: any;
  17803. /**
  17804. * Trigger for the action
  17805. */
  17806. trigger: number;
  17807. /**
  17808. * Internal only - manager for action
  17809. * @hidden
  17810. */
  17811. _actionManager: ActionManager;
  17812. private _nextActiveAction;
  17813. private _child;
  17814. private _condition?;
  17815. private _triggerParameter;
  17816. /**
  17817. * An event triggered prior to action being executed.
  17818. */
  17819. onBeforeExecuteObservable: Observable<Action>;
  17820. /**
  17821. * Creates a new Action
  17822. * @param triggerOptions the trigger, with or without parameters, for the action
  17823. * @param condition an optional determinant of action
  17824. */
  17825. constructor(
  17826. /** the trigger, with or without parameters, for the action */
  17827. triggerOptions: any, condition?: Condition);
  17828. /**
  17829. * Internal only
  17830. * @hidden
  17831. */
  17832. _prepare(): void;
  17833. /**
  17834. * Gets the trigger parameters
  17835. * @returns the trigger parameters
  17836. */
  17837. getTriggerParameter(): any;
  17838. /**
  17839. * Internal only - executes current action event
  17840. * @hidden
  17841. */
  17842. _executeCurrent(evt?: ActionEvent): void;
  17843. /**
  17844. * Execute placeholder for child classes
  17845. * @param evt optional action event
  17846. */
  17847. execute(evt?: ActionEvent): void;
  17848. /**
  17849. * Skips to next active action
  17850. */
  17851. skipToNextActiveAction(): void;
  17852. /**
  17853. * Adds action to chain of actions, may be a DoNothingAction
  17854. * @param action defines the next action to execute
  17855. * @returns The action passed in
  17856. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17857. */
  17858. then(action: Action): Action;
  17859. /**
  17860. * Internal only
  17861. * @hidden
  17862. */
  17863. _getProperty(propertyPath: string): string;
  17864. /**
  17865. * Internal only
  17866. * @hidden
  17867. */
  17868. _getEffectiveTarget(target: any, propertyPath: string): any;
  17869. /**
  17870. * Serialize placeholder for child classes
  17871. * @param parent of child
  17872. * @returns the serialized object
  17873. */
  17874. serialize(parent: any): any;
  17875. /**
  17876. * Internal only called by serialize
  17877. * @hidden
  17878. */
  17879. protected _serialize(serializedAction: any, parent?: any): any;
  17880. /**
  17881. * Internal only
  17882. * @hidden
  17883. */
  17884. static _SerializeValueAsString: (value: any) => string;
  17885. /**
  17886. * Internal only
  17887. * @hidden
  17888. */
  17889. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17890. name: string;
  17891. targetType: string;
  17892. value: string;
  17893. };
  17894. }
  17895. }
  17896. declare module "babylonjs/Actions/condition" {
  17897. import { ActionManager } from "babylonjs/Actions/actionManager";
  17898. /**
  17899. * A Condition applied to an Action
  17900. */
  17901. export class Condition {
  17902. /**
  17903. * Internal only - manager for action
  17904. * @hidden
  17905. */
  17906. _actionManager: ActionManager;
  17907. /**
  17908. * Internal only
  17909. * @hidden
  17910. */
  17911. _evaluationId: number;
  17912. /**
  17913. * Internal only
  17914. * @hidden
  17915. */
  17916. _currentResult: boolean;
  17917. /**
  17918. * Creates a new Condition
  17919. * @param actionManager the manager of the action the condition is applied to
  17920. */
  17921. constructor(actionManager: ActionManager);
  17922. /**
  17923. * Check if the current condition is valid
  17924. * @returns a boolean
  17925. */
  17926. isValid(): boolean;
  17927. /**
  17928. * Internal only
  17929. * @hidden
  17930. */
  17931. _getProperty(propertyPath: string): string;
  17932. /**
  17933. * Internal only
  17934. * @hidden
  17935. */
  17936. _getEffectiveTarget(target: any, propertyPath: string): any;
  17937. /**
  17938. * Serialize placeholder for child classes
  17939. * @returns the serialized object
  17940. */
  17941. serialize(): any;
  17942. /**
  17943. * Internal only
  17944. * @hidden
  17945. */
  17946. protected _serialize(serializedCondition: any): any;
  17947. }
  17948. /**
  17949. * Defines specific conditional operators as extensions of Condition
  17950. */
  17951. export class ValueCondition extends Condition {
  17952. /** path to specify the property of the target the conditional operator uses */
  17953. propertyPath: string;
  17954. /** the value compared by the conditional operator against the current value of the property */
  17955. value: any;
  17956. /** the conditional operator, default ValueCondition.IsEqual */
  17957. operator: number;
  17958. /**
  17959. * Internal only
  17960. * @hidden
  17961. */
  17962. private static _IsEqual;
  17963. /**
  17964. * Internal only
  17965. * @hidden
  17966. */
  17967. private static _IsDifferent;
  17968. /**
  17969. * Internal only
  17970. * @hidden
  17971. */
  17972. private static _IsGreater;
  17973. /**
  17974. * Internal only
  17975. * @hidden
  17976. */
  17977. private static _IsLesser;
  17978. /**
  17979. * returns the number for IsEqual
  17980. */
  17981. static get IsEqual(): number;
  17982. /**
  17983. * Returns the number for IsDifferent
  17984. */
  17985. static get IsDifferent(): number;
  17986. /**
  17987. * Returns the number for IsGreater
  17988. */
  17989. static get IsGreater(): number;
  17990. /**
  17991. * Returns the number for IsLesser
  17992. */
  17993. static get IsLesser(): number;
  17994. /**
  17995. * Internal only The action manager for the condition
  17996. * @hidden
  17997. */
  17998. _actionManager: ActionManager;
  17999. /**
  18000. * Internal only
  18001. * @hidden
  18002. */
  18003. private _target;
  18004. /**
  18005. * Internal only
  18006. * @hidden
  18007. */
  18008. private _effectiveTarget;
  18009. /**
  18010. * Internal only
  18011. * @hidden
  18012. */
  18013. private _property;
  18014. /**
  18015. * Creates a new ValueCondition
  18016. * @param actionManager manager for the action the condition applies to
  18017. * @param target for the action
  18018. * @param propertyPath path to specify the property of the target the conditional operator uses
  18019. * @param value the value compared by the conditional operator against the current value of the property
  18020. * @param operator the conditional operator, default ValueCondition.IsEqual
  18021. */
  18022. constructor(actionManager: ActionManager, target: any,
  18023. /** path to specify the property of the target the conditional operator uses */
  18024. propertyPath: string,
  18025. /** the value compared by the conditional operator against the current value of the property */
  18026. value: any,
  18027. /** the conditional operator, default ValueCondition.IsEqual */
  18028. operator?: number);
  18029. /**
  18030. * Compares the given value with the property value for the specified conditional operator
  18031. * @returns the result of the comparison
  18032. */
  18033. isValid(): boolean;
  18034. /**
  18035. * Serialize the ValueCondition into a JSON compatible object
  18036. * @returns serialization object
  18037. */
  18038. serialize(): any;
  18039. /**
  18040. * Gets the name of the conditional operator for the ValueCondition
  18041. * @param operator the conditional operator
  18042. * @returns the name
  18043. */
  18044. static GetOperatorName(operator: number): string;
  18045. }
  18046. /**
  18047. * Defines a predicate condition as an extension of Condition
  18048. */
  18049. export class PredicateCondition extends Condition {
  18050. /** defines the predicate function used to validate the condition */
  18051. predicate: () => boolean;
  18052. /**
  18053. * Internal only - manager for action
  18054. * @hidden
  18055. */
  18056. _actionManager: ActionManager;
  18057. /**
  18058. * Creates a new PredicateCondition
  18059. * @param actionManager manager for the action the condition applies to
  18060. * @param predicate defines the predicate function used to validate the condition
  18061. */
  18062. constructor(actionManager: ActionManager,
  18063. /** defines the predicate function used to validate the condition */
  18064. predicate: () => boolean);
  18065. /**
  18066. * @returns the validity of the predicate condition
  18067. */
  18068. isValid(): boolean;
  18069. }
  18070. /**
  18071. * Defines a state condition as an extension of Condition
  18072. */
  18073. export class StateCondition extends Condition {
  18074. /** Value to compare with target state */
  18075. value: string;
  18076. /**
  18077. * Internal only - manager for action
  18078. * @hidden
  18079. */
  18080. _actionManager: ActionManager;
  18081. /**
  18082. * Internal only
  18083. * @hidden
  18084. */
  18085. private _target;
  18086. /**
  18087. * Creates a new StateCondition
  18088. * @param actionManager manager for the action the condition applies to
  18089. * @param target of the condition
  18090. * @param value to compare with target state
  18091. */
  18092. constructor(actionManager: ActionManager, target: any,
  18093. /** Value to compare with target state */
  18094. value: string);
  18095. /**
  18096. * Gets a boolean indicating if the current condition is met
  18097. * @returns the validity of the state
  18098. */
  18099. isValid(): boolean;
  18100. /**
  18101. * Serialize the StateCondition into a JSON compatible object
  18102. * @returns serialization object
  18103. */
  18104. serialize(): any;
  18105. }
  18106. }
  18107. declare module "babylonjs/Actions/directActions" {
  18108. import { Action } from "babylonjs/Actions/action";
  18109. import { Condition } from "babylonjs/Actions/condition";
  18110. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18111. /**
  18112. * This defines an action responsible to toggle a boolean once triggered.
  18113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18114. */
  18115. export class SwitchBooleanAction extends Action {
  18116. /**
  18117. * The path to the boolean property in the target object
  18118. */
  18119. propertyPath: string;
  18120. private _target;
  18121. private _effectiveTarget;
  18122. private _property;
  18123. /**
  18124. * Instantiate the action
  18125. * @param triggerOptions defines the trigger options
  18126. * @param target defines the object containing the boolean
  18127. * @param propertyPath defines the path to the boolean property in the target object
  18128. * @param condition defines the trigger related conditions
  18129. */
  18130. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18131. /** @hidden */
  18132. _prepare(): void;
  18133. /**
  18134. * Execute the action toggle the boolean value.
  18135. */
  18136. execute(): void;
  18137. /**
  18138. * Serializes the actions and its related information.
  18139. * @param parent defines the object to serialize in
  18140. * @returns the serialized object
  18141. */
  18142. serialize(parent: any): any;
  18143. }
  18144. /**
  18145. * This defines an action responsible to set a the state field of the target
  18146. * to a desired value once triggered.
  18147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18148. */
  18149. export class SetStateAction extends Action {
  18150. /**
  18151. * The value to store in the state field.
  18152. */
  18153. value: string;
  18154. private _target;
  18155. /**
  18156. * Instantiate the action
  18157. * @param triggerOptions defines the trigger options
  18158. * @param target defines the object containing the state property
  18159. * @param value defines the value to store in the state field
  18160. * @param condition defines the trigger related conditions
  18161. */
  18162. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18163. /**
  18164. * Execute the action and store the value on the target state property.
  18165. */
  18166. execute(): void;
  18167. /**
  18168. * Serializes the actions and its related information.
  18169. * @param parent defines the object to serialize in
  18170. * @returns the serialized object
  18171. */
  18172. serialize(parent: any): any;
  18173. }
  18174. /**
  18175. * This defines an action responsible to set a property of the target
  18176. * to a desired value once triggered.
  18177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18178. */
  18179. export class SetValueAction extends Action {
  18180. /**
  18181. * The path of the property to set in the target.
  18182. */
  18183. propertyPath: string;
  18184. /**
  18185. * The value to set in the property
  18186. */
  18187. value: any;
  18188. private _target;
  18189. private _effectiveTarget;
  18190. private _property;
  18191. /**
  18192. * Instantiate the action
  18193. * @param triggerOptions defines the trigger options
  18194. * @param target defines the object containing the property
  18195. * @param propertyPath defines the path of the property to set in the target
  18196. * @param value defines the value to set in the property
  18197. * @param condition defines the trigger related conditions
  18198. */
  18199. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18200. /** @hidden */
  18201. _prepare(): void;
  18202. /**
  18203. * Execute the action and set the targetted property to the desired value.
  18204. */
  18205. execute(): void;
  18206. /**
  18207. * Serializes the actions and its related information.
  18208. * @param parent defines the object to serialize in
  18209. * @returns the serialized object
  18210. */
  18211. serialize(parent: any): any;
  18212. }
  18213. /**
  18214. * This defines an action responsible to increment the target value
  18215. * to a desired value once triggered.
  18216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18217. */
  18218. export class IncrementValueAction extends Action {
  18219. /**
  18220. * The path of the property to increment in the target.
  18221. */
  18222. propertyPath: string;
  18223. /**
  18224. * The value we should increment the property by.
  18225. */
  18226. value: any;
  18227. private _target;
  18228. private _effectiveTarget;
  18229. private _property;
  18230. /**
  18231. * Instantiate the action
  18232. * @param triggerOptions defines the trigger options
  18233. * @param target defines the object containing the property
  18234. * @param propertyPath defines the path of the property to increment in the target
  18235. * @param value defines the value value we should increment the property by
  18236. * @param condition defines the trigger related conditions
  18237. */
  18238. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18239. /** @hidden */
  18240. _prepare(): void;
  18241. /**
  18242. * Execute the action and increment the target of the value amount.
  18243. */
  18244. execute(): void;
  18245. /**
  18246. * Serializes the actions and its related information.
  18247. * @param parent defines the object to serialize in
  18248. * @returns the serialized object
  18249. */
  18250. serialize(parent: any): any;
  18251. }
  18252. /**
  18253. * This defines an action responsible to start an animation once triggered.
  18254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18255. */
  18256. export class PlayAnimationAction extends Action {
  18257. /**
  18258. * Where the animation should start (animation frame)
  18259. */
  18260. from: number;
  18261. /**
  18262. * Where the animation should stop (animation frame)
  18263. */
  18264. to: number;
  18265. /**
  18266. * Define if the animation should loop or stop after the first play.
  18267. */
  18268. loop?: boolean;
  18269. private _target;
  18270. /**
  18271. * Instantiate the action
  18272. * @param triggerOptions defines the trigger options
  18273. * @param target defines the target animation or animation name
  18274. * @param from defines from where the animation should start (animation frame)
  18275. * @param end defines where the animation should stop (animation frame)
  18276. * @param loop defines if the animation should loop or stop after the first play
  18277. * @param condition defines the trigger related conditions
  18278. */
  18279. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18280. /** @hidden */
  18281. _prepare(): void;
  18282. /**
  18283. * Execute the action and play the animation.
  18284. */
  18285. execute(): void;
  18286. /**
  18287. * Serializes the actions and its related information.
  18288. * @param parent defines the object to serialize in
  18289. * @returns the serialized object
  18290. */
  18291. serialize(parent: any): any;
  18292. }
  18293. /**
  18294. * This defines an action responsible to stop an animation once triggered.
  18295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18296. */
  18297. export class StopAnimationAction extends Action {
  18298. private _target;
  18299. /**
  18300. * Instantiate the action
  18301. * @param triggerOptions defines the trigger options
  18302. * @param target defines the target animation or animation name
  18303. * @param condition defines the trigger related conditions
  18304. */
  18305. constructor(triggerOptions: any, target: any, condition?: Condition);
  18306. /** @hidden */
  18307. _prepare(): void;
  18308. /**
  18309. * Execute the action and stop the animation.
  18310. */
  18311. execute(): void;
  18312. /**
  18313. * Serializes the actions and its related information.
  18314. * @param parent defines the object to serialize in
  18315. * @returns the serialized object
  18316. */
  18317. serialize(parent: any): any;
  18318. }
  18319. /**
  18320. * This defines an action responsible that does nothing once triggered.
  18321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18322. */
  18323. export class DoNothingAction extends Action {
  18324. /**
  18325. * Instantiate the action
  18326. * @param triggerOptions defines the trigger options
  18327. * @param condition defines the trigger related conditions
  18328. */
  18329. constructor(triggerOptions?: any, condition?: Condition);
  18330. /**
  18331. * Execute the action and do nothing.
  18332. */
  18333. execute(): void;
  18334. /**
  18335. * Serializes the actions and its related information.
  18336. * @param parent defines the object to serialize in
  18337. * @returns the serialized object
  18338. */
  18339. serialize(parent: any): any;
  18340. }
  18341. /**
  18342. * This defines an action responsible to trigger several actions once triggered.
  18343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18344. */
  18345. export class CombineAction extends Action {
  18346. /**
  18347. * The list of aggregated animations to run.
  18348. */
  18349. children: Action[];
  18350. /**
  18351. * Instantiate the action
  18352. * @param triggerOptions defines the trigger options
  18353. * @param children defines the list of aggregated animations to run
  18354. * @param condition defines the trigger related conditions
  18355. */
  18356. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18357. /** @hidden */
  18358. _prepare(): void;
  18359. /**
  18360. * Execute the action and executes all the aggregated actions.
  18361. */
  18362. execute(evt: ActionEvent): void;
  18363. /**
  18364. * Serializes the actions and its related information.
  18365. * @param parent defines the object to serialize in
  18366. * @returns the serialized object
  18367. */
  18368. serialize(parent: any): any;
  18369. }
  18370. /**
  18371. * This defines an action responsible to run code (external event) once triggered.
  18372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18373. */
  18374. export class ExecuteCodeAction extends Action {
  18375. /**
  18376. * The callback function to run.
  18377. */
  18378. func: (evt: ActionEvent) => void;
  18379. /**
  18380. * Instantiate the action
  18381. * @param triggerOptions defines the trigger options
  18382. * @param func defines the callback function to run
  18383. * @param condition defines the trigger related conditions
  18384. */
  18385. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18386. /**
  18387. * Execute the action and run the attached code.
  18388. */
  18389. execute(evt: ActionEvent): void;
  18390. }
  18391. /**
  18392. * This defines an action responsible to set the parent property of the target once triggered.
  18393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18394. */
  18395. export class SetParentAction extends Action {
  18396. private _parent;
  18397. private _target;
  18398. /**
  18399. * Instantiate the action
  18400. * @param triggerOptions defines the trigger options
  18401. * @param target defines the target containing the parent property
  18402. * @param parent defines from where the animation should start (animation frame)
  18403. * @param condition defines the trigger related conditions
  18404. */
  18405. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18406. /** @hidden */
  18407. _prepare(): void;
  18408. /**
  18409. * Execute the action and set the parent property.
  18410. */
  18411. execute(): void;
  18412. /**
  18413. * Serializes the actions and its related information.
  18414. * @param parent defines the object to serialize in
  18415. * @returns the serialized object
  18416. */
  18417. serialize(parent: any): any;
  18418. }
  18419. }
  18420. declare module "babylonjs/Actions/actionManager" {
  18421. import { Nullable } from "babylonjs/types";
  18422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18423. import { Scene } from "babylonjs/scene";
  18424. import { IAction } from "babylonjs/Actions/action";
  18425. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18426. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18427. /**
  18428. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18429. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18431. */
  18432. export class ActionManager extends AbstractActionManager {
  18433. /**
  18434. * Nothing
  18435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18436. */
  18437. static readonly NothingTrigger: number;
  18438. /**
  18439. * On pick
  18440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18441. */
  18442. static readonly OnPickTrigger: number;
  18443. /**
  18444. * On left pick
  18445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18446. */
  18447. static readonly OnLeftPickTrigger: number;
  18448. /**
  18449. * On right pick
  18450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18451. */
  18452. static readonly OnRightPickTrigger: number;
  18453. /**
  18454. * On center pick
  18455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18456. */
  18457. static readonly OnCenterPickTrigger: number;
  18458. /**
  18459. * On pick down
  18460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18461. */
  18462. static readonly OnPickDownTrigger: number;
  18463. /**
  18464. * On double pick
  18465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18466. */
  18467. static readonly OnDoublePickTrigger: number;
  18468. /**
  18469. * On pick up
  18470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18471. */
  18472. static readonly OnPickUpTrigger: number;
  18473. /**
  18474. * On pick out.
  18475. * This trigger will only be raised if you also declared a OnPickDown
  18476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18477. */
  18478. static readonly OnPickOutTrigger: number;
  18479. /**
  18480. * On long press
  18481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18482. */
  18483. static readonly OnLongPressTrigger: number;
  18484. /**
  18485. * On pointer over
  18486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18487. */
  18488. static readonly OnPointerOverTrigger: number;
  18489. /**
  18490. * On pointer out
  18491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18492. */
  18493. static readonly OnPointerOutTrigger: number;
  18494. /**
  18495. * On every frame
  18496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18497. */
  18498. static readonly OnEveryFrameTrigger: number;
  18499. /**
  18500. * On intersection enter
  18501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18502. */
  18503. static readonly OnIntersectionEnterTrigger: number;
  18504. /**
  18505. * On intersection exit
  18506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18507. */
  18508. static readonly OnIntersectionExitTrigger: number;
  18509. /**
  18510. * On key down
  18511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18512. */
  18513. static readonly OnKeyDownTrigger: number;
  18514. /**
  18515. * On key up
  18516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18517. */
  18518. static readonly OnKeyUpTrigger: number;
  18519. private _scene;
  18520. /**
  18521. * Creates a new action manager
  18522. * @param scene defines the hosting scene
  18523. */
  18524. constructor(scene: Scene);
  18525. /**
  18526. * Releases all associated resources
  18527. */
  18528. dispose(): void;
  18529. /**
  18530. * Gets hosting scene
  18531. * @returns the hosting scene
  18532. */
  18533. getScene(): Scene;
  18534. /**
  18535. * Does this action manager handles actions of any of the given triggers
  18536. * @param triggers defines the triggers to be tested
  18537. * @return a boolean indicating whether one (or more) of the triggers is handled
  18538. */
  18539. hasSpecificTriggers(triggers: number[]): boolean;
  18540. /**
  18541. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18542. * speed.
  18543. * @param triggerA defines the trigger to be tested
  18544. * @param triggerB defines the trigger to be tested
  18545. * @return a boolean indicating whether one (or more) of the triggers is handled
  18546. */
  18547. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18548. /**
  18549. * Does this action manager handles actions of a given trigger
  18550. * @param trigger defines the trigger to be tested
  18551. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18552. * @return whether the trigger is handled
  18553. */
  18554. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18555. /**
  18556. * Does this action manager has pointer triggers
  18557. */
  18558. get hasPointerTriggers(): boolean;
  18559. /**
  18560. * Does this action manager has pick triggers
  18561. */
  18562. get hasPickTriggers(): boolean;
  18563. /**
  18564. * Registers an action to this action manager
  18565. * @param action defines the action to be registered
  18566. * @return the action amended (prepared) after registration
  18567. */
  18568. registerAction(action: IAction): Nullable<IAction>;
  18569. /**
  18570. * Unregisters an action to this action manager
  18571. * @param action defines the action to be unregistered
  18572. * @return a boolean indicating whether the action has been unregistered
  18573. */
  18574. unregisterAction(action: IAction): Boolean;
  18575. /**
  18576. * Process a specific trigger
  18577. * @param trigger defines the trigger to process
  18578. * @param evt defines the event details to be processed
  18579. */
  18580. processTrigger(trigger: number, evt?: IActionEvent): void;
  18581. /** @hidden */
  18582. _getEffectiveTarget(target: any, propertyPath: string): any;
  18583. /** @hidden */
  18584. _getProperty(propertyPath: string): string;
  18585. /**
  18586. * Serialize this manager to a JSON object
  18587. * @param name defines the property name to store this manager
  18588. * @returns a JSON representation of this manager
  18589. */
  18590. serialize(name: string): any;
  18591. /**
  18592. * Creates a new ActionManager from a JSON data
  18593. * @param parsedActions defines the JSON data to read from
  18594. * @param object defines the hosting mesh
  18595. * @param scene defines the hosting scene
  18596. */
  18597. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18598. /**
  18599. * Get a trigger name by index
  18600. * @param trigger defines the trigger index
  18601. * @returns a trigger name
  18602. */
  18603. static GetTriggerName(trigger: number): string;
  18604. }
  18605. }
  18606. declare module "babylonjs/Sprites/sprite" {
  18607. import { Vector3 } from "babylonjs/Maths/math.vector";
  18608. import { Nullable } from "babylonjs/types";
  18609. import { ActionManager } from "babylonjs/Actions/actionManager";
  18610. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18611. import { Color4 } from "babylonjs/Maths/math.color";
  18612. /**
  18613. * Class used to represent a sprite
  18614. * @see http://doc.babylonjs.com/babylon101/sprites
  18615. */
  18616. export class Sprite {
  18617. /** defines the name */
  18618. name: string;
  18619. /** Gets or sets the current world position */
  18620. position: Vector3;
  18621. /** Gets or sets the main color */
  18622. color: Color4;
  18623. /** Gets or sets the width */
  18624. width: number;
  18625. /** Gets or sets the height */
  18626. height: number;
  18627. /** Gets or sets rotation angle */
  18628. angle: number;
  18629. /** Gets or sets the cell index in the sprite sheet */
  18630. cellIndex: number;
  18631. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18632. cellRef: string;
  18633. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18634. invertU: number;
  18635. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18636. invertV: number;
  18637. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18638. disposeWhenFinishedAnimating: boolean;
  18639. /** Gets the list of attached animations */
  18640. animations: Animation[];
  18641. /** Gets or sets a boolean indicating if the sprite can be picked */
  18642. isPickable: boolean;
  18643. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18644. useAlphaForPicking: boolean;
  18645. /** @hidden */
  18646. _xOffset: number;
  18647. /** @hidden */
  18648. _yOffset: number;
  18649. /** @hidden */
  18650. _xSize: number;
  18651. /** @hidden */
  18652. _ySize: number;
  18653. /**
  18654. * Gets or sets the associated action manager
  18655. */
  18656. actionManager: Nullable<ActionManager>;
  18657. private _animationStarted;
  18658. private _loopAnimation;
  18659. private _fromIndex;
  18660. private _toIndex;
  18661. private _delay;
  18662. private _direction;
  18663. private _manager;
  18664. private _time;
  18665. private _onAnimationEnd;
  18666. /**
  18667. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18668. */
  18669. isVisible: boolean;
  18670. /**
  18671. * Gets or sets the sprite size
  18672. */
  18673. get size(): number;
  18674. set size(value: number);
  18675. /**
  18676. * Creates a new Sprite
  18677. * @param name defines the name
  18678. * @param manager defines the manager
  18679. */
  18680. constructor(
  18681. /** defines the name */
  18682. name: string, manager: ISpriteManager);
  18683. /**
  18684. * Starts an animation
  18685. * @param from defines the initial key
  18686. * @param to defines the end key
  18687. * @param loop defines if the animation must loop
  18688. * @param delay defines the start delay (in ms)
  18689. * @param onAnimationEnd defines a callback to call when animation ends
  18690. */
  18691. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18692. /** Stops current animation (if any) */
  18693. stopAnimation(): void;
  18694. /** @hidden */
  18695. _animate(deltaTime: number): void;
  18696. /** Release associated resources */
  18697. dispose(): void;
  18698. }
  18699. }
  18700. declare module "babylonjs/Collisions/pickingInfo" {
  18701. import { Nullable } from "babylonjs/types";
  18702. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18704. import { Sprite } from "babylonjs/Sprites/sprite";
  18705. import { Ray } from "babylonjs/Culling/ray";
  18706. /**
  18707. * Information about the result of picking within a scene
  18708. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18709. */
  18710. export class PickingInfo {
  18711. /** @hidden */
  18712. _pickingUnavailable: boolean;
  18713. /**
  18714. * If the pick collided with an object
  18715. */
  18716. hit: boolean;
  18717. /**
  18718. * Distance away where the pick collided
  18719. */
  18720. distance: number;
  18721. /**
  18722. * The location of pick collision
  18723. */
  18724. pickedPoint: Nullable<Vector3>;
  18725. /**
  18726. * The mesh corresponding the the pick collision
  18727. */
  18728. pickedMesh: Nullable<AbstractMesh>;
  18729. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18730. bu: number;
  18731. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18732. bv: number;
  18733. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18734. faceId: number;
  18735. /** Id of the the submesh that was picked */
  18736. subMeshId: number;
  18737. /** If a sprite was picked, this will be the sprite the pick collided with */
  18738. pickedSprite: Nullable<Sprite>;
  18739. /**
  18740. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18741. */
  18742. originMesh: Nullable<AbstractMesh>;
  18743. /**
  18744. * The ray that was used to perform the picking.
  18745. */
  18746. ray: Nullable<Ray>;
  18747. /**
  18748. * Gets the normal correspodning to the face the pick collided with
  18749. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18750. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18751. * @returns The normal correspodning to the face the pick collided with
  18752. */
  18753. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18754. /**
  18755. * Gets the texture coordinates of where the pick occured
  18756. * @returns the vector containing the coordnates of the texture
  18757. */
  18758. getTextureCoordinates(): Nullable<Vector2>;
  18759. }
  18760. }
  18761. declare module "babylonjs/Events/pointerEvents" {
  18762. import { Nullable } from "babylonjs/types";
  18763. import { Vector2 } from "babylonjs/Maths/math.vector";
  18764. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18765. import { Ray } from "babylonjs/Culling/ray";
  18766. /**
  18767. * Gather the list of pointer event types as constants.
  18768. */
  18769. export class PointerEventTypes {
  18770. /**
  18771. * 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.
  18772. */
  18773. static readonly POINTERDOWN: number;
  18774. /**
  18775. * The pointerup event is fired when a pointer is no longer active.
  18776. */
  18777. static readonly POINTERUP: number;
  18778. /**
  18779. * The pointermove event is fired when a pointer changes coordinates.
  18780. */
  18781. static readonly POINTERMOVE: number;
  18782. /**
  18783. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18784. */
  18785. static readonly POINTERWHEEL: number;
  18786. /**
  18787. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18788. */
  18789. static readonly POINTERPICK: number;
  18790. /**
  18791. * The pointertap event is fired when a the object has been touched and released without drag.
  18792. */
  18793. static readonly POINTERTAP: number;
  18794. /**
  18795. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18796. */
  18797. static readonly POINTERDOUBLETAP: number;
  18798. }
  18799. /**
  18800. * Base class of pointer info types.
  18801. */
  18802. export class PointerInfoBase {
  18803. /**
  18804. * Defines the type of event (PointerEventTypes)
  18805. */
  18806. type: number;
  18807. /**
  18808. * Defines the related dom event
  18809. */
  18810. event: PointerEvent | MouseWheelEvent;
  18811. /**
  18812. * Instantiates the base class of pointers info.
  18813. * @param type Defines the type of event (PointerEventTypes)
  18814. * @param event Defines the related dom event
  18815. */
  18816. constructor(
  18817. /**
  18818. * Defines the type of event (PointerEventTypes)
  18819. */
  18820. type: number,
  18821. /**
  18822. * Defines the related dom event
  18823. */
  18824. event: PointerEvent | MouseWheelEvent);
  18825. }
  18826. /**
  18827. * This class is used to store pointer related info for the onPrePointerObservable event.
  18828. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18829. */
  18830. export class PointerInfoPre extends PointerInfoBase {
  18831. /**
  18832. * Ray from a pointer if availible (eg. 6dof controller)
  18833. */
  18834. ray: Nullable<Ray>;
  18835. /**
  18836. * Defines the local position of the pointer on the canvas.
  18837. */
  18838. localPosition: Vector2;
  18839. /**
  18840. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18841. */
  18842. skipOnPointerObservable: boolean;
  18843. /**
  18844. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18845. * @param type Defines the type of event (PointerEventTypes)
  18846. * @param event Defines the related dom event
  18847. * @param localX Defines the local x coordinates of the pointer when the event occured
  18848. * @param localY Defines the local y coordinates of the pointer when the event occured
  18849. */
  18850. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18851. }
  18852. /**
  18853. * This type contains all the data related to a pointer event in Babylon.js.
  18854. * 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.
  18855. */
  18856. export class PointerInfo extends PointerInfoBase {
  18857. /**
  18858. * Defines the picking info associated to the info (if any)\
  18859. */
  18860. pickInfo: Nullable<PickingInfo>;
  18861. /**
  18862. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18863. * @param type Defines the type of event (PointerEventTypes)
  18864. * @param event Defines the related dom event
  18865. * @param pickInfo Defines the picking info associated to the info (if any)\
  18866. */
  18867. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18868. /**
  18869. * Defines the picking info associated to the info (if any)\
  18870. */
  18871. pickInfo: Nullable<PickingInfo>);
  18872. }
  18873. /**
  18874. * Data relating to a touch event on the screen.
  18875. */
  18876. export interface PointerTouch {
  18877. /**
  18878. * X coordinate of touch.
  18879. */
  18880. x: number;
  18881. /**
  18882. * Y coordinate of touch.
  18883. */
  18884. y: number;
  18885. /**
  18886. * Id of touch. Unique for each finger.
  18887. */
  18888. pointerId: number;
  18889. /**
  18890. * Event type passed from DOM.
  18891. */
  18892. type: any;
  18893. }
  18894. }
  18895. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18896. import { Observable } from "babylonjs/Misc/observable";
  18897. import { Nullable } from "babylonjs/types";
  18898. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18899. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18900. /**
  18901. * Manage the mouse inputs to control the movement of a free camera.
  18902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18903. */
  18904. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18905. /**
  18906. * Define if touch is enabled in the mouse input
  18907. */
  18908. touchEnabled: boolean;
  18909. /**
  18910. * Defines the camera the input is attached to.
  18911. */
  18912. camera: FreeCamera;
  18913. /**
  18914. * Defines the buttons associated with the input to handle camera move.
  18915. */
  18916. buttons: number[];
  18917. /**
  18918. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18919. */
  18920. angularSensibility: number;
  18921. private _pointerInput;
  18922. private _onMouseMove;
  18923. private _observer;
  18924. private previousPosition;
  18925. /**
  18926. * Observable for when a pointer move event occurs containing the move offset
  18927. */
  18928. onPointerMovedObservable: Observable<{
  18929. offsetX: number;
  18930. offsetY: number;
  18931. }>;
  18932. /**
  18933. * @hidden
  18934. * If the camera should be rotated automatically based on pointer movement
  18935. */
  18936. _allowCameraRotation: boolean;
  18937. /**
  18938. * Manage the mouse inputs to control the movement of a free camera.
  18939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18940. * @param touchEnabled Defines if touch is enabled or not
  18941. */
  18942. constructor(
  18943. /**
  18944. * Define if touch is enabled in the mouse input
  18945. */
  18946. touchEnabled?: boolean);
  18947. /**
  18948. * Attach the input controls to a specific dom element to get the input from.
  18949. * @param element Defines the element the controls should be listened from
  18950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18951. */
  18952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18953. /**
  18954. * Called on JS contextmenu event.
  18955. * Override this method to provide functionality.
  18956. */
  18957. protected onContextMenu(evt: PointerEvent): void;
  18958. /**
  18959. * Detach the current controls from the specified dom element.
  18960. * @param element Defines the element to stop listening the inputs from
  18961. */
  18962. detachControl(element: Nullable<HTMLElement>): void;
  18963. /**
  18964. * Gets the class name of the current intput.
  18965. * @returns the class name
  18966. */
  18967. getClassName(): string;
  18968. /**
  18969. * Get the friendly name associated with the input class.
  18970. * @returns the input friendly name
  18971. */
  18972. getSimpleName(): string;
  18973. }
  18974. }
  18975. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18976. import { Nullable } from "babylonjs/types";
  18977. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18979. /**
  18980. * Manage the touch inputs to control the movement of a free camera.
  18981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18982. */
  18983. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18984. /**
  18985. * Defines the camera the input is attached to.
  18986. */
  18987. camera: FreeCamera;
  18988. /**
  18989. * Defines the touch sensibility for rotation.
  18990. * The higher the faster.
  18991. */
  18992. touchAngularSensibility: number;
  18993. /**
  18994. * Defines the touch sensibility for move.
  18995. * The higher the faster.
  18996. */
  18997. touchMoveSensibility: number;
  18998. private _offsetX;
  18999. private _offsetY;
  19000. private _pointerPressed;
  19001. private _pointerInput;
  19002. private _observer;
  19003. private _onLostFocus;
  19004. /**
  19005. * Attach the input controls to a specific dom element to get the input from.
  19006. * @param element Defines the element the controls should be listened from
  19007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19008. */
  19009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19010. /**
  19011. * Detach the current controls from the specified dom element.
  19012. * @param element Defines the element to stop listening the inputs from
  19013. */
  19014. detachControl(element: Nullable<HTMLElement>): void;
  19015. /**
  19016. * Update the current camera state depending on the inputs that have been used this frame.
  19017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19018. */
  19019. checkInputs(): void;
  19020. /**
  19021. * Gets the class name of the current intput.
  19022. * @returns the class name
  19023. */
  19024. getClassName(): string;
  19025. /**
  19026. * Get the friendly name associated with the input class.
  19027. * @returns the input friendly name
  19028. */
  19029. getSimpleName(): string;
  19030. }
  19031. }
  19032. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19033. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19034. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19035. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19036. import { Nullable } from "babylonjs/types";
  19037. /**
  19038. * Default Inputs manager for the FreeCamera.
  19039. * It groups all the default supported inputs for ease of use.
  19040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19041. */
  19042. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19043. /**
  19044. * @hidden
  19045. */
  19046. _mouseInput: Nullable<FreeCameraMouseInput>;
  19047. /**
  19048. * Instantiates a new FreeCameraInputsManager.
  19049. * @param camera Defines the camera the inputs belong to
  19050. */
  19051. constructor(camera: FreeCamera);
  19052. /**
  19053. * Add keyboard input support to the input manager.
  19054. * @returns the current input manager
  19055. */
  19056. addKeyboard(): FreeCameraInputsManager;
  19057. /**
  19058. * Add mouse input support to the input manager.
  19059. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19060. * @returns the current input manager
  19061. */
  19062. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19063. /**
  19064. * Removes the mouse input support from the manager
  19065. * @returns the current input manager
  19066. */
  19067. removeMouse(): FreeCameraInputsManager;
  19068. /**
  19069. * Add touch input support to the input manager.
  19070. * @returns the current input manager
  19071. */
  19072. addTouch(): FreeCameraInputsManager;
  19073. /**
  19074. * Remove all attached input methods from a camera
  19075. */
  19076. clear(): void;
  19077. }
  19078. }
  19079. declare module "babylonjs/Cameras/freeCamera" {
  19080. import { Vector3 } from "babylonjs/Maths/math.vector";
  19081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19082. import { Scene } from "babylonjs/scene";
  19083. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19084. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19085. /**
  19086. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19087. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19088. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19089. */
  19090. export class FreeCamera extends TargetCamera {
  19091. /**
  19092. * Define the collision ellipsoid of the camera.
  19093. * This is helpful to simulate a camera body like the player body around the camera
  19094. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19095. */
  19096. ellipsoid: Vector3;
  19097. /**
  19098. * Define an offset for the position of the ellipsoid around the camera.
  19099. * This can be helpful to determine the center of the body near the gravity center of the body
  19100. * instead of its head.
  19101. */
  19102. ellipsoidOffset: Vector3;
  19103. /**
  19104. * Enable or disable collisions of the camera with the rest of the scene objects.
  19105. */
  19106. checkCollisions: boolean;
  19107. /**
  19108. * Enable or disable gravity on the camera.
  19109. */
  19110. applyGravity: boolean;
  19111. /**
  19112. * Define the input manager associated to the camera.
  19113. */
  19114. inputs: FreeCameraInputsManager;
  19115. /**
  19116. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19117. * Higher values reduce sensitivity.
  19118. */
  19119. get angularSensibility(): number;
  19120. /**
  19121. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19122. * Higher values reduce sensitivity.
  19123. */
  19124. set angularSensibility(value: number);
  19125. /**
  19126. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19127. */
  19128. get keysUp(): number[];
  19129. set keysUp(value: number[]);
  19130. /**
  19131. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19132. */
  19133. get keysUpward(): number[];
  19134. set keysUpward(value: number[]);
  19135. /**
  19136. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19137. */
  19138. get keysDown(): number[];
  19139. set keysDown(value: number[]);
  19140. /**
  19141. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19142. */
  19143. get keysDownward(): number[];
  19144. set keysDownward(value: number[]);
  19145. /**
  19146. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19147. */
  19148. get keysLeft(): number[];
  19149. set keysLeft(value: number[]);
  19150. /**
  19151. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19152. */
  19153. get keysRight(): number[];
  19154. set keysRight(value: number[]);
  19155. /**
  19156. * Event raised when the camera collide with a mesh in the scene.
  19157. */
  19158. onCollide: (collidedMesh: AbstractMesh) => void;
  19159. private _collider;
  19160. private _needMoveForGravity;
  19161. private _oldPosition;
  19162. private _diffPosition;
  19163. private _newPosition;
  19164. /** @hidden */
  19165. _localDirection: Vector3;
  19166. /** @hidden */
  19167. _transformedDirection: Vector3;
  19168. /**
  19169. * Instantiates a Free Camera.
  19170. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19171. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19172. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19173. * @param name Define the name of the camera in the scene
  19174. * @param position Define the start position of the camera in the scene
  19175. * @param scene Define the scene the camera belongs to
  19176. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19177. */
  19178. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19179. /**
  19180. * Attached controls to the current camera.
  19181. * @param element Defines the element the controls should be listened from
  19182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19183. */
  19184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19185. /**
  19186. * Detach the current controls from the camera.
  19187. * The camera will stop reacting to inputs.
  19188. * @param element Defines the element to stop listening the inputs from
  19189. */
  19190. detachControl(element: HTMLElement): void;
  19191. private _collisionMask;
  19192. /**
  19193. * Define a collision mask to limit the list of object the camera can collide with
  19194. */
  19195. get collisionMask(): number;
  19196. set collisionMask(mask: number);
  19197. /** @hidden */
  19198. _collideWithWorld(displacement: Vector3): void;
  19199. private _onCollisionPositionChange;
  19200. /** @hidden */
  19201. _checkInputs(): void;
  19202. /** @hidden */
  19203. _decideIfNeedsToMove(): boolean;
  19204. /** @hidden */
  19205. _updatePosition(): void;
  19206. /**
  19207. * Destroy the camera and release the current resources hold by it.
  19208. */
  19209. dispose(): void;
  19210. /**
  19211. * Gets the current object class name.
  19212. * @return the class name
  19213. */
  19214. getClassName(): string;
  19215. }
  19216. }
  19217. declare module "babylonjs/Gamepads/gamepad" {
  19218. import { Observable } from "babylonjs/Misc/observable";
  19219. /**
  19220. * Represents a gamepad control stick position
  19221. */
  19222. export class StickValues {
  19223. /**
  19224. * The x component of the control stick
  19225. */
  19226. x: number;
  19227. /**
  19228. * The y component of the control stick
  19229. */
  19230. y: number;
  19231. /**
  19232. * Initializes the gamepad x and y control stick values
  19233. * @param x The x component of the gamepad control stick value
  19234. * @param y The y component of the gamepad control stick value
  19235. */
  19236. constructor(
  19237. /**
  19238. * The x component of the control stick
  19239. */
  19240. x: number,
  19241. /**
  19242. * The y component of the control stick
  19243. */
  19244. y: number);
  19245. }
  19246. /**
  19247. * An interface which manages callbacks for gamepad button changes
  19248. */
  19249. export interface GamepadButtonChanges {
  19250. /**
  19251. * Called when a gamepad has been changed
  19252. */
  19253. changed: boolean;
  19254. /**
  19255. * Called when a gamepad press event has been triggered
  19256. */
  19257. pressChanged: boolean;
  19258. /**
  19259. * Called when a touch event has been triggered
  19260. */
  19261. touchChanged: boolean;
  19262. /**
  19263. * Called when a value has changed
  19264. */
  19265. valueChanged: boolean;
  19266. }
  19267. /**
  19268. * Represents a gamepad
  19269. */
  19270. export class Gamepad {
  19271. /**
  19272. * The id of the gamepad
  19273. */
  19274. id: string;
  19275. /**
  19276. * The index of the gamepad
  19277. */
  19278. index: number;
  19279. /**
  19280. * The browser gamepad
  19281. */
  19282. browserGamepad: any;
  19283. /**
  19284. * Specifies what type of gamepad this represents
  19285. */
  19286. type: number;
  19287. private _leftStick;
  19288. private _rightStick;
  19289. /** @hidden */
  19290. _isConnected: boolean;
  19291. private _leftStickAxisX;
  19292. private _leftStickAxisY;
  19293. private _rightStickAxisX;
  19294. private _rightStickAxisY;
  19295. /**
  19296. * Triggered when the left control stick has been changed
  19297. */
  19298. private _onleftstickchanged;
  19299. /**
  19300. * Triggered when the right control stick has been changed
  19301. */
  19302. private _onrightstickchanged;
  19303. /**
  19304. * Represents a gamepad controller
  19305. */
  19306. static GAMEPAD: number;
  19307. /**
  19308. * Represents a generic controller
  19309. */
  19310. static GENERIC: number;
  19311. /**
  19312. * Represents an XBox controller
  19313. */
  19314. static XBOX: number;
  19315. /**
  19316. * Represents a pose-enabled controller
  19317. */
  19318. static POSE_ENABLED: number;
  19319. /**
  19320. * Represents an Dual Shock controller
  19321. */
  19322. static DUALSHOCK: number;
  19323. /**
  19324. * Specifies whether the left control stick should be Y-inverted
  19325. */
  19326. protected _invertLeftStickY: boolean;
  19327. /**
  19328. * Specifies if the gamepad has been connected
  19329. */
  19330. get isConnected(): boolean;
  19331. /**
  19332. * Initializes the gamepad
  19333. * @param id The id of the gamepad
  19334. * @param index The index of the gamepad
  19335. * @param browserGamepad The browser gamepad
  19336. * @param leftStickX The x component of the left joystick
  19337. * @param leftStickY The y component of the left joystick
  19338. * @param rightStickX The x component of the right joystick
  19339. * @param rightStickY The y component of the right joystick
  19340. */
  19341. constructor(
  19342. /**
  19343. * The id of the gamepad
  19344. */
  19345. id: string,
  19346. /**
  19347. * The index of the gamepad
  19348. */
  19349. index: number,
  19350. /**
  19351. * The browser gamepad
  19352. */
  19353. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19354. /**
  19355. * Callback triggered when the left joystick has changed
  19356. * @param callback
  19357. */
  19358. onleftstickchanged(callback: (values: StickValues) => void): void;
  19359. /**
  19360. * Callback triggered when the right joystick has changed
  19361. * @param callback
  19362. */
  19363. onrightstickchanged(callback: (values: StickValues) => void): void;
  19364. /**
  19365. * Gets the left joystick
  19366. */
  19367. get leftStick(): StickValues;
  19368. /**
  19369. * Sets the left joystick values
  19370. */
  19371. set leftStick(newValues: StickValues);
  19372. /**
  19373. * Gets the right joystick
  19374. */
  19375. get rightStick(): StickValues;
  19376. /**
  19377. * Sets the right joystick value
  19378. */
  19379. set rightStick(newValues: StickValues);
  19380. /**
  19381. * Updates the gamepad joystick positions
  19382. */
  19383. update(): void;
  19384. /**
  19385. * Disposes the gamepad
  19386. */
  19387. dispose(): void;
  19388. }
  19389. /**
  19390. * Represents a generic gamepad
  19391. */
  19392. export class GenericPad extends Gamepad {
  19393. private _buttons;
  19394. private _onbuttondown;
  19395. private _onbuttonup;
  19396. /**
  19397. * Observable triggered when a button has been pressed
  19398. */
  19399. onButtonDownObservable: Observable<number>;
  19400. /**
  19401. * Observable triggered when a button has been released
  19402. */
  19403. onButtonUpObservable: Observable<number>;
  19404. /**
  19405. * Callback triggered when a button has been pressed
  19406. * @param callback Called when a button has been pressed
  19407. */
  19408. onbuttondown(callback: (buttonPressed: number) => void): void;
  19409. /**
  19410. * Callback triggered when a button has been released
  19411. * @param callback Called when a button has been released
  19412. */
  19413. onbuttonup(callback: (buttonReleased: number) => void): void;
  19414. /**
  19415. * Initializes the generic gamepad
  19416. * @param id The id of the generic gamepad
  19417. * @param index The index of the generic gamepad
  19418. * @param browserGamepad The browser gamepad
  19419. */
  19420. constructor(id: string, index: number, browserGamepad: any);
  19421. private _setButtonValue;
  19422. /**
  19423. * Updates the generic gamepad
  19424. */
  19425. update(): void;
  19426. /**
  19427. * Disposes the generic gamepad
  19428. */
  19429. dispose(): void;
  19430. }
  19431. }
  19432. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19433. import { Observable } from "babylonjs/Misc/observable";
  19434. import { Nullable } from "babylonjs/types";
  19435. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19436. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19438. import { Ray } from "babylonjs/Culling/ray";
  19439. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19440. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19441. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19442. /**
  19443. * Defines the types of pose enabled controllers that are supported
  19444. */
  19445. export enum PoseEnabledControllerType {
  19446. /**
  19447. * HTC Vive
  19448. */
  19449. VIVE = 0,
  19450. /**
  19451. * Oculus Rift
  19452. */
  19453. OCULUS = 1,
  19454. /**
  19455. * Windows mixed reality
  19456. */
  19457. WINDOWS = 2,
  19458. /**
  19459. * Samsung gear VR
  19460. */
  19461. GEAR_VR = 3,
  19462. /**
  19463. * Google Daydream
  19464. */
  19465. DAYDREAM = 4,
  19466. /**
  19467. * Generic
  19468. */
  19469. GENERIC = 5
  19470. }
  19471. /**
  19472. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19473. */
  19474. export interface MutableGamepadButton {
  19475. /**
  19476. * Value of the button/trigger
  19477. */
  19478. value: number;
  19479. /**
  19480. * If the button/trigger is currently touched
  19481. */
  19482. touched: boolean;
  19483. /**
  19484. * If the button/trigger is currently pressed
  19485. */
  19486. pressed: boolean;
  19487. }
  19488. /**
  19489. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19490. * @hidden
  19491. */
  19492. export interface ExtendedGamepadButton extends GamepadButton {
  19493. /**
  19494. * If the button/trigger is currently pressed
  19495. */
  19496. readonly pressed: boolean;
  19497. /**
  19498. * If the button/trigger is currently touched
  19499. */
  19500. readonly touched: boolean;
  19501. /**
  19502. * Value of the button/trigger
  19503. */
  19504. readonly value: number;
  19505. }
  19506. /** @hidden */
  19507. export interface _GamePadFactory {
  19508. /**
  19509. * Returns whether or not the current gamepad can be created for this type of controller.
  19510. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19511. * @returns true if it can be created, otherwise false
  19512. */
  19513. canCreate(gamepadInfo: any): boolean;
  19514. /**
  19515. * Creates a new instance of the Gamepad.
  19516. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19517. * @returns the new gamepad instance
  19518. */
  19519. create(gamepadInfo: any): Gamepad;
  19520. }
  19521. /**
  19522. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19523. */
  19524. export class PoseEnabledControllerHelper {
  19525. /** @hidden */
  19526. static _ControllerFactories: _GamePadFactory[];
  19527. /** @hidden */
  19528. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19529. /**
  19530. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19531. * @param vrGamepad the gamepad to initialized
  19532. * @returns a vr controller of the type the gamepad identified as
  19533. */
  19534. static InitiateController(vrGamepad: any): Gamepad;
  19535. }
  19536. /**
  19537. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19538. */
  19539. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19540. /**
  19541. * If the controller is used in a webXR session
  19542. */
  19543. isXR: boolean;
  19544. private _deviceRoomPosition;
  19545. private _deviceRoomRotationQuaternion;
  19546. /**
  19547. * The device position in babylon space
  19548. */
  19549. devicePosition: Vector3;
  19550. /**
  19551. * The device rotation in babylon space
  19552. */
  19553. deviceRotationQuaternion: Quaternion;
  19554. /**
  19555. * The scale factor of the device in babylon space
  19556. */
  19557. deviceScaleFactor: number;
  19558. /**
  19559. * (Likely devicePosition should be used instead) The device position in its room space
  19560. */
  19561. position: Vector3;
  19562. /**
  19563. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19564. */
  19565. rotationQuaternion: Quaternion;
  19566. /**
  19567. * The type of controller (Eg. Windows mixed reality)
  19568. */
  19569. controllerType: PoseEnabledControllerType;
  19570. protected _calculatedPosition: Vector3;
  19571. private _calculatedRotation;
  19572. /**
  19573. * The raw pose from the device
  19574. */
  19575. rawPose: DevicePose;
  19576. private _trackPosition;
  19577. private _maxRotationDistFromHeadset;
  19578. private _draggedRoomRotation;
  19579. /**
  19580. * @hidden
  19581. */
  19582. _disableTrackPosition(fixedPosition: Vector3): void;
  19583. /**
  19584. * Internal, the mesh attached to the controller
  19585. * @hidden
  19586. */
  19587. _mesh: Nullable<AbstractMesh>;
  19588. private _poseControlledCamera;
  19589. private _leftHandSystemQuaternion;
  19590. /**
  19591. * Internal, matrix used to convert room space to babylon space
  19592. * @hidden
  19593. */
  19594. _deviceToWorld: Matrix;
  19595. /**
  19596. * Node to be used when casting a ray from the controller
  19597. * @hidden
  19598. */
  19599. _pointingPoseNode: Nullable<TransformNode>;
  19600. /**
  19601. * Name of the child mesh that can be used to cast a ray from the controller
  19602. */
  19603. static readonly POINTING_POSE: string;
  19604. /**
  19605. * Creates a new PoseEnabledController from a gamepad
  19606. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19607. */
  19608. constructor(browserGamepad: any);
  19609. private _workingMatrix;
  19610. /**
  19611. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19612. */
  19613. update(): void;
  19614. /**
  19615. * Updates only the pose device and mesh without doing any button event checking
  19616. */
  19617. protected _updatePoseAndMesh(): void;
  19618. /**
  19619. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19620. * @param poseData raw pose fromthe device
  19621. */
  19622. updateFromDevice(poseData: DevicePose): void;
  19623. /**
  19624. * @hidden
  19625. */
  19626. _meshAttachedObservable: Observable<AbstractMesh>;
  19627. /**
  19628. * Attaches a mesh to the controller
  19629. * @param mesh the mesh to be attached
  19630. */
  19631. attachToMesh(mesh: AbstractMesh): void;
  19632. /**
  19633. * Attaches the controllers mesh to a camera
  19634. * @param camera the camera the mesh should be attached to
  19635. */
  19636. attachToPoseControlledCamera(camera: TargetCamera): void;
  19637. /**
  19638. * Disposes of the controller
  19639. */
  19640. dispose(): void;
  19641. /**
  19642. * The mesh that is attached to the controller
  19643. */
  19644. get mesh(): Nullable<AbstractMesh>;
  19645. /**
  19646. * Gets the ray of the controller in the direction the controller is pointing
  19647. * @param length the length the resulting ray should be
  19648. * @returns a ray in the direction the controller is pointing
  19649. */
  19650. getForwardRay(length?: number): Ray;
  19651. }
  19652. }
  19653. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19654. import { Observable } from "babylonjs/Misc/observable";
  19655. import { Scene } from "babylonjs/scene";
  19656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19657. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19658. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19659. import { Nullable } from "babylonjs/types";
  19660. /**
  19661. * Defines the WebVRController object that represents controllers tracked in 3D space
  19662. */
  19663. export abstract class WebVRController extends PoseEnabledController {
  19664. /**
  19665. * Internal, the default controller model for the controller
  19666. */
  19667. protected _defaultModel: Nullable<AbstractMesh>;
  19668. /**
  19669. * Fired when the trigger state has changed
  19670. */
  19671. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19672. /**
  19673. * Fired when the main button state has changed
  19674. */
  19675. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19676. /**
  19677. * Fired when the secondary button state has changed
  19678. */
  19679. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19680. /**
  19681. * Fired when the pad state has changed
  19682. */
  19683. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19684. /**
  19685. * Fired when controllers stick values have changed
  19686. */
  19687. onPadValuesChangedObservable: Observable<StickValues>;
  19688. /**
  19689. * Array of button availible on the controller
  19690. */
  19691. protected _buttons: Array<MutableGamepadButton>;
  19692. private _onButtonStateChange;
  19693. /**
  19694. * Fired when a controller button's state has changed
  19695. * @param callback the callback containing the button that was modified
  19696. */
  19697. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19698. /**
  19699. * X and Y axis corresponding to the controllers joystick
  19700. */
  19701. pad: StickValues;
  19702. /**
  19703. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19704. */
  19705. hand: string;
  19706. /**
  19707. * The default controller model for the controller
  19708. */
  19709. get defaultModel(): Nullable<AbstractMesh>;
  19710. /**
  19711. * Creates a new WebVRController from a gamepad
  19712. * @param vrGamepad the gamepad that the WebVRController should be created from
  19713. */
  19714. constructor(vrGamepad: any);
  19715. /**
  19716. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19717. */
  19718. update(): void;
  19719. /**
  19720. * Function to be called when a button is modified
  19721. */
  19722. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19723. /**
  19724. * Loads a mesh and attaches it to the controller
  19725. * @param scene the scene the mesh should be added to
  19726. * @param meshLoaded callback for when the mesh has been loaded
  19727. */
  19728. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19729. private _setButtonValue;
  19730. private _changes;
  19731. private _checkChanges;
  19732. /**
  19733. * Disposes of th webVRCOntroller
  19734. */
  19735. dispose(): void;
  19736. }
  19737. }
  19738. declare module "babylonjs/Lights/hemisphericLight" {
  19739. import { Nullable } from "babylonjs/types";
  19740. import { Scene } from "babylonjs/scene";
  19741. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19742. import { Color3 } from "babylonjs/Maths/math.color";
  19743. import { Effect } from "babylonjs/Materials/effect";
  19744. import { Light } from "babylonjs/Lights/light";
  19745. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19746. /**
  19747. * The HemisphericLight simulates the ambient environment light,
  19748. * so the passed direction is the light reflection direction, not the incoming direction.
  19749. */
  19750. export class HemisphericLight extends Light {
  19751. /**
  19752. * The groundColor is the light in the opposite direction to the one specified during creation.
  19753. * 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.
  19754. */
  19755. groundColor: Color3;
  19756. /**
  19757. * The light reflection direction, not the incoming direction.
  19758. */
  19759. direction: Vector3;
  19760. /**
  19761. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19762. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19763. * The HemisphericLight can't cast shadows.
  19764. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19765. * @param name The friendly name of the light
  19766. * @param direction The direction of the light reflection
  19767. * @param scene The scene the light belongs to
  19768. */
  19769. constructor(name: string, direction: Vector3, scene: Scene);
  19770. protected _buildUniformLayout(): void;
  19771. /**
  19772. * Returns the string "HemisphericLight".
  19773. * @return The class name
  19774. */
  19775. getClassName(): string;
  19776. /**
  19777. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19778. * Returns the updated direction.
  19779. * @param target The target the direction should point to
  19780. * @return The computed direction
  19781. */
  19782. setDirectionToTarget(target: Vector3): Vector3;
  19783. /**
  19784. * Returns the shadow generator associated to the light.
  19785. * @returns Always null for hemispheric lights because it does not support shadows.
  19786. */
  19787. getShadowGenerator(): Nullable<IShadowGenerator>;
  19788. /**
  19789. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19790. * @param effect The effect to update
  19791. * @param lightIndex The index of the light in the effect to update
  19792. * @returns The hemispheric light
  19793. */
  19794. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19795. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19796. /**
  19797. * Computes the world matrix of the node
  19798. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19799. * @param useWasUpdatedFlag defines a reserved property
  19800. * @returns the world matrix
  19801. */
  19802. computeWorldMatrix(): Matrix;
  19803. /**
  19804. * Returns the integer 3.
  19805. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19806. */
  19807. getTypeID(): number;
  19808. /**
  19809. * Prepares the list of defines specific to the light type.
  19810. * @param defines the list of defines
  19811. * @param lightIndex defines the index of the light for the effect
  19812. */
  19813. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19814. }
  19815. }
  19816. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19817. /** @hidden */
  19818. export var vrMultiviewToSingleviewPixelShader: {
  19819. name: string;
  19820. shader: string;
  19821. };
  19822. }
  19823. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19824. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19825. import { Scene } from "babylonjs/scene";
  19826. /**
  19827. * Renders to multiple views with a single draw call
  19828. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19829. */
  19830. export class MultiviewRenderTarget extends RenderTargetTexture {
  19831. /**
  19832. * Creates a multiview render target
  19833. * @param scene scene used with the render target
  19834. * @param size the size of the render target (used for each view)
  19835. */
  19836. constructor(scene: Scene, size?: number | {
  19837. width: number;
  19838. height: number;
  19839. } | {
  19840. ratio: number;
  19841. });
  19842. /**
  19843. * @hidden
  19844. * @param faceIndex the face index, if its a cube texture
  19845. */
  19846. _bindFrameBuffer(faceIndex?: number): void;
  19847. /**
  19848. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19849. * @returns the view count
  19850. */
  19851. getViewCount(): number;
  19852. }
  19853. }
  19854. declare module "babylonjs/Maths/math.frustum" {
  19855. import { Matrix } from "babylonjs/Maths/math.vector";
  19856. import { DeepImmutable } from "babylonjs/types";
  19857. import { Plane } from "babylonjs/Maths/math.plane";
  19858. /**
  19859. * Represents a camera frustum
  19860. */
  19861. export class Frustum {
  19862. /**
  19863. * Gets the planes representing the frustum
  19864. * @param transform matrix to be applied to the returned planes
  19865. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19866. */
  19867. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19868. /**
  19869. * Gets the near frustum plane transformed by the transform matrix
  19870. * @param transform transformation matrix to be applied to the resulting frustum plane
  19871. * @param frustumPlane the resuling frustum plane
  19872. */
  19873. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19874. /**
  19875. * Gets the far frustum plane transformed by the transform matrix
  19876. * @param transform transformation matrix to be applied to the resulting frustum plane
  19877. * @param frustumPlane the resuling frustum plane
  19878. */
  19879. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19880. /**
  19881. * Gets the left frustum plane transformed by the transform matrix
  19882. * @param transform transformation matrix to be applied to the resulting frustum plane
  19883. * @param frustumPlane the resuling frustum plane
  19884. */
  19885. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19886. /**
  19887. * Gets the right frustum plane transformed by the transform matrix
  19888. * @param transform transformation matrix to be applied to the resulting frustum plane
  19889. * @param frustumPlane the resuling frustum plane
  19890. */
  19891. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19892. /**
  19893. * Gets the top frustum plane transformed by the transform matrix
  19894. * @param transform transformation matrix to be applied to the resulting frustum plane
  19895. * @param frustumPlane the resuling frustum plane
  19896. */
  19897. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19898. /**
  19899. * Gets the bottom frustum plane transformed by the transform matrix
  19900. * @param transform transformation matrix to be applied to the resulting frustum plane
  19901. * @param frustumPlane the resuling frustum plane
  19902. */
  19903. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19904. /**
  19905. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19906. * @param transform transformation matrix to be applied to the resulting frustum planes
  19907. * @param frustumPlanes the resuling frustum planes
  19908. */
  19909. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19910. }
  19911. }
  19912. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19913. import { Camera } from "babylonjs/Cameras/camera";
  19914. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19915. import { Nullable } from "babylonjs/types";
  19916. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19917. import { Matrix } from "babylonjs/Maths/math.vector";
  19918. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19919. module "babylonjs/Engines/engine" {
  19920. interface Engine {
  19921. /**
  19922. * Creates a new multiview render target
  19923. * @param width defines the width of the texture
  19924. * @param height defines the height of the texture
  19925. * @returns the created multiview texture
  19926. */
  19927. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19928. /**
  19929. * Binds a multiview framebuffer to be drawn to
  19930. * @param multiviewTexture texture to bind
  19931. */
  19932. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19933. }
  19934. }
  19935. module "babylonjs/Cameras/camera" {
  19936. interface Camera {
  19937. /**
  19938. * @hidden
  19939. * 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)
  19940. */
  19941. _useMultiviewToSingleView: boolean;
  19942. /**
  19943. * @hidden
  19944. * 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)
  19945. */
  19946. _multiviewTexture: Nullable<RenderTargetTexture>;
  19947. /**
  19948. * @hidden
  19949. * ensures the multiview texture of the camera exists and has the specified width/height
  19950. * @param width height to set on the multiview texture
  19951. * @param height width to set on the multiview texture
  19952. */
  19953. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19954. }
  19955. }
  19956. module "babylonjs/scene" {
  19957. interface Scene {
  19958. /** @hidden */
  19959. _transformMatrixR: Matrix;
  19960. /** @hidden */
  19961. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19962. /** @hidden */
  19963. _createMultiviewUbo(): void;
  19964. /** @hidden */
  19965. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19966. /** @hidden */
  19967. _renderMultiviewToSingleView(camera: Camera): void;
  19968. }
  19969. }
  19970. }
  19971. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19972. import { Camera } from "babylonjs/Cameras/camera";
  19973. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19974. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19975. import "babylonjs/Engines/Extensions/engine.multiview";
  19976. /**
  19977. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19978. * This will not be used for webXR as it supports displaying texture arrays directly
  19979. */
  19980. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19981. /**
  19982. * Initializes a VRMultiviewToSingleview
  19983. * @param name name of the post process
  19984. * @param camera camera to be applied to
  19985. * @param scaleFactor scaling factor to the size of the output texture
  19986. */
  19987. constructor(name: string, camera: Camera, scaleFactor: number);
  19988. }
  19989. }
  19990. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19991. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19992. import { Nullable } from "babylonjs/types";
  19993. import { Size } from "babylonjs/Maths/math.size";
  19994. import { Observable } from "babylonjs/Misc/observable";
  19995. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19996. /**
  19997. * Interface used to define additional presentation attributes
  19998. */
  19999. export interface IVRPresentationAttributes {
  20000. /**
  20001. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20002. */
  20003. highRefreshRate: boolean;
  20004. /**
  20005. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20006. */
  20007. foveationLevel: number;
  20008. }
  20009. module "babylonjs/Engines/engine" {
  20010. interface Engine {
  20011. /** @hidden */
  20012. _vrDisplay: any;
  20013. /** @hidden */
  20014. _vrSupported: boolean;
  20015. /** @hidden */
  20016. _oldSize: Size;
  20017. /** @hidden */
  20018. _oldHardwareScaleFactor: number;
  20019. /** @hidden */
  20020. _vrExclusivePointerMode: boolean;
  20021. /** @hidden */
  20022. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20023. /** @hidden */
  20024. _onVRDisplayPointerRestricted: () => void;
  20025. /** @hidden */
  20026. _onVRDisplayPointerUnrestricted: () => void;
  20027. /** @hidden */
  20028. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20029. /** @hidden */
  20030. _onVrDisplayDisconnect: Nullable<() => void>;
  20031. /** @hidden */
  20032. _onVrDisplayPresentChange: Nullable<() => void>;
  20033. /**
  20034. * Observable signaled when VR display mode changes
  20035. */
  20036. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20037. /**
  20038. * Observable signaled when VR request present is complete
  20039. */
  20040. onVRRequestPresentComplete: Observable<boolean>;
  20041. /**
  20042. * Observable signaled when VR request present starts
  20043. */
  20044. onVRRequestPresentStart: Observable<Engine>;
  20045. /**
  20046. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20047. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20048. */
  20049. isInVRExclusivePointerMode: boolean;
  20050. /**
  20051. * Gets a boolean indicating if a webVR device was detected
  20052. * @returns true if a webVR device was detected
  20053. */
  20054. isVRDevicePresent(): boolean;
  20055. /**
  20056. * Gets the current webVR device
  20057. * @returns the current webVR device (or null)
  20058. */
  20059. getVRDevice(): any;
  20060. /**
  20061. * Initializes a webVR display and starts listening to display change events
  20062. * The onVRDisplayChangedObservable will be notified upon these changes
  20063. * @returns A promise containing a VRDisplay and if vr is supported
  20064. */
  20065. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20066. /** @hidden */
  20067. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20068. /**
  20069. * Gets or sets the presentation attributes used to configure VR rendering
  20070. */
  20071. vrPresentationAttributes?: IVRPresentationAttributes;
  20072. /**
  20073. * Call this function to switch to webVR mode
  20074. * Will do nothing if webVR is not supported or if there is no webVR device
  20075. * @param options the webvr options provided to the camera. mainly used for multiview
  20076. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20077. */
  20078. enableVR(options: WebVROptions): void;
  20079. /** @hidden */
  20080. _onVRFullScreenTriggered(): void;
  20081. }
  20082. }
  20083. }
  20084. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20085. import { Nullable } from "babylonjs/types";
  20086. import { Observable } from "babylonjs/Misc/observable";
  20087. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20088. import { Scene } from "babylonjs/scene";
  20089. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20090. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20091. import { Node } from "babylonjs/node";
  20092. import { Ray } from "babylonjs/Culling/ray";
  20093. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20094. import "babylonjs/Engines/Extensions/engine.webVR";
  20095. /**
  20096. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20097. * IMPORTANT!! The data is right-hand data.
  20098. * @export
  20099. * @interface DevicePose
  20100. */
  20101. export interface DevicePose {
  20102. /**
  20103. * The position of the device, values in array are [x,y,z].
  20104. */
  20105. readonly position: Nullable<Float32Array>;
  20106. /**
  20107. * The linearVelocity of the device, values in array are [x,y,z].
  20108. */
  20109. readonly linearVelocity: Nullable<Float32Array>;
  20110. /**
  20111. * The linearAcceleration of the device, values in array are [x,y,z].
  20112. */
  20113. readonly linearAcceleration: Nullable<Float32Array>;
  20114. /**
  20115. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20116. */
  20117. readonly orientation: Nullable<Float32Array>;
  20118. /**
  20119. * The angularVelocity of the device, values in array are [x,y,z].
  20120. */
  20121. readonly angularVelocity: Nullable<Float32Array>;
  20122. /**
  20123. * The angularAcceleration of the device, values in array are [x,y,z].
  20124. */
  20125. readonly angularAcceleration: Nullable<Float32Array>;
  20126. }
  20127. /**
  20128. * Interface representing a pose controlled object in Babylon.
  20129. * A pose controlled object has both regular pose values as well as pose values
  20130. * from an external device such as a VR head mounted display
  20131. */
  20132. export interface PoseControlled {
  20133. /**
  20134. * The position of the object in babylon space.
  20135. */
  20136. position: Vector3;
  20137. /**
  20138. * The rotation quaternion of the object in babylon space.
  20139. */
  20140. rotationQuaternion: Quaternion;
  20141. /**
  20142. * The position of the device in babylon space.
  20143. */
  20144. devicePosition?: Vector3;
  20145. /**
  20146. * The rotation quaternion of the device in babylon space.
  20147. */
  20148. deviceRotationQuaternion: Quaternion;
  20149. /**
  20150. * The raw pose coming from the device.
  20151. */
  20152. rawPose: Nullable<DevicePose>;
  20153. /**
  20154. * The scale of the device to be used when translating from device space to babylon space.
  20155. */
  20156. deviceScaleFactor: number;
  20157. /**
  20158. * Updates the poseControlled values based on the input device pose.
  20159. * @param poseData the pose data to update the object with
  20160. */
  20161. updateFromDevice(poseData: DevicePose): void;
  20162. }
  20163. /**
  20164. * Set of options to customize the webVRCamera
  20165. */
  20166. export interface WebVROptions {
  20167. /**
  20168. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20169. */
  20170. trackPosition?: boolean;
  20171. /**
  20172. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20173. */
  20174. positionScale?: number;
  20175. /**
  20176. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20177. */
  20178. displayName?: string;
  20179. /**
  20180. * Should the native controller meshes be initialized. (default: true)
  20181. */
  20182. controllerMeshes?: boolean;
  20183. /**
  20184. * Creating a default HemiLight only on controllers. (default: true)
  20185. */
  20186. defaultLightingOnControllers?: boolean;
  20187. /**
  20188. * If you don't want to use the default VR button of the helper. (default: false)
  20189. */
  20190. useCustomVRButton?: boolean;
  20191. /**
  20192. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20193. */
  20194. customVRButton?: HTMLButtonElement;
  20195. /**
  20196. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20197. */
  20198. rayLength?: number;
  20199. /**
  20200. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20201. */
  20202. defaultHeight?: number;
  20203. /**
  20204. * If multiview should be used if availible (default: false)
  20205. */
  20206. useMultiview?: boolean;
  20207. }
  20208. /**
  20209. * This represents a WebVR camera.
  20210. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20211. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20212. */
  20213. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20214. private webVROptions;
  20215. /**
  20216. * @hidden
  20217. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20218. */
  20219. _vrDevice: any;
  20220. /**
  20221. * The rawPose of the vrDevice.
  20222. */
  20223. rawPose: Nullable<DevicePose>;
  20224. private _onVREnabled;
  20225. private _specsVersion;
  20226. private _attached;
  20227. private _frameData;
  20228. protected _descendants: Array<Node>;
  20229. private _deviceRoomPosition;
  20230. /** @hidden */
  20231. _deviceRoomRotationQuaternion: Quaternion;
  20232. private _standingMatrix;
  20233. /**
  20234. * Represents device position in babylon space.
  20235. */
  20236. devicePosition: Vector3;
  20237. /**
  20238. * Represents device rotation in babylon space.
  20239. */
  20240. deviceRotationQuaternion: Quaternion;
  20241. /**
  20242. * The scale of the device to be used when translating from device space to babylon space.
  20243. */
  20244. deviceScaleFactor: number;
  20245. private _deviceToWorld;
  20246. private _worldToDevice;
  20247. /**
  20248. * References to the webVR controllers for the vrDevice.
  20249. */
  20250. controllers: Array<WebVRController>;
  20251. /**
  20252. * Emits an event when a controller is attached.
  20253. */
  20254. onControllersAttachedObservable: Observable<WebVRController[]>;
  20255. /**
  20256. * Emits an event when a controller's mesh has been loaded;
  20257. */
  20258. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20259. /**
  20260. * Emits an event when the HMD's pose has been updated.
  20261. */
  20262. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20263. private _poseSet;
  20264. /**
  20265. * If the rig cameras be used as parent instead of this camera.
  20266. */
  20267. rigParenting: boolean;
  20268. private _lightOnControllers;
  20269. private _defaultHeight?;
  20270. /**
  20271. * Instantiates a WebVRFreeCamera.
  20272. * @param name The name of the WebVRFreeCamera
  20273. * @param position The starting anchor position for the camera
  20274. * @param scene The scene the camera belongs to
  20275. * @param webVROptions a set of customizable options for the webVRCamera
  20276. */
  20277. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20278. /**
  20279. * Gets the device distance from the ground in meters.
  20280. * @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.
  20281. */
  20282. deviceDistanceToRoomGround(): number;
  20283. /**
  20284. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20285. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20286. */
  20287. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20288. /**
  20289. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20290. * @returns A promise with a boolean set to if the standing matrix is supported.
  20291. */
  20292. useStandingMatrixAsync(): Promise<boolean>;
  20293. /**
  20294. * Disposes the camera
  20295. */
  20296. dispose(): void;
  20297. /**
  20298. * Gets a vrController by name.
  20299. * @param name The name of the controller to retreive
  20300. * @returns the controller matching the name specified or null if not found
  20301. */
  20302. getControllerByName(name: string): Nullable<WebVRController>;
  20303. private _leftController;
  20304. /**
  20305. * The controller corresponding to the users left hand.
  20306. */
  20307. get leftController(): Nullable<WebVRController>;
  20308. private _rightController;
  20309. /**
  20310. * The controller corresponding to the users right hand.
  20311. */
  20312. get rightController(): Nullable<WebVRController>;
  20313. /**
  20314. * Casts a ray forward from the vrCamera's gaze.
  20315. * @param length Length of the ray (default: 100)
  20316. * @returns the ray corresponding to the gaze
  20317. */
  20318. getForwardRay(length?: number): Ray;
  20319. /**
  20320. * @hidden
  20321. * Updates the camera based on device's frame data
  20322. */
  20323. _checkInputs(): void;
  20324. /**
  20325. * Updates the poseControlled values based on the input device pose.
  20326. * @param poseData Pose coming from the device
  20327. */
  20328. updateFromDevice(poseData: DevicePose): void;
  20329. private _htmlElementAttached;
  20330. private _detachIfAttached;
  20331. /**
  20332. * WebVR's attach control will start broadcasting frames to the device.
  20333. * Note that in certain browsers (chrome for example) this function must be called
  20334. * within a user-interaction callback. Example:
  20335. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20336. *
  20337. * @param element html element to attach the vrDevice to
  20338. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20339. */
  20340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20341. /**
  20342. * Detaches the camera from the html element and disables VR
  20343. *
  20344. * @param element html element to detach from
  20345. */
  20346. detachControl(element: HTMLElement): void;
  20347. /**
  20348. * @returns the name of this class
  20349. */
  20350. getClassName(): string;
  20351. /**
  20352. * Calls resetPose on the vrDisplay
  20353. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20354. */
  20355. resetToCurrentRotation(): void;
  20356. /**
  20357. * @hidden
  20358. * Updates the rig cameras (left and right eye)
  20359. */
  20360. _updateRigCameras(): void;
  20361. private _workingVector;
  20362. private _oneVector;
  20363. private _workingMatrix;
  20364. private updateCacheCalled;
  20365. private _correctPositionIfNotTrackPosition;
  20366. /**
  20367. * @hidden
  20368. * Updates the cached values of the camera
  20369. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20370. */
  20371. _updateCache(ignoreParentClass?: boolean): void;
  20372. /**
  20373. * @hidden
  20374. * Get current device position in babylon world
  20375. */
  20376. _computeDevicePosition(): void;
  20377. /**
  20378. * Updates the current device position and rotation in the babylon world
  20379. */
  20380. update(): void;
  20381. /**
  20382. * @hidden
  20383. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20384. * @returns an identity matrix
  20385. */
  20386. _getViewMatrix(): Matrix;
  20387. private _tmpMatrix;
  20388. /**
  20389. * This function is called by the two RIG cameras.
  20390. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20391. * @hidden
  20392. */
  20393. _getWebVRViewMatrix(): Matrix;
  20394. /** @hidden */
  20395. _getWebVRProjectionMatrix(): Matrix;
  20396. private _onGamepadConnectedObserver;
  20397. private _onGamepadDisconnectedObserver;
  20398. private _updateCacheWhenTrackingDisabledObserver;
  20399. /**
  20400. * Initializes the controllers and their meshes
  20401. */
  20402. initControllers(): void;
  20403. }
  20404. }
  20405. declare module "babylonjs/PostProcesses/postProcess" {
  20406. import { Nullable } from "babylonjs/types";
  20407. import { SmartArray } from "babylonjs/Misc/smartArray";
  20408. import { Observable } from "babylonjs/Misc/observable";
  20409. import { Vector2 } from "babylonjs/Maths/math.vector";
  20410. import { Camera } from "babylonjs/Cameras/camera";
  20411. import { Effect } from "babylonjs/Materials/effect";
  20412. import "babylonjs/Shaders/postprocess.vertex";
  20413. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20414. import { Engine } from "babylonjs/Engines/engine";
  20415. import { Color4 } from "babylonjs/Maths/math.color";
  20416. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20417. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20418. /**
  20419. * Size options for a post process
  20420. */
  20421. export type PostProcessOptions = {
  20422. width: number;
  20423. height: number;
  20424. };
  20425. /**
  20426. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20427. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20428. */
  20429. export class PostProcess {
  20430. /** Name of the PostProcess. */
  20431. name: string;
  20432. /**
  20433. * Gets or sets the unique id of the post process
  20434. */
  20435. uniqueId: number;
  20436. /**
  20437. * Width of the texture to apply the post process on
  20438. */
  20439. width: number;
  20440. /**
  20441. * Height of the texture to apply the post process on
  20442. */
  20443. height: number;
  20444. /**
  20445. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20446. * @hidden
  20447. */
  20448. _outputTexture: Nullable<InternalTexture>;
  20449. /**
  20450. * Sampling mode used by the shader
  20451. * See https://doc.babylonjs.com/classes/3.1/texture
  20452. */
  20453. renderTargetSamplingMode: number;
  20454. /**
  20455. * Clear color to use when screen clearing
  20456. */
  20457. clearColor: Color4;
  20458. /**
  20459. * If the buffer needs to be cleared before applying the post process. (default: true)
  20460. * Should be set to false if shader will overwrite all previous pixels.
  20461. */
  20462. autoClear: boolean;
  20463. /**
  20464. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20465. */
  20466. alphaMode: number;
  20467. /**
  20468. * Sets the setAlphaBlendConstants of the babylon engine
  20469. */
  20470. alphaConstants: Color4;
  20471. /**
  20472. * Animations to be used for the post processing
  20473. */
  20474. animations: import("babylonjs/Animations/animation").Animation[];
  20475. /**
  20476. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20477. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20478. */
  20479. enablePixelPerfectMode: boolean;
  20480. /**
  20481. * Force the postprocess to be applied without taking in account viewport
  20482. */
  20483. forceFullscreenViewport: boolean;
  20484. /**
  20485. * List of inspectable custom properties (used by the Inspector)
  20486. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20487. */
  20488. inspectableCustomProperties: IInspectable[];
  20489. /**
  20490. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20491. *
  20492. * | Value | Type | Description |
  20493. * | ----- | ----------------------------------- | ----------- |
  20494. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20495. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20496. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20497. *
  20498. */
  20499. scaleMode: number;
  20500. /**
  20501. * Force textures to be a power of two (default: false)
  20502. */
  20503. alwaysForcePOT: boolean;
  20504. private _samples;
  20505. /**
  20506. * Number of sample textures (default: 1)
  20507. */
  20508. get samples(): number;
  20509. set samples(n: number);
  20510. /**
  20511. * Modify the scale of the post process to be the same as the viewport (default: false)
  20512. */
  20513. adaptScaleToCurrentViewport: boolean;
  20514. private _camera;
  20515. private _scene;
  20516. private _engine;
  20517. private _options;
  20518. private _reusable;
  20519. private _textureType;
  20520. private _textureFormat;
  20521. /**
  20522. * Smart array of input and output textures for the post process.
  20523. * @hidden
  20524. */
  20525. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20526. /**
  20527. * The index in _textures that corresponds to the output texture.
  20528. * @hidden
  20529. */
  20530. _currentRenderTextureInd: number;
  20531. private _effect;
  20532. private _samplers;
  20533. private _fragmentUrl;
  20534. private _vertexUrl;
  20535. private _parameters;
  20536. private _scaleRatio;
  20537. protected _indexParameters: any;
  20538. private _shareOutputWithPostProcess;
  20539. private _texelSize;
  20540. private _forcedOutputTexture;
  20541. /**
  20542. * Returns the fragment url or shader name used in the post process.
  20543. * @returns the fragment url or name in the shader store.
  20544. */
  20545. getEffectName(): string;
  20546. /**
  20547. * An event triggered when the postprocess is activated.
  20548. */
  20549. onActivateObservable: Observable<Camera>;
  20550. private _onActivateObserver;
  20551. /**
  20552. * A function that is added to the onActivateObservable
  20553. */
  20554. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20555. /**
  20556. * An event triggered when the postprocess changes its size.
  20557. */
  20558. onSizeChangedObservable: Observable<PostProcess>;
  20559. private _onSizeChangedObserver;
  20560. /**
  20561. * A function that is added to the onSizeChangedObservable
  20562. */
  20563. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20564. /**
  20565. * An event triggered when the postprocess applies its effect.
  20566. */
  20567. onApplyObservable: Observable<Effect>;
  20568. private _onApplyObserver;
  20569. /**
  20570. * A function that is added to the onApplyObservable
  20571. */
  20572. set onApply(callback: (effect: Effect) => void);
  20573. /**
  20574. * An event triggered before rendering the postprocess
  20575. */
  20576. onBeforeRenderObservable: Observable<Effect>;
  20577. private _onBeforeRenderObserver;
  20578. /**
  20579. * A function that is added to the onBeforeRenderObservable
  20580. */
  20581. set onBeforeRender(callback: (effect: Effect) => void);
  20582. /**
  20583. * An event triggered after rendering the postprocess
  20584. */
  20585. onAfterRenderObservable: Observable<Effect>;
  20586. private _onAfterRenderObserver;
  20587. /**
  20588. * A function that is added to the onAfterRenderObservable
  20589. */
  20590. set onAfterRender(callback: (efect: Effect) => void);
  20591. /**
  20592. * 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
  20593. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20594. */
  20595. get inputTexture(): InternalTexture;
  20596. set inputTexture(value: InternalTexture);
  20597. /**
  20598. * Gets the camera which post process is applied to.
  20599. * @returns The camera the post process is applied to.
  20600. */
  20601. getCamera(): Camera;
  20602. /**
  20603. * Gets the texel size of the postprocess.
  20604. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20605. */
  20606. get texelSize(): Vector2;
  20607. /**
  20608. * Creates a new instance PostProcess
  20609. * @param name The name of the PostProcess.
  20610. * @param fragmentUrl The url of the fragment shader to be used.
  20611. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20612. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20613. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20614. * @param camera The camera to apply the render pass to.
  20615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20616. * @param engine The engine which the post process will be applied. (default: current engine)
  20617. * @param reusable If the post process can be reused on the same frame. (default: false)
  20618. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20619. * @param textureType Type of textures used when performing the post process. (default: 0)
  20620. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20621. * @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
  20622. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20623. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20624. */
  20625. constructor(
  20626. /** Name of the PostProcess. */
  20627. 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);
  20628. /**
  20629. * Gets a string idenfifying the name of the class
  20630. * @returns "PostProcess" string
  20631. */
  20632. getClassName(): string;
  20633. /**
  20634. * Gets the engine which this post process belongs to.
  20635. * @returns The engine the post process was enabled with.
  20636. */
  20637. getEngine(): Engine;
  20638. /**
  20639. * The effect that is created when initializing the post process.
  20640. * @returns The created effect corresponding the the postprocess.
  20641. */
  20642. getEffect(): Effect;
  20643. /**
  20644. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20645. * @param postProcess The post process to share the output with.
  20646. * @returns This post process.
  20647. */
  20648. shareOutputWith(postProcess: PostProcess): PostProcess;
  20649. /**
  20650. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20651. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20652. */
  20653. useOwnOutput(): void;
  20654. /**
  20655. * Updates the effect with the current post process compile time values and recompiles the shader.
  20656. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20657. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20658. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20659. * @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
  20660. * @param onCompiled Called when the shader has been compiled.
  20661. * @param onError Called if there is an error when compiling a shader.
  20662. */
  20663. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20664. /**
  20665. * The post process is reusable if it can be used multiple times within one frame.
  20666. * @returns If the post process is reusable
  20667. */
  20668. isReusable(): boolean;
  20669. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20670. markTextureDirty(): void;
  20671. /**
  20672. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20673. * 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.
  20674. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20675. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20676. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20677. * @returns The target texture that was bound to be written to.
  20678. */
  20679. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20680. /**
  20681. * If the post process is supported.
  20682. */
  20683. get isSupported(): boolean;
  20684. /**
  20685. * The aspect ratio of the output texture.
  20686. */
  20687. get aspectRatio(): number;
  20688. /**
  20689. * Get a value indicating if the post-process is ready to be used
  20690. * @returns true if the post-process is ready (shader is compiled)
  20691. */
  20692. isReady(): boolean;
  20693. /**
  20694. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20695. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20696. */
  20697. apply(): Nullable<Effect>;
  20698. private _disposeTextures;
  20699. /**
  20700. * Disposes the post process.
  20701. * @param camera The camera to dispose the post process on.
  20702. */
  20703. dispose(camera?: Camera): void;
  20704. }
  20705. }
  20706. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20707. /** @hidden */
  20708. export var kernelBlurVaryingDeclaration: {
  20709. name: string;
  20710. shader: string;
  20711. };
  20712. }
  20713. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20714. /** @hidden */
  20715. export var kernelBlurFragment: {
  20716. name: string;
  20717. shader: string;
  20718. };
  20719. }
  20720. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20721. /** @hidden */
  20722. export var kernelBlurFragment2: {
  20723. name: string;
  20724. shader: string;
  20725. };
  20726. }
  20727. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20728. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20729. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20730. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20731. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20732. /** @hidden */
  20733. export var kernelBlurPixelShader: {
  20734. name: string;
  20735. shader: string;
  20736. };
  20737. }
  20738. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20739. /** @hidden */
  20740. export var kernelBlurVertex: {
  20741. name: string;
  20742. shader: string;
  20743. };
  20744. }
  20745. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20746. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20747. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20748. /** @hidden */
  20749. export var kernelBlurVertexShader: {
  20750. name: string;
  20751. shader: string;
  20752. };
  20753. }
  20754. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20755. import { Vector2 } from "babylonjs/Maths/math.vector";
  20756. import { Nullable } from "babylonjs/types";
  20757. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20758. import { Camera } from "babylonjs/Cameras/camera";
  20759. import { Effect } from "babylonjs/Materials/effect";
  20760. import { Engine } from "babylonjs/Engines/engine";
  20761. import "babylonjs/Shaders/kernelBlur.fragment";
  20762. import "babylonjs/Shaders/kernelBlur.vertex";
  20763. /**
  20764. * The Blur Post Process which blurs an image based on a kernel and direction.
  20765. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20766. */
  20767. export class BlurPostProcess extends PostProcess {
  20768. /** The direction in which to blur the image. */
  20769. direction: Vector2;
  20770. private blockCompilation;
  20771. protected _kernel: number;
  20772. protected _idealKernel: number;
  20773. protected _packedFloat: boolean;
  20774. private _staticDefines;
  20775. /**
  20776. * Sets the length in pixels of the blur sample region
  20777. */
  20778. set kernel(v: number);
  20779. /**
  20780. * Gets the length in pixels of the blur sample region
  20781. */
  20782. get kernel(): number;
  20783. /**
  20784. * Sets wether or not the blur needs to unpack/repack floats
  20785. */
  20786. set packedFloat(v: boolean);
  20787. /**
  20788. * Gets wether or not the blur is unpacking/repacking floats
  20789. */
  20790. get packedFloat(): boolean;
  20791. /**
  20792. * Creates a new instance BlurPostProcess
  20793. * @param name The name of the effect.
  20794. * @param direction The direction in which to blur the image.
  20795. * @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.
  20796. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20797. * @param camera The camera to apply the render pass to.
  20798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20799. * @param engine The engine which the post process will be applied. (default: current engine)
  20800. * @param reusable If the post process can be reused on the same frame. (default: false)
  20801. * @param textureType Type of textures used when performing the post process. (default: 0)
  20802. * @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)
  20803. */
  20804. constructor(name: string,
  20805. /** The direction in which to blur the image. */
  20806. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20807. /**
  20808. * Updates the effect with the current post process compile time values and recompiles the shader.
  20809. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20810. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20811. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20812. * @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
  20813. * @param onCompiled Called when the shader has been compiled.
  20814. * @param onError Called if there is an error when compiling a shader.
  20815. */
  20816. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20817. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20818. /**
  20819. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20820. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20821. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20822. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20823. * The gaps between physical kernels are compensated for in the weighting of the samples
  20824. * @param idealKernel Ideal blur kernel.
  20825. * @return Nearest best kernel.
  20826. */
  20827. protected _nearestBestKernel(idealKernel: number): number;
  20828. /**
  20829. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20830. * @param x The point on the Gaussian distribution to sample.
  20831. * @return the value of the Gaussian function at x.
  20832. */
  20833. protected _gaussianWeight(x: number): number;
  20834. /**
  20835. * Generates a string that can be used as a floating point number in GLSL.
  20836. * @param x Value to print.
  20837. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20838. * @return GLSL float string.
  20839. */
  20840. protected _glslFloat(x: number, decimalFigures?: number): string;
  20841. }
  20842. }
  20843. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20844. import { Scene } from "babylonjs/scene";
  20845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20846. import { Plane } from "babylonjs/Maths/math.plane";
  20847. /**
  20848. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20849. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20850. * You can then easily use it as a reflectionTexture on a flat surface.
  20851. * In case the surface is not a plane, please consider relying on reflection probes.
  20852. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20853. */
  20854. export class MirrorTexture extends RenderTargetTexture {
  20855. private scene;
  20856. /**
  20857. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20858. * 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.
  20859. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20860. */
  20861. mirrorPlane: Plane;
  20862. /**
  20863. * Define the blur ratio used to blur the reflection if needed.
  20864. */
  20865. set blurRatio(value: number);
  20866. get blurRatio(): number;
  20867. /**
  20868. * Define the adaptive blur kernel used to blur the reflection if needed.
  20869. * This will autocompute the closest best match for the `blurKernel`
  20870. */
  20871. set adaptiveBlurKernel(value: number);
  20872. /**
  20873. * Define the blur kernel used to blur the reflection if needed.
  20874. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20875. */
  20876. set blurKernel(value: number);
  20877. /**
  20878. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20879. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20880. */
  20881. set blurKernelX(value: number);
  20882. get blurKernelX(): number;
  20883. /**
  20884. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20885. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20886. */
  20887. set blurKernelY(value: number);
  20888. get blurKernelY(): number;
  20889. private _autoComputeBlurKernel;
  20890. protected _onRatioRescale(): void;
  20891. private _updateGammaSpace;
  20892. private _imageProcessingConfigChangeObserver;
  20893. private _transformMatrix;
  20894. private _mirrorMatrix;
  20895. private _savedViewMatrix;
  20896. private _blurX;
  20897. private _blurY;
  20898. private _adaptiveBlurKernel;
  20899. private _blurKernelX;
  20900. private _blurKernelY;
  20901. private _blurRatio;
  20902. /**
  20903. * Instantiates a Mirror Texture.
  20904. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20905. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20906. * You can then easily use it as a reflectionTexture on a flat surface.
  20907. * In case the surface is not a plane, please consider relying on reflection probes.
  20908. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20909. * @param name
  20910. * @param size
  20911. * @param scene
  20912. * @param generateMipMaps
  20913. * @param type
  20914. * @param samplingMode
  20915. * @param generateDepthBuffer
  20916. */
  20917. constructor(name: string, size: number | {
  20918. width: number;
  20919. height: number;
  20920. } | {
  20921. ratio: number;
  20922. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20923. private _preparePostProcesses;
  20924. /**
  20925. * Clone the mirror texture.
  20926. * @returns the cloned texture
  20927. */
  20928. clone(): MirrorTexture;
  20929. /**
  20930. * Serialize the texture to a JSON representation you could use in Parse later on
  20931. * @returns the serialized JSON representation
  20932. */
  20933. serialize(): any;
  20934. /**
  20935. * Dispose the texture and release its associated resources.
  20936. */
  20937. dispose(): void;
  20938. }
  20939. }
  20940. declare module "babylonjs/Materials/Textures/texture" {
  20941. import { Observable } from "babylonjs/Misc/observable";
  20942. import { Nullable } from "babylonjs/types";
  20943. import { Matrix } from "babylonjs/Maths/math.vector";
  20944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20945. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20946. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20947. import { Scene } from "babylonjs/scene";
  20948. /**
  20949. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20950. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20951. */
  20952. export class Texture extends BaseTexture {
  20953. /**
  20954. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20955. */
  20956. static SerializeBuffers: boolean;
  20957. /** @hidden */
  20958. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20959. /** @hidden */
  20960. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20961. /** @hidden */
  20962. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20963. /** nearest is mag = nearest and min = nearest and mip = linear */
  20964. static readonly NEAREST_SAMPLINGMODE: number;
  20965. /** nearest is mag = nearest and min = nearest and mip = linear */
  20966. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20967. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20968. static readonly BILINEAR_SAMPLINGMODE: number;
  20969. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20970. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20971. /** Trilinear is mag = linear and min = linear and mip = linear */
  20972. static readonly TRILINEAR_SAMPLINGMODE: number;
  20973. /** Trilinear is mag = linear and min = linear and mip = linear */
  20974. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20975. /** mag = nearest and min = nearest and mip = nearest */
  20976. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20977. /** mag = nearest and min = linear and mip = nearest */
  20978. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20979. /** mag = nearest and min = linear and mip = linear */
  20980. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20981. /** mag = nearest and min = linear and mip = none */
  20982. static readonly NEAREST_LINEAR: number;
  20983. /** mag = nearest and min = nearest and mip = none */
  20984. static readonly NEAREST_NEAREST: number;
  20985. /** mag = linear and min = nearest and mip = nearest */
  20986. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20987. /** mag = linear and min = nearest and mip = linear */
  20988. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20989. /** mag = linear and min = linear and mip = none */
  20990. static readonly LINEAR_LINEAR: number;
  20991. /** mag = linear and min = nearest and mip = none */
  20992. static readonly LINEAR_NEAREST: number;
  20993. /** Explicit coordinates mode */
  20994. static readonly EXPLICIT_MODE: number;
  20995. /** Spherical coordinates mode */
  20996. static readonly SPHERICAL_MODE: number;
  20997. /** Planar coordinates mode */
  20998. static readonly PLANAR_MODE: number;
  20999. /** Cubic coordinates mode */
  21000. static readonly CUBIC_MODE: number;
  21001. /** Projection coordinates mode */
  21002. static readonly PROJECTION_MODE: number;
  21003. /** Inverse Cubic coordinates mode */
  21004. static readonly SKYBOX_MODE: number;
  21005. /** Inverse Cubic coordinates mode */
  21006. static readonly INVCUBIC_MODE: number;
  21007. /** Equirectangular coordinates mode */
  21008. static readonly EQUIRECTANGULAR_MODE: number;
  21009. /** Equirectangular Fixed coordinates mode */
  21010. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  21011. /** Equirectangular Fixed Mirrored coordinates mode */
  21012. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  21013. /** Texture is not repeating outside of 0..1 UVs */
  21014. static readonly CLAMP_ADDRESSMODE: number;
  21015. /** Texture is repeating outside of 0..1 UVs */
  21016. static readonly WRAP_ADDRESSMODE: number;
  21017. /** Texture is repeating and mirrored */
  21018. static readonly MIRROR_ADDRESSMODE: number;
  21019. /**
  21020. * 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
  21021. */
  21022. static UseSerializedUrlIfAny: boolean;
  21023. /**
  21024. * Define the url of the texture.
  21025. */
  21026. url: Nullable<string>;
  21027. /**
  21028. * Define an offset on the texture to offset the u coordinates of the UVs
  21029. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21030. */
  21031. uOffset: number;
  21032. /**
  21033. * Define an offset on the texture to offset the v coordinates of the UVs
  21034. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  21035. */
  21036. vOffset: number;
  21037. /**
  21038. * Define an offset on the texture to scale the u coordinates of the UVs
  21039. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21040. */
  21041. uScale: number;
  21042. /**
  21043. * Define an offset on the texture to scale the v coordinates of the UVs
  21044. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  21045. */
  21046. vScale: number;
  21047. /**
  21048. * Define an offset on the texture to rotate around the u coordinates of the UVs
  21049. * @see http://doc.babylonjs.com/how_to/more_materials
  21050. */
  21051. uAng: number;
  21052. /**
  21053. * Define an offset on the texture to rotate around the v coordinates of the UVs
  21054. * @see http://doc.babylonjs.com/how_to/more_materials
  21055. */
  21056. vAng: number;
  21057. /**
  21058. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  21059. * @see http://doc.babylonjs.com/how_to/more_materials
  21060. */
  21061. wAng: number;
  21062. /**
  21063. * Defines the center of rotation (U)
  21064. */
  21065. uRotationCenter: number;
  21066. /**
  21067. * Defines the center of rotation (V)
  21068. */
  21069. vRotationCenter: number;
  21070. /**
  21071. * Defines the center of rotation (W)
  21072. */
  21073. wRotationCenter: number;
  21074. /**
  21075. * Are mip maps generated for this texture or not.
  21076. */
  21077. get noMipmap(): boolean;
  21078. /**
  21079. * List of inspectable custom properties (used by the Inspector)
  21080. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21081. */
  21082. inspectableCustomProperties: Nullable<IInspectable[]>;
  21083. private _noMipmap;
  21084. /** @hidden */
  21085. _invertY: boolean;
  21086. private _rowGenerationMatrix;
  21087. private _cachedTextureMatrix;
  21088. private _projectionModeMatrix;
  21089. private _t0;
  21090. private _t1;
  21091. private _t2;
  21092. private _cachedUOffset;
  21093. private _cachedVOffset;
  21094. private _cachedUScale;
  21095. private _cachedVScale;
  21096. private _cachedUAng;
  21097. private _cachedVAng;
  21098. private _cachedWAng;
  21099. private _cachedProjectionMatrixId;
  21100. private _cachedCoordinatesMode;
  21101. /** @hidden */
  21102. protected _initialSamplingMode: number;
  21103. /** @hidden */
  21104. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21105. private _deleteBuffer;
  21106. protected _format: Nullable<number>;
  21107. private _delayedOnLoad;
  21108. private _delayedOnError;
  21109. private _mimeType?;
  21110. /**
  21111. * Observable triggered once the texture has been loaded.
  21112. */
  21113. onLoadObservable: Observable<Texture>;
  21114. protected _isBlocking: boolean;
  21115. /**
  21116. * Is the texture preventing material to render while loading.
  21117. * If false, a default texture will be used instead of the loading one during the preparation step.
  21118. */
  21119. set isBlocking(value: boolean);
  21120. get isBlocking(): boolean;
  21121. /**
  21122. * Get the current sampling mode associated with the texture.
  21123. */
  21124. get samplingMode(): number;
  21125. /**
  21126. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21127. */
  21128. get invertY(): boolean;
  21129. /**
  21130. * Instantiates a new texture.
  21131. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21132. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21133. * @param url defines the url of the picture to load as a texture
  21134. * @param scene defines the scene or engine the texture will belong to
  21135. * @param noMipmap defines if the texture will require mip maps or not
  21136. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21137. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21138. * @param onLoad defines a callback triggered when the texture has been loaded
  21139. * @param onError defines a callback triggered when an error occurred during the loading session
  21140. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21141. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21142. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21143. * @param mimeType defines an optional mime type information
  21144. */
  21145. 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);
  21146. /**
  21147. * Update the url (and optional buffer) of this texture if url was null during construction.
  21148. * @param url the url of the texture
  21149. * @param buffer the buffer of the texture (defaults to null)
  21150. * @param onLoad callback called when the texture is loaded (defaults to null)
  21151. */
  21152. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21153. /**
  21154. * Finish the loading sequence of a texture flagged as delayed load.
  21155. * @hidden
  21156. */
  21157. delayLoad(): void;
  21158. private _prepareRowForTextureGeneration;
  21159. /**
  21160. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21161. * @returns the transform matrix of the texture.
  21162. */
  21163. getTextureMatrix(uBase?: number): Matrix;
  21164. /**
  21165. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21166. * @returns The reflection texture transform
  21167. */
  21168. getReflectionTextureMatrix(): Matrix;
  21169. /**
  21170. * Clones the texture.
  21171. * @returns the cloned texture
  21172. */
  21173. clone(): Texture;
  21174. /**
  21175. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21176. * @returns The JSON representation of the texture
  21177. */
  21178. serialize(): any;
  21179. /**
  21180. * Get the current class name of the texture useful for serialization or dynamic coding.
  21181. * @returns "Texture"
  21182. */
  21183. getClassName(): string;
  21184. /**
  21185. * Dispose the texture and release its associated resources.
  21186. */
  21187. dispose(): void;
  21188. /**
  21189. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21190. * @param parsedTexture Define the JSON representation of the texture
  21191. * @param scene Define the scene the parsed texture should be instantiated in
  21192. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21193. * @returns The parsed texture if successful
  21194. */
  21195. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21196. /**
  21197. * Creates a texture from its base 64 representation.
  21198. * @param data Define the base64 payload without the data: prefix
  21199. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21200. * @param scene Define the scene the texture should belong to
  21201. * @param noMipmap Forces the texture to not create mip map information if true
  21202. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21203. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21204. * @param onLoad define a callback triggered when the texture has been loaded
  21205. * @param onError define a callback triggered when an error occurred during the loading session
  21206. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21207. * @returns the created texture
  21208. */
  21209. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21210. /**
  21211. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21212. * @param data Define the base64 payload without the data: prefix
  21213. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21214. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21215. * @param scene Define the scene the texture should belong to
  21216. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21217. * @param noMipmap Forces the texture to not create mip map information if true
  21218. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21219. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21220. * @param onLoad define a callback triggered when the texture has been loaded
  21221. * @param onError define a callback triggered when an error occurred during the loading session
  21222. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21223. * @returns the created texture
  21224. */
  21225. 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;
  21226. }
  21227. }
  21228. declare module "babylonjs/PostProcesses/postProcessManager" {
  21229. import { Nullable } from "babylonjs/types";
  21230. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21231. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21232. import { Scene } from "babylonjs/scene";
  21233. /**
  21234. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21235. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21236. */
  21237. export class PostProcessManager {
  21238. private _scene;
  21239. private _indexBuffer;
  21240. private _vertexBuffers;
  21241. /**
  21242. * Creates a new instance PostProcess
  21243. * @param scene The scene that the post process is associated with.
  21244. */
  21245. constructor(scene: Scene);
  21246. private _prepareBuffers;
  21247. private _buildIndexBuffer;
  21248. /**
  21249. * Rebuilds the vertex buffers of the manager.
  21250. * @hidden
  21251. */
  21252. _rebuild(): void;
  21253. /**
  21254. * Prepares a frame to be run through a post process.
  21255. * @param sourceTexture The input texture to the post procesess. (default: null)
  21256. * @param postProcesses An array of post processes to be run. (default: null)
  21257. * @returns True if the post processes were able to be run.
  21258. * @hidden
  21259. */
  21260. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21261. /**
  21262. * Manually render a set of post processes to a texture.
  21263. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  21264. * @param postProcesses An array of post processes to be run.
  21265. * @param targetTexture The target texture to render to.
  21266. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21267. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21268. * @param lodLevel defines which lod of the texture to render to
  21269. */
  21270. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21271. /**
  21272. * Finalize the result of the output of the postprocesses.
  21273. * @param doNotPresent If true the result will not be displayed to the screen.
  21274. * @param targetTexture The target texture to render to.
  21275. * @param faceIndex The index of the face to bind the target texture to.
  21276. * @param postProcesses The array of post processes to render.
  21277. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21278. * @hidden
  21279. */
  21280. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21281. /**
  21282. * Disposes of the post process manager.
  21283. */
  21284. dispose(): void;
  21285. }
  21286. }
  21287. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21288. import { Observable } from "babylonjs/Misc/observable";
  21289. import { SmartArray } from "babylonjs/Misc/smartArray";
  21290. import { Nullable, Immutable } from "babylonjs/types";
  21291. import { Camera } from "babylonjs/Cameras/camera";
  21292. import { Scene } from "babylonjs/scene";
  21293. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21294. import { Color4 } from "babylonjs/Maths/math.color";
  21295. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21297. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21299. import { Texture } from "babylonjs/Materials/Textures/texture";
  21300. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21301. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21302. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21303. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21304. import { Engine } from "babylonjs/Engines/engine";
  21305. /**
  21306. * This Helps creating a texture that will be created from a camera in your scene.
  21307. * It is basically a dynamic texture that could be used to create special effects for instance.
  21308. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21309. */
  21310. export class RenderTargetTexture extends Texture {
  21311. isCube: boolean;
  21312. /**
  21313. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21314. */
  21315. static readonly REFRESHRATE_RENDER_ONCE: number;
  21316. /**
  21317. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21318. */
  21319. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21320. /**
  21321. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21322. * the central point of your effect and can save a lot of performances.
  21323. */
  21324. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21325. /**
  21326. * Use this predicate to dynamically define the list of mesh you want to render.
  21327. * If set, the renderList property will be overwritten.
  21328. */
  21329. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21330. private _renderList;
  21331. /**
  21332. * Use this list to define the list of mesh you want to render.
  21333. */
  21334. get renderList(): Nullable<Array<AbstractMesh>>;
  21335. set renderList(value: Nullable<Array<AbstractMesh>>);
  21336. /**
  21337. * Use this function to overload the renderList array at rendering time.
  21338. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21339. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21340. * the cube (if the RTT is a cube, else layerOrFace=0).
  21341. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21342. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21343. * hold dummy elements!
  21344. */
  21345. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21346. private _hookArray;
  21347. /**
  21348. * Define if particles should be rendered in your texture.
  21349. */
  21350. renderParticles: boolean;
  21351. /**
  21352. * Define if sprites should be rendered in your texture.
  21353. */
  21354. renderSprites: boolean;
  21355. /**
  21356. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21357. */
  21358. coordinatesMode: number;
  21359. /**
  21360. * Define the camera used to render the texture.
  21361. */
  21362. activeCamera: Nullable<Camera>;
  21363. /**
  21364. * Override the mesh isReady function with your own one.
  21365. */
  21366. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21367. /**
  21368. * Override the render function of the texture with your own one.
  21369. */
  21370. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21371. /**
  21372. * Define if camera post processes should be use while rendering the texture.
  21373. */
  21374. useCameraPostProcesses: boolean;
  21375. /**
  21376. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21377. */
  21378. ignoreCameraViewport: boolean;
  21379. private _postProcessManager;
  21380. private _postProcesses;
  21381. private _resizeObserver;
  21382. /**
  21383. * An event triggered when the texture is unbind.
  21384. */
  21385. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21386. /**
  21387. * An event triggered when the texture is unbind.
  21388. */
  21389. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21390. private _onAfterUnbindObserver;
  21391. /**
  21392. * Set a after unbind callback in the texture.
  21393. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21394. */
  21395. set onAfterUnbind(callback: () => void);
  21396. /**
  21397. * An event triggered before rendering the texture
  21398. */
  21399. onBeforeRenderObservable: Observable<number>;
  21400. private _onBeforeRenderObserver;
  21401. /**
  21402. * Set a before render callback in the texture.
  21403. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21404. */
  21405. set onBeforeRender(callback: (faceIndex: number) => void);
  21406. /**
  21407. * An event triggered after rendering the texture
  21408. */
  21409. onAfterRenderObservable: Observable<number>;
  21410. private _onAfterRenderObserver;
  21411. /**
  21412. * Set a after render callback in the texture.
  21413. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21414. */
  21415. set onAfterRender(callback: (faceIndex: number) => void);
  21416. /**
  21417. * An event triggered after the texture clear
  21418. */
  21419. onClearObservable: Observable<Engine>;
  21420. private _onClearObserver;
  21421. /**
  21422. * Set a clear callback in the texture.
  21423. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21424. */
  21425. set onClear(callback: (Engine: Engine) => void);
  21426. /**
  21427. * An event triggered when the texture is resized.
  21428. */
  21429. onResizeObservable: Observable<RenderTargetTexture>;
  21430. /**
  21431. * Define the clear color of the Render Target if it should be different from the scene.
  21432. */
  21433. clearColor: Color4;
  21434. protected _size: number | {
  21435. width: number;
  21436. height: number;
  21437. layers?: number;
  21438. };
  21439. protected _initialSizeParameter: number | {
  21440. width: number;
  21441. height: number;
  21442. } | {
  21443. ratio: number;
  21444. };
  21445. protected _sizeRatio: Nullable<number>;
  21446. /** @hidden */
  21447. _generateMipMaps: boolean;
  21448. protected _renderingManager: RenderingManager;
  21449. /** @hidden */
  21450. _waitingRenderList: string[];
  21451. protected _doNotChangeAspectRatio: boolean;
  21452. protected _currentRefreshId: number;
  21453. protected _refreshRate: number;
  21454. protected _textureMatrix: Matrix;
  21455. protected _samples: number;
  21456. protected _renderTargetOptions: RenderTargetCreationOptions;
  21457. /**
  21458. * Gets render target creation options that were used.
  21459. */
  21460. get renderTargetOptions(): RenderTargetCreationOptions;
  21461. protected _engine: Engine;
  21462. protected _onRatioRescale(): void;
  21463. /**
  21464. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21465. * It must define where the camera used to render the texture is set
  21466. */
  21467. boundingBoxPosition: Vector3;
  21468. private _boundingBoxSize;
  21469. /**
  21470. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21471. * When defined, the cubemap will switch to local mode
  21472. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21473. * @example https://www.babylonjs-playground.com/#RNASML
  21474. */
  21475. set boundingBoxSize(value: Vector3);
  21476. get boundingBoxSize(): Vector3;
  21477. /**
  21478. * In case the RTT has been created with a depth texture, get the associated
  21479. * depth texture.
  21480. * Otherwise, return null.
  21481. */
  21482. get depthStencilTexture(): Nullable<InternalTexture>;
  21483. /**
  21484. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21485. * or used a shadow, depth texture...
  21486. * @param name The friendly name of the texture
  21487. * @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)
  21488. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21489. * @param generateMipMaps True if mip maps need to be generated after render.
  21490. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21491. * @param type The type of the buffer in the RTT (int, half float, float...)
  21492. * @param isCube True if a cube texture needs to be created
  21493. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21494. * @param generateDepthBuffer True to generate a depth buffer
  21495. * @param generateStencilBuffer True to generate a stencil buffer
  21496. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21497. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21498. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21499. */
  21500. constructor(name: string, size: number | {
  21501. width: number;
  21502. height: number;
  21503. layers?: number;
  21504. } | {
  21505. ratio: number;
  21506. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21507. /**
  21508. * Creates a depth stencil texture.
  21509. * This is only available in WebGL 2 or with the depth texture extension available.
  21510. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21511. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21512. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21513. */
  21514. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21515. private _processSizeParameter;
  21516. /**
  21517. * Define the number of samples to use in case of MSAA.
  21518. * It defaults to one meaning no MSAA has been enabled.
  21519. */
  21520. get samples(): number;
  21521. set samples(value: number);
  21522. /**
  21523. * Resets the refresh counter of the texture and start bak from scratch.
  21524. * Could be useful to regenerate the texture if it is setup to render only once.
  21525. */
  21526. resetRefreshCounter(): void;
  21527. /**
  21528. * Define the refresh rate of the texture or the rendering frequency.
  21529. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21530. */
  21531. get refreshRate(): number;
  21532. set refreshRate(value: number);
  21533. /**
  21534. * Adds a post process to the render target rendering passes.
  21535. * @param postProcess define the post process to add
  21536. */
  21537. addPostProcess(postProcess: PostProcess): void;
  21538. /**
  21539. * Clear all the post processes attached to the render target
  21540. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21541. */
  21542. clearPostProcesses(dispose?: boolean): void;
  21543. /**
  21544. * Remove one of the post process from the list of attached post processes to the texture
  21545. * @param postProcess define the post process to remove from the list
  21546. */
  21547. removePostProcess(postProcess: PostProcess): void;
  21548. /** @hidden */
  21549. _shouldRender(): boolean;
  21550. /**
  21551. * Gets the actual render size of the texture.
  21552. * @returns the width of the render size
  21553. */
  21554. getRenderSize(): number;
  21555. /**
  21556. * Gets the actual render width of the texture.
  21557. * @returns the width of the render size
  21558. */
  21559. getRenderWidth(): number;
  21560. /**
  21561. * Gets the actual render height of the texture.
  21562. * @returns the height of the render size
  21563. */
  21564. getRenderHeight(): number;
  21565. /**
  21566. * Gets the actual number of layers of the texture.
  21567. * @returns the number of layers
  21568. */
  21569. getRenderLayers(): number;
  21570. /**
  21571. * Get if the texture can be rescaled or not.
  21572. */
  21573. get canRescale(): boolean;
  21574. /**
  21575. * Resize the texture using a ratio.
  21576. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21577. */
  21578. scale(ratio: number): void;
  21579. /**
  21580. * Get the texture reflection matrix used to rotate/transform the reflection.
  21581. * @returns the reflection matrix
  21582. */
  21583. getReflectionTextureMatrix(): Matrix;
  21584. /**
  21585. * Resize the texture to a new desired size.
  21586. * Be carrefull as it will recreate all the data in the new texture.
  21587. * @param size Define the new size. It can be:
  21588. * - a number for squared texture,
  21589. * - an object containing { width: number, height: number }
  21590. * - or an object containing a ratio { ratio: number }
  21591. */
  21592. resize(size: number | {
  21593. width: number;
  21594. height: number;
  21595. } | {
  21596. ratio: number;
  21597. }): void;
  21598. private _defaultRenderListPrepared;
  21599. /**
  21600. * Renders all the objects from the render list into the texture.
  21601. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21602. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21603. */
  21604. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21605. private _bestReflectionRenderTargetDimension;
  21606. private _prepareRenderingManager;
  21607. /**
  21608. * @hidden
  21609. * @param faceIndex face index to bind to if this is a cubetexture
  21610. * @param layer defines the index of the texture to bind in the array
  21611. */
  21612. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21613. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21614. private renderToTarget;
  21615. /**
  21616. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21617. * This allowed control for front to back rendering or reversly depending of the special needs.
  21618. *
  21619. * @param renderingGroupId The rendering group id corresponding to its index
  21620. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21621. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21622. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21623. */
  21624. 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;
  21625. /**
  21626. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21627. *
  21628. * @param renderingGroupId The rendering group id corresponding to its index
  21629. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21630. */
  21631. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21632. /**
  21633. * Clones the texture.
  21634. * @returns the cloned texture
  21635. */
  21636. clone(): RenderTargetTexture;
  21637. /**
  21638. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21639. * @returns The JSON representation of the texture
  21640. */
  21641. serialize(): any;
  21642. /**
  21643. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21644. */
  21645. disposeFramebufferObjects(): void;
  21646. /**
  21647. * Dispose the texture and release its associated resources.
  21648. */
  21649. dispose(): void;
  21650. /** @hidden */
  21651. _rebuild(): void;
  21652. /**
  21653. * Clear the info related to rendering groups preventing retention point in material dispose.
  21654. */
  21655. freeRenderingGroups(): void;
  21656. /**
  21657. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21658. * @returns the view count
  21659. */
  21660. getViewCount(): number;
  21661. }
  21662. }
  21663. declare module "babylonjs/Misc/guid" {
  21664. /**
  21665. * Class used to manipulate GUIDs
  21666. */
  21667. export class GUID {
  21668. /**
  21669. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21670. * Be aware Math.random() could cause collisions, but:
  21671. * "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"
  21672. * @returns a pseudo random id
  21673. */
  21674. static RandomId(): string;
  21675. }
  21676. }
  21677. declare module "babylonjs/Materials/shadowDepthWrapper" {
  21678. import { Nullable } from "babylonjs/types";
  21679. import { Scene } from "babylonjs/scene";
  21680. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21681. import { Material } from "babylonjs/Materials/material";
  21682. import { Effect } from "babylonjs/Materials/effect";
  21683. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  21684. /**
  21685. * Options to be used when creating a shadow depth material
  21686. */
  21687. export interface IIOptionShadowDepthMaterial {
  21688. /** Variables in the vertex shader code that need to have their names remapped.
  21689. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21690. * "var_name" should be either: worldPos or vNormalW
  21691. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21692. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21693. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21694. */
  21695. remappedVariables?: string[];
  21696. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21697. standalone?: boolean;
  21698. }
  21699. /**
  21700. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21701. */
  21702. export class ShadowDepthWrapper {
  21703. private _scene;
  21704. private _options?;
  21705. private _baseMaterial;
  21706. private _onEffectCreatedObserver;
  21707. private _subMeshToEffect;
  21708. private _subMeshToDepthEffect;
  21709. private _meshes;
  21710. /** @hidden */
  21711. _matriceNames: any;
  21712. /** Gets the standalone status of the wrapper */
  21713. get standalone(): boolean;
  21714. /** Gets the base material the wrapper is built upon */
  21715. get baseMaterial(): Material;
  21716. /**
  21717. * Instantiate a new shadow depth wrapper.
  21718. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21719. * generate the shadow depth map. For more information, please refer to the documentation:
  21720. * https://doc.babylonjs.com/babylon101/shadows
  21721. * @param baseMaterial Material to wrap
  21722. * @param scene Define the scene the material belongs to
  21723. * @param options Options used to create the wrapper
  21724. */
  21725. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21726. /**
  21727. * Gets the effect to use to generate the depth map
  21728. * @param subMesh subMesh to get the effect for
  21729. * @param shadowGenerator shadow generator to get the effect for
  21730. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21731. */
  21732. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21733. /**
  21734. * Specifies that the submesh is ready to be used for depth rendering
  21735. * @param subMesh submesh to check
  21736. * @param defines the list of defines to take into account when checking the effect
  21737. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21738. * @param useInstances specifies that instances should be used
  21739. * @returns a boolean indicating that the submesh is ready or not
  21740. */
  21741. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21742. /**
  21743. * Disposes the resources
  21744. */
  21745. dispose(): void;
  21746. private _makeEffect;
  21747. }
  21748. }
  21749. declare module "babylonjs/Materials/material" {
  21750. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21751. import { SmartArray } from "babylonjs/Misc/smartArray";
  21752. import { Observable } from "babylonjs/Misc/observable";
  21753. import { Nullable } from "babylonjs/types";
  21754. import { Scene } from "babylonjs/scene";
  21755. import { Matrix } from "babylonjs/Maths/math.vector";
  21756. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21759. import { Effect } from "babylonjs/Materials/effect";
  21760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21761. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21762. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21763. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21764. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  21765. import { Mesh } from "babylonjs/Meshes/mesh";
  21766. import { Animation } from "babylonjs/Animations/animation";
  21767. /**
  21768. * Options for compiling materials.
  21769. */
  21770. export interface IMaterialCompilationOptions {
  21771. /**
  21772. * Defines whether clip planes are enabled.
  21773. */
  21774. clipPlane: boolean;
  21775. /**
  21776. * Defines whether instances are enabled.
  21777. */
  21778. useInstances: boolean;
  21779. }
  21780. /**
  21781. * Base class for the main features of a material in Babylon.js
  21782. */
  21783. export class Material implements IAnimatable {
  21784. /**
  21785. * Returns the triangle fill mode
  21786. */
  21787. static readonly TriangleFillMode: number;
  21788. /**
  21789. * Returns the wireframe mode
  21790. */
  21791. static readonly WireFrameFillMode: number;
  21792. /**
  21793. * Returns the point fill mode
  21794. */
  21795. static readonly PointFillMode: number;
  21796. /**
  21797. * Returns the point list draw mode
  21798. */
  21799. static readonly PointListDrawMode: number;
  21800. /**
  21801. * Returns the line list draw mode
  21802. */
  21803. static readonly LineListDrawMode: number;
  21804. /**
  21805. * Returns the line loop draw mode
  21806. */
  21807. static readonly LineLoopDrawMode: number;
  21808. /**
  21809. * Returns the line strip draw mode
  21810. */
  21811. static readonly LineStripDrawMode: number;
  21812. /**
  21813. * Returns the triangle strip draw mode
  21814. */
  21815. static readonly TriangleStripDrawMode: number;
  21816. /**
  21817. * Returns the triangle fan draw mode
  21818. */
  21819. static readonly TriangleFanDrawMode: number;
  21820. /**
  21821. * Stores the clock-wise side orientation
  21822. */
  21823. static readonly ClockWiseSideOrientation: number;
  21824. /**
  21825. * Stores the counter clock-wise side orientation
  21826. */
  21827. static readonly CounterClockWiseSideOrientation: number;
  21828. /**
  21829. * The dirty texture flag value
  21830. */
  21831. static readonly TextureDirtyFlag: number;
  21832. /**
  21833. * The dirty light flag value
  21834. */
  21835. static readonly LightDirtyFlag: number;
  21836. /**
  21837. * The dirty fresnel flag value
  21838. */
  21839. static readonly FresnelDirtyFlag: number;
  21840. /**
  21841. * The dirty attribute flag value
  21842. */
  21843. static readonly AttributesDirtyFlag: number;
  21844. /**
  21845. * The dirty misc flag value
  21846. */
  21847. static readonly MiscDirtyFlag: number;
  21848. /**
  21849. * The all dirty flag value
  21850. */
  21851. static readonly AllDirtyFlag: number;
  21852. /**
  21853. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21854. */
  21855. static readonly MATERIAL_OPAQUE: number;
  21856. /**
  21857. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21858. */
  21859. static readonly MATERIAL_ALPHATEST: number;
  21860. /**
  21861. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21862. */
  21863. static readonly MATERIAL_ALPHABLEND: number;
  21864. /**
  21865. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21866. * They are also discarded below the alpha cutoff threshold to improve performances.
  21867. */
  21868. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21869. /**
  21870. * Custom callback helping to override the default shader used in the material.
  21871. */
  21872. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21873. /**
  21874. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21875. */
  21876. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21877. /**
  21878. * The ID of the material
  21879. */
  21880. id: string;
  21881. /**
  21882. * Gets or sets the unique id of the material
  21883. */
  21884. uniqueId: number;
  21885. /**
  21886. * The name of the material
  21887. */
  21888. name: string;
  21889. /**
  21890. * Gets or sets user defined metadata
  21891. */
  21892. metadata: any;
  21893. /**
  21894. * For internal use only. Please do not use.
  21895. */
  21896. reservedDataStore: any;
  21897. /**
  21898. * Specifies if the ready state should be checked on each call
  21899. */
  21900. checkReadyOnEveryCall: boolean;
  21901. /**
  21902. * Specifies if the ready state should be checked once
  21903. */
  21904. checkReadyOnlyOnce: boolean;
  21905. /**
  21906. * The state of the material
  21907. */
  21908. state: string;
  21909. /**
  21910. * The alpha value of the material
  21911. */
  21912. protected _alpha: number;
  21913. /**
  21914. * List of inspectable custom properties (used by the Inspector)
  21915. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21916. */
  21917. inspectableCustomProperties: IInspectable[];
  21918. /**
  21919. * Sets the alpha value of the material
  21920. */
  21921. set alpha(value: number);
  21922. /**
  21923. * Gets the alpha value of the material
  21924. */
  21925. get alpha(): number;
  21926. /**
  21927. * Specifies if back face culling is enabled
  21928. */
  21929. protected _backFaceCulling: boolean;
  21930. /**
  21931. * Sets the back-face culling state
  21932. */
  21933. set backFaceCulling(value: boolean);
  21934. /**
  21935. * Gets the back-face culling state
  21936. */
  21937. get backFaceCulling(): boolean;
  21938. /**
  21939. * Stores the value for side orientation
  21940. */
  21941. sideOrientation: number;
  21942. /**
  21943. * Callback triggered when the material is compiled
  21944. */
  21945. onCompiled: Nullable<(effect: Effect) => void>;
  21946. /**
  21947. * Callback triggered when an error occurs
  21948. */
  21949. onError: Nullable<(effect: Effect, errors: string) => void>;
  21950. /**
  21951. * Callback triggered to get the render target textures
  21952. */
  21953. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21954. /**
  21955. * Gets a boolean indicating that current material needs to register RTT
  21956. */
  21957. get hasRenderTargetTextures(): boolean;
  21958. /**
  21959. * Specifies if the material should be serialized
  21960. */
  21961. doNotSerialize: boolean;
  21962. /**
  21963. * @hidden
  21964. */
  21965. _storeEffectOnSubMeshes: boolean;
  21966. /**
  21967. * Stores the animations for the material
  21968. */
  21969. animations: Nullable<Array<Animation>>;
  21970. /**
  21971. * An event triggered when the material is disposed
  21972. */
  21973. onDisposeObservable: Observable<Material>;
  21974. /**
  21975. * An observer which watches for dispose events
  21976. */
  21977. private _onDisposeObserver;
  21978. private _onUnBindObservable;
  21979. /**
  21980. * Called during a dispose event
  21981. */
  21982. set onDispose(callback: () => void);
  21983. private _onBindObservable;
  21984. /**
  21985. * An event triggered when the material is bound
  21986. */
  21987. get onBindObservable(): Observable<AbstractMesh>;
  21988. /**
  21989. * An observer which watches for bind events
  21990. */
  21991. private _onBindObserver;
  21992. /**
  21993. * Called during a bind event
  21994. */
  21995. set onBind(callback: (Mesh: AbstractMesh) => void);
  21996. /**
  21997. * An event triggered when the material is unbound
  21998. */
  21999. get onUnBindObservable(): Observable<Material>;
  22000. protected _onEffectCreatedObservable: Nullable<Observable<{
  22001. effect: Effect;
  22002. subMesh: Nullable<SubMesh>;
  22003. }>>;
  22004. /**
  22005. * An event triggered when the effect is (re)created
  22006. */
  22007. get onEffectCreatedObservable(): Observable<{
  22008. effect: Effect;
  22009. subMesh: Nullable<SubMesh>;
  22010. }>;
  22011. /**
  22012. * Stores the value of the alpha mode
  22013. */
  22014. private _alphaMode;
  22015. /**
  22016. * Sets the value of the alpha mode.
  22017. *
  22018. * | Value | Type | Description |
  22019. * | --- | --- | --- |
  22020. * | 0 | ALPHA_DISABLE | |
  22021. * | 1 | ALPHA_ADD | |
  22022. * | 2 | ALPHA_COMBINE | |
  22023. * | 3 | ALPHA_SUBTRACT | |
  22024. * | 4 | ALPHA_MULTIPLY | |
  22025. * | 5 | ALPHA_MAXIMIZED | |
  22026. * | 6 | ALPHA_ONEONE | |
  22027. * | 7 | ALPHA_PREMULTIPLIED | |
  22028. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22029. * | 9 | ALPHA_INTERPOLATE | |
  22030. * | 10 | ALPHA_SCREENMODE | |
  22031. *
  22032. */
  22033. set alphaMode(value: number);
  22034. /**
  22035. * Gets the value of the alpha mode
  22036. */
  22037. get alphaMode(): number;
  22038. /**
  22039. * Stores the state of the need depth pre-pass value
  22040. */
  22041. private _needDepthPrePass;
  22042. /**
  22043. * Sets the need depth pre-pass value
  22044. */
  22045. set needDepthPrePass(value: boolean);
  22046. /**
  22047. * Gets the depth pre-pass value
  22048. */
  22049. get needDepthPrePass(): boolean;
  22050. /**
  22051. * Specifies if depth writing should be disabled
  22052. */
  22053. disableDepthWrite: boolean;
  22054. /**
  22055. * Specifies if color writing should be disabled
  22056. */
  22057. disableColorWrite: boolean;
  22058. /**
  22059. * Specifies if depth writing should be forced
  22060. */
  22061. forceDepthWrite: boolean;
  22062. /**
  22063. * Specifies the depth function that should be used. 0 means the default engine function
  22064. */
  22065. depthFunction: number;
  22066. /**
  22067. * Specifies if there should be a separate pass for culling
  22068. */
  22069. separateCullingPass: boolean;
  22070. /**
  22071. * Stores the state specifing if fog should be enabled
  22072. */
  22073. private _fogEnabled;
  22074. /**
  22075. * Sets the state for enabling fog
  22076. */
  22077. set fogEnabled(value: boolean);
  22078. /**
  22079. * Gets the value of the fog enabled state
  22080. */
  22081. get fogEnabled(): boolean;
  22082. /**
  22083. * Stores the size of points
  22084. */
  22085. pointSize: number;
  22086. /**
  22087. * Stores the z offset value
  22088. */
  22089. zOffset: number;
  22090. get wireframe(): boolean;
  22091. /**
  22092. * Sets the state of wireframe mode
  22093. */
  22094. set wireframe(value: boolean);
  22095. /**
  22096. * Gets the value specifying if point clouds are enabled
  22097. */
  22098. get pointsCloud(): boolean;
  22099. /**
  22100. * Sets the state of point cloud mode
  22101. */
  22102. set pointsCloud(value: boolean);
  22103. /**
  22104. * Gets the material fill mode
  22105. */
  22106. get fillMode(): number;
  22107. /**
  22108. * Sets the material fill mode
  22109. */
  22110. set fillMode(value: number);
  22111. /**
  22112. * @hidden
  22113. * Stores the effects for the material
  22114. */
  22115. _effect: Nullable<Effect>;
  22116. /**
  22117. * Specifies if uniform buffers should be used
  22118. */
  22119. private _useUBO;
  22120. /**
  22121. * Stores a reference to the scene
  22122. */
  22123. private _scene;
  22124. /**
  22125. * Stores the fill mode state
  22126. */
  22127. private _fillMode;
  22128. /**
  22129. * Specifies if the depth write state should be cached
  22130. */
  22131. private _cachedDepthWriteState;
  22132. /**
  22133. * Specifies if the color write state should be cached
  22134. */
  22135. private _cachedColorWriteState;
  22136. /**
  22137. * Specifies if the depth function state should be cached
  22138. */
  22139. private _cachedDepthFunctionState;
  22140. /**
  22141. * Stores the uniform buffer
  22142. */
  22143. protected _uniformBuffer: UniformBuffer;
  22144. /** @hidden */
  22145. _indexInSceneMaterialArray: number;
  22146. /** @hidden */
  22147. meshMap: Nullable<{
  22148. [id: string]: AbstractMesh | undefined;
  22149. }>;
  22150. /**
  22151. * Creates a material instance
  22152. * @param name defines the name of the material
  22153. * @param scene defines the scene to reference
  22154. * @param doNotAdd specifies if the material should be added to the scene
  22155. */
  22156. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22157. /**
  22158. * Returns a string representation of the current material
  22159. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22160. * @returns a string with material information
  22161. */
  22162. toString(fullDetails?: boolean): string;
  22163. /**
  22164. * Gets the class name of the material
  22165. * @returns a string with the class name of the material
  22166. */
  22167. getClassName(): string;
  22168. /**
  22169. * Specifies if updates for the material been locked
  22170. */
  22171. get isFrozen(): boolean;
  22172. /**
  22173. * Locks updates for the material
  22174. */
  22175. freeze(): void;
  22176. /**
  22177. * Unlocks updates for the material
  22178. */
  22179. unfreeze(): void;
  22180. /**
  22181. * Specifies if the material is ready to be used
  22182. * @param mesh defines the mesh to check
  22183. * @param useInstances specifies if instances should be used
  22184. * @returns a boolean indicating if the material is ready to be used
  22185. */
  22186. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22187. /**
  22188. * Specifies that the submesh is ready to be used
  22189. * @param mesh defines the mesh to check
  22190. * @param subMesh defines which submesh to check
  22191. * @param useInstances specifies that instances should be used
  22192. * @returns a boolean indicating that the submesh is ready or not
  22193. */
  22194. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22195. /**
  22196. * Returns the material effect
  22197. * @returns the effect associated with the material
  22198. */
  22199. getEffect(): Nullable<Effect>;
  22200. /**
  22201. * Returns the current scene
  22202. * @returns a Scene
  22203. */
  22204. getScene(): Scene;
  22205. /**
  22206. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22207. */
  22208. protected _forceAlphaTest: boolean;
  22209. /**
  22210. * The transparency mode of the material.
  22211. */
  22212. protected _transparencyMode: Nullable<number>;
  22213. /**
  22214. * Gets the current transparency mode.
  22215. */
  22216. get transparencyMode(): Nullable<number>;
  22217. /**
  22218. * Sets the transparency mode of the material.
  22219. *
  22220. * | Value | Type | Description |
  22221. * | ----- | ----------------------------------- | ----------- |
  22222. * | 0 | OPAQUE | |
  22223. * | 1 | ALPHATEST | |
  22224. * | 2 | ALPHABLEND | |
  22225. * | 3 | ALPHATESTANDBLEND | |
  22226. *
  22227. */
  22228. set transparencyMode(value: Nullable<number>);
  22229. /**
  22230. * Returns true if alpha blending should be disabled.
  22231. */
  22232. protected get _disableAlphaBlending(): boolean;
  22233. /**
  22234. * Specifies whether or not this material should be rendered in alpha blend mode.
  22235. * @returns a boolean specifying if alpha blending is needed
  22236. */
  22237. needAlphaBlending(): boolean;
  22238. /**
  22239. * Specifies if the mesh will require alpha blending
  22240. * @param mesh defines the mesh to check
  22241. * @returns a boolean specifying if alpha blending is needed for the mesh
  22242. */
  22243. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22244. /**
  22245. * Specifies whether or not this material should be rendered in alpha test mode.
  22246. * @returns a boolean specifying if an alpha test is needed.
  22247. */
  22248. needAlphaTesting(): boolean;
  22249. /**
  22250. * Specifies if material alpha testing should be turned on for the mesh
  22251. * @param mesh defines the mesh to check
  22252. */
  22253. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22254. /**
  22255. * Gets the texture used for the alpha test
  22256. * @returns the texture to use for alpha testing
  22257. */
  22258. getAlphaTestTexture(): Nullable<BaseTexture>;
  22259. /**
  22260. * Marks the material to indicate that it needs to be re-calculated
  22261. */
  22262. markDirty(): void;
  22263. /** @hidden */
  22264. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22265. /**
  22266. * Binds the material to the mesh
  22267. * @param world defines the world transformation matrix
  22268. * @param mesh defines the mesh to bind the material to
  22269. */
  22270. bind(world: Matrix, mesh?: Mesh): void;
  22271. /**
  22272. * Binds the submesh to the material
  22273. * @param world defines the world transformation matrix
  22274. * @param mesh defines the mesh containing the submesh
  22275. * @param subMesh defines the submesh to bind the material to
  22276. */
  22277. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22278. /**
  22279. * Binds the world matrix to the material
  22280. * @param world defines the world transformation matrix
  22281. */
  22282. bindOnlyWorldMatrix(world: Matrix): void;
  22283. /**
  22284. * Binds the scene's uniform buffer to the effect.
  22285. * @param effect defines the effect to bind to the scene uniform buffer
  22286. * @param sceneUbo defines the uniform buffer storing scene data
  22287. */
  22288. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22289. /**
  22290. * Binds the view matrix to the effect
  22291. * @param effect defines the effect to bind the view matrix to
  22292. */
  22293. bindView(effect: Effect): void;
  22294. /**
  22295. * Binds the view projection matrix to the effect
  22296. * @param effect defines the effect to bind the view projection matrix to
  22297. */
  22298. bindViewProjection(effect: Effect): void;
  22299. /**
  22300. * Processes to execute after binding the material to a mesh
  22301. * @param mesh defines the rendered mesh
  22302. */
  22303. protected _afterBind(mesh?: Mesh): void;
  22304. /**
  22305. * Unbinds the material from the mesh
  22306. */
  22307. unbind(): void;
  22308. /**
  22309. * Gets the active textures from the material
  22310. * @returns an array of textures
  22311. */
  22312. getActiveTextures(): BaseTexture[];
  22313. /**
  22314. * Specifies if the material uses a texture
  22315. * @param texture defines the texture to check against the material
  22316. * @returns a boolean specifying if the material uses the texture
  22317. */
  22318. hasTexture(texture: BaseTexture): boolean;
  22319. /**
  22320. * Makes a duplicate of the material, and gives it a new name
  22321. * @param name defines the new name for the duplicated material
  22322. * @returns the cloned material
  22323. */
  22324. clone(name: string): Nullable<Material>;
  22325. /**
  22326. * Gets the meshes bound to the material
  22327. * @returns an array of meshes bound to the material
  22328. */
  22329. getBindedMeshes(): AbstractMesh[];
  22330. /**
  22331. * Force shader compilation
  22332. * @param mesh defines the mesh associated with this material
  22333. * @param onCompiled defines a function to execute once the material is compiled
  22334. * @param options defines the options to configure the compilation
  22335. * @param onError defines a function to execute if the material fails compiling
  22336. */
  22337. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22338. /**
  22339. * Force shader compilation
  22340. * @param mesh defines the mesh that will use this material
  22341. * @param options defines additional options for compiling the shaders
  22342. * @returns a promise that resolves when the compilation completes
  22343. */
  22344. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22345. private static readonly _AllDirtyCallBack;
  22346. private static readonly _ImageProcessingDirtyCallBack;
  22347. private static readonly _TextureDirtyCallBack;
  22348. private static readonly _FresnelDirtyCallBack;
  22349. private static readonly _MiscDirtyCallBack;
  22350. private static readonly _LightsDirtyCallBack;
  22351. private static readonly _AttributeDirtyCallBack;
  22352. private static _FresnelAndMiscDirtyCallBack;
  22353. private static _TextureAndMiscDirtyCallBack;
  22354. private static readonly _DirtyCallbackArray;
  22355. private static readonly _RunDirtyCallBacks;
  22356. /**
  22357. * Marks a define in the material to indicate that it needs to be re-computed
  22358. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22359. */
  22360. markAsDirty(flag: number): void;
  22361. /**
  22362. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22363. * @param func defines a function which checks material defines against the submeshes
  22364. */
  22365. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22366. /**
  22367. * Indicates that we need to re-calculated for all submeshes
  22368. */
  22369. protected _markAllSubMeshesAsAllDirty(): void;
  22370. /**
  22371. * Indicates that image processing needs to be re-calculated for all submeshes
  22372. */
  22373. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22374. /**
  22375. * Indicates that textures need to be re-calculated for all submeshes
  22376. */
  22377. protected _markAllSubMeshesAsTexturesDirty(): void;
  22378. /**
  22379. * Indicates that fresnel needs to be re-calculated for all submeshes
  22380. */
  22381. protected _markAllSubMeshesAsFresnelDirty(): void;
  22382. /**
  22383. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22384. */
  22385. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22386. /**
  22387. * Indicates that lights need to be re-calculated for all submeshes
  22388. */
  22389. protected _markAllSubMeshesAsLightsDirty(): void;
  22390. /**
  22391. * Indicates that attributes need to be re-calculated for all submeshes
  22392. */
  22393. protected _markAllSubMeshesAsAttributesDirty(): void;
  22394. /**
  22395. * Indicates that misc needs to be re-calculated for all submeshes
  22396. */
  22397. protected _markAllSubMeshesAsMiscDirty(): void;
  22398. /**
  22399. * Indicates that textures and misc need to be re-calculated for all submeshes
  22400. */
  22401. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22402. /**
  22403. * Disposes the material
  22404. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22405. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22406. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22407. */
  22408. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22409. /** @hidden */
  22410. private releaseVertexArrayObject;
  22411. /**
  22412. * Serializes this material
  22413. * @returns the serialized material object
  22414. */
  22415. serialize(): any;
  22416. /**
  22417. * Creates a material from parsed material data
  22418. * @param parsedMaterial defines parsed material data
  22419. * @param scene defines the hosting scene
  22420. * @param rootUrl defines the root URL to use to load textures
  22421. * @returns a new material
  22422. */
  22423. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22424. }
  22425. }
  22426. declare module "babylonjs/Materials/multiMaterial" {
  22427. import { Nullable } from "babylonjs/types";
  22428. import { Scene } from "babylonjs/scene";
  22429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22430. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22432. import { Material } from "babylonjs/Materials/material";
  22433. /**
  22434. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22435. * separate meshes. This can be use to improve performances.
  22436. * @see http://doc.babylonjs.com/how_to/multi_materials
  22437. */
  22438. export class MultiMaterial extends Material {
  22439. private _subMaterials;
  22440. /**
  22441. * Gets or Sets the list of Materials used within the multi material.
  22442. * They need to be ordered according to the submeshes order in the associated mesh
  22443. */
  22444. get subMaterials(): Nullable<Material>[];
  22445. set subMaterials(value: Nullable<Material>[]);
  22446. /**
  22447. * Function used to align with Node.getChildren()
  22448. * @returns the list of Materials used within the multi material
  22449. */
  22450. getChildren(): Nullable<Material>[];
  22451. /**
  22452. * Instantiates a new Multi Material
  22453. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22454. * separate meshes. This can be use to improve performances.
  22455. * @see http://doc.babylonjs.com/how_to/multi_materials
  22456. * @param name Define the name in the scene
  22457. * @param scene Define the scene the material belongs to
  22458. */
  22459. constructor(name: string, scene: Scene);
  22460. private _hookArray;
  22461. /**
  22462. * Get one of the submaterial by its index in the submaterials array
  22463. * @param index The index to look the sub material at
  22464. * @returns The Material if the index has been defined
  22465. */
  22466. getSubMaterial(index: number): Nullable<Material>;
  22467. /**
  22468. * Get the list of active textures for the whole sub materials list.
  22469. * @returns All the textures that will be used during the rendering
  22470. */
  22471. getActiveTextures(): BaseTexture[];
  22472. /**
  22473. * Gets the current class name of the material e.g. "MultiMaterial"
  22474. * Mainly use in serialization.
  22475. * @returns the class name
  22476. */
  22477. getClassName(): string;
  22478. /**
  22479. * Checks if the material is ready to render the requested sub mesh
  22480. * @param mesh Define the mesh the submesh belongs to
  22481. * @param subMesh Define the sub mesh to look readyness for
  22482. * @param useInstances Define whether or not the material is used with instances
  22483. * @returns true if ready, otherwise false
  22484. */
  22485. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22486. /**
  22487. * Clones the current material and its related sub materials
  22488. * @param name Define the name of the newly cloned material
  22489. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22490. * @returns the cloned material
  22491. */
  22492. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22493. /**
  22494. * Serializes the materials into a JSON representation.
  22495. * @returns the JSON representation
  22496. */
  22497. serialize(): any;
  22498. /**
  22499. * Dispose the material and release its associated resources
  22500. * @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)
  22501. * @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)
  22502. * @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)
  22503. */
  22504. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22505. /**
  22506. * Creates a MultiMaterial from parsed MultiMaterial data.
  22507. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22508. * @param scene defines the hosting scene
  22509. * @returns a new MultiMaterial
  22510. */
  22511. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22512. }
  22513. }
  22514. declare module "babylonjs/Meshes/subMesh" {
  22515. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22516. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22517. import { Engine } from "babylonjs/Engines/engine";
  22518. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22519. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22520. import { Effect } from "babylonjs/Materials/effect";
  22521. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22522. import { Plane } from "babylonjs/Maths/math.plane";
  22523. import { Collider } from "babylonjs/Collisions/collider";
  22524. import { Material } from "babylonjs/Materials/material";
  22525. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22527. import { Mesh } from "babylonjs/Meshes/mesh";
  22528. import { Ray } from "babylonjs/Culling/ray";
  22529. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22530. /**
  22531. * Base class for submeshes
  22532. */
  22533. export class BaseSubMesh {
  22534. /** @hidden */
  22535. _materialDefines: Nullable<MaterialDefines>;
  22536. /** @hidden */
  22537. _materialEffect: Nullable<Effect>;
  22538. /** @hidden */
  22539. _effectOverride: Nullable<Effect>;
  22540. /**
  22541. * Gets material defines used by the effect associated to the sub mesh
  22542. */
  22543. get materialDefines(): Nullable<MaterialDefines>;
  22544. /**
  22545. * Sets material defines used by the effect associated to the sub mesh
  22546. */
  22547. set materialDefines(defines: Nullable<MaterialDefines>);
  22548. /**
  22549. * Gets associated effect
  22550. */
  22551. get effect(): Nullable<Effect>;
  22552. /**
  22553. * Sets associated effect (effect used to render this submesh)
  22554. * @param effect defines the effect to associate with
  22555. * @param defines defines the set of defines used to compile this effect
  22556. */
  22557. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22558. }
  22559. /**
  22560. * Defines a subdivision inside a mesh
  22561. */
  22562. export class SubMesh extends BaseSubMesh implements ICullable {
  22563. /** the material index to use */
  22564. materialIndex: number;
  22565. /** vertex index start */
  22566. verticesStart: number;
  22567. /** vertices count */
  22568. verticesCount: number;
  22569. /** index start */
  22570. indexStart: number;
  22571. /** indices count */
  22572. indexCount: number;
  22573. /** @hidden */
  22574. _linesIndexCount: number;
  22575. private _mesh;
  22576. private _renderingMesh;
  22577. private _boundingInfo;
  22578. private _linesIndexBuffer;
  22579. /** @hidden */
  22580. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22581. /** @hidden */
  22582. _trianglePlanes: Plane[];
  22583. /** @hidden */
  22584. _lastColliderTransformMatrix: Nullable<Matrix>;
  22585. /** @hidden */
  22586. _renderId: number;
  22587. /** @hidden */
  22588. _alphaIndex: number;
  22589. /** @hidden */
  22590. _distanceToCamera: number;
  22591. /** @hidden */
  22592. _id: number;
  22593. private _currentMaterial;
  22594. /**
  22595. * Add a new submesh to a mesh
  22596. * @param materialIndex defines the material index to use
  22597. * @param verticesStart defines vertex index start
  22598. * @param verticesCount defines vertices count
  22599. * @param indexStart defines index start
  22600. * @param indexCount defines indices count
  22601. * @param mesh defines the parent mesh
  22602. * @param renderingMesh defines an optional rendering mesh
  22603. * @param createBoundingBox defines if bounding box should be created for this submesh
  22604. * @returns the new submesh
  22605. */
  22606. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22607. /**
  22608. * Creates a new submesh
  22609. * @param materialIndex defines the material index to use
  22610. * @param verticesStart defines vertex index start
  22611. * @param verticesCount defines vertices count
  22612. * @param indexStart defines index start
  22613. * @param indexCount defines indices count
  22614. * @param mesh defines the parent mesh
  22615. * @param renderingMesh defines an optional rendering mesh
  22616. * @param createBoundingBox defines if bounding box should be created for this submesh
  22617. */
  22618. constructor(
  22619. /** the material index to use */
  22620. materialIndex: number,
  22621. /** vertex index start */
  22622. verticesStart: number,
  22623. /** vertices count */
  22624. verticesCount: number,
  22625. /** index start */
  22626. indexStart: number,
  22627. /** indices count */
  22628. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22629. /**
  22630. * Returns true if this submesh covers the entire parent mesh
  22631. * @ignorenaming
  22632. */
  22633. get IsGlobal(): boolean;
  22634. /**
  22635. * Returns the submesh BoudingInfo object
  22636. * @returns current bounding info (or mesh's one if the submesh is global)
  22637. */
  22638. getBoundingInfo(): BoundingInfo;
  22639. /**
  22640. * Sets the submesh BoundingInfo
  22641. * @param boundingInfo defines the new bounding info to use
  22642. * @returns the SubMesh
  22643. */
  22644. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22645. /**
  22646. * Returns the mesh of the current submesh
  22647. * @return the parent mesh
  22648. */
  22649. getMesh(): AbstractMesh;
  22650. /**
  22651. * Returns the rendering mesh of the submesh
  22652. * @returns the rendering mesh (could be different from parent mesh)
  22653. */
  22654. getRenderingMesh(): Mesh;
  22655. /**
  22656. * Returns the submesh material
  22657. * @returns null or the current material
  22658. */
  22659. getMaterial(): Nullable<Material>;
  22660. /**
  22661. * Sets a new updated BoundingInfo object to the submesh
  22662. * @param data defines an optional position array to use to determine the bounding info
  22663. * @returns the SubMesh
  22664. */
  22665. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22666. /** @hidden */
  22667. _checkCollision(collider: Collider): boolean;
  22668. /**
  22669. * Updates the submesh BoundingInfo
  22670. * @param world defines the world matrix to use to update the bounding info
  22671. * @returns the submesh
  22672. */
  22673. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22674. /**
  22675. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22676. * @param frustumPlanes defines the frustum planes
  22677. * @returns true if the submesh is intersecting with the frustum
  22678. */
  22679. isInFrustum(frustumPlanes: Plane[]): boolean;
  22680. /**
  22681. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22682. * @param frustumPlanes defines the frustum planes
  22683. * @returns true if the submesh is inside the frustum
  22684. */
  22685. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22686. /**
  22687. * Renders the submesh
  22688. * @param enableAlphaMode defines if alpha needs to be used
  22689. * @returns the submesh
  22690. */
  22691. render(enableAlphaMode: boolean): SubMesh;
  22692. /**
  22693. * @hidden
  22694. */
  22695. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22696. /**
  22697. * Checks if the submesh intersects with a ray
  22698. * @param ray defines the ray to test
  22699. * @returns true is the passed ray intersects the submesh bounding box
  22700. */
  22701. canIntersects(ray: Ray): boolean;
  22702. /**
  22703. * Intersects current submesh with a ray
  22704. * @param ray defines the ray to test
  22705. * @param positions defines mesh's positions array
  22706. * @param indices defines mesh's indices array
  22707. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22708. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22709. * @returns intersection info or null if no intersection
  22710. */
  22711. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22712. /** @hidden */
  22713. private _intersectLines;
  22714. /** @hidden */
  22715. private _intersectUnIndexedLines;
  22716. /** @hidden */
  22717. private _intersectTriangles;
  22718. /** @hidden */
  22719. private _intersectUnIndexedTriangles;
  22720. /** @hidden */
  22721. _rebuild(): void;
  22722. /**
  22723. * Creates a new submesh from the passed mesh
  22724. * @param newMesh defines the new hosting mesh
  22725. * @param newRenderingMesh defines an optional rendering mesh
  22726. * @returns the new submesh
  22727. */
  22728. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22729. /**
  22730. * Release associated resources
  22731. */
  22732. dispose(): void;
  22733. /**
  22734. * Gets the class name
  22735. * @returns the string "SubMesh".
  22736. */
  22737. getClassName(): string;
  22738. /**
  22739. * Creates a new submesh from indices data
  22740. * @param materialIndex the index of the main mesh material
  22741. * @param startIndex the index where to start the copy in the mesh indices array
  22742. * @param indexCount the number of indices to copy then from the startIndex
  22743. * @param mesh the main mesh to create the submesh from
  22744. * @param renderingMesh the optional rendering mesh
  22745. * @returns a new submesh
  22746. */
  22747. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22748. }
  22749. }
  22750. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22751. /**
  22752. * Class used to represent data loading progression
  22753. */
  22754. export class SceneLoaderFlags {
  22755. private static _ForceFullSceneLoadingForIncremental;
  22756. private static _ShowLoadingScreen;
  22757. private static _CleanBoneMatrixWeights;
  22758. private static _loggingLevel;
  22759. /**
  22760. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22761. */
  22762. static get ForceFullSceneLoadingForIncremental(): boolean;
  22763. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22764. /**
  22765. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22766. */
  22767. static get ShowLoadingScreen(): boolean;
  22768. static set ShowLoadingScreen(value: boolean);
  22769. /**
  22770. * Defines the current logging level (while loading the scene)
  22771. * @ignorenaming
  22772. */
  22773. static get loggingLevel(): number;
  22774. static set loggingLevel(value: number);
  22775. /**
  22776. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22777. */
  22778. static get CleanBoneMatrixWeights(): boolean;
  22779. static set CleanBoneMatrixWeights(value: boolean);
  22780. }
  22781. }
  22782. declare module "babylonjs/Meshes/geometry" {
  22783. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22784. import { Scene } from "babylonjs/scene";
  22785. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22786. import { Engine } from "babylonjs/Engines/engine";
  22787. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22788. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22789. import { Effect } from "babylonjs/Materials/effect";
  22790. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22791. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22792. import { Mesh } from "babylonjs/Meshes/mesh";
  22793. /**
  22794. * Class used to store geometry data (vertex buffers + index buffer)
  22795. */
  22796. export class Geometry implements IGetSetVerticesData {
  22797. /**
  22798. * Gets or sets the ID of the geometry
  22799. */
  22800. id: string;
  22801. /**
  22802. * Gets or sets the unique ID of the geometry
  22803. */
  22804. uniqueId: number;
  22805. /**
  22806. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22807. */
  22808. delayLoadState: number;
  22809. /**
  22810. * Gets the file containing the data to load when running in delay load state
  22811. */
  22812. delayLoadingFile: Nullable<string>;
  22813. /**
  22814. * Callback called when the geometry is updated
  22815. */
  22816. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22817. private _scene;
  22818. private _engine;
  22819. private _meshes;
  22820. private _totalVertices;
  22821. /** @hidden */
  22822. _indices: IndicesArray;
  22823. /** @hidden */
  22824. _vertexBuffers: {
  22825. [key: string]: VertexBuffer;
  22826. };
  22827. private _isDisposed;
  22828. private _extend;
  22829. private _boundingBias;
  22830. /** @hidden */
  22831. _delayInfo: Array<string>;
  22832. private _indexBuffer;
  22833. private _indexBufferIsUpdatable;
  22834. /** @hidden */
  22835. _boundingInfo: Nullable<BoundingInfo>;
  22836. /** @hidden */
  22837. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22838. /** @hidden */
  22839. _softwareSkinningFrameId: number;
  22840. private _vertexArrayObjects;
  22841. private _updatable;
  22842. /** @hidden */
  22843. _positions: Nullable<Vector3[]>;
  22844. /**
  22845. * 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
  22846. */
  22847. get boundingBias(): Vector2;
  22848. /**
  22849. * 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
  22850. */
  22851. set boundingBias(value: Vector2);
  22852. /**
  22853. * Static function used to attach a new empty geometry to a mesh
  22854. * @param mesh defines the mesh to attach the geometry to
  22855. * @returns the new Geometry
  22856. */
  22857. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22858. /** Get the list of meshes using this geometry */
  22859. get meshes(): Mesh[];
  22860. /**
  22861. * Creates a new geometry
  22862. * @param id defines the unique ID
  22863. * @param scene defines the hosting scene
  22864. * @param vertexData defines the VertexData used to get geometry data
  22865. * @param updatable defines if geometry must be updatable (false by default)
  22866. * @param mesh defines the mesh that will be associated with the geometry
  22867. */
  22868. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22869. /**
  22870. * Gets the current extend of the geometry
  22871. */
  22872. get extend(): {
  22873. minimum: Vector3;
  22874. maximum: Vector3;
  22875. };
  22876. /**
  22877. * Gets the hosting scene
  22878. * @returns the hosting Scene
  22879. */
  22880. getScene(): Scene;
  22881. /**
  22882. * Gets the hosting engine
  22883. * @returns the hosting Engine
  22884. */
  22885. getEngine(): Engine;
  22886. /**
  22887. * Defines if the geometry is ready to use
  22888. * @returns true if the geometry is ready to be used
  22889. */
  22890. isReady(): boolean;
  22891. /**
  22892. * Gets a value indicating that the geometry should not be serialized
  22893. */
  22894. get doNotSerialize(): boolean;
  22895. /** @hidden */
  22896. _rebuild(): void;
  22897. /**
  22898. * Affects all geometry data in one call
  22899. * @param vertexData defines the geometry data
  22900. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22901. */
  22902. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22903. /**
  22904. * Set specific vertex data
  22905. * @param kind defines the data kind (Position, normal, etc...)
  22906. * @param data defines the vertex data to use
  22907. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22908. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22909. */
  22910. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22911. /**
  22912. * Removes a specific vertex data
  22913. * @param kind defines the data kind (Position, normal, etc...)
  22914. */
  22915. removeVerticesData(kind: string): void;
  22916. /**
  22917. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22918. * @param buffer defines the vertex buffer to use
  22919. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22920. */
  22921. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22922. /**
  22923. * Update a specific vertex buffer
  22924. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22925. * It will do nothing if the buffer is not updatable
  22926. * @param kind defines the data kind (Position, normal, etc...)
  22927. * @param data defines the data to use
  22928. * @param offset defines the offset in the target buffer where to store the data
  22929. * @param useBytes set to true if the offset is in bytes
  22930. */
  22931. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22932. /**
  22933. * Update a specific vertex buffer
  22934. * This function will create a new buffer if the current one is not updatable
  22935. * @param kind defines the data kind (Position, normal, etc...)
  22936. * @param data defines the data to use
  22937. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22938. */
  22939. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22940. private _updateBoundingInfo;
  22941. /** @hidden */
  22942. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22943. /**
  22944. * Gets total number of vertices
  22945. * @returns the total number of vertices
  22946. */
  22947. getTotalVertices(): number;
  22948. /**
  22949. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22950. * @param kind defines the data kind (Position, normal, etc...)
  22951. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22952. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22953. * @returns a float array containing vertex data
  22954. */
  22955. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22956. /**
  22957. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22958. * @param kind defines the data kind (Position, normal, etc...)
  22959. * @returns true if the vertex buffer with the specified kind is updatable
  22960. */
  22961. isVertexBufferUpdatable(kind: string): boolean;
  22962. /**
  22963. * Gets a specific vertex buffer
  22964. * @param kind defines the data kind (Position, normal, etc...)
  22965. * @returns a VertexBuffer
  22966. */
  22967. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22968. /**
  22969. * Returns all vertex buffers
  22970. * @return an object holding all vertex buffers indexed by kind
  22971. */
  22972. getVertexBuffers(): Nullable<{
  22973. [key: string]: VertexBuffer;
  22974. }>;
  22975. /**
  22976. * Gets a boolean indicating if specific vertex buffer is present
  22977. * @param kind defines the data kind (Position, normal, etc...)
  22978. * @returns true if data is present
  22979. */
  22980. isVerticesDataPresent(kind: string): boolean;
  22981. /**
  22982. * Gets a list of all attached data kinds (Position, normal, etc...)
  22983. * @returns a list of string containing all kinds
  22984. */
  22985. getVerticesDataKinds(): string[];
  22986. /**
  22987. * Update index buffer
  22988. * @param indices defines the indices to store in the index buffer
  22989. * @param offset defines the offset in the target buffer where to store the data
  22990. * @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)
  22991. */
  22992. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22993. /**
  22994. * Creates a new index buffer
  22995. * @param indices defines the indices to store in the index buffer
  22996. * @param totalVertices defines the total number of vertices (could be null)
  22997. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22998. */
  22999. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23000. /**
  23001. * Return the total number of indices
  23002. * @returns the total number of indices
  23003. */
  23004. getTotalIndices(): number;
  23005. /**
  23006. * Gets the index buffer array
  23007. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23008. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23009. * @returns the index buffer array
  23010. */
  23011. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23012. /**
  23013. * Gets the index buffer
  23014. * @return the index buffer
  23015. */
  23016. getIndexBuffer(): Nullable<DataBuffer>;
  23017. /** @hidden */
  23018. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23019. /**
  23020. * Release the associated resources for a specific mesh
  23021. * @param mesh defines the source mesh
  23022. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23023. */
  23024. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23025. /**
  23026. * Apply current geometry to a given mesh
  23027. * @param mesh defines the mesh to apply geometry to
  23028. */
  23029. applyToMesh(mesh: Mesh): void;
  23030. private _updateExtend;
  23031. private _applyToMesh;
  23032. private notifyUpdate;
  23033. /**
  23034. * Load the geometry if it was flagged as delay loaded
  23035. * @param scene defines the hosting scene
  23036. * @param onLoaded defines a callback called when the geometry is loaded
  23037. */
  23038. load(scene: Scene, onLoaded?: () => void): void;
  23039. private _queueLoad;
  23040. /**
  23041. * Invert the geometry to move from a right handed system to a left handed one.
  23042. */
  23043. toLeftHanded(): void;
  23044. /** @hidden */
  23045. _resetPointsArrayCache(): void;
  23046. /** @hidden */
  23047. _generatePointsArray(): boolean;
  23048. /**
  23049. * Gets a value indicating if the geometry is disposed
  23050. * @returns true if the geometry was disposed
  23051. */
  23052. isDisposed(): boolean;
  23053. private _disposeVertexArrayObjects;
  23054. /**
  23055. * Free all associated resources
  23056. */
  23057. dispose(): void;
  23058. /**
  23059. * Clone the current geometry into a new geometry
  23060. * @param id defines the unique ID of the new geometry
  23061. * @returns a new geometry object
  23062. */
  23063. copy(id: string): Geometry;
  23064. /**
  23065. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23066. * @return a JSON representation of the current geometry data (without the vertices data)
  23067. */
  23068. serialize(): any;
  23069. private toNumberArray;
  23070. /**
  23071. * Serialize all vertices data into a JSON oject
  23072. * @returns a JSON representation of the current geometry data
  23073. */
  23074. serializeVerticeData(): any;
  23075. /**
  23076. * Extracts a clone of a mesh geometry
  23077. * @param mesh defines the source mesh
  23078. * @param id defines the unique ID of the new geometry object
  23079. * @returns the new geometry object
  23080. */
  23081. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23082. /**
  23083. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23084. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23085. * Be aware Math.random() could cause collisions, but:
  23086. * "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"
  23087. * @returns a string containing a new GUID
  23088. */
  23089. static RandomId(): string;
  23090. /** @hidden */
  23091. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23092. private static _CleanMatricesWeights;
  23093. /**
  23094. * Create a new geometry from persisted data (Using .babylon file format)
  23095. * @param parsedVertexData defines the persisted data
  23096. * @param scene defines the hosting scene
  23097. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23098. * @returns the new geometry object
  23099. */
  23100. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23101. }
  23102. }
  23103. declare module "babylonjs/Meshes/mesh.vertexData" {
  23104. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23105. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23106. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  23107. import { Geometry } from "babylonjs/Meshes/geometry";
  23108. import { Mesh } from "babylonjs/Meshes/mesh";
  23109. /**
  23110. * Define an interface for all classes that will get and set the data on vertices
  23111. */
  23112. export interface IGetSetVerticesData {
  23113. /**
  23114. * Gets a boolean indicating if specific vertex data is present
  23115. * @param kind defines the vertex data kind to use
  23116. * @returns true is data kind is present
  23117. */
  23118. isVerticesDataPresent(kind: string): boolean;
  23119. /**
  23120. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23121. * @param kind defines the data kind (Position, normal, etc...)
  23122. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23123. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23124. * @returns a float array containing vertex data
  23125. */
  23126. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23127. /**
  23128. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23129. * @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.
  23130. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23131. * @returns the indices array or an empty array if the mesh has no geometry
  23132. */
  23133. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23134. /**
  23135. * Set specific vertex data
  23136. * @param kind defines the data kind (Position, normal, etc...)
  23137. * @param data defines the vertex data to use
  23138. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23139. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23140. */
  23141. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23142. /**
  23143. * Update a specific associated vertex buffer
  23144. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23145. * - VertexBuffer.PositionKind
  23146. * - VertexBuffer.UVKind
  23147. * - VertexBuffer.UV2Kind
  23148. * - VertexBuffer.UV3Kind
  23149. * - VertexBuffer.UV4Kind
  23150. * - VertexBuffer.UV5Kind
  23151. * - VertexBuffer.UV6Kind
  23152. * - VertexBuffer.ColorKind
  23153. * - VertexBuffer.MatricesIndicesKind
  23154. * - VertexBuffer.MatricesIndicesExtraKind
  23155. * - VertexBuffer.MatricesWeightsKind
  23156. * - VertexBuffer.MatricesWeightsExtraKind
  23157. * @param data defines the data source
  23158. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23159. * @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)
  23160. */
  23161. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23162. /**
  23163. * Creates a new index buffer
  23164. * @param indices defines the indices to store in the index buffer
  23165. * @param totalVertices defines the total number of vertices (could be null)
  23166. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23167. */
  23168. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23169. }
  23170. /**
  23171. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23172. */
  23173. export class VertexData {
  23174. /**
  23175. * Mesh side orientation : usually the external or front surface
  23176. */
  23177. static readonly FRONTSIDE: number;
  23178. /**
  23179. * Mesh side orientation : usually the internal or back surface
  23180. */
  23181. static readonly BACKSIDE: number;
  23182. /**
  23183. * Mesh side orientation : both internal and external or front and back surfaces
  23184. */
  23185. static readonly DOUBLESIDE: number;
  23186. /**
  23187. * Mesh side orientation : by default, `FRONTSIDE`
  23188. */
  23189. static readonly DEFAULTSIDE: number;
  23190. /**
  23191. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23192. */
  23193. positions: Nullable<FloatArray>;
  23194. /**
  23195. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23196. */
  23197. normals: Nullable<FloatArray>;
  23198. /**
  23199. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23200. */
  23201. tangents: Nullable<FloatArray>;
  23202. /**
  23203. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23204. */
  23205. uvs: Nullable<FloatArray>;
  23206. /**
  23207. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23208. */
  23209. uvs2: Nullable<FloatArray>;
  23210. /**
  23211. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23212. */
  23213. uvs3: Nullable<FloatArray>;
  23214. /**
  23215. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23216. */
  23217. uvs4: Nullable<FloatArray>;
  23218. /**
  23219. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23220. */
  23221. uvs5: Nullable<FloatArray>;
  23222. /**
  23223. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23224. */
  23225. uvs6: Nullable<FloatArray>;
  23226. /**
  23227. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23228. */
  23229. colors: Nullable<FloatArray>;
  23230. /**
  23231. * 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).
  23232. */
  23233. matricesIndices: Nullable<FloatArray>;
  23234. /**
  23235. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23236. */
  23237. matricesWeights: Nullable<FloatArray>;
  23238. /**
  23239. * An array extending the number of possible indices
  23240. */
  23241. matricesIndicesExtra: Nullable<FloatArray>;
  23242. /**
  23243. * An array extending the number of possible weights when the number of indices is extended
  23244. */
  23245. matricesWeightsExtra: Nullable<FloatArray>;
  23246. /**
  23247. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23248. */
  23249. indices: Nullable<IndicesArray>;
  23250. /**
  23251. * Uses the passed data array to set the set the values for the specified kind of data
  23252. * @param data a linear array of floating numbers
  23253. * @param kind the type of data that is being set, eg positions, colors etc
  23254. */
  23255. set(data: FloatArray, kind: string): void;
  23256. /**
  23257. * Associates the vertexData to the passed Mesh.
  23258. * Sets it as updatable or not (default `false`)
  23259. * @param mesh the mesh the vertexData is applied to
  23260. * @param updatable when used and having the value true allows new data to update the vertexData
  23261. * @returns the VertexData
  23262. */
  23263. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23264. /**
  23265. * Associates the vertexData to the passed Geometry.
  23266. * Sets it as updatable or not (default `false`)
  23267. * @param geometry the geometry the vertexData is applied to
  23268. * @param updatable when used and having the value true allows new data to update the vertexData
  23269. * @returns VertexData
  23270. */
  23271. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23272. /**
  23273. * Updates the associated mesh
  23274. * @param mesh the mesh to be updated
  23275. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23276. * @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
  23277. * @returns VertexData
  23278. */
  23279. updateMesh(mesh: Mesh): VertexData;
  23280. /**
  23281. * Updates the associated geometry
  23282. * @param geometry the geometry to be updated
  23283. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23284. * @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
  23285. * @returns VertexData.
  23286. */
  23287. updateGeometry(geometry: Geometry): VertexData;
  23288. private _applyTo;
  23289. private _update;
  23290. /**
  23291. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23292. * @param matrix the transforming matrix
  23293. * @returns the VertexData
  23294. */
  23295. transform(matrix: Matrix): VertexData;
  23296. /**
  23297. * Merges the passed VertexData into the current one
  23298. * @param other the VertexData to be merged into the current one
  23299. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23300. * @returns the modified VertexData
  23301. */
  23302. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23303. private _mergeElement;
  23304. private _validate;
  23305. /**
  23306. * Serializes the VertexData
  23307. * @returns a serialized object
  23308. */
  23309. serialize(): any;
  23310. /**
  23311. * Extracts the vertexData from a mesh
  23312. * @param mesh the mesh from which to extract the VertexData
  23313. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23314. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23315. * @returns the object VertexData associated to the passed mesh
  23316. */
  23317. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23318. /**
  23319. * Extracts the vertexData from the geometry
  23320. * @param geometry the geometry from which to extract the VertexData
  23321. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23322. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23323. * @returns the object VertexData associated to the passed mesh
  23324. */
  23325. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23326. private static _ExtractFrom;
  23327. /**
  23328. * Creates the VertexData for a Ribbon
  23329. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23330. * * pathArray array of paths, each of which an array of successive Vector3
  23331. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23332. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23333. * * 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
  23334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23335. * * 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)
  23336. * * 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)
  23337. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23338. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23339. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23340. * @returns the VertexData of the ribbon
  23341. */
  23342. static CreateRibbon(options: {
  23343. pathArray: Vector3[][];
  23344. closeArray?: boolean;
  23345. closePath?: boolean;
  23346. offset?: number;
  23347. sideOrientation?: number;
  23348. frontUVs?: Vector4;
  23349. backUVs?: Vector4;
  23350. invertUV?: boolean;
  23351. uvs?: Vector2[];
  23352. colors?: Color4[];
  23353. }): VertexData;
  23354. /**
  23355. * Creates the VertexData for a box
  23356. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23357. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23358. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23359. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23360. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23361. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23362. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23363. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23364. * * 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)
  23365. * * 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)
  23366. * @returns the VertexData of the box
  23367. */
  23368. static CreateBox(options: {
  23369. size?: number;
  23370. width?: number;
  23371. height?: number;
  23372. depth?: number;
  23373. faceUV?: Vector4[];
  23374. faceColors?: Color4[];
  23375. sideOrientation?: number;
  23376. frontUVs?: Vector4;
  23377. backUVs?: Vector4;
  23378. }): VertexData;
  23379. /**
  23380. * Creates the VertexData for a tiled box
  23381. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23382. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23383. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23384. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23386. * @returns the VertexData of the box
  23387. */
  23388. static CreateTiledBox(options: {
  23389. pattern?: number;
  23390. width?: number;
  23391. height?: number;
  23392. depth?: number;
  23393. tileSize?: number;
  23394. tileWidth?: number;
  23395. tileHeight?: number;
  23396. alignHorizontal?: number;
  23397. alignVertical?: number;
  23398. faceUV?: Vector4[];
  23399. faceColors?: Color4[];
  23400. sideOrientation?: number;
  23401. }): VertexData;
  23402. /**
  23403. * Creates the VertexData for a tiled plane
  23404. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23405. * * pattern a limited pattern arrangement depending on the number
  23406. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23407. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23408. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23409. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23410. * * 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)
  23411. * * 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)
  23412. * @returns the VertexData of the tiled plane
  23413. */
  23414. static CreateTiledPlane(options: {
  23415. pattern?: number;
  23416. tileSize?: number;
  23417. tileWidth?: number;
  23418. tileHeight?: number;
  23419. size?: number;
  23420. width?: number;
  23421. height?: number;
  23422. alignHorizontal?: number;
  23423. alignVertical?: number;
  23424. sideOrientation?: number;
  23425. frontUVs?: Vector4;
  23426. backUVs?: Vector4;
  23427. }): VertexData;
  23428. /**
  23429. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23430. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23431. * * segments sets the number of horizontal strips optional, default 32
  23432. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23433. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23434. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23435. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23436. * * 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
  23437. * * 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
  23438. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23439. * * 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)
  23440. * * 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)
  23441. * @returns the VertexData of the ellipsoid
  23442. */
  23443. static CreateSphere(options: {
  23444. segments?: number;
  23445. diameter?: number;
  23446. diameterX?: number;
  23447. diameterY?: number;
  23448. diameterZ?: number;
  23449. arc?: number;
  23450. slice?: number;
  23451. sideOrientation?: number;
  23452. frontUVs?: Vector4;
  23453. backUVs?: Vector4;
  23454. }): VertexData;
  23455. /**
  23456. * Creates the VertexData for a cylinder, cone or prism
  23457. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23458. * * height sets the height (y direction) of the cylinder, optional, default 2
  23459. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23460. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23461. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23462. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23463. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23464. * * 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
  23465. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23466. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23467. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23468. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23470. * * 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)
  23471. * * 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)
  23472. * @returns the VertexData of the cylinder, cone or prism
  23473. */
  23474. static CreateCylinder(options: {
  23475. height?: number;
  23476. diameterTop?: number;
  23477. diameterBottom?: number;
  23478. diameter?: number;
  23479. tessellation?: number;
  23480. subdivisions?: number;
  23481. arc?: number;
  23482. faceColors?: Color4[];
  23483. faceUV?: Vector4[];
  23484. hasRings?: boolean;
  23485. enclose?: boolean;
  23486. sideOrientation?: number;
  23487. frontUVs?: Vector4;
  23488. backUVs?: Vector4;
  23489. }): VertexData;
  23490. /**
  23491. * Creates the VertexData for a torus
  23492. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23493. * * diameter the diameter of the torus, optional default 1
  23494. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23495. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23497. * * 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)
  23498. * * 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)
  23499. * @returns the VertexData of the torus
  23500. */
  23501. static CreateTorus(options: {
  23502. diameter?: number;
  23503. thickness?: number;
  23504. tessellation?: number;
  23505. sideOrientation?: number;
  23506. frontUVs?: Vector4;
  23507. backUVs?: Vector4;
  23508. }): VertexData;
  23509. /**
  23510. * Creates the VertexData of the LineSystem
  23511. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23512. * - lines an array of lines, each line being an array of successive Vector3
  23513. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23514. * @returns the VertexData of the LineSystem
  23515. */
  23516. static CreateLineSystem(options: {
  23517. lines: Vector3[][];
  23518. colors?: Nullable<Color4[][]>;
  23519. }): VertexData;
  23520. /**
  23521. * Create the VertexData for a DashedLines
  23522. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23523. * - points an array successive Vector3
  23524. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23525. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23526. * - dashNb the intended total number of dashes, optional, default 200
  23527. * @returns the VertexData for the DashedLines
  23528. */
  23529. static CreateDashedLines(options: {
  23530. points: Vector3[];
  23531. dashSize?: number;
  23532. gapSize?: number;
  23533. dashNb?: number;
  23534. }): VertexData;
  23535. /**
  23536. * Creates the VertexData for a Ground
  23537. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23538. * - width the width (x direction) of the ground, optional, default 1
  23539. * - height the height (z direction) of the ground, optional, default 1
  23540. * - subdivisions the number of subdivisions per side, optional, default 1
  23541. * @returns the VertexData of the Ground
  23542. */
  23543. static CreateGround(options: {
  23544. width?: number;
  23545. height?: number;
  23546. subdivisions?: number;
  23547. subdivisionsX?: number;
  23548. subdivisionsY?: number;
  23549. }): VertexData;
  23550. /**
  23551. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23552. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23553. * * xmin the ground minimum X coordinate, optional, default -1
  23554. * * zmin the ground minimum Z coordinate, optional, default -1
  23555. * * xmax the ground maximum X coordinate, optional, default 1
  23556. * * zmax the ground maximum Z coordinate, optional, default 1
  23557. * * 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}
  23558. * * 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}
  23559. * @returns the VertexData of the TiledGround
  23560. */
  23561. static CreateTiledGround(options: {
  23562. xmin: number;
  23563. zmin: number;
  23564. xmax: number;
  23565. zmax: number;
  23566. subdivisions?: {
  23567. w: number;
  23568. h: number;
  23569. };
  23570. precision?: {
  23571. w: number;
  23572. h: number;
  23573. };
  23574. }): VertexData;
  23575. /**
  23576. * Creates the VertexData of the Ground designed from a heightmap
  23577. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23578. * * width the width (x direction) of the ground
  23579. * * height the height (z direction) of the ground
  23580. * * subdivisions the number of subdivisions per side
  23581. * * minHeight the minimum altitude on the ground, optional, default 0
  23582. * * maxHeight the maximum altitude on the ground, optional default 1
  23583. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23584. * * buffer the array holding the image color data
  23585. * * bufferWidth the width of image
  23586. * * bufferHeight the height of image
  23587. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23588. * @returns the VertexData of the Ground designed from a heightmap
  23589. */
  23590. static CreateGroundFromHeightMap(options: {
  23591. width: number;
  23592. height: number;
  23593. subdivisions: number;
  23594. minHeight: number;
  23595. maxHeight: number;
  23596. colorFilter: Color3;
  23597. buffer: Uint8Array;
  23598. bufferWidth: number;
  23599. bufferHeight: number;
  23600. alphaFilter: number;
  23601. }): VertexData;
  23602. /**
  23603. * Creates the VertexData for a Plane
  23604. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23605. * * size sets the width and height of the plane to the value of size, optional default 1
  23606. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23607. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23608. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23609. * * 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)
  23610. * * 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)
  23611. * @returns the VertexData of the box
  23612. */
  23613. static CreatePlane(options: {
  23614. size?: number;
  23615. width?: number;
  23616. height?: number;
  23617. sideOrientation?: number;
  23618. frontUVs?: Vector4;
  23619. backUVs?: Vector4;
  23620. }): VertexData;
  23621. /**
  23622. * Creates the VertexData of the Disc or regular Polygon
  23623. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23624. * * radius the radius of the disc, optional default 0.5
  23625. * * tessellation the number of polygon sides, optional, default 64
  23626. * * 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
  23627. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23628. * * 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)
  23629. * * 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)
  23630. * @returns the VertexData of the box
  23631. */
  23632. static CreateDisc(options: {
  23633. radius?: number;
  23634. tessellation?: number;
  23635. arc?: number;
  23636. sideOrientation?: number;
  23637. frontUVs?: Vector4;
  23638. backUVs?: Vector4;
  23639. }): VertexData;
  23640. /**
  23641. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23642. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23643. * @param polygon a mesh built from polygonTriangulation.build()
  23644. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23645. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23646. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23647. * @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)
  23648. * @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)
  23649. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  23650. * @returns the VertexData of the Polygon
  23651. */
  23652. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  23653. /**
  23654. * Creates the VertexData of the IcoSphere
  23655. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23656. * * radius the radius of the IcoSphere, optional default 1
  23657. * * radiusX allows stretching in the x direction, optional, default radius
  23658. * * radiusY allows stretching in the y direction, optional, default radius
  23659. * * radiusZ allows stretching in the z direction, optional, default radius
  23660. * * flat when true creates a flat shaded mesh, optional, default true
  23661. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23662. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23663. * * 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)
  23664. * * 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)
  23665. * @returns the VertexData of the IcoSphere
  23666. */
  23667. static CreateIcoSphere(options: {
  23668. radius?: number;
  23669. radiusX?: number;
  23670. radiusY?: number;
  23671. radiusZ?: number;
  23672. flat?: boolean;
  23673. subdivisions?: number;
  23674. sideOrientation?: number;
  23675. frontUVs?: Vector4;
  23676. backUVs?: Vector4;
  23677. }): VertexData;
  23678. /**
  23679. * Creates the VertexData for a Polyhedron
  23680. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23681. * * type provided types are:
  23682. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23683. * * 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)
  23684. * * size the size of the IcoSphere, optional default 1
  23685. * * sizeX allows stretching in the x direction, optional, default size
  23686. * * sizeY allows stretching in the y direction, optional, default size
  23687. * * sizeZ allows stretching in the z direction, optional, default size
  23688. * * 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
  23689. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23690. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23691. * * flat when true creates a flat shaded mesh, optional, default true
  23692. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23693. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23694. * * 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)
  23695. * * 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)
  23696. * @returns the VertexData of the Polyhedron
  23697. */
  23698. static CreatePolyhedron(options: {
  23699. type?: number;
  23700. size?: number;
  23701. sizeX?: number;
  23702. sizeY?: number;
  23703. sizeZ?: number;
  23704. custom?: any;
  23705. faceUV?: Vector4[];
  23706. faceColors?: Color4[];
  23707. flat?: boolean;
  23708. sideOrientation?: number;
  23709. frontUVs?: Vector4;
  23710. backUVs?: Vector4;
  23711. }): VertexData;
  23712. /**
  23713. * Creates the VertexData for a TorusKnot
  23714. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23715. * * radius the radius of the torus knot, optional, default 2
  23716. * * tube the thickness of the tube, optional, default 0.5
  23717. * * radialSegments the number of sides on each tube segments, optional, default 32
  23718. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23719. * * p the number of windings around the z axis, optional, default 2
  23720. * * q the number of windings around the x axis, optional, default 3
  23721. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23722. * * 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)
  23723. * * 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)
  23724. * @returns the VertexData of the Torus Knot
  23725. */
  23726. static CreateTorusKnot(options: {
  23727. radius?: number;
  23728. tube?: number;
  23729. radialSegments?: number;
  23730. tubularSegments?: number;
  23731. p?: number;
  23732. q?: number;
  23733. sideOrientation?: number;
  23734. frontUVs?: Vector4;
  23735. backUVs?: Vector4;
  23736. }): VertexData;
  23737. /**
  23738. * Compute normals for given positions and indices
  23739. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23740. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23741. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23742. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23743. * * facetNormals : optional array of facet normals (vector3)
  23744. * * facetPositions : optional array of facet positions (vector3)
  23745. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23746. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23747. * * bInfo : optional bounding info, required for facetPartitioning computation
  23748. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23749. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23750. * * useRightHandedSystem: optional boolean to for right handed system computation
  23751. * * depthSort : optional boolean to enable the facet depth sort computation
  23752. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23753. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23754. */
  23755. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23756. facetNormals?: any;
  23757. facetPositions?: any;
  23758. facetPartitioning?: any;
  23759. ratio?: number;
  23760. bInfo?: any;
  23761. bbSize?: Vector3;
  23762. subDiv?: any;
  23763. useRightHandedSystem?: boolean;
  23764. depthSort?: boolean;
  23765. distanceTo?: Vector3;
  23766. depthSortedFacets?: any;
  23767. }): void;
  23768. /** @hidden */
  23769. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23770. /**
  23771. * Applies VertexData created from the imported parameters to the geometry
  23772. * @param parsedVertexData the parsed data from an imported file
  23773. * @param geometry the geometry to apply the VertexData to
  23774. */
  23775. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23776. }
  23777. }
  23778. declare module "babylonjs/Morph/morphTarget" {
  23779. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23780. import { Observable } from "babylonjs/Misc/observable";
  23781. import { Nullable, FloatArray } from "babylonjs/types";
  23782. import { Scene } from "babylonjs/scene";
  23783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23784. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23785. /**
  23786. * Defines a target to use with MorphTargetManager
  23787. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23788. */
  23789. export class MorphTarget implements IAnimatable {
  23790. /** defines the name of the target */
  23791. name: string;
  23792. /**
  23793. * Gets or sets the list of animations
  23794. */
  23795. animations: import("babylonjs/Animations/animation").Animation[];
  23796. private _scene;
  23797. private _positions;
  23798. private _normals;
  23799. private _tangents;
  23800. private _uvs;
  23801. private _influence;
  23802. private _uniqueId;
  23803. /**
  23804. * Observable raised when the influence changes
  23805. */
  23806. onInfluenceChanged: Observable<boolean>;
  23807. /** @hidden */
  23808. _onDataLayoutChanged: Observable<void>;
  23809. /**
  23810. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23811. */
  23812. get influence(): number;
  23813. set influence(influence: number);
  23814. /**
  23815. * Gets or sets the id of the morph Target
  23816. */
  23817. id: string;
  23818. private _animationPropertiesOverride;
  23819. /**
  23820. * Gets or sets the animation properties override
  23821. */
  23822. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23823. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23824. /**
  23825. * Creates a new MorphTarget
  23826. * @param name defines the name of the target
  23827. * @param influence defines the influence to use
  23828. * @param scene defines the scene the morphtarget belongs to
  23829. */
  23830. constructor(
  23831. /** defines the name of the target */
  23832. name: string, influence?: number, scene?: Nullable<Scene>);
  23833. /**
  23834. * Gets the unique ID of this manager
  23835. */
  23836. get uniqueId(): number;
  23837. /**
  23838. * Gets a boolean defining if the target contains position data
  23839. */
  23840. get hasPositions(): boolean;
  23841. /**
  23842. * Gets a boolean defining if the target contains normal data
  23843. */
  23844. get hasNormals(): boolean;
  23845. /**
  23846. * Gets a boolean defining if the target contains tangent data
  23847. */
  23848. get hasTangents(): boolean;
  23849. /**
  23850. * Gets a boolean defining if the target contains texture coordinates data
  23851. */
  23852. get hasUVs(): boolean;
  23853. /**
  23854. * Affects position data to this target
  23855. * @param data defines the position data to use
  23856. */
  23857. setPositions(data: Nullable<FloatArray>): void;
  23858. /**
  23859. * Gets the position data stored in this target
  23860. * @returns a FloatArray containing the position data (or null if not present)
  23861. */
  23862. getPositions(): Nullable<FloatArray>;
  23863. /**
  23864. * Affects normal data to this target
  23865. * @param data defines the normal data to use
  23866. */
  23867. setNormals(data: Nullable<FloatArray>): void;
  23868. /**
  23869. * Gets the normal data stored in this target
  23870. * @returns a FloatArray containing the normal data (or null if not present)
  23871. */
  23872. getNormals(): Nullable<FloatArray>;
  23873. /**
  23874. * Affects tangent data to this target
  23875. * @param data defines the tangent data to use
  23876. */
  23877. setTangents(data: Nullable<FloatArray>): void;
  23878. /**
  23879. * Gets the tangent data stored in this target
  23880. * @returns a FloatArray containing the tangent data (or null if not present)
  23881. */
  23882. getTangents(): Nullable<FloatArray>;
  23883. /**
  23884. * Affects texture coordinates data to this target
  23885. * @param data defines the texture coordinates data to use
  23886. */
  23887. setUVs(data: Nullable<FloatArray>): void;
  23888. /**
  23889. * Gets the texture coordinates data stored in this target
  23890. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23891. */
  23892. getUVs(): Nullable<FloatArray>;
  23893. /**
  23894. * Clone the current target
  23895. * @returns a new MorphTarget
  23896. */
  23897. clone(): MorphTarget;
  23898. /**
  23899. * Serializes the current target into a Serialization object
  23900. * @returns the serialized object
  23901. */
  23902. serialize(): any;
  23903. /**
  23904. * Returns the string "MorphTarget"
  23905. * @returns "MorphTarget"
  23906. */
  23907. getClassName(): string;
  23908. /**
  23909. * Creates a new target from serialized data
  23910. * @param serializationObject defines the serialized data to use
  23911. * @returns a new MorphTarget
  23912. */
  23913. static Parse(serializationObject: any): MorphTarget;
  23914. /**
  23915. * Creates a MorphTarget from mesh data
  23916. * @param mesh defines the source mesh
  23917. * @param name defines the name to use for the new target
  23918. * @param influence defines the influence to attach to the target
  23919. * @returns a new MorphTarget
  23920. */
  23921. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23922. }
  23923. }
  23924. declare module "babylonjs/Morph/morphTargetManager" {
  23925. import { Nullable } from "babylonjs/types";
  23926. import { Scene } from "babylonjs/scene";
  23927. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23928. /**
  23929. * This class is used to deform meshes using morphing between different targets
  23930. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23931. */
  23932. export class MorphTargetManager {
  23933. private _targets;
  23934. private _targetInfluenceChangedObservers;
  23935. private _targetDataLayoutChangedObservers;
  23936. private _activeTargets;
  23937. private _scene;
  23938. private _influences;
  23939. private _supportsNormals;
  23940. private _supportsTangents;
  23941. private _supportsUVs;
  23942. private _vertexCount;
  23943. private _uniqueId;
  23944. private _tempInfluences;
  23945. /**
  23946. * Gets or sets a boolean indicating if normals must be morphed
  23947. */
  23948. enableNormalMorphing: boolean;
  23949. /**
  23950. * Gets or sets a boolean indicating if tangents must be morphed
  23951. */
  23952. enableTangentMorphing: boolean;
  23953. /**
  23954. * Gets or sets a boolean indicating if UV must be morphed
  23955. */
  23956. enableUVMorphing: boolean;
  23957. /**
  23958. * Creates a new MorphTargetManager
  23959. * @param scene defines the current scene
  23960. */
  23961. constructor(scene?: Nullable<Scene>);
  23962. /**
  23963. * Gets the unique ID of this manager
  23964. */
  23965. get uniqueId(): number;
  23966. /**
  23967. * Gets the number of vertices handled by this manager
  23968. */
  23969. get vertexCount(): number;
  23970. /**
  23971. * Gets a boolean indicating if this manager supports morphing of normals
  23972. */
  23973. get supportsNormals(): boolean;
  23974. /**
  23975. * Gets a boolean indicating if this manager supports morphing of tangents
  23976. */
  23977. get supportsTangents(): boolean;
  23978. /**
  23979. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23980. */
  23981. get supportsUVs(): boolean;
  23982. /**
  23983. * Gets the number of targets stored in this manager
  23984. */
  23985. get numTargets(): number;
  23986. /**
  23987. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23988. */
  23989. get numInfluencers(): number;
  23990. /**
  23991. * Gets the list of influences (one per target)
  23992. */
  23993. get influences(): Float32Array;
  23994. /**
  23995. * Gets the active target at specified index. An active target is a target with an influence > 0
  23996. * @param index defines the index to check
  23997. * @returns the requested target
  23998. */
  23999. getActiveTarget(index: number): MorphTarget;
  24000. /**
  24001. * Gets the target at specified index
  24002. * @param index defines the index to check
  24003. * @returns the requested target
  24004. */
  24005. getTarget(index: number): MorphTarget;
  24006. /**
  24007. * Add a new target to this manager
  24008. * @param target defines the target to add
  24009. */
  24010. addTarget(target: MorphTarget): void;
  24011. /**
  24012. * Removes a target from the manager
  24013. * @param target defines the target to remove
  24014. */
  24015. removeTarget(target: MorphTarget): void;
  24016. /**
  24017. * Clone the current manager
  24018. * @returns a new MorphTargetManager
  24019. */
  24020. clone(): MorphTargetManager;
  24021. /**
  24022. * Serializes the current manager into a Serialization object
  24023. * @returns the serialized object
  24024. */
  24025. serialize(): any;
  24026. private _syncActiveTargets;
  24027. /**
  24028. * Syncrhonize the targets with all the meshes using this morph target manager
  24029. */
  24030. synchronize(): void;
  24031. /**
  24032. * Creates a new MorphTargetManager from serialized data
  24033. * @param serializationObject defines the serialized data
  24034. * @param scene defines the hosting scene
  24035. * @returns the new MorphTargetManager
  24036. */
  24037. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24038. }
  24039. }
  24040. declare module "babylonjs/Meshes/meshLODLevel" {
  24041. import { Mesh } from "babylonjs/Meshes/mesh";
  24042. import { Nullable } from "babylonjs/types";
  24043. /**
  24044. * Class used to represent a specific level of detail of a mesh
  24045. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24046. */
  24047. export class MeshLODLevel {
  24048. /** Defines the distance where this level should start being displayed */
  24049. distance: number;
  24050. /** Defines the mesh to use to render this level */
  24051. mesh: Nullable<Mesh>;
  24052. /**
  24053. * Creates a new LOD level
  24054. * @param distance defines the distance where this level should star being displayed
  24055. * @param mesh defines the mesh to use to render this level
  24056. */
  24057. constructor(
  24058. /** Defines the distance where this level should start being displayed */
  24059. distance: number,
  24060. /** Defines the mesh to use to render this level */
  24061. mesh: Nullable<Mesh>);
  24062. }
  24063. }
  24064. declare module "babylonjs/Meshes/groundMesh" {
  24065. import { Scene } from "babylonjs/scene";
  24066. import { Vector3 } from "babylonjs/Maths/math.vector";
  24067. import { Mesh } from "babylonjs/Meshes/mesh";
  24068. /**
  24069. * Mesh representing the gorund
  24070. */
  24071. export class GroundMesh extends Mesh {
  24072. /** If octree should be generated */
  24073. generateOctree: boolean;
  24074. private _heightQuads;
  24075. /** @hidden */
  24076. _subdivisionsX: number;
  24077. /** @hidden */
  24078. _subdivisionsY: number;
  24079. /** @hidden */
  24080. _width: number;
  24081. /** @hidden */
  24082. _height: number;
  24083. /** @hidden */
  24084. _minX: number;
  24085. /** @hidden */
  24086. _maxX: number;
  24087. /** @hidden */
  24088. _minZ: number;
  24089. /** @hidden */
  24090. _maxZ: number;
  24091. constructor(name: string, scene: Scene);
  24092. /**
  24093. * "GroundMesh"
  24094. * @returns "GroundMesh"
  24095. */
  24096. getClassName(): string;
  24097. /**
  24098. * The minimum of x and y subdivisions
  24099. */
  24100. get subdivisions(): number;
  24101. /**
  24102. * X subdivisions
  24103. */
  24104. get subdivisionsX(): number;
  24105. /**
  24106. * Y subdivisions
  24107. */
  24108. get subdivisionsY(): number;
  24109. /**
  24110. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  24111. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24112. * @param chunksCount the number of subdivisions for x and y
  24113. * @param octreeBlocksSize (Default: 32)
  24114. */
  24115. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  24116. /**
  24117. * Returns a height (y) value in the Worl system :
  24118. * the ground altitude at the coordinates (x, z) expressed in the World system.
  24119. * @param x x coordinate
  24120. * @param z z coordinate
  24121. * @returns the ground y position if (x, z) are outside the ground surface.
  24122. */
  24123. getHeightAtCoordinates(x: number, z: number): number;
  24124. /**
  24125. * Returns a normalized vector (Vector3) orthogonal to the ground
  24126. * at the ground coordinates (x, z) expressed in the World system.
  24127. * @param x x coordinate
  24128. * @param z z coordinate
  24129. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  24130. */
  24131. getNormalAtCoordinates(x: number, z: number): Vector3;
  24132. /**
  24133. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  24134. * at the ground coordinates (x, z) expressed in the World system.
  24135. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  24136. * @param x x coordinate
  24137. * @param z z coordinate
  24138. * @param ref vector to store the result
  24139. * @returns the GroundMesh.
  24140. */
  24141. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  24142. /**
  24143. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  24144. * if the ground has been updated.
  24145. * This can be used in the render loop.
  24146. * @returns the GroundMesh.
  24147. */
  24148. updateCoordinateHeights(): GroundMesh;
  24149. private _getFacetAt;
  24150. private _initHeightQuads;
  24151. private _computeHeightQuads;
  24152. /**
  24153. * Serializes this ground mesh
  24154. * @param serializationObject object to write serialization to
  24155. */
  24156. serialize(serializationObject: any): void;
  24157. /**
  24158. * Parses a serialized ground mesh
  24159. * @param parsedMesh the serialized mesh
  24160. * @param scene the scene to create the ground mesh in
  24161. * @returns the created ground mesh
  24162. */
  24163. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  24164. }
  24165. }
  24166. declare module "babylonjs/Physics/physicsJoint" {
  24167. import { Vector3 } from "babylonjs/Maths/math.vector";
  24168. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  24169. /**
  24170. * Interface for Physics-Joint data
  24171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24172. */
  24173. export interface PhysicsJointData {
  24174. /**
  24175. * The main pivot of the joint
  24176. */
  24177. mainPivot?: Vector3;
  24178. /**
  24179. * The connected pivot of the joint
  24180. */
  24181. connectedPivot?: Vector3;
  24182. /**
  24183. * The main axis of the joint
  24184. */
  24185. mainAxis?: Vector3;
  24186. /**
  24187. * The connected axis of the joint
  24188. */
  24189. connectedAxis?: Vector3;
  24190. /**
  24191. * The collision of the joint
  24192. */
  24193. collision?: boolean;
  24194. /**
  24195. * Native Oimo/Cannon/Energy data
  24196. */
  24197. nativeParams?: any;
  24198. }
  24199. /**
  24200. * This is a holder class for the physics joint created by the physics plugin
  24201. * It holds a set of functions to control the underlying joint
  24202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24203. */
  24204. export class PhysicsJoint {
  24205. /**
  24206. * The type of the physics joint
  24207. */
  24208. type: number;
  24209. /**
  24210. * The data for the physics joint
  24211. */
  24212. jointData: PhysicsJointData;
  24213. private _physicsJoint;
  24214. protected _physicsPlugin: IPhysicsEnginePlugin;
  24215. /**
  24216. * Initializes the physics joint
  24217. * @param type The type of the physics joint
  24218. * @param jointData The data for the physics joint
  24219. */
  24220. constructor(
  24221. /**
  24222. * The type of the physics joint
  24223. */
  24224. type: number,
  24225. /**
  24226. * The data for the physics joint
  24227. */
  24228. jointData: PhysicsJointData);
  24229. /**
  24230. * Gets the physics joint
  24231. */
  24232. get physicsJoint(): any;
  24233. /**
  24234. * Sets the physics joint
  24235. */
  24236. set physicsJoint(newJoint: any);
  24237. /**
  24238. * Sets the physics plugin
  24239. */
  24240. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24241. /**
  24242. * Execute a function that is physics-plugin specific.
  24243. * @param {Function} func the function that will be executed.
  24244. * It accepts two parameters: the physics world and the physics joint
  24245. */
  24246. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24247. /**
  24248. * Distance-Joint type
  24249. */
  24250. static DistanceJoint: number;
  24251. /**
  24252. * Hinge-Joint type
  24253. */
  24254. static HingeJoint: number;
  24255. /**
  24256. * Ball-and-Socket joint type
  24257. */
  24258. static BallAndSocketJoint: number;
  24259. /**
  24260. * Wheel-Joint type
  24261. */
  24262. static WheelJoint: number;
  24263. /**
  24264. * Slider-Joint type
  24265. */
  24266. static SliderJoint: number;
  24267. /**
  24268. * Prismatic-Joint type
  24269. */
  24270. static PrismaticJoint: number;
  24271. /**
  24272. * Universal-Joint type
  24273. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24274. */
  24275. static UniversalJoint: number;
  24276. /**
  24277. * Hinge-Joint 2 type
  24278. */
  24279. static Hinge2Joint: number;
  24280. /**
  24281. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24282. */
  24283. static PointToPointJoint: number;
  24284. /**
  24285. * Spring-Joint type
  24286. */
  24287. static SpringJoint: number;
  24288. /**
  24289. * Lock-Joint type
  24290. */
  24291. static LockJoint: number;
  24292. }
  24293. /**
  24294. * A class representing a physics distance joint
  24295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24296. */
  24297. export class DistanceJoint extends PhysicsJoint {
  24298. /**
  24299. *
  24300. * @param jointData The data for the Distance-Joint
  24301. */
  24302. constructor(jointData: DistanceJointData);
  24303. /**
  24304. * Update the predefined distance.
  24305. * @param maxDistance The maximum preferred distance
  24306. * @param minDistance The minimum preferred distance
  24307. */
  24308. updateDistance(maxDistance: number, minDistance?: number): void;
  24309. }
  24310. /**
  24311. * Represents a Motor-Enabled Joint
  24312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24313. */
  24314. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24315. /**
  24316. * Initializes the Motor-Enabled Joint
  24317. * @param type The type of the joint
  24318. * @param jointData The physica joint data for the joint
  24319. */
  24320. constructor(type: number, jointData: PhysicsJointData);
  24321. /**
  24322. * Set the motor values.
  24323. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24324. * @param force the force to apply
  24325. * @param maxForce max force for this motor.
  24326. */
  24327. setMotor(force?: number, maxForce?: number): void;
  24328. /**
  24329. * Set the motor's limits.
  24330. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24331. * @param upperLimit The upper limit of the motor
  24332. * @param lowerLimit The lower limit of the motor
  24333. */
  24334. setLimit(upperLimit: number, lowerLimit?: number): void;
  24335. }
  24336. /**
  24337. * This class represents a single physics Hinge-Joint
  24338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24339. */
  24340. export class HingeJoint extends MotorEnabledJoint {
  24341. /**
  24342. * Initializes the Hinge-Joint
  24343. * @param jointData The joint data for the Hinge-Joint
  24344. */
  24345. constructor(jointData: PhysicsJointData);
  24346. /**
  24347. * Set the motor values.
  24348. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24349. * @param {number} force the force to apply
  24350. * @param {number} maxForce max force for this motor.
  24351. */
  24352. setMotor(force?: number, maxForce?: number): void;
  24353. /**
  24354. * Set the motor's limits.
  24355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24356. * @param upperLimit The upper limit of the motor
  24357. * @param lowerLimit The lower limit of the motor
  24358. */
  24359. setLimit(upperLimit: number, lowerLimit?: number): void;
  24360. }
  24361. /**
  24362. * This class represents a dual hinge physics joint (same as wheel joint)
  24363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24364. */
  24365. export class Hinge2Joint extends MotorEnabledJoint {
  24366. /**
  24367. * Initializes the Hinge2-Joint
  24368. * @param jointData The joint data for the Hinge2-Joint
  24369. */
  24370. constructor(jointData: PhysicsJointData);
  24371. /**
  24372. * Set the motor values.
  24373. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24374. * @param {number} targetSpeed the speed the motor is to reach
  24375. * @param {number} maxForce max force for this motor.
  24376. * @param {motorIndex} the motor's index, 0 or 1.
  24377. */
  24378. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24379. /**
  24380. * Set the motor limits.
  24381. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24382. * @param {number} upperLimit the upper limit
  24383. * @param {number} lowerLimit lower limit
  24384. * @param {motorIndex} the motor's index, 0 or 1.
  24385. */
  24386. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24387. }
  24388. /**
  24389. * Interface for a motor enabled joint
  24390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24391. */
  24392. export interface IMotorEnabledJoint {
  24393. /**
  24394. * Physics joint
  24395. */
  24396. physicsJoint: any;
  24397. /**
  24398. * Sets the motor of the motor-enabled joint
  24399. * @param force The force of the motor
  24400. * @param maxForce The maximum force of the motor
  24401. * @param motorIndex The index of the motor
  24402. */
  24403. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24404. /**
  24405. * Sets the limit of the motor
  24406. * @param upperLimit The upper limit of the motor
  24407. * @param lowerLimit The lower limit of the motor
  24408. * @param motorIndex The index of the motor
  24409. */
  24410. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24411. }
  24412. /**
  24413. * Joint data for a Distance-Joint
  24414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24415. */
  24416. export interface DistanceJointData extends PhysicsJointData {
  24417. /**
  24418. * Max distance the 2 joint objects can be apart
  24419. */
  24420. maxDistance: number;
  24421. }
  24422. /**
  24423. * Joint data from a spring joint
  24424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24425. */
  24426. export interface SpringJointData extends PhysicsJointData {
  24427. /**
  24428. * Length of the spring
  24429. */
  24430. length: number;
  24431. /**
  24432. * Stiffness of the spring
  24433. */
  24434. stiffness: number;
  24435. /**
  24436. * Damping of the spring
  24437. */
  24438. damping: number;
  24439. /** this callback will be called when applying the force to the impostors. */
  24440. forceApplicationCallback: () => void;
  24441. }
  24442. }
  24443. declare module "babylonjs/Physics/physicsRaycastResult" {
  24444. import { Vector3 } from "babylonjs/Maths/math.vector";
  24445. /**
  24446. * Holds the data for the raycast result
  24447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24448. */
  24449. export class PhysicsRaycastResult {
  24450. private _hasHit;
  24451. private _hitDistance;
  24452. private _hitNormalWorld;
  24453. private _hitPointWorld;
  24454. private _rayFromWorld;
  24455. private _rayToWorld;
  24456. /**
  24457. * Gets if there was a hit
  24458. */
  24459. get hasHit(): boolean;
  24460. /**
  24461. * Gets the distance from the hit
  24462. */
  24463. get hitDistance(): number;
  24464. /**
  24465. * Gets the hit normal/direction in the world
  24466. */
  24467. get hitNormalWorld(): Vector3;
  24468. /**
  24469. * Gets the hit point in the world
  24470. */
  24471. get hitPointWorld(): Vector3;
  24472. /**
  24473. * Gets the ray "start point" of the ray in the world
  24474. */
  24475. get rayFromWorld(): Vector3;
  24476. /**
  24477. * Gets the ray "end point" of the ray in the world
  24478. */
  24479. get rayToWorld(): Vector3;
  24480. /**
  24481. * Sets the hit data (normal & point in world space)
  24482. * @param hitNormalWorld defines the normal in world space
  24483. * @param hitPointWorld defines the point in world space
  24484. */
  24485. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24486. /**
  24487. * Sets the distance from the start point to the hit point
  24488. * @param distance
  24489. */
  24490. setHitDistance(distance: number): void;
  24491. /**
  24492. * Calculates the distance manually
  24493. */
  24494. calculateHitDistance(): void;
  24495. /**
  24496. * Resets all the values to default
  24497. * @param from The from point on world space
  24498. * @param to The to point on world space
  24499. */
  24500. reset(from?: Vector3, to?: Vector3): void;
  24501. }
  24502. /**
  24503. * Interface for the size containing width and height
  24504. */
  24505. interface IXYZ {
  24506. /**
  24507. * X
  24508. */
  24509. x: number;
  24510. /**
  24511. * Y
  24512. */
  24513. y: number;
  24514. /**
  24515. * Z
  24516. */
  24517. z: number;
  24518. }
  24519. }
  24520. declare module "babylonjs/Physics/IPhysicsEngine" {
  24521. import { Nullable } from "babylonjs/types";
  24522. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24524. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24525. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24526. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24527. /**
  24528. * Interface used to describe a physics joint
  24529. */
  24530. export interface PhysicsImpostorJoint {
  24531. /** Defines the main impostor to which the joint is linked */
  24532. mainImpostor: PhysicsImpostor;
  24533. /** Defines the impostor that is connected to the main impostor using this joint */
  24534. connectedImpostor: PhysicsImpostor;
  24535. /** Defines the joint itself */
  24536. joint: PhysicsJoint;
  24537. }
  24538. /** @hidden */
  24539. export interface IPhysicsEnginePlugin {
  24540. world: any;
  24541. name: string;
  24542. setGravity(gravity: Vector3): void;
  24543. setTimeStep(timeStep: number): void;
  24544. getTimeStep(): number;
  24545. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24546. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24547. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24548. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24549. removePhysicsBody(impostor: PhysicsImpostor): void;
  24550. generateJoint(joint: PhysicsImpostorJoint): void;
  24551. removeJoint(joint: PhysicsImpostorJoint): void;
  24552. isSupported(): boolean;
  24553. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24554. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24555. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24556. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24557. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24558. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24559. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24560. getBodyMass(impostor: PhysicsImpostor): number;
  24561. getBodyFriction(impostor: PhysicsImpostor): number;
  24562. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24563. getBodyRestitution(impostor: PhysicsImpostor): number;
  24564. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24565. getBodyPressure?(impostor: PhysicsImpostor): number;
  24566. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24567. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24568. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24569. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24570. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24571. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24572. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24573. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24574. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24575. sleepBody(impostor: PhysicsImpostor): void;
  24576. wakeUpBody(impostor: PhysicsImpostor): void;
  24577. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24578. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24579. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24580. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24581. getRadius(impostor: PhysicsImpostor): number;
  24582. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24583. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24584. dispose(): void;
  24585. }
  24586. /**
  24587. * Interface used to define a physics engine
  24588. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24589. */
  24590. export interface IPhysicsEngine {
  24591. /**
  24592. * Gets the gravity vector used by the simulation
  24593. */
  24594. gravity: Vector3;
  24595. /**
  24596. * Sets the gravity vector used by the simulation
  24597. * @param gravity defines the gravity vector to use
  24598. */
  24599. setGravity(gravity: Vector3): void;
  24600. /**
  24601. * Set the time step of the physics engine.
  24602. * Default is 1/60.
  24603. * To slow it down, enter 1/600 for example.
  24604. * To speed it up, 1/30
  24605. * @param newTimeStep the new timestep to apply to this world.
  24606. */
  24607. setTimeStep(newTimeStep: number): void;
  24608. /**
  24609. * Get the time step of the physics engine.
  24610. * @returns the current time step
  24611. */
  24612. getTimeStep(): number;
  24613. /**
  24614. * Set the sub time step of the physics engine.
  24615. * Default is 0 meaning there is no sub steps
  24616. * To increase physics resolution precision, set a small value (like 1 ms)
  24617. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24618. */
  24619. setSubTimeStep(subTimeStep: number): void;
  24620. /**
  24621. * Get the sub time step of the physics engine.
  24622. * @returns the current sub time step
  24623. */
  24624. getSubTimeStep(): number;
  24625. /**
  24626. * Release all resources
  24627. */
  24628. dispose(): void;
  24629. /**
  24630. * Gets the name of the current physics plugin
  24631. * @returns the name of the plugin
  24632. */
  24633. getPhysicsPluginName(): string;
  24634. /**
  24635. * Adding a new impostor for the impostor tracking.
  24636. * This will be done by the impostor itself.
  24637. * @param impostor the impostor to add
  24638. */
  24639. addImpostor(impostor: PhysicsImpostor): void;
  24640. /**
  24641. * Remove an impostor from the engine.
  24642. * This impostor and its mesh will not longer be updated by the physics engine.
  24643. * @param impostor the impostor to remove
  24644. */
  24645. removeImpostor(impostor: PhysicsImpostor): void;
  24646. /**
  24647. * Add a joint to the physics engine
  24648. * @param mainImpostor defines the main impostor to which the joint is added.
  24649. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24650. * @param joint defines the joint that will connect both impostors.
  24651. */
  24652. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24653. /**
  24654. * Removes a joint from the simulation
  24655. * @param mainImpostor defines the impostor used with the joint
  24656. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24657. * @param joint defines the joint to remove
  24658. */
  24659. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24660. /**
  24661. * Gets the current plugin used to run the simulation
  24662. * @returns current plugin
  24663. */
  24664. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24665. /**
  24666. * Gets the list of physic impostors
  24667. * @returns an array of PhysicsImpostor
  24668. */
  24669. getImpostors(): Array<PhysicsImpostor>;
  24670. /**
  24671. * Gets the impostor for a physics enabled object
  24672. * @param object defines the object impersonated by the impostor
  24673. * @returns the PhysicsImpostor or null if not found
  24674. */
  24675. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24676. /**
  24677. * Gets the impostor for a physics body object
  24678. * @param body defines physics body used by the impostor
  24679. * @returns the PhysicsImpostor or null if not found
  24680. */
  24681. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24682. /**
  24683. * Does a raycast in the physics world
  24684. * @param from when should the ray start?
  24685. * @param to when should the ray end?
  24686. * @returns PhysicsRaycastResult
  24687. */
  24688. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24689. /**
  24690. * Called by the scene. No need to call it.
  24691. * @param delta defines the timespam between frames
  24692. */
  24693. _step(delta: number): void;
  24694. }
  24695. }
  24696. declare module "babylonjs/Physics/physicsImpostor" {
  24697. import { Nullable, IndicesArray } from "babylonjs/types";
  24698. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24699. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24701. import { Scene } from "babylonjs/scene";
  24702. import { Bone } from "babylonjs/Bones/bone";
  24703. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24704. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24705. import { Space } from "babylonjs/Maths/math.axis";
  24706. /**
  24707. * The interface for the physics imposter parameters
  24708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24709. */
  24710. export interface PhysicsImpostorParameters {
  24711. /**
  24712. * The mass of the physics imposter
  24713. */
  24714. mass: number;
  24715. /**
  24716. * The friction of the physics imposter
  24717. */
  24718. friction?: number;
  24719. /**
  24720. * The coefficient of restitution of the physics imposter
  24721. */
  24722. restitution?: number;
  24723. /**
  24724. * The native options of the physics imposter
  24725. */
  24726. nativeOptions?: any;
  24727. /**
  24728. * Specifies if the parent should be ignored
  24729. */
  24730. ignoreParent?: boolean;
  24731. /**
  24732. * Specifies if bi-directional transformations should be disabled
  24733. */
  24734. disableBidirectionalTransformation?: boolean;
  24735. /**
  24736. * The pressure inside the physics imposter, soft object only
  24737. */
  24738. pressure?: number;
  24739. /**
  24740. * The stiffness the physics imposter, soft object only
  24741. */
  24742. stiffness?: number;
  24743. /**
  24744. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24745. */
  24746. velocityIterations?: number;
  24747. /**
  24748. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24749. */
  24750. positionIterations?: number;
  24751. /**
  24752. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24753. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24754. * Add to fix multiple points
  24755. */
  24756. fixedPoints?: number;
  24757. /**
  24758. * The collision margin around a soft object
  24759. */
  24760. margin?: number;
  24761. /**
  24762. * The collision margin around a soft object
  24763. */
  24764. damping?: number;
  24765. /**
  24766. * The path for a rope based on an extrusion
  24767. */
  24768. path?: any;
  24769. /**
  24770. * The shape of an extrusion used for a rope based on an extrusion
  24771. */
  24772. shape?: any;
  24773. }
  24774. /**
  24775. * Interface for a physics-enabled object
  24776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24777. */
  24778. export interface IPhysicsEnabledObject {
  24779. /**
  24780. * The position of the physics-enabled object
  24781. */
  24782. position: Vector3;
  24783. /**
  24784. * The rotation of the physics-enabled object
  24785. */
  24786. rotationQuaternion: Nullable<Quaternion>;
  24787. /**
  24788. * The scale of the physics-enabled object
  24789. */
  24790. scaling: Vector3;
  24791. /**
  24792. * The rotation of the physics-enabled object
  24793. */
  24794. rotation?: Vector3;
  24795. /**
  24796. * The parent of the physics-enabled object
  24797. */
  24798. parent?: any;
  24799. /**
  24800. * The bounding info of the physics-enabled object
  24801. * @returns The bounding info of the physics-enabled object
  24802. */
  24803. getBoundingInfo(): BoundingInfo;
  24804. /**
  24805. * Computes the world matrix
  24806. * @param force Specifies if the world matrix should be computed by force
  24807. * @returns A world matrix
  24808. */
  24809. computeWorldMatrix(force: boolean): Matrix;
  24810. /**
  24811. * Gets the world matrix
  24812. * @returns A world matrix
  24813. */
  24814. getWorldMatrix?(): Matrix;
  24815. /**
  24816. * Gets the child meshes
  24817. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24818. * @returns An array of abstract meshes
  24819. */
  24820. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24821. /**
  24822. * Gets the vertex data
  24823. * @param kind The type of vertex data
  24824. * @returns A nullable array of numbers, or a float32 array
  24825. */
  24826. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24827. /**
  24828. * Gets the indices from the mesh
  24829. * @returns A nullable array of index arrays
  24830. */
  24831. getIndices?(): Nullable<IndicesArray>;
  24832. /**
  24833. * Gets the scene from the mesh
  24834. * @returns the indices array or null
  24835. */
  24836. getScene?(): Scene;
  24837. /**
  24838. * Gets the absolute position from the mesh
  24839. * @returns the absolute position
  24840. */
  24841. getAbsolutePosition(): Vector3;
  24842. /**
  24843. * Gets the absolute pivot point from the mesh
  24844. * @returns the absolute pivot point
  24845. */
  24846. getAbsolutePivotPoint(): Vector3;
  24847. /**
  24848. * Rotates the mesh
  24849. * @param axis The axis of rotation
  24850. * @param amount The amount of rotation
  24851. * @param space The space of the rotation
  24852. * @returns The rotation transform node
  24853. */
  24854. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24855. /**
  24856. * Translates the mesh
  24857. * @param axis The axis of translation
  24858. * @param distance The distance of translation
  24859. * @param space The space of the translation
  24860. * @returns The transform node
  24861. */
  24862. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24863. /**
  24864. * Sets the absolute position of the mesh
  24865. * @param absolutePosition The absolute position of the mesh
  24866. * @returns The transform node
  24867. */
  24868. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24869. /**
  24870. * Gets the class name of the mesh
  24871. * @returns The class name
  24872. */
  24873. getClassName(): string;
  24874. }
  24875. /**
  24876. * Represents a physics imposter
  24877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24878. */
  24879. export class PhysicsImpostor {
  24880. /**
  24881. * The physics-enabled object used as the physics imposter
  24882. */
  24883. object: IPhysicsEnabledObject;
  24884. /**
  24885. * The type of the physics imposter
  24886. */
  24887. type: number;
  24888. private _options;
  24889. private _scene?;
  24890. /**
  24891. * The default object size of the imposter
  24892. */
  24893. static DEFAULT_OBJECT_SIZE: Vector3;
  24894. /**
  24895. * The identity quaternion of the imposter
  24896. */
  24897. static IDENTITY_QUATERNION: Quaternion;
  24898. /** @hidden */
  24899. _pluginData: any;
  24900. private _physicsEngine;
  24901. private _physicsBody;
  24902. private _bodyUpdateRequired;
  24903. private _onBeforePhysicsStepCallbacks;
  24904. private _onAfterPhysicsStepCallbacks;
  24905. /** @hidden */
  24906. _onPhysicsCollideCallbacks: Array<{
  24907. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24908. otherImpostors: Array<PhysicsImpostor>;
  24909. }>;
  24910. private _deltaPosition;
  24911. private _deltaRotation;
  24912. private _deltaRotationConjugated;
  24913. /** @hidden */
  24914. _isFromLine: boolean;
  24915. private _parent;
  24916. private _isDisposed;
  24917. private static _tmpVecs;
  24918. private static _tmpQuat;
  24919. /**
  24920. * Specifies if the physics imposter is disposed
  24921. */
  24922. get isDisposed(): boolean;
  24923. /**
  24924. * Gets the mass of the physics imposter
  24925. */
  24926. get mass(): number;
  24927. set mass(value: number);
  24928. /**
  24929. * Gets the coefficient of friction
  24930. */
  24931. get friction(): number;
  24932. /**
  24933. * Sets the coefficient of friction
  24934. */
  24935. set friction(value: number);
  24936. /**
  24937. * Gets the coefficient of restitution
  24938. */
  24939. get restitution(): number;
  24940. /**
  24941. * Sets the coefficient of restitution
  24942. */
  24943. set restitution(value: number);
  24944. /**
  24945. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24946. */
  24947. get pressure(): number;
  24948. /**
  24949. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24950. */
  24951. set pressure(value: number);
  24952. /**
  24953. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24954. */
  24955. get stiffness(): number;
  24956. /**
  24957. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24958. */
  24959. set stiffness(value: number);
  24960. /**
  24961. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24962. */
  24963. get velocityIterations(): number;
  24964. /**
  24965. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24966. */
  24967. set velocityIterations(value: number);
  24968. /**
  24969. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24970. */
  24971. get positionIterations(): number;
  24972. /**
  24973. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24974. */
  24975. set positionIterations(value: number);
  24976. /**
  24977. * The unique id of the physics imposter
  24978. * set by the physics engine when adding this impostor to the array
  24979. */
  24980. uniqueId: number;
  24981. /**
  24982. * @hidden
  24983. */
  24984. soft: boolean;
  24985. /**
  24986. * @hidden
  24987. */
  24988. segments: number;
  24989. private _joints;
  24990. /**
  24991. * Initializes the physics imposter
  24992. * @param object The physics-enabled object used as the physics imposter
  24993. * @param type The type of the physics imposter
  24994. * @param _options The options for the physics imposter
  24995. * @param _scene The Babylon scene
  24996. */
  24997. constructor(
  24998. /**
  24999. * The physics-enabled object used as the physics imposter
  25000. */
  25001. object: IPhysicsEnabledObject,
  25002. /**
  25003. * The type of the physics imposter
  25004. */
  25005. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  25006. /**
  25007. * This function will completly initialize this impostor.
  25008. * It will create a new body - but only if this mesh has no parent.
  25009. * If it has, this impostor will not be used other than to define the impostor
  25010. * of the child mesh.
  25011. * @hidden
  25012. */
  25013. _init(): void;
  25014. private _getPhysicsParent;
  25015. /**
  25016. * Should a new body be generated.
  25017. * @returns boolean specifying if body initialization is required
  25018. */
  25019. isBodyInitRequired(): boolean;
  25020. /**
  25021. * Sets the updated scaling
  25022. * @param updated Specifies if the scaling is updated
  25023. */
  25024. setScalingUpdated(): void;
  25025. /**
  25026. * Force a regeneration of this or the parent's impostor's body.
  25027. * Use under cautious - This will remove all joints already implemented.
  25028. */
  25029. forceUpdate(): void;
  25030. /**
  25031. * Gets the body that holds this impostor. Either its own, or its parent.
  25032. */
  25033. get physicsBody(): any;
  25034. /**
  25035. * Get the parent of the physics imposter
  25036. * @returns Physics imposter or null
  25037. */
  25038. get parent(): Nullable<PhysicsImpostor>;
  25039. /**
  25040. * Sets the parent of the physics imposter
  25041. */
  25042. set parent(value: Nullable<PhysicsImpostor>);
  25043. /**
  25044. * Set the physics body. Used mainly by the physics engine/plugin
  25045. */
  25046. set physicsBody(physicsBody: any);
  25047. /**
  25048. * Resets the update flags
  25049. */
  25050. resetUpdateFlags(): void;
  25051. /**
  25052. * Gets the object extend size
  25053. * @returns the object extend size
  25054. */
  25055. getObjectExtendSize(): Vector3;
  25056. /**
  25057. * Gets the object center
  25058. * @returns The object center
  25059. */
  25060. getObjectCenter(): Vector3;
  25061. /**
  25062. * Get a specific parameter from the options parameters
  25063. * @param paramName The object parameter name
  25064. * @returns The object parameter
  25065. */
  25066. getParam(paramName: string): any;
  25067. /**
  25068. * Sets a specific parameter in the options given to the physics plugin
  25069. * @param paramName The parameter name
  25070. * @param value The value of the parameter
  25071. */
  25072. setParam(paramName: string, value: number): void;
  25073. /**
  25074. * Specifically change the body's mass option. Won't recreate the physics body object
  25075. * @param mass The mass of the physics imposter
  25076. */
  25077. setMass(mass: number): void;
  25078. /**
  25079. * Gets the linear velocity
  25080. * @returns linear velocity or null
  25081. */
  25082. getLinearVelocity(): Nullable<Vector3>;
  25083. /**
  25084. * Sets the linear velocity
  25085. * @param velocity linear velocity or null
  25086. */
  25087. setLinearVelocity(velocity: Nullable<Vector3>): void;
  25088. /**
  25089. * Gets the angular velocity
  25090. * @returns angular velocity or null
  25091. */
  25092. getAngularVelocity(): Nullable<Vector3>;
  25093. /**
  25094. * Sets the angular velocity
  25095. * @param velocity The velocity or null
  25096. */
  25097. setAngularVelocity(velocity: Nullable<Vector3>): void;
  25098. /**
  25099. * Execute a function with the physics plugin native code
  25100. * Provide a function the will have two variables - the world object and the physics body object
  25101. * @param func The function to execute with the physics plugin native code
  25102. */
  25103. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  25104. /**
  25105. * Register a function that will be executed before the physics world is stepping forward
  25106. * @param func The function to execute before the physics world is stepped forward
  25107. */
  25108. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25109. /**
  25110. * Unregister a function that will be executed before the physics world is stepping forward
  25111. * @param func The function to execute before the physics world is stepped forward
  25112. */
  25113. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25114. /**
  25115. * Register a function that will be executed after the physics step
  25116. * @param func The function to execute after physics step
  25117. */
  25118. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25119. /**
  25120. * Unregisters a function that will be executed after the physics step
  25121. * @param func The function to execute after physics step
  25122. */
  25123. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  25124. /**
  25125. * register a function that will be executed when this impostor collides against a different body
  25126. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  25127. * @param func Callback that is executed on collision
  25128. */
  25129. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  25130. /**
  25131. * Unregisters the physics imposter on contact
  25132. * @param collideAgainst The physics object to collide against
  25133. * @param func Callback to execute on collision
  25134. */
  25135. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  25136. private _tmpQuat;
  25137. private _tmpQuat2;
  25138. /**
  25139. * Get the parent rotation
  25140. * @returns The parent rotation
  25141. */
  25142. getParentsRotation(): Quaternion;
  25143. /**
  25144. * this function is executed by the physics engine.
  25145. */
  25146. beforeStep: () => void;
  25147. /**
  25148. * this function is executed by the physics engine
  25149. */
  25150. afterStep: () => void;
  25151. /**
  25152. * Legacy collision detection event support
  25153. */
  25154. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25155. /**
  25156. * event and body object due to cannon's event-based architecture.
  25157. */
  25158. onCollide: (e: {
  25159. body: any;
  25160. }) => void;
  25161. /**
  25162. * Apply a force
  25163. * @param force The force to apply
  25164. * @param contactPoint The contact point for the force
  25165. * @returns The physics imposter
  25166. */
  25167. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25168. /**
  25169. * Apply an impulse
  25170. * @param force The impulse force
  25171. * @param contactPoint The contact point for the impulse force
  25172. * @returns The physics imposter
  25173. */
  25174. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25175. /**
  25176. * A help function to create a joint
  25177. * @param otherImpostor A physics imposter used to create a joint
  25178. * @param jointType The type of joint
  25179. * @param jointData The data for the joint
  25180. * @returns The physics imposter
  25181. */
  25182. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25183. /**
  25184. * Add a joint to this impostor with a different impostor
  25185. * @param otherImpostor A physics imposter used to add a joint
  25186. * @param joint The joint to add
  25187. * @returns The physics imposter
  25188. */
  25189. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25190. /**
  25191. * Add an anchor to a cloth impostor
  25192. * @param otherImpostor rigid impostor to anchor to
  25193. * @param width ratio across width from 0 to 1
  25194. * @param height ratio up height from 0 to 1
  25195. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  25196. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  25197. * @returns impostor the soft imposter
  25198. */
  25199. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25200. /**
  25201. * Add a hook to a rope impostor
  25202. * @param otherImpostor rigid impostor to anchor to
  25203. * @param length ratio across rope from 0 to 1
  25204. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  25205. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  25206. * @returns impostor the rope imposter
  25207. */
  25208. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25209. /**
  25210. * Will keep this body still, in a sleep mode.
  25211. * @returns the physics imposter
  25212. */
  25213. sleep(): PhysicsImpostor;
  25214. /**
  25215. * Wake the body up.
  25216. * @returns The physics imposter
  25217. */
  25218. wakeUp(): PhysicsImpostor;
  25219. /**
  25220. * Clones the physics imposter
  25221. * @param newObject The physics imposter clones to this physics-enabled object
  25222. * @returns A nullable physics imposter
  25223. */
  25224. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25225. /**
  25226. * Disposes the physics imposter
  25227. */
  25228. dispose(): void;
  25229. /**
  25230. * Sets the delta position
  25231. * @param position The delta position amount
  25232. */
  25233. setDeltaPosition(position: Vector3): void;
  25234. /**
  25235. * Sets the delta rotation
  25236. * @param rotation The delta rotation amount
  25237. */
  25238. setDeltaRotation(rotation: Quaternion): void;
  25239. /**
  25240. * Gets the box size of the physics imposter and stores the result in the input parameter
  25241. * @param result Stores the box size
  25242. * @returns The physics imposter
  25243. */
  25244. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25245. /**
  25246. * Gets the radius of the physics imposter
  25247. * @returns Radius of the physics imposter
  25248. */
  25249. getRadius(): number;
  25250. /**
  25251. * Sync a bone with this impostor
  25252. * @param bone The bone to sync to the impostor.
  25253. * @param boneMesh The mesh that the bone is influencing.
  25254. * @param jointPivot The pivot of the joint / bone in local space.
  25255. * @param distToJoint Optional distance from the impostor to the joint.
  25256. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25257. */
  25258. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25259. /**
  25260. * Sync impostor to a bone
  25261. * @param bone The bone that the impostor will be synced to.
  25262. * @param boneMesh The mesh that the bone is influencing.
  25263. * @param jointPivot The pivot of the joint / bone in local space.
  25264. * @param distToJoint Optional distance from the impostor to the joint.
  25265. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25266. * @param boneAxis Optional vector3 axis the bone is aligned with
  25267. */
  25268. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25269. /**
  25270. * No-Imposter type
  25271. */
  25272. static NoImpostor: number;
  25273. /**
  25274. * Sphere-Imposter type
  25275. */
  25276. static SphereImpostor: number;
  25277. /**
  25278. * Box-Imposter type
  25279. */
  25280. static BoxImpostor: number;
  25281. /**
  25282. * Plane-Imposter type
  25283. */
  25284. static PlaneImpostor: number;
  25285. /**
  25286. * Mesh-imposter type
  25287. */
  25288. static MeshImpostor: number;
  25289. /**
  25290. * Capsule-Impostor type (Ammo.js plugin only)
  25291. */
  25292. static CapsuleImpostor: number;
  25293. /**
  25294. * Cylinder-Imposter type
  25295. */
  25296. static CylinderImpostor: number;
  25297. /**
  25298. * Particle-Imposter type
  25299. */
  25300. static ParticleImpostor: number;
  25301. /**
  25302. * Heightmap-Imposter type
  25303. */
  25304. static HeightmapImpostor: number;
  25305. /**
  25306. * ConvexHull-Impostor type (Ammo.js plugin only)
  25307. */
  25308. static ConvexHullImpostor: number;
  25309. /**
  25310. * Custom-Imposter type (Ammo.js plugin only)
  25311. */
  25312. static CustomImpostor: number;
  25313. /**
  25314. * Rope-Imposter type
  25315. */
  25316. static RopeImpostor: number;
  25317. /**
  25318. * Cloth-Imposter type
  25319. */
  25320. static ClothImpostor: number;
  25321. /**
  25322. * Softbody-Imposter type
  25323. */
  25324. static SoftbodyImpostor: number;
  25325. }
  25326. }
  25327. declare module "babylonjs/Meshes/mesh" {
  25328. import { Observable } from "babylonjs/Misc/observable";
  25329. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25330. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25331. import { Camera } from "babylonjs/Cameras/camera";
  25332. import { Scene } from "babylonjs/scene";
  25333. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25334. import { Color4 } from "babylonjs/Maths/math.color";
  25335. import { Engine } from "babylonjs/Engines/engine";
  25336. import { Node } from "babylonjs/node";
  25337. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25338. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25339. import { Buffer } from "babylonjs/Meshes/buffer";
  25340. import { Geometry } from "babylonjs/Meshes/geometry";
  25341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25343. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25344. import { Effect } from "babylonjs/Materials/effect";
  25345. import { Material } from "babylonjs/Materials/material";
  25346. import { Skeleton } from "babylonjs/Bones/skeleton";
  25347. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25348. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25349. import { Path3D } from "babylonjs/Maths/math.path";
  25350. import { Plane } from "babylonjs/Maths/math.plane";
  25351. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25352. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25353. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25354. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25355. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25356. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25357. /**
  25358. * @hidden
  25359. **/
  25360. export class _CreationDataStorage {
  25361. closePath?: boolean;
  25362. closeArray?: boolean;
  25363. idx: number[];
  25364. dashSize: number;
  25365. gapSize: number;
  25366. path3D: Path3D;
  25367. pathArray: Vector3[][];
  25368. arc: number;
  25369. radius: number;
  25370. cap: number;
  25371. tessellation: number;
  25372. }
  25373. /**
  25374. * @hidden
  25375. **/
  25376. class _InstanceDataStorage {
  25377. visibleInstances: any;
  25378. batchCache: _InstancesBatch;
  25379. instancesBufferSize: number;
  25380. instancesBuffer: Nullable<Buffer>;
  25381. instancesData: Float32Array;
  25382. overridenInstanceCount: number;
  25383. isFrozen: boolean;
  25384. previousBatch: Nullable<_InstancesBatch>;
  25385. hardwareInstancedRendering: boolean;
  25386. sideOrientation: number;
  25387. manualUpdate: boolean;
  25388. }
  25389. /**
  25390. * @hidden
  25391. **/
  25392. export class _InstancesBatch {
  25393. mustReturn: boolean;
  25394. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25395. renderSelf: boolean[];
  25396. hardwareInstancedRendering: boolean[];
  25397. }
  25398. /**
  25399. * Class used to represent renderable models
  25400. */
  25401. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25402. /**
  25403. * Mesh side orientation : usually the external or front surface
  25404. */
  25405. static readonly FRONTSIDE: number;
  25406. /**
  25407. * Mesh side orientation : usually the internal or back surface
  25408. */
  25409. static readonly BACKSIDE: number;
  25410. /**
  25411. * Mesh side orientation : both internal and external or front and back surfaces
  25412. */
  25413. static readonly DOUBLESIDE: number;
  25414. /**
  25415. * Mesh side orientation : by default, `FRONTSIDE`
  25416. */
  25417. static readonly DEFAULTSIDE: number;
  25418. /**
  25419. * Mesh cap setting : no cap
  25420. */
  25421. static readonly NO_CAP: number;
  25422. /**
  25423. * Mesh cap setting : one cap at the beginning of the mesh
  25424. */
  25425. static readonly CAP_START: number;
  25426. /**
  25427. * Mesh cap setting : one cap at the end of the mesh
  25428. */
  25429. static readonly CAP_END: number;
  25430. /**
  25431. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25432. */
  25433. static readonly CAP_ALL: number;
  25434. /**
  25435. * Mesh pattern setting : no flip or rotate
  25436. */
  25437. static readonly NO_FLIP: number;
  25438. /**
  25439. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25440. */
  25441. static readonly FLIP_TILE: number;
  25442. /**
  25443. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25444. */
  25445. static readonly ROTATE_TILE: number;
  25446. /**
  25447. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25448. */
  25449. static readonly FLIP_ROW: number;
  25450. /**
  25451. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25452. */
  25453. static readonly ROTATE_ROW: number;
  25454. /**
  25455. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25456. */
  25457. static readonly FLIP_N_ROTATE_TILE: number;
  25458. /**
  25459. * Mesh pattern setting : rotate pattern and rotate
  25460. */
  25461. static readonly FLIP_N_ROTATE_ROW: number;
  25462. /**
  25463. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25464. */
  25465. static readonly CENTER: number;
  25466. /**
  25467. * Mesh tile positioning : part tiles on left
  25468. */
  25469. static readonly LEFT: number;
  25470. /**
  25471. * Mesh tile positioning : part tiles on right
  25472. */
  25473. static readonly RIGHT: number;
  25474. /**
  25475. * Mesh tile positioning : part tiles on top
  25476. */
  25477. static readonly TOP: number;
  25478. /**
  25479. * Mesh tile positioning : part tiles on bottom
  25480. */
  25481. static readonly BOTTOM: number;
  25482. /**
  25483. * Gets the default side orientation.
  25484. * @param orientation the orientation to value to attempt to get
  25485. * @returns the default orientation
  25486. * @hidden
  25487. */
  25488. static _GetDefaultSideOrientation(orientation?: number): number;
  25489. private _internalMeshDataInfo;
  25490. /**
  25491. * An event triggered before rendering the mesh
  25492. */
  25493. get onBeforeRenderObservable(): Observable<Mesh>;
  25494. /**
  25495. * An event triggered before binding the mesh
  25496. */
  25497. get onBeforeBindObservable(): Observable<Mesh>;
  25498. /**
  25499. * An event triggered after rendering the mesh
  25500. */
  25501. get onAfterRenderObservable(): Observable<Mesh>;
  25502. /**
  25503. * An event triggered before drawing the mesh
  25504. */
  25505. get onBeforeDrawObservable(): Observable<Mesh>;
  25506. private _onBeforeDrawObserver;
  25507. /**
  25508. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25509. */
  25510. set onBeforeDraw(callback: () => void);
  25511. get hasInstances(): boolean;
  25512. /**
  25513. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25514. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25515. */
  25516. delayLoadState: number;
  25517. /**
  25518. * Gets the list of instances created from this mesh
  25519. * it is not supposed to be modified manually.
  25520. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25521. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25522. */
  25523. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25524. /**
  25525. * Gets the file containing delay loading data for this mesh
  25526. */
  25527. delayLoadingFile: string;
  25528. /** @hidden */
  25529. _binaryInfo: any;
  25530. /**
  25531. * User defined function used to change how LOD level selection is done
  25532. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25533. */
  25534. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25535. /**
  25536. * Gets or sets the morph target manager
  25537. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25538. */
  25539. get morphTargetManager(): Nullable<MorphTargetManager>;
  25540. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25541. /** @hidden */
  25542. _creationDataStorage: Nullable<_CreationDataStorage>;
  25543. /** @hidden */
  25544. _geometry: Nullable<Geometry>;
  25545. /** @hidden */
  25546. _delayInfo: Array<string>;
  25547. /** @hidden */
  25548. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25549. /** @hidden */
  25550. _instanceDataStorage: _InstanceDataStorage;
  25551. private _effectiveMaterial;
  25552. /** @hidden */
  25553. _shouldGenerateFlatShading: boolean;
  25554. /** @hidden */
  25555. _originalBuilderSideOrientation: number;
  25556. /**
  25557. * Use this property to change the original side orientation defined at construction time
  25558. */
  25559. overrideMaterialSideOrientation: Nullable<number>;
  25560. /**
  25561. * Gets the source mesh (the one used to clone this one from)
  25562. */
  25563. get source(): Nullable<Mesh>;
  25564. /**
  25565. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25566. */
  25567. get isUnIndexed(): boolean;
  25568. set isUnIndexed(value: boolean);
  25569. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25570. get worldMatrixInstancedBuffer(): Float32Array;
  25571. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25572. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25573. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25574. /**
  25575. * @constructor
  25576. * @param name The value used by scene.getMeshByName() to do a lookup.
  25577. * @param scene The scene to add this mesh to.
  25578. * @param parent The parent of this mesh, if it has one
  25579. * @param source An optional Mesh from which geometry is shared, cloned.
  25580. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25581. * When false, achieved by calling a clone(), also passing False.
  25582. * This will make creation of children, recursive.
  25583. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25584. */
  25585. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25586. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25587. doNotInstantiate: boolean;
  25588. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25589. /**
  25590. * Gets the class name
  25591. * @returns the string "Mesh".
  25592. */
  25593. getClassName(): string;
  25594. /** @hidden */
  25595. get _isMesh(): boolean;
  25596. /**
  25597. * Returns a description of this mesh
  25598. * @param fullDetails define if full details about this mesh must be used
  25599. * @returns a descriptive string representing this mesh
  25600. */
  25601. toString(fullDetails?: boolean): string;
  25602. /** @hidden */
  25603. _unBindEffect(): void;
  25604. /**
  25605. * Gets a boolean indicating if this mesh has LOD
  25606. */
  25607. get hasLODLevels(): boolean;
  25608. /**
  25609. * Gets the list of MeshLODLevel associated with the current mesh
  25610. * @returns an array of MeshLODLevel
  25611. */
  25612. getLODLevels(): MeshLODLevel[];
  25613. private _sortLODLevels;
  25614. /**
  25615. * Add a mesh as LOD level triggered at the given distance.
  25616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25617. * @param distance The distance from the center of the object to show this level
  25618. * @param mesh The mesh to be added as LOD level (can be null)
  25619. * @return This mesh (for chaining)
  25620. */
  25621. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25622. /**
  25623. * Returns the LOD level mesh at the passed distance or null if not found.
  25624. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25625. * @param distance The distance from the center of the object to show this level
  25626. * @returns a Mesh or `null`
  25627. */
  25628. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25629. /**
  25630. * Remove a mesh from the LOD array
  25631. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25632. * @param mesh defines the mesh to be removed
  25633. * @return This mesh (for chaining)
  25634. */
  25635. removeLODLevel(mesh: Mesh): Mesh;
  25636. /**
  25637. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25638. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25639. * @param camera defines the camera to use to compute distance
  25640. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25641. * @return This mesh (for chaining)
  25642. */
  25643. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25644. /**
  25645. * Gets the mesh internal Geometry object
  25646. */
  25647. get geometry(): Nullable<Geometry>;
  25648. /**
  25649. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25650. * @returns the total number of vertices
  25651. */
  25652. getTotalVertices(): number;
  25653. /**
  25654. * Returns the content of an associated vertex buffer
  25655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25656. * - VertexBuffer.PositionKind
  25657. * - VertexBuffer.UVKind
  25658. * - VertexBuffer.UV2Kind
  25659. * - VertexBuffer.UV3Kind
  25660. * - VertexBuffer.UV4Kind
  25661. * - VertexBuffer.UV5Kind
  25662. * - VertexBuffer.UV6Kind
  25663. * - VertexBuffer.ColorKind
  25664. * - VertexBuffer.MatricesIndicesKind
  25665. * - VertexBuffer.MatricesIndicesExtraKind
  25666. * - VertexBuffer.MatricesWeightsKind
  25667. * - VertexBuffer.MatricesWeightsExtraKind
  25668. * @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
  25669. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25670. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25671. */
  25672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25673. /**
  25674. * Returns the mesh VertexBuffer object from the requested `kind`
  25675. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25676. * - VertexBuffer.PositionKind
  25677. * - VertexBuffer.NormalKind
  25678. * - VertexBuffer.UVKind
  25679. * - VertexBuffer.UV2Kind
  25680. * - VertexBuffer.UV3Kind
  25681. * - VertexBuffer.UV4Kind
  25682. * - VertexBuffer.UV5Kind
  25683. * - VertexBuffer.UV6Kind
  25684. * - VertexBuffer.ColorKind
  25685. * - VertexBuffer.MatricesIndicesKind
  25686. * - VertexBuffer.MatricesIndicesExtraKind
  25687. * - VertexBuffer.MatricesWeightsKind
  25688. * - VertexBuffer.MatricesWeightsExtraKind
  25689. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25690. */
  25691. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25692. /**
  25693. * Tests if a specific vertex buffer is associated with this mesh
  25694. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25695. * - VertexBuffer.PositionKind
  25696. * - VertexBuffer.NormalKind
  25697. * - VertexBuffer.UVKind
  25698. * - VertexBuffer.UV2Kind
  25699. * - VertexBuffer.UV3Kind
  25700. * - VertexBuffer.UV4Kind
  25701. * - VertexBuffer.UV5Kind
  25702. * - VertexBuffer.UV6Kind
  25703. * - VertexBuffer.ColorKind
  25704. * - VertexBuffer.MatricesIndicesKind
  25705. * - VertexBuffer.MatricesIndicesExtraKind
  25706. * - VertexBuffer.MatricesWeightsKind
  25707. * - VertexBuffer.MatricesWeightsExtraKind
  25708. * @returns a boolean
  25709. */
  25710. isVerticesDataPresent(kind: string): boolean;
  25711. /**
  25712. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25713. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25714. * - VertexBuffer.PositionKind
  25715. * - VertexBuffer.UVKind
  25716. * - VertexBuffer.UV2Kind
  25717. * - VertexBuffer.UV3Kind
  25718. * - VertexBuffer.UV4Kind
  25719. * - VertexBuffer.UV5Kind
  25720. * - VertexBuffer.UV6Kind
  25721. * - VertexBuffer.ColorKind
  25722. * - VertexBuffer.MatricesIndicesKind
  25723. * - VertexBuffer.MatricesIndicesExtraKind
  25724. * - VertexBuffer.MatricesWeightsKind
  25725. * - VertexBuffer.MatricesWeightsExtraKind
  25726. * @returns a boolean
  25727. */
  25728. isVertexBufferUpdatable(kind: string): boolean;
  25729. /**
  25730. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25731. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25732. * - VertexBuffer.PositionKind
  25733. * - VertexBuffer.NormalKind
  25734. * - VertexBuffer.UVKind
  25735. * - VertexBuffer.UV2Kind
  25736. * - VertexBuffer.UV3Kind
  25737. * - VertexBuffer.UV4Kind
  25738. * - VertexBuffer.UV5Kind
  25739. * - VertexBuffer.UV6Kind
  25740. * - VertexBuffer.ColorKind
  25741. * - VertexBuffer.MatricesIndicesKind
  25742. * - VertexBuffer.MatricesIndicesExtraKind
  25743. * - VertexBuffer.MatricesWeightsKind
  25744. * - VertexBuffer.MatricesWeightsExtraKind
  25745. * @returns an array of strings
  25746. */
  25747. getVerticesDataKinds(): string[];
  25748. /**
  25749. * Returns a positive integer : the total number of indices in this mesh geometry.
  25750. * @returns the numner of indices or zero if the mesh has no geometry.
  25751. */
  25752. getTotalIndices(): number;
  25753. /**
  25754. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25755. * @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.
  25756. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25757. * @returns the indices array or an empty array if the mesh has no geometry
  25758. */
  25759. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25760. get isBlocked(): boolean;
  25761. /**
  25762. * Determine if the current mesh is ready to be rendered
  25763. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25764. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25765. * @returns true if all associated assets are ready (material, textures, shaders)
  25766. */
  25767. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25768. /**
  25769. * 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.
  25770. */
  25771. get areNormalsFrozen(): boolean;
  25772. /**
  25773. * 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.
  25774. * @returns the current mesh
  25775. */
  25776. freezeNormals(): Mesh;
  25777. /**
  25778. * 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
  25779. * @returns the current mesh
  25780. */
  25781. unfreezeNormals(): Mesh;
  25782. /**
  25783. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25784. */
  25785. set overridenInstanceCount(count: number);
  25786. /** @hidden */
  25787. _preActivate(): Mesh;
  25788. /** @hidden */
  25789. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25790. /** @hidden */
  25791. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25792. /**
  25793. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25794. * This means the mesh underlying bounding box and sphere are recomputed.
  25795. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25796. * @returns the current mesh
  25797. */
  25798. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25799. /** @hidden */
  25800. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25801. /**
  25802. * This function will subdivide the mesh into multiple submeshes
  25803. * @param count defines the expected number of submeshes
  25804. */
  25805. subdivide(count: number): void;
  25806. /**
  25807. * Copy a FloatArray into a specific associated vertex buffer
  25808. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25809. * - VertexBuffer.PositionKind
  25810. * - VertexBuffer.UVKind
  25811. * - VertexBuffer.UV2Kind
  25812. * - VertexBuffer.UV3Kind
  25813. * - VertexBuffer.UV4Kind
  25814. * - VertexBuffer.UV5Kind
  25815. * - VertexBuffer.UV6Kind
  25816. * - VertexBuffer.ColorKind
  25817. * - VertexBuffer.MatricesIndicesKind
  25818. * - VertexBuffer.MatricesIndicesExtraKind
  25819. * - VertexBuffer.MatricesWeightsKind
  25820. * - VertexBuffer.MatricesWeightsExtraKind
  25821. * @param data defines the data source
  25822. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25823. * @param stride defines the data stride size (can be null)
  25824. * @returns the current mesh
  25825. */
  25826. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25827. /**
  25828. * Delete a vertex buffer associated with this mesh
  25829. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25830. * - VertexBuffer.PositionKind
  25831. * - VertexBuffer.UVKind
  25832. * - VertexBuffer.UV2Kind
  25833. * - VertexBuffer.UV3Kind
  25834. * - VertexBuffer.UV4Kind
  25835. * - VertexBuffer.UV5Kind
  25836. * - VertexBuffer.UV6Kind
  25837. * - VertexBuffer.ColorKind
  25838. * - VertexBuffer.MatricesIndicesKind
  25839. * - VertexBuffer.MatricesIndicesExtraKind
  25840. * - VertexBuffer.MatricesWeightsKind
  25841. * - VertexBuffer.MatricesWeightsExtraKind
  25842. */
  25843. removeVerticesData(kind: string): void;
  25844. /**
  25845. * Flags an associated vertex buffer as updatable
  25846. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25847. * - VertexBuffer.PositionKind
  25848. * - VertexBuffer.UVKind
  25849. * - VertexBuffer.UV2Kind
  25850. * - VertexBuffer.UV3Kind
  25851. * - VertexBuffer.UV4Kind
  25852. * - VertexBuffer.UV5Kind
  25853. * - VertexBuffer.UV6Kind
  25854. * - VertexBuffer.ColorKind
  25855. * - VertexBuffer.MatricesIndicesKind
  25856. * - VertexBuffer.MatricesIndicesExtraKind
  25857. * - VertexBuffer.MatricesWeightsKind
  25858. * - VertexBuffer.MatricesWeightsExtraKind
  25859. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25860. */
  25861. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25862. /**
  25863. * Sets the mesh global Vertex Buffer
  25864. * @param buffer defines the buffer to use
  25865. * @returns the current mesh
  25866. */
  25867. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25868. /**
  25869. * Update a specific associated vertex buffer
  25870. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25871. * - VertexBuffer.PositionKind
  25872. * - VertexBuffer.UVKind
  25873. * - VertexBuffer.UV2Kind
  25874. * - VertexBuffer.UV3Kind
  25875. * - VertexBuffer.UV4Kind
  25876. * - VertexBuffer.UV5Kind
  25877. * - VertexBuffer.UV6Kind
  25878. * - VertexBuffer.ColorKind
  25879. * - VertexBuffer.MatricesIndicesKind
  25880. * - VertexBuffer.MatricesIndicesExtraKind
  25881. * - VertexBuffer.MatricesWeightsKind
  25882. * - VertexBuffer.MatricesWeightsExtraKind
  25883. * @param data defines the data source
  25884. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25885. * @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)
  25886. * @returns the current mesh
  25887. */
  25888. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25889. /**
  25890. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25891. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25892. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25893. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25894. * @returns the current mesh
  25895. */
  25896. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25897. /**
  25898. * Creates a un-shared specific occurence of the geometry for the mesh.
  25899. * @returns the current mesh
  25900. */
  25901. makeGeometryUnique(): Mesh;
  25902. /**
  25903. * Set the index buffer of this mesh
  25904. * @param indices defines the source data
  25905. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25906. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25907. * @returns the current mesh
  25908. */
  25909. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25910. /**
  25911. * Update the current index buffer
  25912. * @param indices defines the source data
  25913. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25914. * @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)
  25915. * @returns the current mesh
  25916. */
  25917. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25918. /**
  25919. * Invert the geometry to move from a right handed system to a left handed one.
  25920. * @returns the current mesh
  25921. */
  25922. toLeftHanded(): Mesh;
  25923. /** @hidden */
  25924. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25925. /** @hidden */
  25926. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25927. /**
  25928. * Registers for this mesh a javascript function called just before the rendering process
  25929. * @param func defines the function to call before rendering this mesh
  25930. * @returns the current mesh
  25931. */
  25932. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25933. /**
  25934. * Disposes a previously registered javascript function called before the rendering
  25935. * @param func defines the function to remove
  25936. * @returns the current mesh
  25937. */
  25938. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25939. /**
  25940. * Registers for this mesh a javascript function called just after the rendering is complete
  25941. * @param func defines the function to call after rendering this mesh
  25942. * @returns the current mesh
  25943. */
  25944. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25945. /**
  25946. * Disposes a previously registered javascript function called after the rendering.
  25947. * @param func defines the function to remove
  25948. * @returns the current mesh
  25949. */
  25950. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25951. /** @hidden */
  25952. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25953. /** @hidden */
  25954. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25955. /** @hidden */
  25956. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25957. /** @hidden */
  25958. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25959. /** @hidden */
  25960. _rebuild(): void;
  25961. /** @hidden */
  25962. _freeze(): void;
  25963. /** @hidden */
  25964. _unFreeze(): void;
  25965. /**
  25966. * 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
  25967. * @param subMesh defines the subMesh to render
  25968. * @param enableAlphaMode defines if alpha mode can be changed
  25969. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25970. * @returns the current mesh
  25971. */
  25972. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25973. private _onBeforeDraw;
  25974. /**
  25975. * Renormalize the mesh and patch it up if there are no weights
  25976. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25977. * However in the case of zero weights then we set just a single influence to 1.
  25978. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25979. */
  25980. cleanMatrixWeights(): void;
  25981. private normalizeSkinFourWeights;
  25982. private normalizeSkinWeightsAndExtra;
  25983. /**
  25984. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25985. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25986. * the user know there was an issue with importing the mesh
  25987. * @returns a validation object with skinned, valid and report string
  25988. */
  25989. validateSkinning(): {
  25990. skinned: boolean;
  25991. valid: boolean;
  25992. report: string;
  25993. };
  25994. /** @hidden */
  25995. _checkDelayState(): Mesh;
  25996. private _queueLoad;
  25997. /**
  25998. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25999. * A mesh is in the frustum if its bounding box intersects the frustum
  26000. * @param frustumPlanes defines the frustum to test
  26001. * @returns true if the mesh is in the frustum planes
  26002. */
  26003. isInFrustum(frustumPlanes: Plane[]): boolean;
  26004. /**
  26005. * Sets the mesh material by the material or multiMaterial `id` property
  26006. * @param id is a string identifying the material or the multiMaterial
  26007. * @returns the current mesh
  26008. */
  26009. setMaterialByID(id: string): Mesh;
  26010. /**
  26011. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26012. * @returns an array of IAnimatable
  26013. */
  26014. getAnimatables(): IAnimatable[];
  26015. /**
  26016. * Modifies the mesh geometry according to the passed transformation matrix.
  26017. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26018. * The mesh normals are modified using the same transformation.
  26019. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26020. * @param transform defines the transform matrix to use
  26021. * @see http://doc.babylonjs.com/resources/baking_transformations
  26022. * @returns the current mesh
  26023. */
  26024. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26025. /**
  26026. * Modifies the mesh geometry according to its own current World Matrix.
  26027. * The mesh World Matrix is then reset.
  26028. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26029. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26030. * @see http://doc.babylonjs.com/resources/baking_transformations
  26031. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  26032. * @returns the current mesh
  26033. */
  26034. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  26035. /** @hidden */
  26036. get _positions(): Nullable<Vector3[]>;
  26037. /** @hidden */
  26038. _resetPointsArrayCache(): Mesh;
  26039. /** @hidden */
  26040. _generatePointsArray(): boolean;
  26041. /**
  26042. * Returns a new Mesh object generated from the current mesh properties.
  26043. * This method must not get confused with createInstance()
  26044. * @param name is a string, the name given to the new mesh
  26045. * @param newParent can be any Node object (default `null`)
  26046. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26047. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26048. * @returns a new mesh
  26049. */
  26050. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26051. /**
  26052. * Releases resources associated with this mesh.
  26053. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26054. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26055. */
  26056. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26057. /** @hidden */
  26058. _disposeInstanceSpecificData(): void;
  26059. /**
  26060. * Modifies the mesh geometry according to a displacement map.
  26061. * 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.
  26062. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26063. * @param url is a string, the URL from the image file is to be downloaded.
  26064. * @param minHeight is the lower limit of the displacement.
  26065. * @param maxHeight is the upper limit of the displacement.
  26066. * @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.
  26067. * @param uvOffset is an optional vector2 used to offset UV.
  26068. * @param uvScale is an optional vector2 used to scale UV.
  26069. * @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.
  26070. * @returns the Mesh.
  26071. */
  26072. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26073. /**
  26074. * Modifies the mesh geometry according to a displacementMap buffer.
  26075. * 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.
  26076. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26077. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26078. * @param heightMapWidth is the width of the buffer image.
  26079. * @param heightMapHeight is the height of the buffer image.
  26080. * @param minHeight is the lower limit of the displacement.
  26081. * @param maxHeight is the upper limit of the displacement.
  26082. * @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.
  26083. * @param uvOffset is an optional vector2 used to offset UV.
  26084. * @param uvScale is an optional vector2 used to scale UV.
  26085. * @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.
  26086. * @returns the Mesh.
  26087. */
  26088. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26089. /**
  26090. * Modify the mesh to get a flat shading rendering.
  26091. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26092. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26093. * @returns current mesh
  26094. */
  26095. convertToFlatShadedMesh(): Mesh;
  26096. /**
  26097. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26098. * In other words, more vertices, no more indices and a single bigger VBO.
  26099. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26100. * @returns current mesh
  26101. */
  26102. convertToUnIndexedMesh(): Mesh;
  26103. /**
  26104. * Inverses facet orientations.
  26105. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26106. * @param flipNormals will also inverts the normals
  26107. * @returns current mesh
  26108. */
  26109. flipFaces(flipNormals?: boolean): Mesh;
  26110. /**
  26111. * Increase the number of facets and hence vertices in a mesh
  26112. * Vertex normals are interpolated from existing vertex normals
  26113. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26114. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  26115. */
  26116. increaseVertices(numberPerEdge: number): void;
  26117. /**
  26118. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  26119. * This will undo any application of covertToFlatShadedMesh
  26120. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26121. */
  26122. forceSharedVertices(): void;
  26123. /** @hidden */
  26124. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  26125. /** @hidden */
  26126. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  26127. /**
  26128. * Creates a new InstancedMesh object from the mesh model.
  26129. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26130. * @param name defines the name of the new instance
  26131. * @returns a new InstancedMesh
  26132. */
  26133. createInstance(name: string): InstancedMesh;
  26134. /**
  26135. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26136. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26137. * @returns the current mesh
  26138. */
  26139. synchronizeInstances(): Mesh;
  26140. /**
  26141. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26142. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26143. * This should be used together with the simplification to avoid disappearing triangles.
  26144. * @param successCallback an optional success callback to be called after the optimization finished.
  26145. * @returns the current mesh
  26146. */
  26147. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26148. /**
  26149. * Serialize current mesh
  26150. * @param serializationObject defines the object which will receive the serialization data
  26151. */
  26152. serialize(serializationObject: any): void;
  26153. /** @hidden */
  26154. _syncGeometryWithMorphTargetManager(): void;
  26155. /** @hidden */
  26156. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  26157. /**
  26158. * Returns a new Mesh object parsed from the source provided.
  26159. * @param parsedMesh is the source
  26160. * @param scene defines the hosting scene
  26161. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26162. * @returns a new Mesh
  26163. */
  26164. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26165. /**
  26166. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26167. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26168. * @param name defines the name of the mesh to create
  26169. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26170. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26171. * @param closePath creates a seam between the first and the last points of each path of the path array
  26172. * @param offset is taken in account only if the `pathArray` is containing a single path
  26173. * @param scene defines the hosting scene
  26174. * @param updatable defines if the mesh must be flagged as updatable
  26175. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26176. * @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)
  26177. * @returns a new Mesh
  26178. */
  26179. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26180. /**
  26181. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26182. * @param name defines the name of the mesh to create
  26183. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26184. * @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
  26185. * @param scene defines the hosting scene
  26186. * @param updatable defines if the mesh must be flagged as updatable
  26187. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26188. * @returns a new Mesh
  26189. */
  26190. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26191. /**
  26192. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26193. * @param name defines the name of the mesh to create
  26194. * @param size sets the size (float) of each box side (default 1)
  26195. * @param scene defines the hosting scene
  26196. * @param updatable defines if the mesh must be flagged as updatable
  26197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26198. * @returns a new Mesh
  26199. */
  26200. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26201. /**
  26202. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26203. * @param name defines the name of the mesh to create
  26204. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26205. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26206. * @param scene defines the hosting scene
  26207. * @param updatable defines if the mesh must be flagged as updatable
  26208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26209. * @returns a new Mesh
  26210. */
  26211. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26212. /**
  26213. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26214. * @param name defines the name of the mesh to create
  26215. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26216. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26217. * @param scene defines the hosting scene
  26218. * @returns a new Mesh
  26219. */
  26220. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26221. /**
  26222. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26223. * @param name defines the name of the mesh to create
  26224. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26225. * @param diameterTop set the top cap diameter (floats, default 1)
  26226. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26227. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26228. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26229. * @param scene defines the hosting scene
  26230. * @param updatable defines if the mesh must be flagged as updatable
  26231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26232. * @returns a new Mesh
  26233. */
  26234. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26235. /**
  26236. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26237. * @param name defines the name of the mesh to create
  26238. * @param diameter sets the diameter size (float) of the torus (default 1)
  26239. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26240. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26241. * @param scene defines the hosting scene
  26242. * @param updatable defines if the mesh must be flagged as updatable
  26243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26244. * @returns a new Mesh
  26245. */
  26246. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26247. /**
  26248. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26249. * @param name defines the name of the mesh to create
  26250. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26251. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26252. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26253. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26254. * @param p the number of windings on X axis (positive integers, default 2)
  26255. * @param q the number of windings on Y axis (positive integers, default 3)
  26256. * @param scene defines the hosting scene
  26257. * @param updatable defines if the mesh must be flagged as updatable
  26258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26259. * @returns a new Mesh
  26260. */
  26261. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26262. /**
  26263. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26264. * @param name defines the name of the mesh to create
  26265. * @param points is an array successive Vector3
  26266. * @param scene defines the hosting scene
  26267. * @param updatable defines if the mesh must be flagged as updatable
  26268. * @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).
  26269. * @returns a new Mesh
  26270. */
  26271. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26272. /**
  26273. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26274. * @param name defines the name of the mesh to create
  26275. * @param points is an array successive Vector3
  26276. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26277. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26278. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26279. * @param scene defines the hosting scene
  26280. * @param updatable defines if the mesh must be flagged as updatable
  26281. * @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)
  26282. * @returns a new Mesh
  26283. */
  26284. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26285. /**
  26286. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26287. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26288. * 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.
  26289. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26290. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26291. * Remember you can only change the shape positions, not their number when updating a polygon.
  26292. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26293. * @param name defines the name of the mesh to create
  26294. * @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
  26295. * @param scene defines the hosting scene
  26296. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26297. * @param updatable defines if the mesh must be flagged as updatable
  26298. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26299. * @param earcutInjection can be used to inject your own earcut reference
  26300. * @returns a new Mesh
  26301. */
  26302. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26303. /**
  26304. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26305. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26306. * @param name defines the name of the mesh to create
  26307. * @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
  26308. * @param depth defines the height of extrusion
  26309. * @param scene defines the hosting scene
  26310. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26311. * @param updatable defines if the mesh must be flagged as updatable
  26312. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26313. * @param earcutInjection can be used to inject your own earcut reference
  26314. * @returns a new Mesh
  26315. */
  26316. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26317. /**
  26318. * Creates an extruded shape mesh.
  26319. * 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
  26320. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26321. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26322. * @param name defines the name of the mesh to create
  26323. * @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
  26324. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26325. * @param scale is the value to scale the shape
  26326. * @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
  26327. * @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
  26328. * @param scene defines the hosting scene
  26329. * @param updatable defines if the mesh must be flagged as updatable
  26330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26331. * @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)
  26332. * @returns a new Mesh
  26333. */
  26334. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26335. /**
  26336. * Creates an custom extruded shape mesh.
  26337. * The custom extrusion is a parametric shape.
  26338. * It has no predefined shape. Its final shape will depend on the input parameters.
  26339. * Please consider using the same method from the MeshBuilder class instead
  26340. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26341. * @param name defines the name of the mesh to create
  26342. * @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
  26343. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26344. * @param scaleFunction is a custom Javascript function called on each path point
  26345. * @param rotationFunction is a custom Javascript function called on each path point
  26346. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26347. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26348. * @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
  26349. * @param scene defines the hosting scene
  26350. * @param updatable defines if the mesh must be flagged as updatable
  26351. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26352. * @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)
  26353. * @returns a new Mesh
  26354. */
  26355. 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;
  26356. /**
  26357. * Creates lathe mesh.
  26358. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26359. * Please consider using the same method from the MeshBuilder class instead
  26360. * @param name defines the name of the mesh to create
  26361. * @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
  26362. * @param radius is the radius value of the lathe
  26363. * @param tessellation is the side number of the lathe.
  26364. * @param scene defines the hosting scene
  26365. * @param updatable defines if the mesh must be flagged as updatable
  26366. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26367. * @returns a new Mesh
  26368. */
  26369. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26370. /**
  26371. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26372. * @param name defines the name of the mesh to create
  26373. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26374. * @param scene defines the hosting scene
  26375. * @param updatable defines if the mesh must be flagged as updatable
  26376. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26377. * @returns a new Mesh
  26378. */
  26379. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26380. /**
  26381. * Creates a ground mesh.
  26382. * Please consider using the same method from the MeshBuilder class instead
  26383. * @param name defines the name of the mesh to create
  26384. * @param width set the width of the ground
  26385. * @param height set the height of the ground
  26386. * @param subdivisions sets the number of subdivisions per side
  26387. * @param scene defines the hosting scene
  26388. * @param updatable defines if the mesh must be flagged as updatable
  26389. * @returns a new Mesh
  26390. */
  26391. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26392. /**
  26393. * Creates a tiled ground mesh.
  26394. * Please consider using the same method from the MeshBuilder class instead
  26395. * @param name defines the name of the mesh to create
  26396. * @param xmin set the ground minimum X coordinate
  26397. * @param zmin set the ground minimum Y coordinate
  26398. * @param xmax set the ground maximum X coordinate
  26399. * @param zmax set the ground maximum Z coordinate
  26400. * @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
  26401. * @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
  26402. * @param scene defines the hosting scene
  26403. * @param updatable defines if the mesh must be flagged as updatable
  26404. * @returns a new Mesh
  26405. */
  26406. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26407. w: number;
  26408. h: number;
  26409. }, precision: {
  26410. w: number;
  26411. h: number;
  26412. }, scene: Scene, updatable?: boolean): Mesh;
  26413. /**
  26414. * Creates a ground mesh from a height map.
  26415. * Please consider using the same method from the MeshBuilder class instead
  26416. * @see http://doc.babylonjs.com/babylon101/height_map
  26417. * @param name defines the name of the mesh to create
  26418. * @param url sets the URL of the height map image resource
  26419. * @param width set the ground width size
  26420. * @param height set the ground height size
  26421. * @param subdivisions sets the number of subdivision per side
  26422. * @param minHeight is the minimum altitude on the ground
  26423. * @param maxHeight is the maximum altitude on the ground
  26424. * @param scene defines the hosting scene
  26425. * @param updatable defines if the mesh must be flagged as updatable
  26426. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26427. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26428. * @returns a new Mesh
  26429. */
  26430. 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;
  26431. /**
  26432. * Creates a tube mesh.
  26433. * The tube is a parametric shape.
  26434. * It has no predefined shape. Its final shape will depend on the input parameters.
  26435. * Please consider using the same method from the MeshBuilder class instead
  26436. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26437. * @param name defines the name of the mesh to create
  26438. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26439. * @param radius sets the tube radius size
  26440. * @param tessellation is the number of sides on the tubular surface
  26441. * @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
  26442. * @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
  26443. * @param scene defines the hosting scene
  26444. * @param updatable defines if the mesh must be flagged as updatable
  26445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26446. * @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)
  26447. * @returns a new Mesh
  26448. */
  26449. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26450. (i: number, distance: number): number;
  26451. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26452. /**
  26453. * Creates a polyhedron mesh.
  26454. * Please consider using the same method from the MeshBuilder class instead.
  26455. * * 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
  26456. * * The parameter `size` (positive float, default 1) sets the polygon size
  26457. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26458. * * 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`
  26459. * * 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
  26460. * * 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)`)
  26461. * * 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
  26462. * * 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
  26463. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26464. * * If you create a double-sided mesh, you can choose what parts of 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
  26465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26466. * @param name defines the name of the mesh to create
  26467. * @param options defines the options used to create the mesh
  26468. * @param scene defines the hosting scene
  26469. * @returns a new Mesh
  26470. */
  26471. static CreatePolyhedron(name: string, options: {
  26472. type?: number;
  26473. size?: number;
  26474. sizeX?: number;
  26475. sizeY?: number;
  26476. sizeZ?: number;
  26477. custom?: any;
  26478. faceUV?: Vector4[];
  26479. faceColors?: Color4[];
  26480. updatable?: boolean;
  26481. sideOrientation?: number;
  26482. }, scene: Scene): Mesh;
  26483. /**
  26484. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26485. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26486. * * 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`)
  26487. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26488. * * 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
  26489. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26490. * * If you create a double-sided mesh, you can choose what parts of 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
  26491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26492. * @param name defines the name of the mesh
  26493. * @param options defines the options used to create the mesh
  26494. * @param scene defines the hosting scene
  26495. * @returns a new Mesh
  26496. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26497. */
  26498. static CreateIcoSphere(name: string, options: {
  26499. radius?: number;
  26500. flat?: boolean;
  26501. subdivisions?: number;
  26502. sideOrientation?: number;
  26503. updatable?: boolean;
  26504. }, scene: Scene): Mesh;
  26505. /**
  26506. * Creates a decal mesh.
  26507. * Please consider using the same method from the MeshBuilder class instead.
  26508. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26509. * @param name defines the name of the mesh
  26510. * @param sourceMesh defines the mesh receiving the decal
  26511. * @param position sets the position of the decal in world coordinates
  26512. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26513. * @param size sets the decal scaling
  26514. * @param angle sets the angle to rotate the decal
  26515. * @returns a new Mesh
  26516. */
  26517. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26518. /**
  26519. * Prepare internal position array for software CPU skinning
  26520. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26521. */
  26522. setPositionsForCPUSkinning(): Float32Array;
  26523. /**
  26524. * Prepare internal normal array for software CPU skinning
  26525. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26526. */
  26527. setNormalsForCPUSkinning(): Float32Array;
  26528. /**
  26529. * Updates the vertex buffer by applying transformation from the bones
  26530. * @param skeleton defines the skeleton to apply to current mesh
  26531. * @returns the current mesh
  26532. */
  26533. applySkeleton(skeleton: Skeleton): Mesh;
  26534. /**
  26535. * 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
  26536. * @param meshes defines the list of meshes to scan
  26537. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26538. */
  26539. static MinMax(meshes: AbstractMesh[]): {
  26540. min: Vector3;
  26541. max: Vector3;
  26542. };
  26543. /**
  26544. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26545. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26546. * @returns a vector3
  26547. */
  26548. static Center(meshesOrMinMaxVector: {
  26549. min: Vector3;
  26550. max: Vector3;
  26551. } | AbstractMesh[]): Vector3;
  26552. /**
  26553. * Merge the array of meshes into a single mesh for performance reasons.
  26554. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26555. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26556. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26557. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26558. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26559. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26560. * @returns a new mesh
  26561. */
  26562. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26563. /** @hidden */
  26564. addInstance(instance: InstancedMesh): void;
  26565. /** @hidden */
  26566. removeInstance(instance: InstancedMesh): void;
  26567. }
  26568. }
  26569. declare module "babylonjs/Cameras/camera" {
  26570. import { SmartArray } from "babylonjs/Misc/smartArray";
  26571. import { Observable } from "babylonjs/Misc/observable";
  26572. import { Nullable } from "babylonjs/types";
  26573. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26574. import { Scene } from "babylonjs/scene";
  26575. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26576. import { Node } from "babylonjs/node";
  26577. import { Mesh } from "babylonjs/Meshes/mesh";
  26578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26579. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26580. import { Viewport } from "babylonjs/Maths/math.viewport";
  26581. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26583. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26584. import { Ray } from "babylonjs/Culling/ray";
  26585. /**
  26586. * This is the base class of all the camera used in the application.
  26587. * @see http://doc.babylonjs.com/features/cameras
  26588. */
  26589. export class Camera extends Node {
  26590. /** @hidden */
  26591. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26592. /**
  26593. * This is the default projection mode used by the cameras.
  26594. * It helps recreating a feeling of perspective and better appreciate depth.
  26595. * This is the best way to simulate real life cameras.
  26596. */
  26597. static readonly PERSPECTIVE_CAMERA: number;
  26598. /**
  26599. * This helps creating camera with an orthographic mode.
  26600. * 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.
  26601. */
  26602. static readonly ORTHOGRAPHIC_CAMERA: number;
  26603. /**
  26604. * This is the default FOV mode for perspective cameras.
  26605. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26606. */
  26607. static readonly FOVMODE_VERTICAL_FIXED: number;
  26608. /**
  26609. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26610. */
  26611. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26612. /**
  26613. * This specifies ther is no need for a camera rig.
  26614. * Basically only one eye is rendered corresponding to the camera.
  26615. */
  26616. static readonly RIG_MODE_NONE: number;
  26617. /**
  26618. * Simulates a camera Rig with one blue eye and one red eye.
  26619. * This can be use with 3d blue and red glasses.
  26620. */
  26621. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26622. /**
  26623. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26624. */
  26625. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26626. /**
  26627. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26628. */
  26629. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26630. /**
  26631. * Defines that both eyes of the camera will be rendered over under each other.
  26632. */
  26633. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26634. /**
  26635. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26636. */
  26637. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26638. /**
  26639. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26640. */
  26641. static readonly RIG_MODE_VR: number;
  26642. /**
  26643. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26644. */
  26645. static readonly RIG_MODE_WEBVR: number;
  26646. /**
  26647. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26648. */
  26649. static readonly RIG_MODE_CUSTOM: number;
  26650. /**
  26651. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26652. */
  26653. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26654. /**
  26655. * Define the input manager associated with the camera.
  26656. */
  26657. inputs: CameraInputsManager<Camera>;
  26658. /** @hidden */
  26659. _position: Vector3;
  26660. /**
  26661. * Define the current local position of the camera in the scene
  26662. */
  26663. get position(): Vector3;
  26664. set position(newPosition: Vector3);
  26665. /**
  26666. * The vector the camera should consider as up.
  26667. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26668. */
  26669. upVector: Vector3;
  26670. /**
  26671. * Define the current limit on the left side for an orthographic camera
  26672. * In scene unit
  26673. */
  26674. orthoLeft: Nullable<number>;
  26675. /**
  26676. * Define the current limit on the right side for an orthographic camera
  26677. * In scene unit
  26678. */
  26679. orthoRight: Nullable<number>;
  26680. /**
  26681. * Define the current limit on the bottom side for an orthographic camera
  26682. * In scene unit
  26683. */
  26684. orthoBottom: Nullable<number>;
  26685. /**
  26686. * Define the current limit on the top side for an orthographic camera
  26687. * In scene unit
  26688. */
  26689. orthoTop: Nullable<number>;
  26690. /**
  26691. * Field Of View is set in Radians. (default is 0.8)
  26692. */
  26693. fov: number;
  26694. /**
  26695. * Define the minimum distance the camera can see from.
  26696. * This is important to note that the depth buffer are not infinite and the closer it starts
  26697. * the more your scene might encounter depth fighting issue.
  26698. */
  26699. minZ: number;
  26700. /**
  26701. * Define the maximum distance the camera can see to.
  26702. * This is important to note that the depth buffer are not infinite and the further it end
  26703. * the more your scene might encounter depth fighting issue.
  26704. */
  26705. maxZ: number;
  26706. /**
  26707. * Define the default inertia of the camera.
  26708. * This helps giving a smooth feeling to the camera movement.
  26709. */
  26710. inertia: number;
  26711. /**
  26712. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26713. */
  26714. mode: number;
  26715. /**
  26716. * Define whether the camera is intermediate.
  26717. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26718. */
  26719. isIntermediate: boolean;
  26720. /**
  26721. * Define the viewport of the camera.
  26722. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26723. */
  26724. viewport: Viewport;
  26725. /**
  26726. * Restricts the camera to viewing objects with the same layerMask.
  26727. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26728. */
  26729. layerMask: number;
  26730. /**
  26731. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26732. */
  26733. fovMode: number;
  26734. /**
  26735. * Rig mode of the camera.
  26736. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26737. * This is normally controlled byt the camera themselves as internal use.
  26738. */
  26739. cameraRigMode: number;
  26740. /**
  26741. * Defines the distance between both "eyes" in case of a RIG
  26742. */
  26743. interaxialDistance: number;
  26744. /**
  26745. * Defines if stereoscopic rendering is done side by side or over under.
  26746. */
  26747. isStereoscopicSideBySide: boolean;
  26748. /**
  26749. * 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
  26750. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26751. * else in the scene. (Eg. security camera)
  26752. *
  26753. * 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)
  26754. */
  26755. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26756. /**
  26757. * When set, the camera will render to this render target instead of the default canvas
  26758. *
  26759. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26760. */
  26761. outputRenderTarget: Nullable<RenderTargetTexture>;
  26762. /**
  26763. * Observable triggered when the camera view matrix has changed.
  26764. */
  26765. onViewMatrixChangedObservable: Observable<Camera>;
  26766. /**
  26767. * Observable triggered when the camera Projection matrix has changed.
  26768. */
  26769. onProjectionMatrixChangedObservable: Observable<Camera>;
  26770. /**
  26771. * Observable triggered when the inputs have been processed.
  26772. */
  26773. onAfterCheckInputsObservable: Observable<Camera>;
  26774. /**
  26775. * Observable triggered when reset has been called and applied to the camera.
  26776. */
  26777. onRestoreStateObservable: Observable<Camera>;
  26778. /**
  26779. * Is this camera a part of a rig system?
  26780. */
  26781. isRigCamera: boolean;
  26782. /**
  26783. * If isRigCamera set to true this will be set with the parent camera.
  26784. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26785. */
  26786. rigParent?: Camera;
  26787. /** @hidden */
  26788. _cameraRigParams: any;
  26789. /** @hidden */
  26790. _rigCameras: Camera[];
  26791. /** @hidden */
  26792. _rigPostProcess: Nullable<PostProcess>;
  26793. protected _webvrViewMatrix: Matrix;
  26794. /** @hidden */
  26795. _skipRendering: boolean;
  26796. /** @hidden */
  26797. _projectionMatrix: Matrix;
  26798. /** @hidden */
  26799. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26800. /** @hidden */
  26801. _activeMeshes: SmartArray<AbstractMesh>;
  26802. protected _globalPosition: Vector3;
  26803. /** @hidden */
  26804. _computedViewMatrix: Matrix;
  26805. private _doNotComputeProjectionMatrix;
  26806. private _transformMatrix;
  26807. private _frustumPlanes;
  26808. private _refreshFrustumPlanes;
  26809. private _storedFov;
  26810. private _stateStored;
  26811. /**
  26812. * Instantiates a new camera object.
  26813. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26814. * @see http://doc.babylonjs.com/features/cameras
  26815. * @param name Defines the name of the camera in the scene
  26816. * @param position Defines the position of the camera
  26817. * @param scene Defines the scene the camera belongs too
  26818. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26819. */
  26820. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26821. /**
  26822. * Store current camera state (fov, position, etc..)
  26823. * @returns the camera
  26824. */
  26825. storeState(): Camera;
  26826. /**
  26827. * Restores the camera state values if it has been stored. You must call storeState() first
  26828. */
  26829. protected _restoreStateValues(): boolean;
  26830. /**
  26831. * Restored camera state. You must call storeState() first.
  26832. * @returns true if restored and false otherwise
  26833. */
  26834. restoreState(): boolean;
  26835. /**
  26836. * Gets the class name of the camera.
  26837. * @returns the class name
  26838. */
  26839. getClassName(): string;
  26840. /** @hidden */
  26841. readonly _isCamera: boolean;
  26842. /**
  26843. * Gets a string representation of the camera useful for debug purpose.
  26844. * @param fullDetails Defines that a more verboe level of logging is required
  26845. * @returns the string representation
  26846. */
  26847. toString(fullDetails?: boolean): string;
  26848. /**
  26849. * Gets the current world space position of the camera.
  26850. */
  26851. get globalPosition(): Vector3;
  26852. /**
  26853. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26854. * @returns the active meshe list
  26855. */
  26856. getActiveMeshes(): SmartArray<AbstractMesh>;
  26857. /**
  26858. * Check whether a mesh is part of the current active mesh list of the camera
  26859. * @param mesh Defines the mesh to check
  26860. * @returns true if active, false otherwise
  26861. */
  26862. isActiveMesh(mesh: Mesh): boolean;
  26863. /**
  26864. * Is this camera ready to be used/rendered
  26865. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26866. * @return true if the camera is ready
  26867. */
  26868. isReady(completeCheck?: boolean): boolean;
  26869. /** @hidden */
  26870. _initCache(): void;
  26871. /** @hidden */
  26872. _updateCache(ignoreParentClass?: boolean): void;
  26873. /** @hidden */
  26874. _isSynchronized(): boolean;
  26875. /** @hidden */
  26876. _isSynchronizedViewMatrix(): boolean;
  26877. /** @hidden */
  26878. _isSynchronizedProjectionMatrix(): boolean;
  26879. /**
  26880. * Attach the input controls to a specific dom element to get the input from.
  26881. * @param element Defines the element the controls should be listened from
  26882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26883. */
  26884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26885. /**
  26886. * Detach the current controls from the specified dom element.
  26887. * @param element Defines the element to stop listening the inputs from
  26888. */
  26889. detachControl(element: HTMLElement): void;
  26890. /**
  26891. * Update the camera state according to the different inputs gathered during the frame.
  26892. */
  26893. update(): void;
  26894. /** @hidden */
  26895. _checkInputs(): void;
  26896. /** @hidden */
  26897. get rigCameras(): Camera[];
  26898. /**
  26899. * Gets the post process used by the rig cameras
  26900. */
  26901. get rigPostProcess(): Nullable<PostProcess>;
  26902. /**
  26903. * Internal, gets the first post proces.
  26904. * @returns the first post process to be run on this camera.
  26905. */
  26906. _getFirstPostProcess(): Nullable<PostProcess>;
  26907. private _cascadePostProcessesToRigCams;
  26908. /**
  26909. * Attach a post process to the camera.
  26910. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26911. * @param postProcess The post process to attach to the camera
  26912. * @param insertAt The position of the post process in case several of them are in use in the scene
  26913. * @returns the position the post process has been inserted at
  26914. */
  26915. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26916. /**
  26917. * Detach a post process to the camera.
  26918. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26919. * @param postProcess The post process to detach from the camera
  26920. */
  26921. detachPostProcess(postProcess: PostProcess): void;
  26922. /**
  26923. * Gets the current world matrix of the camera
  26924. */
  26925. getWorldMatrix(): Matrix;
  26926. /** @hidden */
  26927. _getViewMatrix(): Matrix;
  26928. /**
  26929. * Gets the current view matrix of the camera.
  26930. * @param force forces the camera to recompute the matrix without looking at the cached state
  26931. * @returns the view matrix
  26932. */
  26933. getViewMatrix(force?: boolean): Matrix;
  26934. /**
  26935. * Freeze the projection matrix.
  26936. * It will prevent the cache check of the camera projection compute and can speed up perf
  26937. * if no parameter of the camera are meant to change
  26938. * @param projection Defines manually a projection if necessary
  26939. */
  26940. freezeProjectionMatrix(projection?: Matrix): void;
  26941. /**
  26942. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26943. */
  26944. unfreezeProjectionMatrix(): void;
  26945. /**
  26946. * Gets the current projection matrix of the camera.
  26947. * @param force forces the camera to recompute the matrix without looking at the cached state
  26948. * @returns the projection matrix
  26949. */
  26950. getProjectionMatrix(force?: boolean): Matrix;
  26951. /**
  26952. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26953. * @returns a Matrix
  26954. */
  26955. getTransformationMatrix(): Matrix;
  26956. private _updateFrustumPlanes;
  26957. /**
  26958. * Checks if a cullable object (mesh...) is in the camera frustum
  26959. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26960. * @param target The object to check
  26961. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26962. * @returns true if the object is in frustum otherwise false
  26963. */
  26964. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26965. /**
  26966. * Checks if a cullable object (mesh...) is in the camera frustum
  26967. * Unlike isInFrustum this cheks the full bounding box
  26968. * @param target The object to check
  26969. * @returns true if the object is in frustum otherwise false
  26970. */
  26971. isCompletelyInFrustum(target: ICullable): boolean;
  26972. /**
  26973. * Gets a ray in the forward direction from the camera.
  26974. * @param length Defines the length of the ray to create
  26975. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26976. * @param origin Defines the start point of the ray which defaults to the camera position
  26977. * @returns the forward ray
  26978. */
  26979. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26980. /**
  26981. * Releases resources associated with this node.
  26982. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26983. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26984. */
  26985. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26986. /** @hidden */
  26987. _isLeftCamera: boolean;
  26988. /**
  26989. * Gets the left camera of a rig setup in case of Rigged Camera
  26990. */
  26991. get isLeftCamera(): boolean;
  26992. /** @hidden */
  26993. _isRightCamera: boolean;
  26994. /**
  26995. * Gets the right camera of a rig setup in case of Rigged Camera
  26996. */
  26997. get isRightCamera(): boolean;
  26998. /**
  26999. * Gets the left camera of a rig setup in case of Rigged Camera
  27000. */
  27001. get leftCamera(): Nullable<FreeCamera>;
  27002. /**
  27003. * Gets the right camera of a rig setup in case of Rigged Camera
  27004. */
  27005. get rightCamera(): Nullable<FreeCamera>;
  27006. /**
  27007. * Gets the left camera target of a rig setup in case of Rigged Camera
  27008. * @returns the target position
  27009. */
  27010. getLeftTarget(): Nullable<Vector3>;
  27011. /**
  27012. * Gets the right camera target of a rig setup in case of Rigged Camera
  27013. * @returns the target position
  27014. */
  27015. getRightTarget(): Nullable<Vector3>;
  27016. /**
  27017. * @hidden
  27018. */
  27019. setCameraRigMode(mode: number, rigParams: any): void;
  27020. /** @hidden */
  27021. static _setStereoscopicRigMode(camera: Camera): void;
  27022. /** @hidden */
  27023. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  27024. /** @hidden */
  27025. static _setVRRigMode(camera: Camera, rigParams: any): void;
  27026. /** @hidden */
  27027. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  27028. /** @hidden */
  27029. _getVRProjectionMatrix(): Matrix;
  27030. protected _updateCameraRotationMatrix(): void;
  27031. protected _updateWebVRCameraRotationMatrix(): void;
  27032. /**
  27033. * This function MUST be overwritten by the different WebVR cameras available.
  27034. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27035. * @hidden
  27036. */
  27037. _getWebVRProjectionMatrix(): Matrix;
  27038. /**
  27039. * This function MUST be overwritten by the different WebVR cameras available.
  27040. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  27041. * @hidden
  27042. */
  27043. _getWebVRViewMatrix(): Matrix;
  27044. /** @hidden */
  27045. setCameraRigParameter(name: string, value: any): void;
  27046. /**
  27047. * needs to be overridden by children so sub has required properties to be copied
  27048. * @hidden
  27049. */
  27050. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  27051. /**
  27052. * May need to be overridden by children
  27053. * @hidden
  27054. */
  27055. _updateRigCameras(): void;
  27056. /** @hidden */
  27057. _setupInputs(): void;
  27058. /**
  27059. * Serialiaze the camera setup to a json represention
  27060. * @returns the JSON representation
  27061. */
  27062. serialize(): any;
  27063. /**
  27064. * Clones the current camera.
  27065. * @param name The cloned camera name
  27066. * @returns the cloned camera
  27067. */
  27068. clone(name: string): Camera;
  27069. /**
  27070. * Gets the direction of the camera relative to a given local axis.
  27071. * @param localAxis Defines the reference axis to provide a relative direction.
  27072. * @return the direction
  27073. */
  27074. getDirection(localAxis: Vector3): Vector3;
  27075. /**
  27076. * Returns the current camera absolute rotation
  27077. */
  27078. get absoluteRotation(): Quaternion;
  27079. /**
  27080. * Gets the direction of the camera relative to a given local axis into a passed vector.
  27081. * @param localAxis Defines the reference axis to provide a relative direction.
  27082. * @param result Defines the vector to store the result in
  27083. */
  27084. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  27085. /**
  27086. * Gets a camera constructor for a given camera type
  27087. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  27088. * @param name The name of the camera the result will be able to instantiate
  27089. * @param scene The scene the result will construct the camera in
  27090. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  27091. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  27092. * @returns a factory method to construc the camera
  27093. */
  27094. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  27095. /**
  27096. * Compute the world matrix of the camera.
  27097. * @returns the camera world matrix
  27098. */
  27099. computeWorldMatrix(): Matrix;
  27100. /**
  27101. * Parse a JSON and creates the camera from the parsed information
  27102. * @param parsedCamera The JSON to parse
  27103. * @param scene The scene to instantiate the camera in
  27104. * @returns the newly constructed camera
  27105. */
  27106. static Parse(parsedCamera: any, scene: Scene): Camera;
  27107. }
  27108. }
  27109. declare module "babylonjs/Meshes/Builders/discBuilder" {
  27110. import { Nullable } from "babylonjs/types";
  27111. import { Scene } from "babylonjs/scene";
  27112. import { Vector4 } from "babylonjs/Maths/math.vector";
  27113. import { Mesh } from "babylonjs/Meshes/mesh";
  27114. /**
  27115. * Class containing static functions to help procedurally build meshes
  27116. */
  27117. export class DiscBuilder {
  27118. /**
  27119. * Creates a plane polygonal mesh. By default, this is a disc
  27120. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27121. * * 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
  27122. * * 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
  27123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27126. * @param name defines the name of the mesh
  27127. * @param options defines the options used to create the mesh
  27128. * @param scene defines the hosting scene
  27129. * @returns the plane polygonal mesh
  27130. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27131. */
  27132. static CreateDisc(name: string, options: {
  27133. radius?: number;
  27134. tessellation?: number;
  27135. arc?: number;
  27136. updatable?: boolean;
  27137. sideOrientation?: number;
  27138. frontUVs?: Vector4;
  27139. backUVs?: Vector4;
  27140. }, scene?: Nullable<Scene>): Mesh;
  27141. }
  27142. }
  27143. declare module "babylonjs/Materials/fresnelParameters" {
  27144. import { DeepImmutable } from "babylonjs/types";
  27145. import { Color3 } from "babylonjs/Maths/math.color";
  27146. /**
  27147. * Options to be used when creating a FresnelParameters.
  27148. */
  27149. export type IFresnelParametersCreationOptions = {
  27150. /**
  27151. * Define the color used on edges (grazing angle)
  27152. */
  27153. leftColor?: Color3;
  27154. /**
  27155. * Define the color used on center
  27156. */
  27157. rightColor?: Color3;
  27158. /**
  27159. * Define bias applied to computed fresnel term
  27160. */
  27161. bias?: number;
  27162. /**
  27163. * Defined the power exponent applied to fresnel term
  27164. */
  27165. power?: number;
  27166. /**
  27167. * Define if the fresnel effect is enable or not.
  27168. */
  27169. isEnabled?: boolean;
  27170. };
  27171. /**
  27172. * Serialized format for FresnelParameters.
  27173. */
  27174. export type IFresnelParametersSerialized = {
  27175. /**
  27176. * Define the color used on edges (grazing angle) [as an array]
  27177. */
  27178. leftColor: number[];
  27179. /**
  27180. * Define the color used on center [as an array]
  27181. */
  27182. rightColor: number[];
  27183. /**
  27184. * Define bias applied to computed fresnel term
  27185. */
  27186. bias: number;
  27187. /**
  27188. * Defined the power exponent applied to fresnel term
  27189. */
  27190. power?: number;
  27191. /**
  27192. * Define if the fresnel effect is enable or not.
  27193. */
  27194. isEnabled: boolean;
  27195. };
  27196. /**
  27197. * This represents all the required information to add a fresnel effect on a material:
  27198. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27199. */
  27200. export class FresnelParameters {
  27201. private _isEnabled;
  27202. /**
  27203. * Define if the fresnel effect is enable or not.
  27204. */
  27205. get isEnabled(): boolean;
  27206. set isEnabled(value: boolean);
  27207. /**
  27208. * Define the color used on edges (grazing angle)
  27209. */
  27210. leftColor: Color3;
  27211. /**
  27212. * Define the color used on center
  27213. */
  27214. rightColor: Color3;
  27215. /**
  27216. * Define bias applied to computed fresnel term
  27217. */
  27218. bias: number;
  27219. /**
  27220. * Defined the power exponent applied to fresnel term
  27221. */
  27222. power: number;
  27223. /**
  27224. * Creates a new FresnelParameters object.
  27225. *
  27226. * @param options provide your own settings to optionally to override defaults
  27227. */
  27228. constructor(options?: IFresnelParametersCreationOptions);
  27229. /**
  27230. * Clones the current fresnel and its valuues
  27231. * @returns a clone fresnel configuration
  27232. */
  27233. clone(): FresnelParameters;
  27234. /**
  27235. * Determines equality between FresnelParameters objects
  27236. * @param otherFresnelParameters defines the second operand
  27237. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27238. */
  27239. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27240. /**
  27241. * Serializes the current fresnel parameters to a JSON representation.
  27242. * @return the JSON serialization
  27243. */
  27244. serialize(): IFresnelParametersSerialized;
  27245. /**
  27246. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27247. * @param parsedFresnelParameters Define the JSON representation
  27248. * @returns the parsed parameters
  27249. */
  27250. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27251. }
  27252. }
  27253. declare module "babylonjs/Materials/pushMaterial" {
  27254. import { Nullable } from "babylonjs/types";
  27255. import { Scene } from "babylonjs/scene";
  27256. import { Matrix } from "babylonjs/Maths/math.vector";
  27257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27258. import { Mesh } from "babylonjs/Meshes/mesh";
  27259. import { Material } from "babylonjs/Materials/material";
  27260. import { Effect } from "babylonjs/Materials/effect";
  27261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27262. /**
  27263. * Base class of materials working in push mode in babylon JS
  27264. * @hidden
  27265. */
  27266. export class PushMaterial extends Material {
  27267. protected _activeEffect: Effect;
  27268. protected _normalMatrix: Matrix;
  27269. /**
  27270. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27271. * This means that the material can keep using a previous shader while a new one is being compiled.
  27272. * This is mostly used when shader parallel compilation is supported (true by default)
  27273. */
  27274. allowShaderHotSwapping: boolean;
  27275. constructor(name: string, scene: Scene);
  27276. getEffect(): Effect;
  27277. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27278. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  27279. /**
  27280. * Binds the given world matrix to the active effect
  27281. *
  27282. * @param world the matrix to bind
  27283. */
  27284. bindOnlyWorldMatrix(world: Matrix): void;
  27285. /**
  27286. * Binds the given normal matrix to the active effect
  27287. *
  27288. * @param normalMatrix the matrix to bind
  27289. */
  27290. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27291. bind(world: Matrix, mesh?: Mesh): void;
  27292. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27293. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27294. }
  27295. }
  27296. declare module "babylonjs/Materials/materialFlags" {
  27297. /**
  27298. * This groups all the flags used to control the materials channel.
  27299. */
  27300. export class MaterialFlags {
  27301. private static _DiffuseTextureEnabled;
  27302. /**
  27303. * Are diffuse textures enabled in the application.
  27304. */
  27305. static get DiffuseTextureEnabled(): boolean;
  27306. static set DiffuseTextureEnabled(value: boolean);
  27307. private static _AmbientTextureEnabled;
  27308. /**
  27309. * Are ambient textures enabled in the application.
  27310. */
  27311. static get AmbientTextureEnabled(): boolean;
  27312. static set AmbientTextureEnabled(value: boolean);
  27313. private static _OpacityTextureEnabled;
  27314. /**
  27315. * Are opacity textures enabled in the application.
  27316. */
  27317. static get OpacityTextureEnabled(): boolean;
  27318. static set OpacityTextureEnabled(value: boolean);
  27319. private static _ReflectionTextureEnabled;
  27320. /**
  27321. * Are reflection textures enabled in the application.
  27322. */
  27323. static get ReflectionTextureEnabled(): boolean;
  27324. static set ReflectionTextureEnabled(value: boolean);
  27325. private static _EmissiveTextureEnabled;
  27326. /**
  27327. * Are emissive textures enabled in the application.
  27328. */
  27329. static get EmissiveTextureEnabled(): boolean;
  27330. static set EmissiveTextureEnabled(value: boolean);
  27331. private static _SpecularTextureEnabled;
  27332. /**
  27333. * Are specular textures enabled in the application.
  27334. */
  27335. static get SpecularTextureEnabled(): boolean;
  27336. static set SpecularTextureEnabled(value: boolean);
  27337. private static _BumpTextureEnabled;
  27338. /**
  27339. * Are bump textures enabled in the application.
  27340. */
  27341. static get BumpTextureEnabled(): boolean;
  27342. static set BumpTextureEnabled(value: boolean);
  27343. private static _LightmapTextureEnabled;
  27344. /**
  27345. * Are lightmap textures enabled in the application.
  27346. */
  27347. static get LightmapTextureEnabled(): boolean;
  27348. static set LightmapTextureEnabled(value: boolean);
  27349. private static _RefractionTextureEnabled;
  27350. /**
  27351. * Are refraction textures enabled in the application.
  27352. */
  27353. static get RefractionTextureEnabled(): boolean;
  27354. static set RefractionTextureEnabled(value: boolean);
  27355. private static _ColorGradingTextureEnabled;
  27356. /**
  27357. * Are color grading textures enabled in the application.
  27358. */
  27359. static get ColorGradingTextureEnabled(): boolean;
  27360. static set ColorGradingTextureEnabled(value: boolean);
  27361. private static _FresnelEnabled;
  27362. /**
  27363. * Are fresnels enabled in the application.
  27364. */
  27365. static get FresnelEnabled(): boolean;
  27366. static set FresnelEnabled(value: boolean);
  27367. private static _ClearCoatTextureEnabled;
  27368. /**
  27369. * Are clear coat textures enabled in the application.
  27370. */
  27371. static get ClearCoatTextureEnabled(): boolean;
  27372. static set ClearCoatTextureEnabled(value: boolean);
  27373. private static _ClearCoatBumpTextureEnabled;
  27374. /**
  27375. * Are clear coat bump textures enabled in the application.
  27376. */
  27377. static get ClearCoatBumpTextureEnabled(): boolean;
  27378. static set ClearCoatBumpTextureEnabled(value: boolean);
  27379. private static _ClearCoatTintTextureEnabled;
  27380. /**
  27381. * Are clear coat tint textures enabled in the application.
  27382. */
  27383. static get ClearCoatTintTextureEnabled(): boolean;
  27384. static set ClearCoatTintTextureEnabled(value: boolean);
  27385. private static _SheenTextureEnabled;
  27386. /**
  27387. * Are sheen textures enabled in the application.
  27388. */
  27389. static get SheenTextureEnabled(): boolean;
  27390. static set SheenTextureEnabled(value: boolean);
  27391. private static _AnisotropicTextureEnabled;
  27392. /**
  27393. * Are anisotropic textures enabled in the application.
  27394. */
  27395. static get AnisotropicTextureEnabled(): boolean;
  27396. static set AnisotropicTextureEnabled(value: boolean);
  27397. private static _ThicknessTextureEnabled;
  27398. /**
  27399. * Are thickness textures enabled in the application.
  27400. */
  27401. static get ThicknessTextureEnabled(): boolean;
  27402. static set ThicknessTextureEnabled(value: boolean);
  27403. }
  27404. }
  27405. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27406. /** @hidden */
  27407. export var defaultFragmentDeclaration: {
  27408. name: string;
  27409. shader: string;
  27410. };
  27411. }
  27412. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27413. /** @hidden */
  27414. export var defaultUboDeclaration: {
  27415. name: string;
  27416. shader: string;
  27417. };
  27418. }
  27419. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27420. /** @hidden */
  27421. export var lightFragmentDeclaration: {
  27422. name: string;
  27423. shader: string;
  27424. };
  27425. }
  27426. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27427. /** @hidden */
  27428. export var lightUboDeclaration: {
  27429. name: string;
  27430. shader: string;
  27431. };
  27432. }
  27433. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27434. /** @hidden */
  27435. export var lightsFragmentFunctions: {
  27436. name: string;
  27437. shader: string;
  27438. };
  27439. }
  27440. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27441. /** @hidden */
  27442. export var shadowsFragmentFunctions: {
  27443. name: string;
  27444. shader: string;
  27445. };
  27446. }
  27447. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27448. /** @hidden */
  27449. export var fresnelFunction: {
  27450. name: string;
  27451. shader: string;
  27452. };
  27453. }
  27454. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27455. /** @hidden */
  27456. export var reflectionFunction: {
  27457. name: string;
  27458. shader: string;
  27459. };
  27460. }
  27461. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  27462. /** @hidden */
  27463. export var bumpFragmentMainFunctions: {
  27464. name: string;
  27465. shader: string;
  27466. };
  27467. }
  27468. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27469. /** @hidden */
  27470. export var bumpFragmentFunctions: {
  27471. name: string;
  27472. shader: string;
  27473. };
  27474. }
  27475. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27476. /** @hidden */
  27477. export var logDepthDeclaration: {
  27478. name: string;
  27479. shader: string;
  27480. };
  27481. }
  27482. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27483. /** @hidden */
  27484. export var bumpFragment: {
  27485. name: string;
  27486. shader: string;
  27487. };
  27488. }
  27489. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27490. /** @hidden */
  27491. export var depthPrePass: {
  27492. name: string;
  27493. shader: string;
  27494. };
  27495. }
  27496. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27497. /** @hidden */
  27498. export var lightFragment: {
  27499. name: string;
  27500. shader: string;
  27501. };
  27502. }
  27503. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27504. /** @hidden */
  27505. export var logDepthFragment: {
  27506. name: string;
  27507. shader: string;
  27508. };
  27509. }
  27510. declare module "babylonjs/Shaders/default.fragment" {
  27511. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27512. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27513. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27514. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27515. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27516. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27517. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27518. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27519. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27520. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27521. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27522. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27523. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27524. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27525. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27526. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27527. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27528. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27529. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27530. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27531. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27532. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27533. /** @hidden */
  27534. export var defaultPixelShader: {
  27535. name: string;
  27536. shader: string;
  27537. };
  27538. }
  27539. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27540. /** @hidden */
  27541. export var defaultVertexDeclaration: {
  27542. name: string;
  27543. shader: string;
  27544. };
  27545. }
  27546. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27547. /** @hidden */
  27548. export var bumpVertexDeclaration: {
  27549. name: string;
  27550. shader: string;
  27551. };
  27552. }
  27553. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27554. /** @hidden */
  27555. export var bumpVertex: {
  27556. name: string;
  27557. shader: string;
  27558. };
  27559. }
  27560. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27561. /** @hidden */
  27562. export var fogVertex: {
  27563. name: string;
  27564. shader: string;
  27565. };
  27566. }
  27567. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27568. /** @hidden */
  27569. export var shadowsVertex: {
  27570. name: string;
  27571. shader: string;
  27572. };
  27573. }
  27574. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27575. /** @hidden */
  27576. export var pointCloudVertex: {
  27577. name: string;
  27578. shader: string;
  27579. };
  27580. }
  27581. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27582. /** @hidden */
  27583. export var logDepthVertex: {
  27584. name: string;
  27585. shader: string;
  27586. };
  27587. }
  27588. declare module "babylonjs/Shaders/default.vertex" {
  27589. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27590. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27591. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27592. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27593. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27594. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27595. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27596. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27597. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27598. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27599. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27600. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27601. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27602. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27603. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27604. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27605. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27606. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27607. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27608. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27609. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27610. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27611. /** @hidden */
  27612. export var defaultVertexShader: {
  27613. name: string;
  27614. shader: string;
  27615. };
  27616. }
  27617. declare module "babylonjs/Materials/standardMaterial" {
  27618. import { SmartArray } from "babylonjs/Misc/smartArray";
  27619. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27620. import { Nullable } from "babylonjs/types";
  27621. import { Scene } from "babylonjs/scene";
  27622. import { Matrix } from "babylonjs/Maths/math.vector";
  27623. import { Color3 } from "babylonjs/Maths/math.color";
  27624. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27626. import { Mesh } from "babylonjs/Meshes/mesh";
  27627. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27628. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27629. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27630. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27631. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27633. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27634. import "babylonjs/Shaders/default.fragment";
  27635. import "babylonjs/Shaders/default.vertex";
  27636. /** @hidden */
  27637. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27638. MAINUV1: boolean;
  27639. MAINUV2: boolean;
  27640. DIFFUSE: boolean;
  27641. DIFFUSEDIRECTUV: number;
  27642. AMBIENT: boolean;
  27643. AMBIENTDIRECTUV: number;
  27644. OPACITY: boolean;
  27645. OPACITYDIRECTUV: number;
  27646. OPACITYRGB: boolean;
  27647. REFLECTION: boolean;
  27648. EMISSIVE: boolean;
  27649. EMISSIVEDIRECTUV: number;
  27650. SPECULAR: boolean;
  27651. SPECULARDIRECTUV: number;
  27652. BUMP: boolean;
  27653. BUMPDIRECTUV: number;
  27654. PARALLAX: boolean;
  27655. PARALLAXOCCLUSION: boolean;
  27656. SPECULAROVERALPHA: boolean;
  27657. CLIPPLANE: boolean;
  27658. CLIPPLANE2: boolean;
  27659. CLIPPLANE3: boolean;
  27660. CLIPPLANE4: boolean;
  27661. CLIPPLANE5: boolean;
  27662. CLIPPLANE6: boolean;
  27663. ALPHATEST: boolean;
  27664. DEPTHPREPASS: boolean;
  27665. ALPHAFROMDIFFUSE: boolean;
  27666. POINTSIZE: boolean;
  27667. FOG: boolean;
  27668. SPECULARTERM: boolean;
  27669. DIFFUSEFRESNEL: boolean;
  27670. OPACITYFRESNEL: boolean;
  27671. REFLECTIONFRESNEL: boolean;
  27672. REFRACTIONFRESNEL: boolean;
  27673. EMISSIVEFRESNEL: boolean;
  27674. FRESNEL: boolean;
  27675. NORMAL: boolean;
  27676. UV1: boolean;
  27677. UV2: boolean;
  27678. VERTEXCOLOR: boolean;
  27679. VERTEXALPHA: boolean;
  27680. NUM_BONE_INFLUENCERS: number;
  27681. BonesPerMesh: number;
  27682. BONETEXTURE: boolean;
  27683. INSTANCES: boolean;
  27684. GLOSSINESS: boolean;
  27685. ROUGHNESS: boolean;
  27686. EMISSIVEASILLUMINATION: boolean;
  27687. LINKEMISSIVEWITHDIFFUSE: boolean;
  27688. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27689. LIGHTMAP: boolean;
  27690. LIGHTMAPDIRECTUV: number;
  27691. OBJECTSPACE_NORMALMAP: boolean;
  27692. USELIGHTMAPASSHADOWMAP: boolean;
  27693. REFLECTIONMAP_3D: boolean;
  27694. REFLECTIONMAP_SPHERICAL: boolean;
  27695. REFLECTIONMAP_PLANAR: boolean;
  27696. REFLECTIONMAP_CUBIC: boolean;
  27697. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27698. REFLECTIONMAP_PROJECTION: boolean;
  27699. REFLECTIONMAP_SKYBOX: boolean;
  27700. REFLECTIONMAP_EXPLICIT: boolean;
  27701. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27702. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27703. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27704. INVERTCUBICMAP: boolean;
  27705. LOGARITHMICDEPTH: boolean;
  27706. REFRACTION: boolean;
  27707. REFRACTIONMAP_3D: boolean;
  27708. REFLECTIONOVERALPHA: boolean;
  27709. TWOSIDEDLIGHTING: boolean;
  27710. SHADOWFLOAT: boolean;
  27711. MORPHTARGETS: boolean;
  27712. MORPHTARGETS_NORMAL: boolean;
  27713. MORPHTARGETS_TANGENT: boolean;
  27714. MORPHTARGETS_UV: boolean;
  27715. NUM_MORPH_INFLUENCERS: number;
  27716. NONUNIFORMSCALING: boolean;
  27717. PREMULTIPLYALPHA: boolean;
  27718. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27719. ALPHABLEND: boolean;
  27720. IMAGEPROCESSING: boolean;
  27721. VIGNETTE: boolean;
  27722. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27723. VIGNETTEBLENDMODEOPAQUE: boolean;
  27724. TONEMAPPING: boolean;
  27725. TONEMAPPING_ACES: boolean;
  27726. CONTRAST: boolean;
  27727. COLORCURVES: boolean;
  27728. COLORGRADING: boolean;
  27729. COLORGRADING3D: boolean;
  27730. SAMPLER3DGREENDEPTH: boolean;
  27731. SAMPLER3DBGRMAP: boolean;
  27732. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27733. MULTIVIEW: boolean;
  27734. /**
  27735. * If the reflection texture on this material is in linear color space
  27736. * @hidden
  27737. */
  27738. IS_REFLECTION_LINEAR: boolean;
  27739. /**
  27740. * If the refraction texture on this material is in linear color space
  27741. * @hidden
  27742. */
  27743. IS_REFRACTION_LINEAR: boolean;
  27744. EXPOSURE: boolean;
  27745. constructor();
  27746. setReflectionMode(modeToEnable: string): void;
  27747. }
  27748. /**
  27749. * This is the default material used in Babylon. It is the best trade off between quality
  27750. * and performances.
  27751. * @see http://doc.babylonjs.com/babylon101/materials
  27752. */
  27753. export class StandardMaterial extends PushMaterial {
  27754. private _diffuseTexture;
  27755. /**
  27756. * The basic texture of the material as viewed under a light.
  27757. */
  27758. diffuseTexture: Nullable<BaseTexture>;
  27759. private _ambientTexture;
  27760. /**
  27761. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27762. */
  27763. ambientTexture: Nullable<BaseTexture>;
  27764. private _opacityTexture;
  27765. /**
  27766. * Define the transparency of the material from a texture.
  27767. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27768. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27769. */
  27770. opacityTexture: Nullable<BaseTexture>;
  27771. private _reflectionTexture;
  27772. /**
  27773. * Define the texture used to display the reflection.
  27774. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27775. */
  27776. reflectionTexture: Nullable<BaseTexture>;
  27777. private _emissiveTexture;
  27778. /**
  27779. * Define texture of the material as if self lit.
  27780. * This will be mixed in the final result even in the absence of light.
  27781. */
  27782. emissiveTexture: Nullable<BaseTexture>;
  27783. private _specularTexture;
  27784. /**
  27785. * Define how the color and intensity of the highlight given by the light in the material.
  27786. */
  27787. specularTexture: Nullable<BaseTexture>;
  27788. private _bumpTexture;
  27789. /**
  27790. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27791. * 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.
  27792. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27793. */
  27794. bumpTexture: Nullable<BaseTexture>;
  27795. private _lightmapTexture;
  27796. /**
  27797. * Complex lighting can be computationally expensive to compute at runtime.
  27798. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27799. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27800. */
  27801. lightmapTexture: Nullable<BaseTexture>;
  27802. private _refractionTexture;
  27803. /**
  27804. * Define the texture used to display the refraction.
  27805. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27806. */
  27807. refractionTexture: Nullable<BaseTexture>;
  27808. /**
  27809. * The color of the material lit by the environmental background lighting.
  27810. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27811. */
  27812. ambientColor: Color3;
  27813. /**
  27814. * The basic color of the material as viewed under a light.
  27815. */
  27816. diffuseColor: Color3;
  27817. /**
  27818. * Define how the color and intensity of the highlight given by the light in the material.
  27819. */
  27820. specularColor: Color3;
  27821. /**
  27822. * Define the color of the material as if self lit.
  27823. * This will be mixed in the final result even in the absence of light.
  27824. */
  27825. emissiveColor: Color3;
  27826. /**
  27827. * Defines how sharp are the highlights in the material.
  27828. * The bigger the value the sharper giving a more glossy feeling to the result.
  27829. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27830. */
  27831. specularPower: number;
  27832. private _useAlphaFromDiffuseTexture;
  27833. /**
  27834. * Does the transparency come from the diffuse texture alpha channel.
  27835. */
  27836. useAlphaFromDiffuseTexture: boolean;
  27837. private _useEmissiveAsIllumination;
  27838. /**
  27839. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27840. */
  27841. useEmissiveAsIllumination: boolean;
  27842. private _linkEmissiveWithDiffuse;
  27843. /**
  27844. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27845. * the emissive level when the final color is close to one.
  27846. */
  27847. linkEmissiveWithDiffuse: boolean;
  27848. private _useSpecularOverAlpha;
  27849. /**
  27850. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27851. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27852. */
  27853. useSpecularOverAlpha: boolean;
  27854. private _useReflectionOverAlpha;
  27855. /**
  27856. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27857. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27858. */
  27859. useReflectionOverAlpha: boolean;
  27860. private _disableLighting;
  27861. /**
  27862. * Does lights from the scene impacts this material.
  27863. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27864. */
  27865. disableLighting: boolean;
  27866. private _useObjectSpaceNormalMap;
  27867. /**
  27868. * Allows using an object space normal map (instead of tangent space).
  27869. */
  27870. useObjectSpaceNormalMap: boolean;
  27871. private _useParallax;
  27872. /**
  27873. * Is parallax enabled or not.
  27874. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27875. */
  27876. useParallax: boolean;
  27877. private _useParallaxOcclusion;
  27878. /**
  27879. * Is parallax occlusion enabled or not.
  27880. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27881. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27882. */
  27883. useParallaxOcclusion: boolean;
  27884. /**
  27885. * 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.
  27886. */
  27887. parallaxScaleBias: number;
  27888. private _roughness;
  27889. /**
  27890. * Helps to define how blurry the reflections should appears in the material.
  27891. */
  27892. roughness: number;
  27893. /**
  27894. * In case of refraction, define the value of the index of refraction.
  27895. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27896. */
  27897. indexOfRefraction: number;
  27898. /**
  27899. * Invert the refraction texture alongside the y axis.
  27900. * It can be useful with procedural textures or probe for instance.
  27901. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27902. */
  27903. invertRefractionY: boolean;
  27904. /**
  27905. * Defines the alpha limits in alpha test mode.
  27906. */
  27907. alphaCutOff: number;
  27908. private _useLightmapAsShadowmap;
  27909. /**
  27910. * In case of light mapping, define whether the map contains light or shadow informations.
  27911. */
  27912. useLightmapAsShadowmap: boolean;
  27913. private _diffuseFresnelParameters;
  27914. /**
  27915. * Define the diffuse fresnel parameters of the material.
  27916. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27917. */
  27918. diffuseFresnelParameters: FresnelParameters;
  27919. private _opacityFresnelParameters;
  27920. /**
  27921. * Define the opacity fresnel parameters of the material.
  27922. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27923. */
  27924. opacityFresnelParameters: FresnelParameters;
  27925. private _reflectionFresnelParameters;
  27926. /**
  27927. * Define the reflection fresnel parameters of the material.
  27928. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27929. */
  27930. reflectionFresnelParameters: FresnelParameters;
  27931. private _refractionFresnelParameters;
  27932. /**
  27933. * Define the refraction fresnel parameters of the material.
  27934. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27935. */
  27936. refractionFresnelParameters: FresnelParameters;
  27937. private _emissiveFresnelParameters;
  27938. /**
  27939. * Define the emissive fresnel parameters of the material.
  27940. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27941. */
  27942. emissiveFresnelParameters: FresnelParameters;
  27943. private _useReflectionFresnelFromSpecular;
  27944. /**
  27945. * If true automatically deducts the fresnels values from the material specularity.
  27946. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27947. */
  27948. useReflectionFresnelFromSpecular: boolean;
  27949. private _useGlossinessFromSpecularMapAlpha;
  27950. /**
  27951. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27952. */
  27953. useGlossinessFromSpecularMapAlpha: boolean;
  27954. private _maxSimultaneousLights;
  27955. /**
  27956. * Defines the maximum number of lights that can be used in the material
  27957. */
  27958. maxSimultaneousLights: number;
  27959. private _invertNormalMapX;
  27960. /**
  27961. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27962. */
  27963. invertNormalMapX: boolean;
  27964. private _invertNormalMapY;
  27965. /**
  27966. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27967. */
  27968. invertNormalMapY: boolean;
  27969. private _twoSidedLighting;
  27970. /**
  27971. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27972. */
  27973. twoSidedLighting: boolean;
  27974. /**
  27975. * Default configuration related to image processing available in the standard Material.
  27976. */
  27977. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27978. /**
  27979. * Gets the image processing configuration used either in this material.
  27980. */
  27981. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27982. /**
  27983. * Sets the Default image processing configuration used either in the this material.
  27984. *
  27985. * If sets to null, the scene one is in use.
  27986. */
  27987. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27988. /**
  27989. * Keep track of the image processing observer to allow dispose and replace.
  27990. */
  27991. private _imageProcessingObserver;
  27992. /**
  27993. * Attaches a new image processing configuration to the Standard Material.
  27994. * @param configuration
  27995. */
  27996. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27997. /**
  27998. * Gets wether the color curves effect is enabled.
  27999. */
  28000. get cameraColorCurvesEnabled(): boolean;
  28001. /**
  28002. * Sets wether the color curves effect is enabled.
  28003. */
  28004. set cameraColorCurvesEnabled(value: boolean);
  28005. /**
  28006. * Gets wether the color grading effect is enabled.
  28007. */
  28008. get cameraColorGradingEnabled(): boolean;
  28009. /**
  28010. * Gets wether the color grading effect is enabled.
  28011. */
  28012. set cameraColorGradingEnabled(value: boolean);
  28013. /**
  28014. * Gets wether tonemapping is enabled or not.
  28015. */
  28016. get cameraToneMappingEnabled(): boolean;
  28017. /**
  28018. * Sets wether tonemapping is enabled or not
  28019. */
  28020. set cameraToneMappingEnabled(value: boolean);
  28021. /**
  28022. * The camera exposure used on this material.
  28023. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28024. * This corresponds to a photographic exposure.
  28025. */
  28026. get cameraExposure(): number;
  28027. /**
  28028. * The camera exposure used on this material.
  28029. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28030. * This corresponds to a photographic exposure.
  28031. */
  28032. set cameraExposure(value: number);
  28033. /**
  28034. * Gets The camera contrast used on this material.
  28035. */
  28036. get cameraContrast(): number;
  28037. /**
  28038. * Sets The camera contrast used on this material.
  28039. */
  28040. set cameraContrast(value: number);
  28041. /**
  28042. * Gets the Color Grading 2D Lookup Texture.
  28043. */
  28044. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28045. /**
  28046. * Sets the Color Grading 2D Lookup Texture.
  28047. */
  28048. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28049. /**
  28050. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28051. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28052. * 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;
  28053. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28054. */
  28055. get cameraColorCurves(): Nullable<ColorCurves>;
  28056. /**
  28057. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28058. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28059. * 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;
  28060. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28061. */
  28062. set cameraColorCurves(value: Nullable<ColorCurves>);
  28063. protected _renderTargets: SmartArray<RenderTargetTexture>;
  28064. protected _worldViewProjectionMatrix: Matrix;
  28065. protected _globalAmbientColor: Color3;
  28066. protected _useLogarithmicDepth: boolean;
  28067. protected _rebuildInParallel: boolean;
  28068. /**
  28069. * Instantiates a new standard material.
  28070. * This is the default material used in Babylon. It is the best trade off between quality
  28071. * and performances.
  28072. * @see http://doc.babylonjs.com/babylon101/materials
  28073. * @param name Define the name of the material in the scene
  28074. * @param scene Define the scene the material belong to
  28075. */
  28076. constructor(name: string, scene: Scene);
  28077. /**
  28078. * Gets a boolean indicating that current material needs to register RTT
  28079. */
  28080. get hasRenderTargetTextures(): boolean;
  28081. /**
  28082. * Gets the current class name of the material e.g. "StandardMaterial"
  28083. * Mainly use in serialization.
  28084. * @returns the class name
  28085. */
  28086. getClassName(): string;
  28087. /**
  28088. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  28089. * You can try switching to logarithmic depth.
  28090. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  28091. */
  28092. get useLogarithmicDepth(): boolean;
  28093. set useLogarithmicDepth(value: boolean);
  28094. /**
  28095. * Specifies if the material will require alpha blending
  28096. * @returns a boolean specifying if alpha blending is needed
  28097. */
  28098. needAlphaBlending(): boolean;
  28099. /**
  28100. * Specifies if this material should be rendered in alpha test mode
  28101. * @returns a boolean specifying if an alpha test is needed.
  28102. */
  28103. needAlphaTesting(): boolean;
  28104. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  28105. /**
  28106. * Get the texture used for alpha test purpose.
  28107. * @returns the diffuse texture in case of the standard material.
  28108. */
  28109. getAlphaTestTexture(): Nullable<BaseTexture>;
  28110. /**
  28111. * Get if the submesh is ready to be used and all its information available.
  28112. * Child classes can use it to update shaders
  28113. * @param mesh defines the mesh to check
  28114. * @param subMesh defines which submesh to check
  28115. * @param useInstances specifies that instances should be used
  28116. * @returns a boolean indicating that the submesh is ready or not
  28117. */
  28118. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28119. /**
  28120. * Builds the material UBO layouts.
  28121. * Used internally during the effect preparation.
  28122. */
  28123. buildUniformLayout(): void;
  28124. /**
  28125. * Unbinds the material from the mesh
  28126. */
  28127. unbind(): void;
  28128. /**
  28129. * Binds the submesh to this material by preparing the effect and shader to draw
  28130. * @param world defines the world transformation matrix
  28131. * @param mesh defines the mesh containing the submesh
  28132. * @param subMesh defines the submesh to bind the material to
  28133. */
  28134. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28135. /**
  28136. * Get the list of animatables in the material.
  28137. * @returns the list of animatables object used in the material
  28138. */
  28139. getAnimatables(): IAnimatable[];
  28140. /**
  28141. * Gets the active textures from the material
  28142. * @returns an array of textures
  28143. */
  28144. getActiveTextures(): BaseTexture[];
  28145. /**
  28146. * Specifies if the material uses a texture
  28147. * @param texture defines the texture to check against the material
  28148. * @returns a boolean specifying if the material uses the texture
  28149. */
  28150. hasTexture(texture: BaseTexture): boolean;
  28151. /**
  28152. * Disposes the material
  28153. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28154. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28155. */
  28156. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28157. /**
  28158. * Makes a duplicate of the material, and gives it a new name
  28159. * @param name defines the new name for the duplicated material
  28160. * @returns the cloned material
  28161. */
  28162. clone(name: string): StandardMaterial;
  28163. /**
  28164. * Serializes this material in a JSON representation
  28165. * @returns the serialized material object
  28166. */
  28167. serialize(): any;
  28168. /**
  28169. * Creates a standard material from parsed material data
  28170. * @param source defines the JSON representation of the material
  28171. * @param scene defines the hosting scene
  28172. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28173. * @returns a new standard material
  28174. */
  28175. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  28176. /**
  28177. * Are diffuse textures enabled in the application.
  28178. */
  28179. static get DiffuseTextureEnabled(): boolean;
  28180. static set DiffuseTextureEnabled(value: boolean);
  28181. /**
  28182. * Are ambient textures enabled in the application.
  28183. */
  28184. static get AmbientTextureEnabled(): boolean;
  28185. static set AmbientTextureEnabled(value: boolean);
  28186. /**
  28187. * Are opacity textures enabled in the application.
  28188. */
  28189. static get OpacityTextureEnabled(): boolean;
  28190. static set OpacityTextureEnabled(value: boolean);
  28191. /**
  28192. * Are reflection textures enabled in the application.
  28193. */
  28194. static get ReflectionTextureEnabled(): boolean;
  28195. static set ReflectionTextureEnabled(value: boolean);
  28196. /**
  28197. * Are emissive textures enabled in the application.
  28198. */
  28199. static get EmissiveTextureEnabled(): boolean;
  28200. static set EmissiveTextureEnabled(value: boolean);
  28201. /**
  28202. * Are specular textures enabled in the application.
  28203. */
  28204. static get SpecularTextureEnabled(): boolean;
  28205. static set SpecularTextureEnabled(value: boolean);
  28206. /**
  28207. * Are bump textures enabled in the application.
  28208. */
  28209. static get BumpTextureEnabled(): boolean;
  28210. static set BumpTextureEnabled(value: boolean);
  28211. /**
  28212. * Are lightmap textures enabled in the application.
  28213. */
  28214. static get LightmapTextureEnabled(): boolean;
  28215. static set LightmapTextureEnabled(value: boolean);
  28216. /**
  28217. * Are refraction textures enabled in the application.
  28218. */
  28219. static get RefractionTextureEnabled(): boolean;
  28220. static set RefractionTextureEnabled(value: boolean);
  28221. /**
  28222. * Are color grading textures enabled in the application.
  28223. */
  28224. static get ColorGradingTextureEnabled(): boolean;
  28225. static set ColorGradingTextureEnabled(value: boolean);
  28226. /**
  28227. * Are fresnels enabled in the application.
  28228. */
  28229. static get FresnelEnabled(): boolean;
  28230. static set FresnelEnabled(value: boolean);
  28231. }
  28232. }
  28233. declare module "babylonjs/Particles/solidParticleSystem" {
  28234. import { Nullable } from "babylonjs/types";
  28235. import { Mesh } from "babylonjs/Meshes/mesh";
  28236. import { Scene, IDisposable } from "babylonjs/scene";
  28237. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  28238. import { Material } from "babylonjs/Materials/material";
  28239. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28240. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28241. /**
  28242. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28243. *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.
  28244. * The SPS is also a particle system. It provides some methods to manage the particles.
  28245. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28246. *
  28247. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28248. */
  28249. export class SolidParticleSystem implements IDisposable {
  28250. /**
  28251. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28252. * Example : var p = SPS.particles[i];
  28253. */
  28254. particles: SolidParticle[];
  28255. /**
  28256. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28257. */
  28258. nbParticles: number;
  28259. /**
  28260. * If the particles must ever face the camera (default false). Useful for planar particles.
  28261. */
  28262. billboard: boolean;
  28263. /**
  28264. * Recompute normals when adding a shape
  28265. */
  28266. recomputeNormals: boolean;
  28267. /**
  28268. * This a counter ofr your own usage. It's not set by any SPS functions.
  28269. */
  28270. counter: number;
  28271. /**
  28272. * The SPS name. This name is also given to the underlying mesh.
  28273. */
  28274. name: string;
  28275. /**
  28276. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28277. */
  28278. mesh: Mesh;
  28279. /**
  28280. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28281. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28282. */
  28283. vars: any;
  28284. /**
  28285. * This array is populated when the SPS is set as 'pickable'.
  28286. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28287. * Each element of this array is an object `{idx: int, faceId: int}`.
  28288. * `idx` is the picked particle index in the `SPS.particles` array
  28289. * `faceId` is the picked face index counted within this particle.
  28290. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28291. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28292. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28293. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28294. */
  28295. pickedParticles: {
  28296. idx: number;
  28297. faceId: number;
  28298. }[];
  28299. /**
  28300. * This array is populated when the SPS is set as 'pickable'
  28301. * Each key of this array is a submesh index.
  28302. * Each element of this array is a second array defined like this :
  28303. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28304. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28305. * `idx` is the picked particle index in the `SPS.particles` array
  28306. * `faceId` is the picked face index counted within this particle.
  28307. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28308. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28309. */
  28310. pickedBySubMesh: {
  28311. idx: number;
  28312. faceId: number;
  28313. }[][];
  28314. /**
  28315. * This array is populated when `enableDepthSort` is set to true.
  28316. * Each element of this array is an instance of the class DepthSortedParticle.
  28317. */
  28318. depthSortedParticles: DepthSortedParticle[];
  28319. /**
  28320. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28321. * @hidden
  28322. */
  28323. _bSphereOnly: boolean;
  28324. /**
  28325. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28326. * @hidden
  28327. */
  28328. _bSphereRadiusFactor: number;
  28329. private _scene;
  28330. private _positions;
  28331. private _indices;
  28332. private _normals;
  28333. private _colors;
  28334. private _uvs;
  28335. private _indices32;
  28336. private _positions32;
  28337. private _normals32;
  28338. private _fixedNormal32;
  28339. private _colors32;
  28340. private _uvs32;
  28341. private _index;
  28342. private _updatable;
  28343. private _pickable;
  28344. private _isVisibilityBoxLocked;
  28345. private _alwaysVisible;
  28346. private _depthSort;
  28347. private _expandable;
  28348. private _shapeCounter;
  28349. private _copy;
  28350. private _color;
  28351. private _computeParticleColor;
  28352. private _computeParticleTexture;
  28353. private _computeParticleRotation;
  28354. private _computeParticleVertex;
  28355. private _computeBoundingBox;
  28356. private _depthSortParticles;
  28357. private _camera;
  28358. private _mustUnrotateFixedNormals;
  28359. private _particlesIntersect;
  28360. private _needs32Bits;
  28361. private _isNotBuilt;
  28362. private _lastParticleId;
  28363. private _idxOfId;
  28364. private _multimaterialEnabled;
  28365. private _useModelMaterial;
  28366. private _indicesByMaterial;
  28367. private _materialIndexes;
  28368. private _depthSortFunction;
  28369. private _materialSortFunction;
  28370. private _materials;
  28371. private _multimaterial;
  28372. private _materialIndexesById;
  28373. private _defaultMaterial;
  28374. private _autoUpdateSubMeshes;
  28375. private _tmpVertex;
  28376. /**
  28377. * Creates a SPS (Solid Particle System) object.
  28378. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28379. * @param scene (Scene) is the scene in which the SPS is added.
  28380. * @param options defines the options of the sps e.g.
  28381. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28382. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28383. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28384. * * 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.
  28385. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28386. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28387. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28388. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28389. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28390. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28391. */
  28392. constructor(name: string, scene: Scene, options?: {
  28393. updatable?: boolean;
  28394. isPickable?: boolean;
  28395. enableDepthSort?: boolean;
  28396. particleIntersection?: boolean;
  28397. boundingSphereOnly?: boolean;
  28398. bSphereRadiusFactor?: number;
  28399. expandable?: boolean;
  28400. useModelMaterial?: boolean;
  28401. enableMultiMaterial?: boolean;
  28402. });
  28403. /**
  28404. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28405. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28406. * @returns the created mesh
  28407. */
  28408. buildMesh(): Mesh;
  28409. /**
  28410. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28411. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28412. * Thus the particles generated from `digest()` have their property `position` set yet.
  28413. * @param mesh ( Mesh ) is the mesh to be digested
  28414. * @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
  28415. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28416. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28417. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28418. * @returns the current SPS
  28419. */
  28420. digest(mesh: Mesh, options?: {
  28421. facetNb?: number;
  28422. number?: number;
  28423. delta?: number;
  28424. storage?: [];
  28425. }): SolidParticleSystem;
  28426. /**
  28427. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28428. * @hidden
  28429. */
  28430. private _unrotateFixedNormals;
  28431. /**
  28432. * Resets the temporary working copy particle
  28433. * @hidden
  28434. */
  28435. private _resetCopy;
  28436. /**
  28437. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28438. * @param p the current index in the positions array to be updated
  28439. * @param ind the current index in the indices array
  28440. * @param shape a Vector3 array, the shape geometry
  28441. * @param positions the positions array to be updated
  28442. * @param meshInd the shape indices array
  28443. * @param indices the indices array to be updated
  28444. * @param meshUV the shape uv array
  28445. * @param uvs the uv array to be updated
  28446. * @param meshCol the shape color array
  28447. * @param colors the color array to be updated
  28448. * @param meshNor the shape normals array
  28449. * @param normals the normals array to be updated
  28450. * @param idx the particle index
  28451. * @param idxInShape the particle index in its shape
  28452. * @param options the addShape() method passed options
  28453. * @model the particle model
  28454. * @hidden
  28455. */
  28456. private _meshBuilder;
  28457. /**
  28458. * Returns a shape Vector3 array from positions float array
  28459. * @param positions float array
  28460. * @returns a vector3 array
  28461. * @hidden
  28462. */
  28463. private _posToShape;
  28464. /**
  28465. * Returns a shapeUV array from a float uvs (array deep copy)
  28466. * @param uvs as a float array
  28467. * @returns a shapeUV array
  28468. * @hidden
  28469. */
  28470. private _uvsToShapeUV;
  28471. /**
  28472. * Adds a new particle object in the particles array
  28473. * @param idx particle index in particles array
  28474. * @param id particle id
  28475. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28476. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28477. * @param model particle ModelShape object
  28478. * @param shapeId model shape identifier
  28479. * @param idxInShape index of the particle in the current model
  28480. * @param bInfo model bounding info object
  28481. * @param storage target storage array, if any
  28482. * @hidden
  28483. */
  28484. private _addParticle;
  28485. /**
  28486. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28487. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28488. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28489. * @param nb (positive integer) the number of particles to be created from this model
  28490. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28491. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28492. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28493. * @returns the number of shapes in the system
  28494. */
  28495. addShape(mesh: Mesh, nb: number, options?: {
  28496. positionFunction?: any;
  28497. vertexFunction?: any;
  28498. storage?: [];
  28499. }): number;
  28500. /**
  28501. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28502. * @hidden
  28503. */
  28504. private _rebuildParticle;
  28505. /**
  28506. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28507. * @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.
  28508. * @returns the SPS.
  28509. */
  28510. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28511. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28512. * Returns an array with the removed particles.
  28513. * 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.
  28514. * The SPS can't be empty so at least one particle needs to remain in place.
  28515. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28516. * @param start index of the first particle to remove
  28517. * @param end index of the last particle to remove (included)
  28518. * @returns an array populated with the removed particles
  28519. */
  28520. removeParticles(start: number, end: number): SolidParticle[];
  28521. /**
  28522. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28523. * @param solidParticleArray an array populated with Solid Particles objects
  28524. * @returns the SPS
  28525. */
  28526. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28527. /**
  28528. * Creates a new particle and modifies the SPS mesh geometry :
  28529. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28530. * - calls _addParticle() to populate the particle array
  28531. * factorized code from addShape() and insertParticlesFromArray()
  28532. * @param idx particle index in the particles array
  28533. * @param i particle index in its shape
  28534. * @param modelShape particle ModelShape object
  28535. * @param shape shape vertex array
  28536. * @param meshInd shape indices array
  28537. * @param meshUV shape uv array
  28538. * @param meshCol shape color array
  28539. * @param meshNor shape normals array
  28540. * @param bbInfo shape bounding info
  28541. * @param storage target particle storage
  28542. * @options addShape() passed options
  28543. * @hidden
  28544. */
  28545. private _insertNewParticle;
  28546. /**
  28547. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28548. * This method calls `updateParticle()` for each particle of the SPS.
  28549. * For an animated SPS, it is usually called within the render loop.
  28550. * 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.
  28551. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28552. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28553. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28554. * @returns the SPS.
  28555. */
  28556. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28557. /**
  28558. * Disposes the SPS.
  28559. */
  28560. dispose(): void;
  28561. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28562. * idx is the particle index in the SPS
  28563. * faceId is the picked face index counted within this particle.
  28564. * Returns null if the pickInfo can't identify a picked particle.
  28565. * @param pickingInfo (PickingInfo object)
  28566. * @returns {idx: number, faceId: number} or null
  28567. */
  28568. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28569. idx: number;
  28570. faceId: number;
  28571. }>;
  28572. /**
  28573. * Returns a SolidParticle object from its identifier : particle.id
  28574. * @param id (integer) the particle Id
  28575. * @returns the searched particle or null if not found in the SPS.
  28576. */
  28577. getParticleById(id: number): Nullable<SolidParticle>;
  28578. /**
  28579. * Returns a new array populated with the particles having the passed shapeId.
  28580. * @param shapeId (integer) the shape identifier
  28581. * @returns a new solid particle array
  28582. */
  28583. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28584. /**
  28585. * Populates the passed array "ref" with the particles having the passed shapeId.
  28586. * @param shapeId the shape identifier
  28587. * @returns the SPS
  28588. * @param ref
  28589. */
  28590. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28591. /**
  28592. * Computes the required SubMeshes according the materials assigned to the particles.
  28593. * @returns the solid particle system.
  28594. * Does nothing if called before the SPS mesh is built.
  28595. */
  28596. computeSubMeshes(): SolidParticleSystem;
  28597. /**
  28598. * Sorts the solid particles by material when MultiMaterial is enabled.
  28599. * Updates the indices32 array.
  28600. * Updates the indicesByMaterial array.
  28601. * Updates the mesh indices array.
  28602. * @returns the SPS
  28603. * @hidden
  28604. */
  28605. private _sortParticlesByMaterial;
  28606. /**
  28607. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28608. * @hidden
  28609. */
  28610. private _setMaterialIndexesById;
  28611. /**
  28612. * Returns an array with unique values of Materials from the passed array
  28613. * @param array the material array to be checked and filtered
  28614. * @hidden
  28615. */
  28616. private _filterUniqueMaterialId;
  28617. /**
  28618. * Sets a new Standard Material as _defaultMaterial if not already set.
  28619. * @hidden
  28620. */
  28621. private _setDefaultMaterial;
  28622. /**
  28623. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28624. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28625. * @returns the SPS.
  28626. */
  28627. refreshVisibleSize(): SolidParticleSystem;
  28628. /**
  28629. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28630. * @param size the size (float) of the visibility box
  28631. * note : this doesn't lock the SPS mesh bounding box.
  28632. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28633. */
  28634. setVisibilityBox(size: number): void;
  28635. /**
  28636. * Gets whether the SPS as always visible or not
  28637. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28638. */
  28639. get isAlwaysVisible(): boolean;
  28640. /**
  28641. * Sets the SPS as always visible or not
  28642. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28643. */
  28644. set isAlwaysVisible(val: boolean);
  28645. /**
  28646. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28647. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28648. */
  28649. set isVisibilityBoxLocked(val: boolean);
  28650. /**
  28651. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28652. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28653. */
  28654. get isVisibilityBoxLocked(): boolean;
  28655. /**
  28656. * Tells to `setParticles()` to compute the particle rotations or not.
  28657. * Default value : true. The SPS is faster when it's set to false.
  28658. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28659. */
  28660. set computeParticleRotation(val: boolean);
  28661. /**
  28662. * Tells to `setParticles()` to compute the particle colors or not.
  28663. * Default value : true. The SPS is faster when it's set to false.
  28664. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28665. */
  28666. set computeParticleColor(val: boolean);
  28667. set computeParticleTexture(val: boolean);
  28668. /**
  28669. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28670. * Default value : false. The SPS is faster when it's set to false.
  28671. * Note : the particle custom vertex positions aren't stored values.
  28672. */
  28673. set computeParticleVertex(val: boolean);
  28674. /**
  28675. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28676. */
  28677. set computeBoundingBox(val: boolean);
  28678. /**
  28679. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28680. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28681. * Default : `true`
  28682. */
  28683. set depthSortParticles(val: boolean);
  28684. /**
  28685. * Gets if `setParticles()` computes the particle rotations or not.
  28686. * Default value : true. The SPS is faster when it's set to false.
  28687. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28688. */
  28689. get computeParticleRotation(): boolean;
  28690. /**
  28691. * Gets if `setParticles()` computes the particle colors or not.
  28692. * Default value : true. The SPS is faster when it's set to false.
  28693. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28694. */
  28695. get computeParticleColor(): boolean;
  28696. /**
  28697. * Gets if `setParticles()` computes the particle textures or not.
  28698. * Default value : true. The SPS is faster when it's set to false.
  28699. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28700. */
  28701. get computeParticleTexture(): boolean;
  28702. /**
  28703. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28704. * Default value : false. The SPS is faster when it's set to false.
  28705. * Note : the particle custom vertex positions aren't stored values.
  28706. */
  28707. get computeParticleVertex(): boolean;
  28708. /**
  28709. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28710. */
  28711. get computeBoundingBox(): boolean;
  28712. /**
  28713. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28714. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28715. * Default : `true`
  28716. */
  28717. get depthSortParticles(): boolean;
  28718. /**
  28719. * Gets if the SPS is created as expandable at construction time.
  28720. * Default : `false`
  28721. */
  28722. get expandable(): boolean;
  28723. /**
  28724. * Gets if the SPS supports the Multi Materials
  28725. */
  28726. get multimaterialEnabled(): boolean;
  28727. /**
  28728. * Gets if the SPS uses the model materials for its own multimaterial.
  28729. */
  28730. get useModelMaterial(): boolean;
  28731. /**
  28732. * The SPS used material array.
  28733. */
  28734. get materials(): Material[];
  28735. /**
  28736. * Sets the SPS MultiMaterial from the passed materials.
  28737. * Note : the passed array is internally copied and not used then by reference.
  28738. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28739. */
  28740. setMultiMaterial(materials: Material[]): void;
  28741. /**
  28742. * The SPS computed multimaterial object
  28743. */
  28744. get multimaterial(): MultiMaterial;
  28745. set multimaterial(mm: MultiMaterial);
  28746. /**
  28747. * If the subMeshes must be updated on the next call to setParticles()
  28748. */
  28749. get autoUpdateSubMeshes(): boolean;
  28750. set autoUpdateSubMeshes(val: boolean);
  28751. /**
  28752. * This function does nothing. It may be overwritten to set all the particle first values.
  28753. * The SPS doesn't call this function, you may have to call it by your own.
  28754. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28755. */
  28756. initParticles(): void;
  28757. /**
  28758. * This function does nothing. It may be overwritten to recycle a particle.
  28759. * The SPS doesn't call this function, you may have to call it by your own.
  28760. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28761. * @param particle The particle to recycle
  28762. * @returns the recycled particle
  28763. */
  28764. recycleParticle(particle: SolidParticle): SolidParticle;
  28765. /**
  28766. * Updates a particle : this function should be overwritten by the user.
  28767. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28768. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28769. * @example : just set a particle position or velocity and recycle conditions
  28770. * @param particle The particle to update
  28771. * @returns the updated particle
  28772. */
  28773. updateParticle(particle: SolidParticle): SolidParticle;
  28774. /**
  28775. * Updates a vertex of a particle : it can be overwritten by the user.
  28776. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28777. * @param particle the current particle
  28778. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  28779. * @param pt the index of the current vertex in the particle shape
  28780. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28781. * @example : just set a vertex particle position or color
  28782. * @returns the sps
  28783. */
  28784. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  28785. /**
  28786. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28787. * This does nothing and may be overwritten by the user.
  28788. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28789. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28790. * @param update the boolean update value actually passed to setParticles()
  28791. */
  28792. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28793. /**
  28794. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28795. * This will be passed three parameters.
  28796. * This does nothing and may be overwritten by the user.
  28797. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28798. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28799. * @param update the boolean update value actually passed to setParticles()
  28800. */
  28801. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28802. }
  28803. }
  28804. declare module "babylonjs/Particles/solidParticle" {
  28805. import { Nullable } from "babylonjs/types";
  28806. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  28807. import { Color4 } from "babylonjs/Maths/math.color";
  28808. import { Mesh } from "babylonjs/Meshes/mesh";
  28809. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28810. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28811. import { Plane } from "babylonjs/Maths/math.plane";
  28812. import { Material } from "babylonjs/Materials/material";
  28813. /**
  28814. * Represents one particle of a solid particle system.
  28815. */
  28816. export class SolidParticle {
  28817. /**
  28818. * particle global index
  28819. */
  28820. idx: number;
  28821. /**
  28822. * particle identifier
  28823. */
  28824. id: number;
  28825. /**
  28826. * The color of the particle
  28827. */
  28828. color: Nullable<Color4>;
  28829. /**
  28830. * The world space position of the particle.
  28831. */
  28832. position: Vector3;
  28833. /**
  28834. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28835. */
  28836. rotation: Vector3;
  28837. /**
  28838. * The world space rotation quaternion of the particle.
  28839. */
  28840. rotationQuaternion: Nullable<Quaternion>;
  28841. /**
  28842. * The scaling of the particle.
  28843. */
  28844. scaling: Vector3;
  28845. /**
  28846. * The uvs of the particle.
  28847. */
  28848. uvs: Vector4;
  28849. /**
  28850. * The current speed of the particle.
  28851. */
  28852. velocity: Vector3;
  28853. /**
  28854. * The pivot point in the particle local space.
  28855. */
  28856. pivot: Vector3;
  28857. /**
  28858. * Must the particle be translated from its pivot point in its local space ?
  28859. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28860. * Default : false
  28861. */
  28862. translateFromPivot: boolean;
  28863. /**
  28864. * Is the particle active or not ?
  28865. */
  28866. alive: boolean;
  28867. /**
  28868. * Is the particle visible or not ?
  28869. */
  28870. isVisible: boolean;
  28871. /**
  28872. * Index of this particle in the global "positions" array (Internal use)
  28873. * @hidden
  28874. */
  28875. _pos: number;
  28876. /**
  28877. * @hidden Index of this particle in the global "indices" array (Internal use)
  28878. */
  28879. _ind: number;
  28880. /**
  28881. * @hidden ModelShape of this particle (Internal use)
  28882. */
  28883. _model: ModelShape;
  28884. /**
  28885. * ModelShape id of this particle
  28886. */
  28887. shapeId: number;
  28888. /**
  28889. * Index of the particle in its shape id
  28890. */
  28891. idxInShape: number;
  28892. /**
  28893. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28894. */
  28895. _modelBoundingInfo: BoundingInfo;
  28896. /**
  28897. * @hidden Particle BoundingInfo object (Internal use)
  28898. */
  28899. _boundingInfo: BoundingInfo;
  28900. /**
  28901. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28902. */
  28903. _sps: SolidParticleSystem;
  28904. /**
  28905. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28906. */
  28907. _stillInvisible: boolean;
  28908. /**
  28909. * @hidden Last computed particle rotation matrix
  28910. */
  28911. _rotationMatrix: number[];
  28912. /**
  28913. * Parent particle Id, if any.
  28914. * Default null.
  28915. */
  28916. parentId: Nullable<number>;
  28917. /**
  28918. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28919. */
  28920. materialIndex: Nullable<number>;
  28921. /**
  28922. * Custom object or properties.
  28923. */
  28924. props: Nullable<any>;
  28925. /**
  28926. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28927. * The possible values are :
  28928. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28929. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28930. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28931. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28932. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28933. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28934. * */
  28935. cullingStrategy: number;
  28936. /**
  28937. * @hidden Internal global position in the SPS.
  28938. */
  28939. _globalPosition: Vector3;
  28940. /**
  28941. * Creates a Solid Particle object.
  28942. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28943. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28944. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28945. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28946. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28947. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28948. * @param shapeId (integer) is the model shape identifier in the SPS.
  28949. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28950. * @param sps defines the sps it is associated to
  28951. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28952. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28953. */
  28954. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28955. /**
  28956. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28957. * @param target the particle target
  28958. * @returns the current particle
  28959. */
  28960. copyToRef(target: SolidParticle): SolidParticle;
  28961. /**
  28962. * Legacy support, changed scale to scaling
  28963. */
  28964. get scale(): Vector3;
  28965. /**
  28966. * Legacy support, changed scale to scaling
  28967. */
  28968. set scale(scale: Vector3);
  28969. /**
  28970. * Legacy support, changed quaternion to rotationQuaternion
  28971. */
  28972. get quaternion(): Nullable<Quaternion>;
  28973. /**
  28974. * Legacy support, changed quaternion to rotationQuaternion
  28975. */
  28976. set quaternion(q: Nullable<Quaternion>);
  28977. /**
  28978. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28979. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28980. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28981. * @returns true if it intersects
  28982. */
  28983. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28984. /**
  28985. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28986. * A particle is in the frustum if its bounding box intersects the frustum
  28987. * @param frustumPlanes defines the frustum to test
  28988. * @returns true if the particle is in the frustum planes
  28989. */
  28990. isInFrustum(frustumPlanes: Plane[]): boolean;
  28991. /**
  28992. * get the rotation matrix of the particle
  28993. * @hidden
  28994. */
  28995. getRotationMatrix(m: Matrix): void;
  28996. }
  28997. /**
  28998. * Represents the shape of the model used by one particle of a solid particle system.
  28999. * SPS internal tool, don't use it manually.
  29000. */
  29001. export class ModelShape {
  29002. /**
  29003. * The shape id
  29004. * @hidden
  29005. */
  29006. shapeID: number;
  29007. /**
  29008. * flat array of model positions (internal use)
  29009. * @hidden
  29010. */
  29011. _shape: Vector3[];
  29012. /**
  29013. * flat array of model UVs (internal use)
  29014. * @hidden
  29015. */
  29016. _shapeUV: number[];
  29017. /**
  29018. * color array of the model
  29019. * @hidden
  29020. */
  29021. _shapeColors: number[];
  29022. /**
  29023. * indices array of the model
  29024. * @hidden
  29025. */
  29026. _indices: number[];
  29027. /**
  29028. * normals array of the model
  29029. * @hidden
  29030. */
  29031. _normals: number[];
  29032. /**
  29033. * length of the shape in the model indices array (internal use)
  29034. * @hidden
  29035. */
  29036. _indicesLength: number;
  29037. /**
  29038. * Custom position function (internal use)
  29039. * @hidden
  29040. */
  29041. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  29042. /**
  29043. * Custom vertex function (internal use)
  29044. * @hidden
  29045. */
  29046. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  29047. /**
  29048. * Model material (internal use)
  29049. * @hidden
  29050. */
  29051. _material: Nullable<Material>;
  29052. /**
  29053. * 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.
  29054. * SPS internal tool, don't use it manually.
  29055. * @hidden
  29056. */
  29057. 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>);
  29058. }
  29059. /**
  29060. * Represents a Depth Sorted Particle in the solid particle system.
  29061. * @hidden
  29062. */
  29063. export class DepthSortedParticle {
  29064. /**
  29065. * Particle index
  29066. */
  29067. idx: number;
  29068. /**
  29069. * Index of the particle in the "indices" array
  29070. */
  29071. ind: number;
  29072. /**
  29073. * Length of the particle shape in the "indices" array
  29074. */
  29075. indicesLength: number;
  29076. /**
  29077. * Squared distance from the particle to the camera
  29078. */
  29079. sqDistance: number;
  29080. /**
  29081. * Material index when used with MultiMaterials
  29082. */
  29083. materialIndex: number;
  29084. /**
  29085. * Creates a new sorted particle
  29086. * @param materialIndex
  29087. */
  29088. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  29089. }
  29090. /**
  29091. * Represents a solid particle vertex
  29092. */
  29093. export class SolidParticleVertex {
  29094. /**
  29095. * Vertex position
  29096. */
  29097. position: Vector3;
  29098. /**
  29099. * Vertex color
  29100. */
  29101. color: Color4;
  29102. /**
  29103. * Vertex UV
  29104. */
  29105. uv: Vector2;
  29106. /**
  29107. * Creates a new solid particle vertex
  29108. */
  29109. constructor();
  29110. /** Vertex x coordinate */
  29111. get x(): number;
  29112. set x(val: number);
  29113. /** Vertex y coordinate */
  29114. get y(): number;
  29115. set y(val: number);
  29116. /** Vertex z coordinate */
  29117. get z(): number;
  29118. set z(val: number);
  29119. }
  29120. }
  29121. declare module "babylonjs/Collisions/meshCollisionData" {
  29122. import { Collider } from "babylonjs/Collisions/collider";
  29123. import { Vector3 } from "babylonjs/Maths/math.vector";
  29124. import { Nullable } from "babylonjs/types";
  29125. import { Observer } from "babylonjs/Misc/observable";
  29126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29127. /**
  29128. * @hidden
  29129. */
  29130. export class _MeshCollisionData {
  29131. _checkCollisions: boolean;
  29132. _collisionMask: number;
  29133. _collisionGroup: number;
  29134. _surroundingMeshes: Nullable<AbstractMesh[]>;
  29135. _collider: Nullable<Collider>;
  29136. _oldPositionForCollisions: Vector3;
  29137. _diffPositionForCollisions: Vector3;
  29138. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  29139. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  29140. }
  29141. }
  29142. declare module "babylonjs/Meshes/abstractMesh" {
  29143. import { Observable } from "babylonjs/Misc/observable";
  29144. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  29145. import { Camera } from "babylonjs/Cameras/camera";
  29146. import { Scene, IDisposable } from "babylonjs/scene";
  29147. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  29148. import { Node } from "babylonjs/node";
  29149. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29150. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29151. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29152. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  29153. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  29154. import { Material } from "babylonjs/Materials/material";
  29155. import { Light } from "babylonjs/Lights/light";
  29156. import { Skeleton } from "babylonjs/Bones/skeleton";
  29157. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29158. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  29159. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29160. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  29161. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29162. import { Plane } from "babylonjs/Maths/math.plane";
  29163. import { Ray } from "babylonjs/Culling/ray";
  29164. import { Collider } from "babylonjs/Collisions/collider";
  29165. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  29166. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  29167. /** @hidden */
  29168. class _FacetDataStorage {
  29169. facetPositions: Vector3[];
  29170. facetNormals: Vector3[];
  29171. facetPartitioning: number[][];
  29172. facetNb: number;
  29173. partitioningSubdivisions: number;
  29174. partitioningBBoxRatio: number;
  29175. facetDataEnabled: boolean;
  29176. facetParameters: any;
  29177. bbSize: Vector3;
  29178. subDiv: {
  29179. max: number;
  29180. X: number;
  29181. Y: number;
  29182. Z: number;
  29183. };
  29184. facetDepthSort: boolean;
  29185. facetDepthSortEnabled: boolean;
  29186. depthSortedIndices: IndicesArray;
  29187. depthSortedFacets: {
  29188. ind: number;
  29189. sqDistance: number;
  29190. }[];
  29191. facetDepthSortFunction: (f1: {
  29192. ind: number;
  29193. sqDistance: number;
  29194. }, f2: {
  29195. ind: number;
  29196. sqDistance: number;
  29197. }) => number;
  29198. facetDepthSortFrom: Vector3;
  29199. facetDepthSortOrigin: Vector3;
  29200. invertedMatrix: Matrix;
  29201. }
  29202. /**
  29203. * @hidden
  29204. **/
  29205. class _InternalAbstractMeshDataInfo {
  29206. _hasVertexAlpha: boolean;
  29207. _useVertexColors: boolean;
  29208. _numBoneInfluencers: number;
  29209. _applyFog: boolean;
  29210. _receiveShadows: boolean;
  29211. _facetData: _FacetDataStorage;
  29212. _visibility: number;
  29213. _skeleton: Nullable<Skeleton>;
  29214. _layerMask: number;
  29215. _computeBonesUsingShaders: boolean;
  29216. _isActive: boolean;
  29217. _onlyForInstances: boolean;
  29218. _isActiveIntermediate: boolean;
  29219. _onlyForInstancesIntermediate: boolean;
  29220. _actAsRegularMesh: boolean;
  29221. }
  29222. /**
  29223. * Class used to store all common mesh properties
  29224. */
  29225. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  29226. /** No occlusion */
  29227. static OCCLUSION_TYPE_NONE: number;
  29228. /** Occlusion set to optimisitic */
  29229. static OCCLUSION_TYPE_OPTIMISTIC: number;
  29230. /** Occlusion set to strict */
  29231. static OCCLUSION_TYPE_STRICT: number;
  29232. /** Use an accurante occlusion algorithm */
  29233. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  29234. /** Use a conservative occlusion algorithm */
  29235. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29236. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29237. * Test order :
  29238. * Is the bounding sphere outside the frustum ?
  29239. * If not, are the bounding box vertices outside the frustum ?
  29240. * It not, then the cullable object is in the frustum.
  29241. */
  29242. static readonly CULLINGSTRATEGY_STANDARD: number;
  29243. /** Culling strategy : Bounding Sphere Only.
  29244. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29245. * It's also less accurate than the standard because some not visible objects can still be selected.
  29246. * Test : is the bounding sphere outside the frustum ?
  29247. * If not, then the cullable object is in the frustum.
  29248. */
  29249. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29250. /** Culling strategy : Optimistic Inclusion.
  29251. * This in an inclusion test first, then the standard exclusion test.
  29252. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29253. * 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.
  29254. * Anyway, it's as accurate as the standard strategy.
  29255. * Test :
  29256. * Is the cullable object bounding sphere center in the frustum ?
  29257. * If not, apply the default culling strategy.
  29258. */
  29259. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29260. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29261. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29262. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29263. * 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.
  29264. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29265. * Test :
  29266. * Is the cullable object bounding sphere center in the frustum ?
  29267. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29268. */
  29269. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29270. /**
  29271. * No billboard
  29272. */
  29273. static get BILLBOARDMODE_NONE(): number;
  29274. /** Billboard on X axis */
  29275. static get BILLBOARDMODE_X(): number;
  29276. /** Billboard on Y axis */
  29277. static get BILLBOARDMODE_Y(): number;
  29278. /** Billboard on Z axis */
  29279. static get BILLBOARDMODE_Z(): number;
  29280. /** Billboard on all axes */
  29281. static get BILLBOARDMODE_ALL(): number;
  29282. /** Billboard on using position instead of orientation */
  29283. static get BILLBOARDMODE_USE_POSITION(): number;
  29284. /** @hidden */
  29285. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29286. /**
  29287. * The culling strategy to use to check whether the mesh must be rendered or not.
  29288. * This value can be changed at any time and will be used on the next render mesh selection.
  29289. * The possible values are :
  29290. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29291. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29293. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29294. * Please read each static variable documentation to get details about the culling process.
  29295. * */
  29296. cullingStrategy: number;
  29297. /**
  29298. * Gets the number of facets in the mesh
  29299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29300. */
  29301. get facetNb(): number;
  29302. /**
  29303. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29305. */
  29306. get partitioningSubdivisions(): number;
  29307. set partitioningSubdivisions(nb: number);
  29308. /**
  29309. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29310. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29312. */
  29313. get partitioningBBoxRatio(): number;
  29314. set partitioningBBoxRatio(ratio: number);
  29315. /**
  29316. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29317. * Works only for updatable meshes.
  29318. * Doesn't work with multi-materials
  29319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29320. */
  29321. get mustDepthSortFacets(): boolean;
  29322. set mustDepthSortFacets(sort: boolean);
  29323. /**
  29324. * The location (Vector3) where the facet depth sort must be computed from.
  29325. * By default, the active camera position.
  29326. * Used only when facet depth sort is enabled
  29327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29328. */
  29329. get facetDepthSortFrom(): Vector3;
  29330. set facetDepthSortFrom(location: Vector3);
  29331. /**
  29332. * gets a boolean indicating if facetData is enabled
  29333. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29334. */
  29335. get isFacetDataEnabled(): boolean;
  29336. /** @hidden */
  29337. _updateNonUniformScalingState(value: boolean): boolean;
  29338. /**
  29339. * An event triggered when this mesh collides with another one
  29340. */
  29341. onCollideObservable: Observable<AbstractMesh>;
  29342. /** Set a function to call when this mesh collides with another one */
  29343. set onCollide(callback: () => void);
  29344. /**
  29345. * An event triggered when the collision's position changes
  29346. */
  29347. onCollisionPositionChangeObservable: Observable<Vector3>;
  29348. /** Set a function to call when the collision's position changes */
  29349. set onCollisionPositionChange(callback: () => void);
  29350. /**
  29351. * An event triggered when material is changed
  29352. */
  29353. onMaterialChangedObservable: Observable<AbstractMesh>;
  29354. /**
  29355. * Gets or sets the orientation for POV movement & rotation
  29356. */
  29357. definedFacingForward: boolean;
  29358. /** @hidden */
  29359. _occlusionQuery: Nullable<WebGLQuery>;
  29360. /** @hidden */
  29361. _renderingGroup: Nullable<RenderingGroup>;
  29362. /**
  29363. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29364. */
  29365. get visibility(): number;
  29366. /**
  29367. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29368. */
  29369. set visibility(value: number);
  29370. /** Gets or sets the alpha index used to sort transparent meshes
  29371. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29372. */
  29373. alphaIndex: number;
  29374. /**
  29375. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29376. */
  29377. isVisible: boolean;
  29378. /**
  29379. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29380. */
  29381. isPickable: boolean;
  29382. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29383. showSubMeshesBoundingBox: boolean;
  29384. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29385. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29386. */
  29387. isBlocker: boolean;
  29388. /**
  29389. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29390. */
  29391. enablePointerMoveEvents: boolean;
  29392. /**
  29393. * Specifies the rendering group id for this mesh (0 by default)
  29394. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29395. */
  29396. renderingGroupId: number;
  29397. private _material;
  29398. /** Gets or sets current material */
  29399. get material(): Nullable<Material>;
  29400. set material(value: Nullable<Material>);
  29401. /**
  29402. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29403. * @see http://doc.babylonjs.com/babylon101/shadows
  29404. */
  29405. get receiveShadows(): boolean;
  29406. set receiveShadows(value: boolean);
  29407. /** Defines color to use when rendering outline */
  29408. outlineColor: Color3;
  29409. /** Define width to use when rendering outline */
  29410. outlineWidth: number;
  29411. /** Defines color to use when rendering overlay */
  29412. overlayColor: Color3;
  29413. /** Defines alpha to use when rendering overlay */
  29414. overlayAlpha: number;
  29415. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29416. get hasVertexAlpha(): boolean;
  29417. set hasVertexAlpha(value: boolean);
  29418. /** 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) */
  29419. get useVertexColors(): boolean;
  29420. set useVertexColors(value: boolean);
  29421. /**
  29422. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29423. */
  29424. get computeBonesUsingShaders(): boolean;
  29425. set computeBonesUsingShaders(value: boolean);
  29426. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29427. get numBoneInfluencers(): number;
  29428. set numBoneInfluencers(value: number);
  29429. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29430. get applyFog(): boolean;
  29431. set applyFog(value: boolean);
  29432. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29433. useOctreeForRenderingSelection: boolean;
  29434. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29435. useOctreeForPicking: boolean;
  29436. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29437. useOctreeForCollisions: boolean;
  29438. /**
  29439. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29440. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29441. */
  29442. get layerMask(): number;
  29443. set layerMask(value: number);
  29444. /**
  29445. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29446. */
  29447. alwaysSelectAsActiveMesh: boolean;
  29448. /**
  29449. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29450. */
  29451. doNotSyncBoundingInfo: boolean;
  29452. /**
  29453. * Gets or sets the current action manager
  29454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29455. */
  29456. actionManager: Nullable<AbstractActionManager>;
  29457. private _meshCollisionData;
  29458. /**
  29459. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29460. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29461. */
  29462. ellipsoid: Vector3;
  29463. /**
  29464. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29466. */
  29467. ellipsoidOffset: Vector3;
  29468. /**
  29469. * Gets or sets a collision mask used to mask collisions (default is -1).
  29470. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29471. */
  29472. get collisionMask(): number;
  29473. set collisionMask(mask: number);
  29474. /**
  29475. * Gets or sets the current collision group mask (-1 by default).
  29476. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29477. */
  29478. get collisionGroup(): number;
  29479. set collisionGroup(mask: number);
  29480. /**
  29481. * Gets or sets current surrounding meshes (null by default).
  29482. *
  29483. * By default collision detection is tested against every mesh in the scene.
  29484. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29485. * meshes will be tested for the collision.
  29486. *
  29487. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29488. */
  29489. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29490. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29491. /**
  29492. * Defines edge width used when edgesRenderer is enabled
  29493. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29494. */
  29495. edgesWidth: number;
  29496. /**
  29497. * Defines edge color used when edgesRenderer is enabled
  29498. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29499. */
  29500. edgesColor: Color4;
  29501. /** @hidden */
  29502. _edgesRenderer: Nullable<IEdgesRenderer>;
  29503. /** @hidden */
  29504. _masterMesh: Nullable<AbstractMesh>;
  29505. /** @hidden */
  29506. _boundingInfo: Nullable<BoundingInfo>;
  29507. /** @hidden */
  29508. _renderId: number;
  29509. /**
  29510. * Gets or sets the list of subMeshes
  29511. * @see http://doc.babylonjs.com/how_to/multi_materials
  29512. */
  29513. subMeshes: SubMesh[];
  29514. /** @hidden */
  29515. _intersectionsInProgress: AbstractMesh[];
  29516. /** @hidden */
  29517. _unIndexed: boolean;
  29518. /** @hidden */
  29519. _lightSources: Light[];
  29520. /** Gets the list of lights affecting that mesh */
  29521. get lightSources(): Light[];
  29522. /** @hidden */
  29523. get _positions(): Nullable<Vector3[]>;
  29524. /** @hidden */
  29525. _waitingData: {
  29526. lods: Nullable<any>;
  29527. actions: Nullable<any>;
  29528. freezeWorldMatrix: Nullable<boolean>;
  29529. };
  29530. /** @hidden */
  29531. _bonesTransformMatrices: Nullable<Float32Array>;
  29532. /** @hidden */
  29533. _transformMatrixTexture: Nullable<RawTexture>;
  29534. /**
  29535. * Gets or sets a skeleton to apply skining transformations
  29536. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29537. */
  29538. set skeleton(value: Nullable<Skeleton>);
  29539. get skeleton(): Nullable<Skeleton>;
  29540. /**
  29541. * An event triggered when the mesh is rebuilt.
  29542. */
  29543. onRebuildObservable: Observable<AbstractMesh>;
  29544. /**
  29545. * Creates a new AbstractMesh
  29546. * @param name defines the name of the mesh
  29547. * @param scene defines the hosting scene
  29548. */
  29549. constructor(name: string, scene?: Nullable<Scene>);
  29550. /**
  29551. * Returns the string "AbstractMesh"
  29552. * @returns "AbstractMesh"
  29553. */
  29554. getClassName(): string;
  29555. /**
  29556. * Gets a string representation of the current mesh
  29557. * @param fullDetails defines a boolean indicating if full details must be included
  29558. * @returns a string representation of the current mesh
  29559. */
  29560. toString(fullDetails?: boolean): string;
  29561. /**
  29562. * @hidden
  29563. */
  29564. protected _getEffectiveParent(): Nullable<Node>;
  29565. /** @hidden */
  29566. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29567. /** @hidden */
  29568. _rebuild(): void;
  29569. /** @hidden */
  29570. _resyncLightSources(): void;
  29571. /** @hidden */
  29572. _resyncLightSource(light: Light): void;
  29573. /** @hidden */
  29574. _unBindEffect(): void;
  29575. /** @hidden */
  29576. _removeLightSource(light: Light, dispose: boolean): void;
  29577. private _markSubMeshesAsDirty;
  29578. /** @hidden */
  29579. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29580. /** @hidden */
  29581. _markSubMeshesAsAttributesDirty(): void;
  29582. /** @hidden */
  29583. _markSubMeshesAsMiscDirty(): void;
  29584. /**
  29585. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29586. */
  29587. get scaling(): Vector3;
  29588. set scaling(newScaling: Vector3);
  29589. /**
  29590. * Returns true if the mesh is blocked. Implemented by child classes
  29591. */
  29592. get isBlocked(): boolean;
  29593. /**
  29594. * Returns the mesh itself by default. Implemented by child classes
  29595. * @param camera defines the camera to use to pick the right LOD level
  29596. * @returns the currentAbstractMesh
  29597. */
  29598. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29599. /**
  29600. * Returns 0 by default. Implemented by child classes
  29601. * @returns an integer
  29602. */
  29603. getTotalVertices(): number;
  29604. /**
  29605. * Returns a positive integer : the total number of indices in this mesh geometry.
  29606. * @returns the numner of indices or zero if the mesh has no geometry.
  29607. */
  29608. getTotalIndices(): number;
  29609. /**
  29610. * Returns null by default. Implemented by child classes
  29611. * @returns null
  29612. */
  29613. getIndices(): Nullable<IndicesArray>;
  29614. /**
  29615. * Returns the array of the requested vertex data kind. Implemented by child classes
  29616. * @param kind defines the vertex data kind to use
  29617. * @returns null
  29618. */
  29619. getVerticesData(kind: string): Nullable<FloatArray>;
  29620. /**
  29621. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29622. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29623. * Note that a new underlying VertexBuffer object is created each call.
  29624. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29625. * @param kind defines vertex data kind:
  29626. * * VertexBuffer.PositionKind
  29627. * * VertexBuffer.UVKind
  29628. * * VertexBuffer.UV2Kind
  29629. * * VertexBuffer.UV3Kind
  29630. * * VertexBuffer.UV4Kind
  29631. * * VertexBuffer.UV5Kind
  29632. * * VertexBuffer.UV6Kind
  29633. * * VertexBuffer.ColorKind
  29634. * * VertexBuffer.MatricesIndicesKind
  29635. * * VertexBuffer.MatricesIndicesExtraKind
  29636. * * VertexBuffer.MatricesWeightsKind
  29637. * * VertexBuffer.MatricesWeightsExtraKind
  29638. * @param data defines the data source
  29639. * @param updatable defines if the data must be flagged as updatable (or static)
  29640. * @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
  29641. * @returns the current mesh
  29642. */
  29643. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29644. /**
  29645. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29646. * If the mesh has no geometry, it is simply returned as it is.
  29647. * @param kind defines vertex data kind:
  29648. * * VertexBuffer.PositionKind
  29649. * * VertexBuffer.UVKind
  29650. * * VertexBuffer.UV2Kind
  29651. * * VertexBuffer.UV3Kind
  29652. * * VertexBuffer.UV4Kind
  29653. * * VertexBuffer.UV5Kind
  29654. * * VertexBuffer.UV6Kind
  29655. * * VertexBuffer.ColorKind
  29656. * * VertexBuffer.MatricesIndicesKind
  29657. * * VertexBuffer.MatricesIndicesExtraKind
  29658. * * VertexBuffer.MatricesWeightsKind
  29659. * * VertexBuffer.MatricesWeightsExtraKind
  29660. * @param data defines the data source
  29661. * @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
  29662. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29663. * @returns the current mesh
  29664. */
  29665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29666. /**
  29667. * Sets the mesh indices,
  29668. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29669. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29670. * @param totalVertices Defines the total number of vertices
  29671. * @returns the current mesh
  29672. */
  29673. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29674. /**
  29675. * Gets a boolean indicating if specific vertex data is present
  29676. * @param kind defines the vertex data kind to use
  29677. * @returns true is data kind is present
  29678. */
  29679. isVerticesDataPresent(kind: string): boolean;
  29680. /**
  29681. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29682. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29683. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29684. * @returns a BoundingInfo
  29685. */
  29686. getBoundingInfo(): BoundingInfo;
  29687. /**
  29688. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29689. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29690. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29691. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29692. * @returns the current mesh
  29693. */
  29694. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29695. /**
  29696. * Overwrite the current bounding info
  29697. * @param boundingInfo defines the new bounding info
  29698. * @returns the current mesh
  29699. */
  29700. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29701. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29702. get useBones(): boolean;
  29703. /** @hidden */
  29704. _preActivate(): void;
  29705. /** @hidden */
  29706. _preActivateForIntermediateRendering(renderId: number): void;
  29707. /** @hidden */
  29708. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29709. /** @hidden */
  29710. _postActivate(): void;
  29711. /** @hidden */
  29712. _freeze(): void;
  29713. /** @hidden */
  29714. _unFreeze(): void;
  29715. /**
  29716. * Gets the current world matrix
  29717. * @returns a Matrix
  29718. */
  29719. getWorldMatrix(): Matrix;
  29720. /** @hidden */
  29721. _getWorldMatrixDeterminant(): number;
  29722. /**
  29723. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29724. */
  29725. get isAnInstance(): boolean;
  29726. /**
  29727. * Gets a boolean indicating if this mesh has instances
  29728. */
  29729. get hasInstances(): boolean;
  29730. /**
  29731. * Perform relative position change from the point of view of behind the front of the mesh.
  29732. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29733. * Supports definition of mesh facing forward or backward
  29734. * @param amountRight defines the distance on the right axis
  29735. * @param amountUp defines the distance on the up axis
  29736. * @param amountForward defines the distance on the forward axis
  29737. * @returns the current mesh
  29738. */
  29739. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29740. /**
  29741. * Calculate relative position change from the point of view of behind the front of the mesh.
  29742. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29743. * Supports definition of mesh facing forward or backward
  29744. * @param amountRight defines the distance on the right axis
  29745. * @param amountUp defines the distance on the up axis
  29746. * @param amountForward defines the distance on the forward axis
  29747. * @returns the new displacement vector
  29748. */
  29749. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29750. /**
  29751. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29752. * Supports definition of mesh facing forward or backward
  29753. * @param flipBack defines the flip
  29754. * @param twirlClockwise defines the twirl
  29755. * @param tiltRight defines the tilt
  29756. * @returns the current mesh
  29757. */
  29758. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29759. /**
  29760. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29761. * Supports definition of mesh facing forward or backward.
  29762. * @param flipBack defines the flip
  29763. * @param twirlClockwise defines the twirl
  29764. * @param tiltRight defines the tilt
  29765. * @returns the new rotation vector
  29766. */
  29767. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29768. /**
  29769. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29770. * This means the mesh underlying bounding box and sphere are recomputed.
  29771. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29772. * @returns the current mesh
  29773. */
  29774. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29775. /** @hidden */
  29776. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29777. /** @hidden */
  29778. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29779. /** @hidden */
  29780. _updateBoundingInfo(): AbstractMesh;
  29781. /** @hidden */
  29782. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29783. /** @hidden */
  29784. protected _afterComputeWorldMatrix(): void;
  29785. /** @hidden */
  29786. get _effectiveMesh(): AbstractMesh;
  29787. /**
  29788. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29789. * A mesh is in the frustum if its bounding box intersects the frustum
  29790. * @param frustumPlanes defines the frustum to test
  29791. * @returns true if the mesh is in the frustum planes
  29792. */
  29793. isInFrustum(frustumPlanes: Plane[]): boolean;
  29794. /**
  29795. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29796. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29797. * @param frustumPlanes defines the frustum to test
  29798. * @returns true if the mesh is completely in the frustum planes
  29799. */
  29800. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29801. /**
  29802. * True if the mesh intersects another mesh or a SolidParticle object
  29803. * @param mesh defines a target mesh or SolidParticle to test
  29804. * @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)
  29805. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29806. * @returns true if there is an intersection
  29807. */
  29808. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29809. /**
  29810. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29811. * @param point defines the point to test
  29812. * @returns true if there is an intersection
  29813. */
  29814. intersectsPoint(point: Vector3): boolean;
  29815. /**
  29816. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29818. */
  29819. get checkCollisions(): boolean;
  29820. set checkCollisions(collisionEnabled: boolean);
  29821. /**
  29822. * Gets Collider object used to compute collisions (not physics)
  29823. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29824. */
  29825. get collider(): Nullable<Collider>;
  29826. /**
  29827. * Move the mesh using collision engine
  29828. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29829. * @param displacement defines the requested displacement vector
  29830. * @returns the current mesh
  29831. */
  29832. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29833. private _onCollisionPositionChange;
  29834. /** @hidden */
  29835. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29836. /** @hidden */
  29837. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29838. /** @hidden */
  29839. _checkCollision(collider: Collider): AbstractMesh;
  29840. /** @hidden */
  29841. _generatePointsArray(): boolean;
  29842. /**
  29843. * Checks if the passed Ray intersects with the mesh
  29844. * @param ray defines the ray to use
  29845. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29846. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29847. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29848. * @returns the picking info
  29849. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29850. */
  29851. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29852. /**
  29853. * Clones the current mesh
  29854. * @param name defines the mesh name
  29855. * @param newParent defines the new mesh parent
  29856. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29857. * @returns the new mesh
  29858. */
  29859. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29860. /**
  29861. * Disposes all the submeshes of the current meshnp
  29862. * @returns the current mesh
  29863. */
  29864. releaseSubMeshes(): AbstractMesh;
  29865. /**
  29866. * Releases resources associated with this abstract mesh.
  29867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29869. */
  29870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29871. /**
  29872. * Adds the passed mesh as a child to the current mesh
  29873. * @param mesh defines the child mesh
  29874. * @returns the current mesh
  29875. */
  29876. addChild(mesh: AbstractMesh): AbstractMesh;
  29877. /**
  29878. * Removes the passed mesh from the current mesh children list
  29879. * @param mesh defines the child mesh
  29880. * @returns the current mesh
  29881. */
  29882. removeChild(mesh: AbstractMesh): AbstractMesh;
  29883. /** @hidden */
  29884. private _initFacetData;
  29885. /**
  29886. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29887. * This method can be called within the render loop.
  29888. * 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
  29889. * @returns the current mesh
  29890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29891. */
  29892. updateFacetData(): AbstractMesh;
  29893. /**
  29894. * Returns the facetLocalNormals array.
  29895. * The normals are expressed in the mesh local spac
  29896. * @returns an array of Vector3
  29897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29898. */
  29899. getFacetLocalNormals(): Vector3[];
  29900. /**
  29901. * Returns the facetLocalPositions array.
  29902. * The facet positions are expressed in the mesh local space
  29903. * @returns an array of Vector3
  29904. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29905. */
  29906. getFacetLocalPositions(): Vector3[];
  29907. /**
  29908. * Returns the facetLocalPartioning array
  29909. * @returns an array of array of numbers
  29910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29911. */
  29912. getFacetLocalPartitioning(): number[][];
  29913. /**
  29914. * Returns the i-th facet position in the world system.
  29915. * This method allocates a new Vector3 per call
  29916. * @param i defines the facet index
  29917. * @returns a new Vector3
  29918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29919. */
  29920. getFacetPosition(i: number): Vector3;
  29921. /**
  29922. * Sets the reference Vector3 with the i-th facet position in the world system
  29923. * @param i defines the facet index
  29924. * @param ref defines the target vector
  29925. * @returns the current mesh
  29926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29927. */
  29928. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29929. /**
  29930. * Returns the i-th facet normal in the world system.
  29931. * This method allocates a new Vector3 per call
  29932. * @param i defines the facet index
  29933. * @returns a new Vector3
  29934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29935. */
  29936. getFacetNormal(i: number): Vector3;
  29937. /**
  29938. * Sets the reference Vector3 with the i-th facet normal in the world system
  29939. * @param i defines the facet index
  29940. * @param ref defines the target vector
  29941. * @returns the current mesh
  29942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29943. */
  29944. getFacetNormalToRef(i: number, ref: Vector3): this;
  29945. /**
  29946. * 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)
  29947. * @param x defines x coordinate
  29948. * @param y defines y coordinate
  29949. * @param z defines z coordinate
  29950. * @returns the array of facet indexes
  29951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29952. */
  29953. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29954. /**
  29955. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29956. * @param projected sets as the (x,y,z) world projection on the facet
  29957. * @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
  29958. * @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
  29959. * @param x defines x coordinate
  29960. * @param y defines y coordinate
  29961. * @param z defines z coordinate
  29962. * @returns the face index if found (or null instead)
  29963. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29964. */
  29965. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29966. /**
  29967. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29968. * @param projected sets as the (x,y,z) local projection on the facet
  29969. * @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
  29970. * @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
  29971. * @param x defines x coordinate
  29972. * @param y defines y coordinate
  29973. * @param z defines z coordinate
  29974. * @returns the face index if found (or null instead)
  29975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29976. */
  29977. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29978. /**
  29979. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29980. * @returns the parameters
  29981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29982. */
  29983. getFacetDataParameters(): any;
  29984. /**
  29985. * Disables the feature FacetData and frees the related memory
  29986. * @returns the current mesh
  29987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29988. */
  29989. disableFacetData(): AbstractMesh;
  29990. /**
  29991. * Updates the AbstractMesh indices array
  29992. * @param indices defines the data source
  29993. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29994. * @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)
  29995. * @returns the current mesh
  29996. */
  29997. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29998. /**
  29999. * Creates new normals data for the mesh
  30000. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  30001. * @returns the current mesh
  30002. */
  30003. createNormals(updatable: boolean): AbstractMesh;
  30004. /**
  30005. * Align the mesh with a normal
  30006. * @param normal defines the normal to use
  30007. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  30008. * @returns the current mesh
  30009. */
  30010. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  30011. /** @hidden */
  30012. _checkOcclusionQuery(): boolean;
  30013. /**
  30014. * Disables the mesh edge rendering mode
  30015. * @returns the currentAbstractMesh
  30016. */
  30017. disableEdgesRendering(): AbstractMesh;
  30018. /**
  30019. * Enables the edge rendering mode on the mesh.
  30020. * This mode makes the mesh edges visible
  30021. * @param epsilon defines the maximal distance between two angles to detect a face
  30022. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30023. * @returns the currentAbstractMesh
  30024. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30025. */
  30026. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30027. }
  30028. }
  30029. declare module "babylonjs/Actions/actionEvent" {
  30030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30031. import { Nullable } from "babylonjs/types";
  30032. import { Sprite } from "babylonjs/Sprites/sprite";
  30033. import { Scene } from "babylonjs/scene";
  30034. import { Vector2 } from "babylonjs/Maths/math.vector";
  30035. /**
  30036. * Interface used to define ActionEvent
  30037. */
  30038. export interface IActionEvent {
  30039. /** The mesh or sprite that triggered the action */
  30040. source: any;
  30041. /** The X mouse cursor position at the time of the event */
  30042. pointerX: number;
  30043. /** The Y mouse cursor position at the time of the event */
  30044. pointerY: number;
  30045. /** The mesh that is currently pointed at (can be null) */
  30046. meshUnderPointer: Nullable<AbstractMesh>;
  30047. /** the original (browser) event that triggered the ActionEvent */
  30048. sourceEvent?: any;
  30049. /** additional data for the event */
  30050. additionalData?: any;
  30051. }
  30052. /**
  30053. * ActionEvent is the event being sent when an action is triggered.
  30054. */
  30055. export class ActionEvent implements IActionEvent {
  30056. /** The mesh or sprite that triggered the action */
  30057. source: any;
  30058. /** The X mouse cursor position at the time of the event */
  30059. pointerX: number;
  30060. /** The Y mouse cursor position at the time of the event */
  30061. pointerY: number;
  30062. /** The mesh that is currently pointed at (can be null) */
  30063. meshUnderPointer: Nullable<AbstractMesh>;
  30064. /** the original (browser) event that triggered the ActionEvent */
  30065. sourceEvent?: any;
  30066. /** additional data for the event */
  30067. additionalData?: any;
  30068. /**
  30069. * Creates a new ActionEvent
  30070. * @param source The mesh or sprite that triggered the action
  30071. * @param pointerX The X mouse cursor position at the time of the event
  30072. * @param pointerY The Y mouse cursor position at the time of the event
  30073. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  30074. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  30075. * @param additionalData additional data for the event
  30076. */
  30077. constructor(
  30078. /** The mesh or sprite that triggered the action */
  30079. source: any,
  30080. /** The X mouse cursor position at the time of the event */
  30081. pointerX: number,
  30082. /** The Y mouse cursor position at the time of the event */
  30083. pointerY: number,
  30084. /** The mesh that is currently pointed at (can be null) */
  30085. meshUnderPointer: Nullable<AbstractMesh>,
  30086. /** the original (browser) event that triggered the ActionEvent */
  30087. sourceEvent?: any,
  30088. /** additional data for the event */
  30089. additionalData?: any);
  30090. /**
  30091. * Helper function to auto-create an ActionEvent from a source mesh.
  30092. * @param source The source mesh that triggered the event
  30093. * @param evt The original (browser) event
  30094. * @param additionalData additional data for the event
  30095. * @returns the new ActionEvent
  30096. */
  30097. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  30098. /**
  30099. * Helper function to auto-create an ActionEvent from a source sprite
  30100. * @param source The source sprite that triggered the event
  30101. * @param scene Scene associated with the sprite
  30102. * @param evt The original (browser) event
  30103. * @param additionalData additional data for the event
  30104. * @returns the new ActionEvent
  30105. */
  30106. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  30107. /**
  30108. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  30109. * @param scene the scene where the event occurred
  30110. * @param evt The original (browser) event
  30111. * @returns the new ActionEvent
  30112. */
  30113. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  30114. /**
  30115. * Helper function to auto-create an ActionEvent from a primitive
  30116. * @param prim defines the target primitive
  30117. * @param pointerPos defines the pointer position
  30118. * @param evt The original (browser) event
  30119. * @param additionalData additional data for the event
  30120. * @returns the new ActionEvent
  30121. */
  30122. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  30123. }
  30124. }
  30125. declare module "babylonjs/Actions/abstractActionManager" {
  30126. import { IDisposable } from "babylonjs/scene";
  30127. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  30128. import { IAction } from "babylonjs/Actions/action";
  30129. import { Nullable } from "babylonjs/types";
  30130. /**
  30131. * Abstract class used to decouple action Manager from scene and meshes.
  30132. * Do not instantiate.
  30133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  30134. */
  30135. export abstract class AbstractActionManager implements IDisposable {
  30136. /** Gets the list of active triggers */
  30137. static Triggers: {
  30138. [key: string]: number;
  30139. };
  30140. /** Gets the cursor to use when hovering items */
  30141. hoverCursor: string;
  30142. /** Gets the list of actions */
  30143. actions: IAction[];
  30144. /**
  30145. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  30146. */
  30147. isRecursive: boolean;
  30148. /**
  30149. * Releases all associated resources
  30150. */
  30151. abstract dispose(): void;
  30152. /**
  30153. * Does this action manager has pointer triggers
  30154. */
  30155. abstract get hasPointerTriggers(): boolean;
  30156. /**
  30157. * Does this action manager has pick triggers
  30158. */
  30159. abstract get hasPickTriggers(): boolean;
  30160. /**
  30161. * Process a specific trigger
  30162. * @param trigger defines the trigger to process
  30163. * @param evt defines the event details to be processed
  30164. */
  30165. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  30166. /**
  30167. * Does this action manager handles actions of any of the given triggers
  30168. * @param triggers defines the triggers to be tested
  30169. * @return a boolean indicating whether one (or more) of the triggers is handled
  30170. */
  30171. abstract hasSpecificTriggers(triggers: number[]): boolean;
  30172. /**
  30173. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  30174. * speed.
  30175. * @param triggerA defines the trigger to be tested
  30176. * @param triggerB defines the trigger to be tested
  30177. * @return a boolean indicating whether one (or more) of the triggers is handled
  30178. */
  30179. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  30180. /**
  30181. * Does this action manager handles actions of a given trigger
  30182. * @param trigger defines the trigger to be tested
  30183. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  30184. * @return whether the trigger is handled
  30185. */
  30186. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  30187. /**
  30188. * Serialize this manager to a JSON object
  30189. * @param name defines the property name to store this manager
  30190. * @returns a JSON representation of this manager
  30191. */
  30192. abstract serialize(name: string): any;
  30193. /**
  30194. * Registers an action to this action manager
  30195. * @param action defines the action to be registered
  30196. * @return the action amended (prepared) after registration
  30197. */
  30198. abstract registerAction(action: IAction): Nullable<IAction>;
  30199. /**
  30200. * Unregisters an action to this action manager
  30201. * @param action defines the action to be unregistered
  30202. * @return a boolean indicating whether the action has been unregistered
  30203. */
  30204. abstract unregisterAction(action: IAction): Boolean;
  30205. /**
  30206. * Does exist one action manager with at least one trigger
  30207. **/
  30208. static get HasTriggers(): boolean;
  30209. /**
  30210. * Does exist one action manager with at least one pick trigger
  30211. **/
  30212. static get HasPickTriggers(): boolean;
  30213. /**
  30214. * Does exist one action manager that handles actions of a given trigger
  30215. * @param trigger defines the trigger to be tested
  30216. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  30217. **/
  30218. static HasSpecificTrigger(trigger: number): boolean;
  30219. }
  30220. }
  30221. declare module "babylonjs/node" {
  30222. import { Scene } from "babylonjs/scene";
  30223. import { Nullable } from "babylonjs/types";
  30224. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30225. import { Engine } from "babylonjs/Engines/engine";
  30226. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  30227. import { Observable } from "babylonjs/Misc/observable";
  30228. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  30229. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30230. import { Animatable } from "babylonjs/Animations/animatable";
  30231. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  30232. import { Animation } from "babylonjs/Animations/animation";
  30233. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30235. /**
  30236. * Defines how a node can be built from a string name.
  30237. */
  30238. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30239. /**
  30240. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30241. */
  30242. export class Node implements IBehaviorAware<Node> {
  30243. /** @hidden */
  30244. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30245. private static _NodeConstructors;
  30246. /**
  30247. * Add a new node constructor
  30248. * @param type defines the type name of the node to construct
  30249. * @param constructorFunc defines the constructor function
  30250. */
  30251. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30252. /**
  30253. * Returns a node constructor based on type name
  30254. * @param type defines the type name
  30255. * @param name defines the new node name
  30256. * @param scene defines the hosting scene
  30257. * @param options defines optional options to transmit to constructors
  30258. * @returns the new constructor or null
  30259. */
  30260. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30261. /**
  30262. * Gets or sets the name of the node
  30263. */
  30264. name: string;
  30265. /**
  30266. * Gets or sets the id of the node
  30267. */
  30268. id: string;
  30269. /**
  30270. * Gets or sets the unique id of the node
  30271. */
  30272. uniqueId: number;
  30273. /**
  30274. * Gets or sets a string used to store user defined state for the node
  30275. */
  30276. state: string;
  30277. /**
  30278. * Gets or sets an object used to store user defined information for the node
  30279. */
  30280. metadata: any;
  30281. /**
  30282. * For internal use only. Please do not use.
  30283. */
  30284. reservedDataStore: any;
  30285. /**
  30286. * List of inspectable custom properties (used by the Inspector)
  30287. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30288. */
  30289. inspectableCustomProperties: IInspectable[];
  30290. private _doNotSerialize;
  30291. /**
  30292. * Gets or sets a boolean used to define if the node must be serialized
  30293. */
  30294. get doNotSerialize(): boolean;
  30295. set doNotSerialize(value: boolean);
  30296. /** @hidden */
  30297. _isDisposed: boolean;
  30298. /**
  30299. * Gets a list of Animations associated with the node
  30300. */
  30301. animations: import("babylonjs/Animations/animation").Animation[];
  30302. protected _ranges: {
  30303. [name: string]: Nullable<AnimationRange>;
  30304. };
  30305. /**
  30306. * Callback raised when the node is ready to be used
  30307. */
  30308. onReady: Nullable<(node: Node) => void>;
  30309. private _isEnabled;
  30310. private _isParentEnabled;
  30311. private _isReady;
  30312. /** @hidden */
  30313. _currentRenderId: number;
  30314. private _parentUpdateId;
  30315. /** @hidden */
  30316. _childUpdateId: number;
  30317. /** @hidden */
  30318. _waitingParentId: Nullable<string>;
  30319. /** @hidden */
  30320. _scene: Scene;
  30321. /** @hidden */
  30322. _cache: any;
  30323. private _parentNode;
  30324. private _children;
  30325. /** @hidden */
  30326. _worldMatrix: Matrix;
  30327. /** @hidden */
  30328. _worldMatrixDeterminant: number;
  30329. /** @hidden */
  30330. _worldMatrixDeterminantIsDirty: boolean;
  30331. /** @hidden */
  30332. private _sceneRootNodesIndex;
  30333. /**
  30334. * Gets a boolean indicating if the node has been disposed
  30335. * @returns true if the node was disposed
  30336. */
  30337. isDisposed(): boolean;
  30338. /**
  30339. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30340. * @see https://doc.babylonjs.com/how_to/parenting
  30341. */
  30342. set parent(parent: Nullable<Node>);
  30343. get parent(): Nullable<Node>;
  30344. /** @hidden */
  30345. _addToSceneRootNodes(): void;
  30346. /** @hidden */
  30347. _removeFromSceneRootNodes(): void;
  30348. private _animationPropertiesOverride;
  30349. /**
  30350. * Gets or sets the animation properties override
  30351. */
  30352. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30353. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30354. /**
  30355. * Gets a string idenfifying the name of the class
  30356. * @returns "Node" string
  30357. */
  30358. getClassName(): string;
  30359. /** @hidden */
  30360. readonly _isNode: boolean;
  30361. /**
  30362. * An event triggered when the mesh is disposed
  30363. */
  30364. onDisposeObservable: Observable<Node>;
  30365. private _onDisposeObserver;
  30366. /**
  30367. * Sets a callback that will be raised when the node will be disposed
  30368. */
  30369. set onDispose(callback: () => void);
  30370. /**
  30371. * Creates a new Node
  30372. * @param name the name and id to be given to this node
  30373. * @param scene the scene this node will be added to
  30374. */
  30375. constructor(name: string, scene?: Nullable<Scene>);
  30376. /**
  30377. * Gets the scene of the node
  30378. * @returns a scene
  30379. */
  30380. getScene(): Scene;
  30381. /**
  30382. * Gets the engine of the node
  30383. * @returns a Engine
  30384. */
  30385. getEngine(): Engine;
  30386. private _behaviors;
  30387. /**
  30388. * Attach a behavior to the node
  30389. * @see http://doc.babylonjs.com/features/behaviour
  30390. * @param behavior defines the behavior to attach
  30391. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30392. * @returns the current Node
  30393. */
  30394. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30395. /**
  30396. * Remove an attached behavior
  30397. * @see http://doc.babylonjs.com/features/behaviour
  30398. * @param behavior defines the behavior to attach
  30399. * @returns the current Node
  30400. */
  30401. removeBehavior(behavior: Behavior<Node>): Node;
  30402. /**
  30403. * Gets the list of attached behaviors
  30404. * @see http://doc.babylonjs.com/features/behaviour
  30405. */
  30406. get behaviors(): Behavior<Node>[];
  30407. /**
  30408. * Gets an attached behavior by name
  30409. * @param name defines the name of the behavior to look for
  30410. * @see http://doc.babylonjs.com/features/behaviour
  30411. * @returns null if behavior was not found else the requested behavior
  30412. */
  30413. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30414. /**
  30415. * Returns the latest update of the World matrix
  30416. * @returns a Matrix
  30417. */
  30418. getWorldMatrix(): Matrix;
  30419. /** @hidden */
  30420. _getWorldMatrixDeterminant(): number;
  30421. /**
  30422. * Returns directly the latest state of the mesh World matrix.
  30423. * A Matrix is returned.
  30424. */
  30425. get worldMatrixFromCache(): Matrix;
  30426. /** @hidden */
  30427. _initCache(): void;
  30428. /** @hidden */
  30429. updateCache(force?: boolean): void;
  30430. /** @hidden */
  30431. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30432. /** @hidden */
  30433. _updateCache(ignoreParentClass?: boolean): void;
  30434. /** @hidden */
  30435. _isSynchronized(): boolean;
  30436. /** @hidden */
  30437. _markSyncedWithParent(): void;
  30438. /** @hidden */
  30439. isSynchronizedWithParent(): boolean;
  30440. /** @hidden */
  30441. isSynchronized(): boolean;
  30442. /**
  30443. * Is this node ready to be used/rendered
  30444. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30445. * @return true if the node is ready
  30446. */
  30447. isReady(completeCheck?: boolean): boolean;
  30448. /**
  30449. * Is this node enabled?
  30450. * 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
  30451. * @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
  30452. * @return whether this node (and its parent) is enabled
  30453. */
  30454. isEnabled(checkAncestors?: boolean): boolean;
  30455. /** @hidden */
  30456. protected _syncParentEnabledState(): void;
  30457. /**
  30458. * Set the enabled state of this node
  30459. * @param value defines the new enabled state
  30460. */
  30461. setEnabled(value: boolean): void;
  30462. /**
  30463. * Is this node a descendant of the given node?
  30464. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30465. * @param ancestor defines the parent node to inspect
  30466. * @returns a boolean indicating if this node is a descendant of the given node
  30467. */
  30468. isDescendantOf(ancestor: Node): boolean;
  30469. /** @hidden */
  30470. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30471. /**
  30472. * Will return all nodes that have this node as ascendant
  30473. * @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
  30474. * @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
  30475. * @return all children nodes of all types
  30476. */
  30477. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30478. /**
  30479. * Get all child-meshes of this node
  30480. * @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)
  30481. * @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
  30482. * @returns an array of AbstractMesh
  30483. */
  30484. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30485. /**
  30486. * Get all direct children of this node
  30487. * @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
  30488. * @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)
  30489. * @returns an array of Node
  30490. */
  30491. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30492. /** @hidden */
  30493. _setReady(state: boolean): void;
  30494. /**
  30495. * Get an animation by name
  30496. * @param name defines the name of the animation to look for
  30497. * @returns null if not found else the requested animation
  30498. */
  30499. getAnimationByName(name: string): Nullable<Animation>;
  30500. /**
  30501. * Creates an animation range for this node
  30502. * @param name defines the name of the range
  30503. * @param from defines the starting key
  30504. * @param to defines the end key
  30505. */
  30506. createAnimationRange(name: string, from: number, to: number): void;
  30507. /**
  30508. * Delete a specific animation range
  30509. * @param name defines the name of the range to delete
  30510. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30511. */
  30512. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30513. /**
  30514. * Get an animation range by name
  30515. * @param name defines the name of the animation range to look for
  30516. * @returns null if not found else the requested animation range
  30517. */
  30518. getAnimationRange(name: string): Nullable<AnimationRange>;
  30519. /**
  30520. * Gets the list of all animation ranges defined on this node
  30521. * @returns an array
  30522. */
  30523. getAnimationRanges(): Nullable<AnimationRange>[];
  30524. /**
  30525. * Will start the animation sequence
  30526. * @param name defines the range frames for animation sequence
  30527. * @param loop defines if the animation should loop (false by default)
  30528. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30529. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30530. * @returns the object created for this animation. If range does not exist, it will return null
  30531. */
  30532. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30533. /**
  30534. * Serialize animation ranges into a JSON compatible object
  30535. * @returns serialization object
  30536. */
  30537. serializeAnimationRanges(): any;
  30538. /**
  30539. * Computes the world matrix of the node
  30540. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30541. * @returns the world matrix
  30542. */
  30543. computeWorldMatrix(force?: boolean): Matrix;
  30544. /**
  30545. * Releases resources associated with this node.
  30546. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30547. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30548. */
  30549. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30550. /**
  30551. * Parse animation range data from a serialization object and store them into a given node
  30552. * @param node defines where to store the animation ranges
  30553. * @param parsedNode defines the serialization object to read data from
  30554. * @param scene defines the hosting scene
  30555. */
  30556. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30557. /**
  30558. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30559. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30560. * @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
  30561. * @returns the new bounding vectors
  30562. */
  30563. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30564. min: Vector3;
  30565. max: Vector3;
  30566. };
  30567. }
  30568. }
  30569. declare module "babylonjs/Animations/animation" {
  30570. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30571. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30572. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30573. import { Nullable } from "babylonjs/types";
  30574. import { Scene } from "babylonjs/scene";
  30575. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30576. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30577. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30578. import { Node } from "babylonjs/node";
  30579. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30580. import { Size } from "babylonjs/Maths/math.size";
  30581. import { Animatable } from "babylonjs/Animations/animatable";
  30582. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30583. /**
  30584. * @hidden
  30585. */
  30586. export class _IAnimationState {
  30587. key: number;
  30588. repeatCount: number;
  30589. workValue?: any;
  30590. loopMode?: number;
  30591. offsetValue?: any;
  30592. highLimitValue?: any;
  30593. }
  30594. /**
  30595. * Class used to store any kind of animation
  30596. */
  30597. export class Animation {
  30598. /**Name of the animation */
  30599. name: string;
  30600. /**Property to animate */
  30601. targetProperty: string;
  30602. /**The frames per second of the animation */
  30603. framePerSecond: number;
  30604. /**The data type of the animation */
  30605. dataType: number;
  30606. /**The loop mode of the animation */
  30607. loopMode?: number | undefined;
  30608. /**Specifies if blending should be enabled */
  30609. enableBlending?: boolean | undefined;
  30610. /**
  30611. * Use matrix interpolation instead of using direct key value when animating matrices
  30612. */
  30613. static AllowMatricesInterpolation: boolean;
  30614. /**
  30615. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30616. */
  30617. static AllowMatrixDecomposeForInterpolation: boolean;
  30618. /**
  30619. * Stores the key frames of the animation
  30620. */
  30621. private _keys;
  30622. /**
  30623. * Stores the easing function of the animation
  30624. */
  30625. private _easingFunction;
  30626. /**
  30627. * @hidden Internal use only
  30628. */
  30629. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30630. /**
  30631. * The set of event that will be linked to this animation
  30632. */
  30633. private _events;
  30634. /**
  30635. * Stores an array of target property paths
  30636. */
  30637. targetPropertyPath: string[];
  30638. /**
  30639. * Stores the blending speed of the animation
  30640. */
  30641. blendingSpeed: number;
  30642. /**
  30643. * Stores the animation ranges for the animation
  30644. */
  30645. private _ranges;
  30646. /**
  30647. * @hidden Internal use
  30648. */
  30649. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30650. /**
  30651. * Sets up an animation
  30652. * @param property The property to animate
  30653. * @param animationType The animation type to apply
  30654. * @param framePerSecond The frames per second of the animation
  30655. * @param easingFunction The easing function used in the animation
  30656. * @returns The created animation
  30657. */
  30658. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30659. /**
  30660. * Create and start an animation on a node
  30661. * @param name defines the name of the global animation that will be run on all nodes
  30662. * @param node defines the root node where the animation will take place
  30663. * @param targetProperty defines property to animate
  30664. * @param framePerSecond defines the number of frame per second yo use
  30665. * @param totalFrame defines the number of frames in total
  30666. * @param from defines the initial value
  30667. * @param to defines the final value
  30668. * @param loopMode defines which loop mode you want to use (off by default)
  30669. * @param easingFunction defines the easing function to use (linear by default)
  30670. * @param onAnimationEnd defines the callback to call when animation end
  30671. * @returns the animatable created for this animation
  30672. */
  30673. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30674. /**
  30675. * Create and start an animation on a node and its descendants
  30676. * @param name defines the name of the global animation that will be run on all nodes
  30677. * @param node defines the root node where the animation will take place
  30678. * @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
  30679. * @param targetProperty defines property to animate
  30680. * @param framePerSecond defines the number of frame per second to use
  30681. * @param totalFrame defines the number of frames in total
  30682. * @param from defines the initial value
  30683. * @param to defines the final value
  30684. * @param loopMode defines which loop mode you want to use (off by default)
  30685. * @param easingFunction defines the easing function to use (linear by default)
  30686. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30687. * @returns the list of animatables created for all nodes
  30688. * @example https://www.babylonjs-playground.com/#MH0VLI
  30689. */
  30690. 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[]>;
  30691. /**
  30692. * Creates a new animation, merges it with the existing animations and starts it
  30693. * @param name Name of the animation
  30694. * @param node Node which contains the scene that begins the animations
  30695. * @param targetProperty Specifies which property to animate
  30696. * @param framePerSecond The frames per second of the animation
  30697. * @param totalFrame The total number of frames
  30698. * @param from The frame at the beginning of the animation
  30699. * @param to The frame at the end of the animation
  30700. * @param loopMode Specifies the loop mode of the animation
  30701. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30702. * @param onAnimationEnd Callback to run once the animation is complete
  30703. * @returns Nullable animation
  30704. */
  30705. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30706. /**
  30707. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30708. * @param sourceAnimation defines the Animation containing keyframes to convert
  30709. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30710. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30711. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30712. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30713. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30714. */
  30715. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30716. /**
  30717. * Transition property of an host to the target Value
  30718. * @param property The property to transition
  30719. * @param targetValue The target Value of the property
  30720. * @param host The object where the property to animate belongs
  30721. * @param scene Scene used to run the animation
  30722. * @param frameRate Framerate (in frame/s) to use
  30723. * @param transition The transition type we want to use
  30724. * @param duration The duration of the animation, in milliseconds
  30725. * @param onAnimationEnd Callback trigger at the end of the animation
  30726. * @returns Nullable animation
  30727. */
  30728. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30729. /**
  30730. * Return the array of runtime animations currently using this animation
  30731. */
  30732. get runtimeAnimations(): RuntimeAnimation[];
  30733. /**
  30734. * Specifies if any of the runtime animations are currently running
  30735. */
  30736. get hasRunningRuntimeAnimations(): boolean;
  30737. /**
  30738. * Initializes the animation
  30739. * @param name Name of the animation
  30740. * @param targetProperty Property to animate
  30741. * @param framePerSecond The frames per second of the animation
  30742. * @param dataType The data type of the animation
  30743. * @param loopMode The loop mode of the animation
  30744. * @param enableBlending Specifies if blending should be enabled
  30745. */
  30746. constructor(
  30747. /**Name of the animation */
  30748. name: string,
  30749. /**Property to animate */
  30750. targetProperty: string,
  30751. /**The frames per second of the animation */
  30752. framePerSecond: number,
  30753. /**The data type of the animation */
  30754. dataType: number,
  30755. /**The loop mode of the animation */
  30756. loopMode?: number | undefined,
  30757. /**Specifies if blending should be enabled */
  30758. enableBlending?: boolean | undefined);
  30759. /**
  30760. * Converts the animation to a string
  30761. * @param fullDetails support for multiple levels of logging within scene loading
  30762. * @returns String form of the animation
  30763. */
  30764. toString(fullDetails?: boolean): string;
  30765. /**
  30766. * Add an event to this animation
  30767. * @param event Event to add
  30768. */
  30769. addEvent(event: AnimationEvent): void;
  30770. /**
  30771. * Remove all events found at the given frame
  30772. * @param frame The frame to remove events from
  30773. */
  30774. removeEvents(frame: number): void;
  30775. /**
  30776. * Retrieves all the events from the animation
  30777. * @returns Events from the animation
  30778. */
  30779. getEvents(): AnimationEvent[];
  30780. /**
  30781. * Creates an animation range
  30782. * @param name Name of the animation range
  30783. * @param from Starting frame of the animation range
  30784. * @param to Ending frame of the animation
  30785. */
  30786. createRange(name: string, from: number, to: number): void;
  30787. /**
  30788. * Deletes an animation range by name
  30789. * @param name Name of the animation range to delete
  30790. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30791. */
  30792. deleteRange(name: string, deleteFrames?: boolean): void;
  30793. /**
  30794. * Gets the animation range by name, or null if not defined
  30795. * @param name Name of the animation range
  30796. * @returns Nullable animation range
  30797. */
  30798. getRange(name: string): Nullable<AnimationRange>;
  30799. /**
  30800. * Gets the key frames from the animation
  30801. * @returns The key frames of the animation
  30802. */
  30803. getKeys(): Array<IAnimationKey>;
  30804. /**
  30805. * Gets the highest frame rate of the animation
  30806. * @returns Highest frame rate of the animation
  30807. */
  30808. getHighestFrame(): number;
  30809. /**
  30810. * Gets the easing function of the animation
  30811. * @returns Easing function of the animation
  30812. */
  30813. getEasingFunction(): IEasingFunction;
  30814. /**
  30815. * Sets the easing function of the animation
  30816. * @param easingFunction A custom mathematical formula for animation
  30817. */
  30818. setEasingFunction(easingFunction: EasingFunction): void;
  30819. /**
  30820. * Interpolates a scalar linearly
  30821. * @param startValue Start value of the animation curve
  30822. * @param endValue End value of the animation curve
  30823. * @param gradient Scalar amount to interpolate
  30824. * @returns Interpolated scalar value
  30825. */
  30826. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30827. /**
  30828. * Interpolates a scalar cubically
  30829. * @param startValue Start value of the animation curve
  30830. * @param outTangent End tangent of the animation
  30831. * @param endValue End value of the animation curve
  30832. * @param inTangent Start tangent of the animation curve
  30833. * @param gradient Scalar amount to interpolate
  30834. * @returns Interpolated scalar value
  30835. */
  30836. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30837. /**
  30838. * Interpolates a quaternion using a spherical linear interpolation
  30839. * @param startValue Start value of the animation curve
  30840. * @param endValue End value of the animation curve
  30841. * @param gradient Scalar amount to interpolate
  30842. * @returns Interpolated quaternion value
  30843. */
  30844. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30845. /**
  30846. * Interpolates a quaternion cubically
  30847. * @param startValue Start value of the animation curve
  30848. * @param outTangent End tangent of the animation curve
  30849. * @param endValue End value of the animation curve
  30850. * @param inTangent Start tangent of the animation curve
  30851. * @param gradient Scalar amount to interpolate
  30852. * @returns Interpolated quaternion value
  30853. */
  30854. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30855. /**
  30856. * Interpolates a Vector3 linearl
  30857. * @param startValue Start value of the animation curve
  30858. * @param endValue End value of the animation curve
  30859. * @param gradient Scalar amount to interpolate
  30860. * @returns Interpolated scalar value
  30861. */
  30862. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30863. /**
  30864. * Interpolates a Vector3 cubically
  30865. * @param startValue Start value of the animation curve
  30866. * @param outTangent End tangent of the animation
  30867. * @param endValue End value of the animation curve
  30868. * @param inTangent Start tangent of the animation curve
  30869. * @param gradient Scalar amount to interpolate
  30870. * @returns InterpolatedVector3 value
  30871. */
  30872. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30873. /**
  30874. * Interpolates a Vector2 linearly
  30875. * @param startValue Start value of the animation curve
  30876. * @param endValue End value of the animation curve
  30877. * @param gradient Scalar amount to interpolate
  30878. * @returns Interpolated Vector2 value
  30879. */
  30880. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30881. /**
  30882. * Interpolates a Vector2 cubically
  30883. * @param startValue Start value of the animation curve
  30884. * @param outTangent End tangent of the animation
  30885. * @param endValue End value of the animation curve
  30886. * @param inTangent Start tangent of the animation curve
  30887. * @param gradient Scalar amount to interpolate
  30888. * @returns Interpolated Vector2 value
  30889. */
  30890. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30891. /**
  30892. * Interpolates a size linearly
  30893. * @param startValue Start value of the animation curve
  30894. * @param endValue End value of the animation curve
  30895. * @param gradient Scalar amount to interpolate
  30896. * @returns Interpolated Size value
  30897. */
  30898. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30899. /**
  30900. * Interpolates a Color3 linearly
  30901. * @param startValue Start value of the animation curve
  30902. * @param endValue End value of the animation curve
  30903. * @param gradient Scalar amount to interpolate
  30904. * @returns Interpolated Color3 value
  30905. */
  30906. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30907. /**
  30908. * Interpolates a Color4 linearly
  30909. * @param startValue Start value of the animation curve
  30910. * @param endValue End value of the animation curve
  30911. * @param gradient Scalar amount to interpolate
  30912. * @returns Interpolated Color3 value
  30913. */
  30914. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30915. /**
  30916. * @hidden Internal use only
  30917. */
  30918. _getKeyValue(value: any): any;
  30919. /**
  30920. * @hidden Internal use only
  30921. */
  30922. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30923. /**
  30924. * Defines the function to use to interpolate matrices
  30925. * @param startValue defines the start matrix
  30926. * @param endValue defines the end matrix
  30927. * @param gradient defines the gradient between both matrices
  30928. * @param result defines an optional target matrix where to store the interpolation
  30929. * @returns the interpolated matrix
  30930. */
  30931. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30932. /**
  30933. * Makes a copy of the animation
  30934. * @returns Cloned animation
  30935. */
  30936. clone(): Animation;
  30937. /**
  30938. * Sets the key frames of the animation
  30939. * @param values The animation key frames to set
  30940. */
  30941. setKeys(values: Array<IAnimationKey>): void;
  30942. /**
  30943. * Serializes the animation to an object
  30944. * @returns Serialized object
  30945. */
  30946. serialize(): any;
  30947. /**
  30948. * Float animation type
  30949. */
  30950. static readonly ANIMATIONTYPE_FLOAT: number;
  30951. /**
  30952. * Vector3 animation type
  30953. */
  30954. static readonly ANIMATIONTYPE_VECTOR3: number;
  30955. /**
  30956. * Quaternion animation type
  30957. */
  30958. static readonly ANIMATIONTYPE_QUATERNION: number;
  30959. /**
  30960. * Matrix animation type
  30961. */
  30962. static readonly ANIMATIONTYPE_MATRIX: number;
  30963. /**
  30964. * Color3 animation type
  30965. */
  30966. static readonly ANIMATIONTYPE_COLOR3: number;
  30967. /**
  30968. * Color3 animation type
  30969. */
  30970. static readonly ANIMATIONTYPE_COLOR4: number;
  30971. /**
  30972. * Vector2 animation type
  30973. */
  30974. static readonly ANIMATIONTYPE_VECTOR2: number;
  30975. /**
  30976. * Size animation type
  30977. */
  30978. static readonly ANIMATIONTYPE_SIZE: number;
  30979. /**
  30980. * Relative Loop Mode
  30981. */
  30982. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30983. /**
  30984. * Cycle Loop Mode
  30985. */
  30986. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30987. /**
  30988. * Constant Loop Mode
  30989. */
  30990. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30991. /** @hidden */
  30992. static _UniversalLerp(left: any, right: any, amount: number): any;
  30993. /**
  30994. * Parses an animation object and creates an animation
  30995. * @param parsedAnimation Parsed animation object
  30996. * @returns Animation object
  30997. */
  30998. static Parse(parsedAnimation: any): Animation;
  30999. /**
  31000. * Appends the serialized animations from the source animations
  31001. * @param source Source containing the animations
  31002. * @param destination Target to store the animations
  31003. */
  31004. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31005. }
  31006. }
  31007. declare module "babylonjs/Animations/animatable.interface" {
  31008. import { Nullable } from "babylonjs/types";
  31009. import { Animation } from "babylonjs/Animations/animation";
  31010. /**
  31011. * Interface containing an array of animations
  31012. */
  31013. export interface IAnimatable {
  31014. /**
  31015. * Array of animations
  31016. */
  31017. animations: Nullable<Array<Animation>>;
  31018. }
  31019. }
  31020. declare module "babylonjs/Misc/decorators" {
  31021. import { Nullable } from "babylonjs/types";
  31022. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31023. import { Scene } from "babylonjs/scene";
  31024. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31025. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31026. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31027. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31028. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31029. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31030. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31031. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31032. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31033. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31034. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31035. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31036. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31037. /**
  31038. * Decorator used to define property that can be serialized as reference to a camera
  31039. * @param sourceName defines the name of the property to decorate
  31040. */
  31041. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31042. /**
  31043. * Class used to help serialization objects
  31044. */
  31045. export class SerializationHelper {
  31046. /** @hidden */
  31047. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31048. /** @hidden */
  31049. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31050. /** @hidden */
  31051. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31052. /** @hidden */
  31053. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31054. /**
  31055. * Appends the serialized animations from the source animations
  31056. * @param source Source containing the animations
  31057. * @param destination Target to store the animations
  31058. */
  31059. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31060. /**
  31061. * Static function used to serialized a specific entity
  31062. * @param entity defines the entity to serialize
  31063. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31064. * @returns a JSON compatible object representing the serialization of the entity
  31065. */
  31066. static Serialize<T>(entity: T, serializationObject?: any): any;
  31067. /**
  31068. * Creates a new entity from a serialization data object
  31069. * @param creationFunction defines a function used to instanciated the new entity
  31070. * @param source defines the source serialization data
  31071. * @param scene defines the hosting scene
  31072. * @param rootUrl defines the root url for resources
  31073. * @returns a new entity
  31074. */
  31075. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31076. /**
  31077. * Clones an object
  31078. * @param creationFunction defines the function used to instanciate the new object
  31079. * @param source defines the source object
  31080. * @returns the cloned object
  31081. */
  31082. static Clone<T>(creationFunction: () => T, source: T): T;
  31083. /**
  31084. * Instanciates a new object based on a source one (some data will be shared between both object)
  31085. * @param creationFunction defines the function used to instanciate the new object
  31086. * @param source defines the source object
  31087. * @returns the new object
  31088. */
  31089. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31090. }
  31091. }
  31092. declare module "babylonjs/Materials/Textures/baseTexture" {
  31093. import { Observable } from "babylonjs/Misc/observable";
  31094. import { Nullable } from "babylonjs/types";
  31095. import { Scene } from "babylonjs/scene";
  31096. import { Matrix } from "babylonjs/Maths/math.vector";
  31097. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31098. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31099. import { ISize } from "babylonjs/Maths/math.size";
  31100. import "babylonjs/Misc/fileTools";
  31101. /**
  31102. * Base class of all the textures in babylon.
  31103. * It groups all the common properties the materials, post process, lights... might need
  31104. * in order to make a correct use of the texture.
  31105. */
  31106. export class BaseTexture implements IAnimatable {
  31107. /**
  31108. * Default anisotropic filtering level for the application.
  31109. * It is set to 4 as a good tradeoff between perf and quality.
  31110. */
  31111. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  31112. /**
  31113. * Gets or sets the unique id of the texture
  31114. */
  31115. uniqueId: number;
  31116. /**
  31117. * Define the name of the texture.
  31118. */
  31119. name: string;
  31120. /**
  31121. * Gets or sets an object used to store user defined information.
  31122. */
  31123. metadata: any;
  31124. /**
  31125. * For internal use only. Please do not use.
  31126. */
  31127. reservedDataStore: any;
  31128. private _hasAlpha;
  31129. /**
  31130. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  31131. */
  31132. set hasAlpha(value: boolean);
  31133. get hasAlpha(): boolean;
  31134. /**
  31135. * Defines if the alpha value should be determined via the rgb values.
  31136. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  31137. */
  31138. getAlphaFromRGB: boolean;
  31139. /**
  31140. * Intensity or strength of the texture.
  31141. * It is commonly used by materials to fine tune the intensity of the texture
  31142. */
  31143. level: number;
  31144. /**
  31145. * Define the UV chanel to use starting from 0 and defaulting to 0.
  31146. * This is part of the texture as textures usually maps to one uv set.
  31147. */
  31148. coordinatesIndex: number;
  31149. private _coordinatesMode;
  31150. /**
  31151. * How a texture is mapped.
  31152. *
  31153. * | Value | Type | Description |
  31154. * | ----- | ----------------------------------- | ----------- |
  31155. * | 0 | EXPLICIT_MODE | |
  31156. * | 1 | SPHERICAL_MODE | |
  31157. * | 2 | PLANAR_MODE | |
  31158. * | 3 | CUBIC_MODE | |
  31159. * | 4 | PROJECTION_MODE | |
  31160. * | 5 | SKYBOX_MODE | |
  31161. * | 6 | INVCUBIC_MODE | |
  31162. * | 7 | EQUIRECTANGULAR_MODE | |
  31163. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  31164. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  31165. */
  31166. set coordinatesMode(value: number);
  31167. get coordinatesMode(): number;
  31168. /**
  31169. * | Value | Type | Description |
  31170. * | ----- | ------------------ | ----------- |
  31171. * | 0 | CLAMP_ADDRESSMODE | |
  31172. * | 1 | WRAP_ADDRESSMODE | |
  31173. * | 2 | MIRROR_ADDRESSMODE | |
  31174. */
  31175. wrapU: number;
  31176. /**
  31177. * | Value | Type | Description |
  31178. * | ----- | ------------------ | ----------- |
  31179. * | 0 | CLAMP_ADDRESSMODE | |
  31180. * | 1 | WRAP_ADDRESSMODE | |
  31181. * | 2 | MIRROR_ADDRESSMODE | |
  31182. */
  31183. wrapV: number;
  31184. /**
  31185. * | Value | Type | Description |
  31186. * | ----- | ------------------ | ----------- |
  31187. * | 0 | CLAMP_ADDRESSMODE | |
  31188. * | 1 | WRAP_ADDRESSMODE | |
  31189. * | 2 | MIRROR_ADDRESSMODE | |
  31190. */
  31191. wrapR: number;
  31192. /**
  31193. * With compliant hardware and browser (supporting anisotropic filtering)
  31194. * this defines the level of anisotropic filtering in the texture.
  31195. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  31196. */
  31197. anisotropicFilteringLevel: number;
  31198. /**
  31199. * Define if the texture is a cube texture or if false a 2d texture.
  31200. */
  31201. get isCube(): boolean;
  31202. set isCube(value: boolean);
  31203. /**
  31204. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  31205. */
  31206. get is3D(): boolean;
  31207. set is3D(value: boolean);
  31208. /**
  31209. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  31210. */
  31211. get is2DArray(): boolean;
  31212. set is2DArray(value: boolean);
  31213. /**
  31214. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  31215. * HDR texture are usually stored in linear space.
  31216. * This only impacts the PBR and Background materials
  31217. */
  31218. gammaSpace: boolean;
  31219. /**
  31220. * Gets or sets whether or not the texture contains RGBD data.
  31221. */
  31222. get isRGBD(): boolean;
  31223. set isRGBD(value: boolean);
  31224. /**
  31225. * Is Z inverted in the texture (useful in a cube texture).
  31226. */
  31227. invertZ: boolean;
  31228. /**
  31229. * Are mip maps generated for this texture or not.
  31230. */
  31231. get noMipmap(): boolean;
  31232. /**
  31233. * @hidden
  31234. */
  31235. lodLevelInAlpha: boolean;
  31236. /**
  31237. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31238. */
  31239. get lodGenerationOffset(): number;
  31240. set lodGenerationOffset(value: number);
  31241. /**
  31242. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31243. */
  31244. get lodGenerationScale(): number;
  31245. set lodGenerationScale(value: number);
  31246. /**
  31247. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31248. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31249. * average roughness values.
  31250. */
  31251. get linearSpecularLOD(): boolean;
  31252. set linearSpecularLOD(value: boolean);
  31253. /**
  31254. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31255. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31256. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31257. */
  31258. get irradianceTexture(): Nullable<BaseTexture>;
  31259. set irradianceTexture(value: Nullable<BaseTexture>);
  31260. /**
  31261. * Define if the texture is a render target.
  31262. */
  31263. isRenderTarget: boolean;
  31264. /**
  31265. * Define the unique id of the texture in the scene.
  31266. */
  31267. get uid(): string;
  31268. /**
  31269. * Return a string representation of the texture.
  31270. * @returns the texture as a string
  31271. */
  31272. toString(): string;
  31273. /**
  31274. * Get the class name of the texture.
  31275. * @returns "BaseTexture"
  31276. */
  31277. getClassName(): string;
  31278. /**
  31279. * Define the list of animation attached to the texture.
  31280. */
  31281. animations: import("babylonjs/Animations/animation").Animation[];
  31282. /**
  31283. * An event triggered when the texture is disposed.
  31284. */
  31285. onDisposeObservable: Observable<BaseTexture>;
  31286. private _onDisposeObserver;
  31287. /**
  31288. * Callback triggered when the texture has been disposed.
  31289. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31290. */
  31291. set onDispose(callback: () => void);
  31292. /**
  31293. * Define the current state of the loading sequence when in delayed load mode.
  31294. */
  31295. delayLoadState: number;
  31296. private _scene;
  31297. /** @hidden */
  31298. _texture: Nullable<InternalTexture>;
  31299. private _uid;
  31300. /**
  31301. * Define if the texture is preventinga material to render or not.
  31302. * If not and the texture is not ready, the engine will use a default black texture instead.
  31303. */
  31304. get isBlocking(): boolean;
  31305. /**
  31306. * Instantiates a new BaseTexture.
  31307. * Base class of all the textures in babylon.
  31308. * It groups all the common properties the materials, post process, lights... might need
  31309. * in order to make a correct use of the texture.
  31310. * @param scene Define the scene the texture blongs to
  31311. */
  31312. constructor(scene: Nullable<Scene>);
  31313. /**
  31314. * Get the scene the texture belongs to.
  31315. * @returns the scene or null if undefined
  31316. */
  31317. getScene(): Nullable<Scene>;
  31318. /**
  31319. * Get the texture transform matrix used to offset tile the texture for istance.
  31320. * @returns the transformation matrix
  31321. */
  31322. getTextureMatrix(): Matrix;
  31323. /**
  31324. * Get the texture reflection matrix used to rotate/transform the reflection.
  31325. * @returns the reflection matrix
  31326. */
  31327. getReflectionTextureMatrix(): Matrix;
  31328. /**
  31329. * Get the underlying lower level texture from Babylon.
  31330. * @returns the insternal texture
  31331. */
  31332. getInternalTexture(): Nullable<InternalTexture>;
  31333. /**
  31334. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31335. * @returns true if ready or not blocking
  31336. */
  31337. isReadyOrNotBlocking(): boolean;
  31338. /**
  31339. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31340. * @returns true if fully ready
  31341. */
  31342. isReady(): boolean;
  31343. private _cachedSize;
  31344. /**
  31345. * Get the size of the texture.
  31346. * @returns the texture size.
  31347. */
  31348. getSize(): ISize;
  31349. /**
  31350. * Get the base size of the texture.
  31351. * It can be different from the size if the texture has been resized for POT for instance
  31352. * @returns the base size
  31353. */
  31354. getBaseSize(): ISize;
  31355. /**
  31356. * Update the sampling mode of the texture.
  31357. * Default is Trilinear mode.
  31358. *
  31359. * | Value | Type | Description |
  31360. * | ----- | ------------------ | ----------- |
  31361. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31362. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31363. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31364. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31365. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31366. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31367. * | 7 | NEAREST_LINEAR | |
  31368. * | 8 | NEAREST_NEAREST | |
  31369. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31370. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31371. * | 11 | LINEAR_LINEAR | |
  31372. * | 12 | LINEAR_NEAREST | |
  31373. *
  31374. * > _mag_: magnification filter (close to the viewer)
  31375. * > _min_: minification filter (far from the viewer)
  31376. * > _mip_: filter used between mip map levels
  31377. *@param samplingMode Define the new sampling mode of the texture
  31378. */
  31379. updateSamplingMode(samplingMode: number): void;
  31380. /**
  31381. * Scales the texture if is `canRescale()`
  31382. * @param ratio the resize factor we want to use to rescale
  31383. */
  31384. scale(ratio: number): void;
  31385. /**
  31386. * Get if the texture can rescale.
  31387. */
  31388. get canRescale(): boolean;
  31389. /** @hidden */
  31390. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31391. /** @hidden */
  31392. _rebuild(): void;
  31393. /**
  31394. * Triggers the load sequence in delayed load mode.
  31395. */
  31396. delayLoad(): void;
  31397. /**
  31398. * Clones the texture.
  31399. * @returns the cloned texture
  31400. */
  31401. clone(): Nullable<BaseTexture>;
  31402. /**
  31403. * Get the texture underlying type (INT, FLOAT...)
  31404. */
  31405. get textureType(): number;
  31406. /**
  31407. * Get the texture underlying format (RGB, RGBA...)
  31408. */
  31409. get textureFormat(): number;
  31410. /**
  31411. * Indicates that textures need to be re-calculated for all materials
  31412. */
  31413. protected _markAllSubMeshesAsTexturesDirty(): void;
  31414. /**
  31415. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31416. * This will returns an RGBA array buffer containing either in values (0-255) or
  31417. * float values (0-1) depending of the underlying buffer type.
  31418. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31419. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31420. * @param buffer defines a user defined buffer to fill with data (can be null)
  31421. * @returns The Array buffer containing the pixels data.
  31422. */
  31423. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31424. /**
  31425. * Release and destroy the underlying lower level texture aka internalTexture.
  31426. */
  31427. releaseInternalTexture(): void;
  31428. /** @hidden */
  31429. get _lodTextureHigh(): Nullable<BaseTexture>;
  31430. /** @hidden */
  31431. get _lodTextureMid(): Nullable<BaseTexture>;
  31432. /** @hidden */
  31433. get _lodTextureLow(): Nullable<BaseTexture>;
  31434. /**
  31435. * Dispose the texture and release its associated resources.
  31436. */
  31437. dispose(): void;
  31438. /**
  31439. * Serialize the texture into a JSON representation that can be parsed later on.
  31440. * @returns the JSON representation of the texture
  31441. */
  31442. serialize(): any;
  31443. /**
  31444. * Helper function to be called back once a list of texture contains only ready textures.
  31445. * @param textures Define the list of textures to wait for
  31446. * @param callback Define the callback triggered once the entire list will be ready
  31447. */
  31448. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31449. }
  31450. }
  31451. declare module "babylonjs/Materials/effect" {
  31452. import { Observable } from "babylonjs/Misc/observable";
  31453. import { Nullable } from "babylonjs/types";
  31454. import { IDisposable } from "babylonjs/scene";
  31455. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31456. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31457. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31458. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31459. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31460. import { Engine } from "babylonjs/Engines/engine";
  31461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31463. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31464. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31465. /**
  31466. * Options to be used when creating an effect.
  31467. */
  31468. export interface IEffectCreationOptions {
  31469. /**
  31470. * Atrributes that will be used in the shader.
  31471. */
  31472. attributes: string[];
  31473. /**
  31474. * Uniform varible names that will be set in the shader.
  31475. */
  31476. uniformsNames: string[];
  31477. /**
  31478. * Uniform buffer variable names that will be set in the shader.
  31479. */
  31480. uniformBuffersNames: string[];
  31481. /**
  31482. * Sampler texture variable names that will be set in the shader.
  31483. */
  31484. samplers: string[];
  31485. /**
  31486. * Define statements that will be set in the shader.
  31487. */
  31488. defines: any;
  31489. /**
  31490. * Possible fallbacks for this effect to improve performance when needed.
  31491. */
  31492. fallbacks: Nullable<IEffectFallbacks>;
  31493. /**
  31494. * Callback that will be called when the shader is compiled.
  31495. */
  31496. onCompiled: Nullable<(effect: Effect) => void>;
  31497. /**
  31498. * Callback that will be called if an error occurs during shader compilation.
  31499. */
  31500. onError: Nullable<(effect: Effect, errors: string) => void>;
  31501. /**
  31502. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31503. */
  31504. indexParameters?: any;
  31505. /**
  31506. * Max number of lights that can be used in the shader.
  31507. */
  31508. maxSimultaneousLights?: number;
  31509. /**
  31510. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31511. */
  31512. transformFeedbackVaryings?: Nullable<string[]>;
  31513. }
  31514. /**
  31515. * Effect containing vertex and fragment shader that can be executed on an object.
  31516. */
  31517. export class Effect implements IDisposable {
  31518. /**
  31519. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31520. */
  31521. static ShadersRepository: string;
  31522. /**
  31523. * Enable logging of the shader code when a compilation error occurs
  31524. */
  31525. static LogShaderCodeOnCompilationError: boolean;
  31526. /**
  31527. * Name of the effect.
  31528. */
  31529. name: any;
  31530. /**
  31531. * String container all the define statements that should be set on the shader.
  31532. */
  31533. defines: string;
  31534. /**
  31535. * Callback that will be called when the shader is compiled.
  31536. */
  31537. onCompiled: Nullable<(effect: Effect) => void>;
  31538. /**
  31539. * Callback that will be called if an error occurs during shader compilation.
  31540. */
  31541. onError: Nullable<(effect: Effect, errors: string) => void>;
  31542. /**
  31543. * Callback that will be called when effect is bound.
  31544. */
  31545. onBind: Nullable<(effect: Effect) => void>;
  31546. /**
  31547. * Unique ID of the effect.
  31548. */
  31549. uniqueId: number;
  31550. /**
  31551. * Observable that will be called when the shader is compiled.
  31552. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31553. */
  31554. onCompileObservable: Observable<Effect>;
  31555. /**
  31556. * Observable that will be called if an error occurs during shader compilation.
  31557. */
  31558. onErrorObservable: Observable<Effect>;
  31559. /** @hidden */
  31560. _onBindObservable: Nullable<Observable<Effect>>;
  31561. /**
  31562. * @hidden
  31563. * Specifies if the effect was previously ready
  31564. */
  31565. _wasPreviouslyReady: boolean;
  31566. /**
  31567. * Observable that will be called when effect is bound.
  31568. */
  31569. get onBindObservable(): Observable<Effect>;
  31570. /** @hidden */
  31571. _bonesComputationForcedToCPU: boolean;
  31572. private static _uniqueIdSeed;
  31573. private _engine;
  31574. private _uniformBuffersNames;
  31575. private _uniformBuffersNamesList;
  31576. private _uniformsNames;
  31577. private _samplerList;
  31578. private _samplers;
  31579. private _isReady;
  31580. private _compilationError;
  31581. private _allFallbacksProcessed;
  31582. private _attributesNames;
  31583. private _attributes;
  31584. private _attributeLocationByName;
  31585. private _uniforms;
  31586. /**
  31587. * Key for the effect.
  31588. * @hidden
  31589. */
  31590. _key: string;
  31591. private _indexParameters;
  31592. private _fallbacks;
  31593. private _vertexSourceCode;
  31594. private _fragmentSourceCode;
  31595. private _vertexSourceCodeOverride;
  31596. private _fragmentSourceCodeOverride;
  31597. private _transformFeedbackVaryings;
  31598. /**
  31599. * Compiled shader to webGL program.
  31600. * @hidden
  31601. */
  31602. _pipelineContext: Nullable<IPipelineContext>;
  31603. private _valueCache;
  31604. private static _baseCache;
  31605. /**
  31606. * Instantiates an effect.
  31607. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31608. * @param baseName Name of the effect.
  31609. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31610. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31611. * @param samplers List of sampler variables that will be passed to the shader.
  31612. * @param engine Engine to be used to render the effect
  31613. * @param defines Define statements to be added to the shader.
  31614. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31615. * @param onCompiled Callback that will be called when the shader is compiled.
  31616. * @param onError Callback that will be called if an error occurs during shader compilation.
  31617. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31618. */
  31619. 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);
  31620. private _useFinalCode;
  31621. /**
  31622. * Unique key for this effect
  31623. */
  31624. get key(): string;
  31625. /**
  31626. * If the effect has been compiled and prepared.
  31627. * @returns if the effect is compiled and prepared.
  31628. */
  31629. isReady(): boolean;
  31630. private _isReadyInternal;
  31631. /**
  31632. * The engine the effect was initialized with.
  31633. * @returns the engine.
  31634. */
  31635. getEngine(): Engine;
  31636. /**
  31637. * The pipeline context for this effect
  31638. * @returns the associated pipeline context
  31639. */
  31640. getPipelineContext(): Nullable<IPipelineContext>;
  31641. /**
  31642. * The set of names of attribute variables for the shader.
  31643. * @returns An array of attribute names.
  31644. */
  31645. getAttributesNames(): string[];
  31646. /**
  31647. * Returns the attribute at the given index.
  31648. * @param index The index of the attribute.
  31649. * @returns The location of the attribute.
  31650. */
  31651. getAttributeLocation(index: number): number;
  31652. /**
  31653. * Returns the attribute based on the name of the variable.
  31654. * @param name of the attribute to look up.
  31655. * @returns the attribute location.
  31656. */
  31657. getAttributeLocationByName(name: string): number;
  31658. /**
  31659. * The number of attributes.
  31660. * @returns the numnber of attributes.
  31661. */
  31662. getAttributesCount(): number;
  31663. /**
  31664. * Gets the index of a uniform variable.
  31665. * @param uniformName of the uniform to look up.
  31666. * @returns the index.
  31667. */
  31668. getUniformIndex(uniformName: string): number;
  31669. /**
  31670. * Returns the attribute based on the name of the variable.
  31671. * @param uniformName of the uniform to look up.
  31672. * @returns the location of the uniform.
  31673. */
  31674. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31675. /**
  31676. * Returns an array of sampler variable names
  31677. * @returns The array of sampler variable names.
  31678. */
  31679. getSamplers(): string[];
  31680. /**
  31681. * Returns an array of uniform variable names
  31682. * @returns The array of uniform variable names.
  31683. */
  31684. getUniformNames(): string[];
  31685. /**
  31686. * Returns an array of uniform buffer variable names
  31687. * @returns The array of uniform buffer variable names.
  31688. */
  31689. getUniformBuffersNames(): string[];
  31690. /**
  31691. * Returns the index parameters used to create the effect
  31692. * @returns The index parameters object
  31693. */
  31694. getIndexParameters(): any;
  31695. /**
  31696. * The error from the last compilation.
  31697. * @returns the error string.
  31698. */
  31699. getCompilationError(): string;
  31700. /**
  31701. * Gets a boolean indicating that all fallbacks were used during compilation
  31702. * @returns true if all fallbacks were used
  31703. */
  31704. allFallbacksProcessed(): boolean;
  31705. /**
  31706. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31707. * @param func The callback to be used.
  31708. */
  31709. executeWhenCompiled(func: (effect: Effect) => void): void;
  31710. private _checkIsReady;
  31711. private _loadShader;
  31712. /**
  31713. * Gets the vertex shader source code of this effect
  31714. */
  31715. get vertexSourceCode(): string;
  31716. /**
  31717. * Gets the fragment shader source code of this effect
  31718. */
  31719. get fragmentSourceCode(): string;
  31720. /**
  31721. * Recompiles the webGL program
  31722. * @param vertexSourceCode The source code for the vertex shader.
  31723. * @param fragmentSourceCode The source code for the fragment shader.
  31724. * @param onCompiled Callback called when completed.
  31725. * @param onError Callback called on error.
  31726. * @hidden
  31727. */
  31728. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31729. /**
  31730. * Prepares the effect
  31731. * @hidden
  31732. */
  31733. _prepareEffect(): void;
  31734. private _getShaderCodeAndErrorLine;
  31735. private _processCompilationErrors;
  31736. /**
  31737. * Checks if the effect is supported. (Must be called after compilation)
  31738. */
  31739. get isSupported(): boolean;
  31740. /**
  31741. * Binds a texture to the engine to be used as output of the shader.
  31742. * @param channel Name of the output variable.
  31743. * @param texture Texture to bind.
  31744. * @hidden
  31745. */
  31746. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31747. /**
  31748. * Sets a texture on the engine to be used in the shader.
  31749. * @param channel Name of the sampler variable.
  31750. * @param texture Texture to set.
  31751. */
  31752. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31753. /**
  31754. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31755. * @param channel Name of the sampler variable.
  31756. * @param texture Texture to set.
  31757. */
  31758. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31759. /**
  31760. * Sets an array of textures on the engine to be used in the shader.
  31761. * @param channel Name of the variable.
  31762. * @param textures Textures to set.
  31763. */
  31764. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31765. /**
  31766. * 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)
  31767. * @param channel Name of the sampler variable.
  31768. * @param postProcess Post process to get the input texture from.
  31769. */
  31770. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31771. /**
  31772. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31773. * 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)
  31774. * @param channel Name of the sampler variable.
  31775. * @param postProcess Post process to get the output texture from.
  31776. */
  31777. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31778. /** @hidden */
  31779. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31780. /** @hidden */
  31781. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31782. /** @hidden */
  31783. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31784. /** @hidden */
  31785. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31786. /**
  31787. * Binds a buffer to a uniform.
  31788. * @param buffer Buffer to bind.
  31789. * @param name Name of the uniform variable to bind to.
  31790. */
  31791. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31792. /**
  31793. * Binds block to a uniform.
  31794. * @param blockName Name of the block to bind.
  31795. * @param index Index to bind.
  31796. */
  31797. bindUniformBlock(blockName: string, index: number): void;
  31798. /**
  31799. * Sets an interger value on a uniform variable.
  31800. * @param uniformName Name of the variable.
  31801. * @param value Value to be set.
  31802. * @returns this effect.
  31803. */
  31804. setInt(uniformName: string, value: number): Effect;
  31805. /**
  31806. * Sets an int array on a uniform variable.
  31807. * @param uniformName Name of the variable.
  31808. * @param array array to be set.
  31809. * @returns this effect.
  31810. */
  31811. setIntArray(uniformName: string, array: Int32Array): Effect;
  31812. /**
  31813. * 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)
  31814. * @param uniformName Name of the variable.
  31815. * @param array array to be set.
  31816. * @returns this effect.
  31817. */
  31818. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31819. /**
  31820. * 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)
  31821. * @param uniformName Name of the variable.
  31822. * @param array array to be set.
  31823. * @returns this effect.
  31824. */
  31825. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31826. /**
  31827. * 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)
  31828. * @param uniformName Name of the variable.
  31829. * @param array array to be set.
  31830. * @returns this effect.
  31831. */
  31832. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31833. /**
  31834. * Sets an float array on a uniform variable.
  31835. * @param uniformName Name of the variable.
  31836. * @param array array to be set.
  31837. * @returns this effect.
  31838. */
  31839. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31840. /**
  31841. * 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)
  31842. * @param uniformName Name of the variable.
  31843. * @param array array to be set.
  31844. * @returns this effect.
  31845. */
  31846. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31847. /**
  31848. * 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)
  31849. * @param uniformName Name of the variable.
  31850. * @param array array to be set.
  31851. * @returns this effect.
  31852. */
  31853. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31854. /**
  31855. * 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)
  31856. * @param uniformName Name of the variable.
  31857. * @param array array to be set.
  31858. * @returns this effect.
  31859. */
  31860. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31861. /**
  31862. * Sets an array on a uniform variable.
  31863. * @param uniformName Name of the variable.
  31864. * @param array array to be set.
  31865. * @returns this effect.
  31866. */
  31867. setArray(uniformName: string, array: number[]): Effect;
  31868. /**
  31869. * 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)
  31870. * @param uniformName Name of the variable.
  31871. * @param array array to be set.
  31872. * @returns this effect.
  31873. */
  31874. setArray2(uniformName: string, array: number[]): Effect;
  31875. /**
  31876. * 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)
  31877. * @param uniformName Name of the variable.
  31878. * @param array array to be set.
  31879. * @returns this effect.
  31880. */
  31881. setArray3(uniformName: string, array: number[]): Effect;
  31882. /**
  31883. * 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)
  31884. * @param uniformName Name of the variable.
  31885. * @param array array to be set.
  31886. * @returns this effect.
  31887. */
  31888. setArray4(uniformName: string, array: number[]): Effect;
  31889. /**
  31890. * Sets matrices on a uniform variable.
  31891. * @param uniformName Name of the variable.
  31892. * @param matrices matrices to be set.
  31893. * @returns this effect.
  31894. */
  31895. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31896. /**
  31897. * Sets matrix on a uniform variable.
  31898. * @param uniformName Name of the variable.
  31899. * @param matrix matrix to be set.
  31900. * @returns this effect.
  31901. */
  31902. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31903. /**
  31904. * 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)
  31905. * @param uniformName Name of the variable.
  31906. * @param matrix matrix to be set.
  31907. * @returns this effect.
  31908. */
  31909. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31910. /**
  31911. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31912. * @param uniformName Name of the variable.
  31913. * @param matrix matrix to be set.
  31914. * @returns this effect.
  31915. */
  31916. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31917. /**
  31918. * Sets a float on a uniform variable.
  31919. * @param uniformName Name of the variable.
  31920. * @param value value to be set.
  31921. * @returns this effect.
  31922. */
  31923. setFloat(uniformName: string, value: number): Effect;
  31924. /**
  31925. * Sets a boolean on a uniform variable.
  31926. * @param uniformName Name of the variable.
  31927. * @param bool value to be set.
  31928. * @returns this effect.
  31929. */
  31930. setBool(uniformName: string, bool: boolean): Effect;
  31931. /**
  31932. * Sets a Vector2 on a uniform variable.
  31933. * @param uniformName Name of the variable.
  31934. * @param vector2 vector2 to be set.
  31935. * @returns this effect.
  31936. */
  31937. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31938. /**
  31939. * Sets a float2 on a uniform variable.
  31940. * @param uniformName Name of the variable.
  31941. * @param x First float in float2.
  31942. * @param y Second float in float2.
  31943. * @returns this effect.
  31944. */
  31945. setFloat2(uniformName: string, x: number, y: number): Effect;
  31946. /**
  31947. * Sets a Vector3 on a uniform variable.
  31948. * @param uniformName Name of the variable.
  31949. * @param vector3 Value to be set.
  31950. * @returns this effect.
  31951. */
  31952. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31953. /**
  31954. * Sets a float3 on a uniform variable.
  31955. * @param uniformName Name of the variable.
  31956. * @param x First float in float3.
  31957. * @param y Second float in float3.
  31958. * @param z Third float in float3.
  31959. * @returns this effect.
  31960. */
  31961. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31962. /**
  31963. * Sets a Vector4 on a uniform variable.
  31964. * @param uniformName Name of the variable.
  31965. * @param vector4 Value to be set.
  31966. * @returns this effect.
  31967. */
  31968. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31969. /**
  31970. * Sets a float4 on a uniform variable.
  31971. * @param uniformName Name of the variable.
  31972. * @param x First float in float4.
  31973. * @param y Second float in float4.
  31974. * @param z Third float in float4.
  31975. * @param w Fourth float in float4.
  31976. * @returns this effect.
  31977. */
  31978. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31979. /**
  31980. * Sets a Color3 on a uniform variable.
  31981. * @param uniformName Name of the variable.
  31982. * @param color3 Value to be set.
  31983. * @returns this effect.
  31984. */
  31985. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31986. /**
  31987. * Sets a Color4 on a uniform variable.
  31988. * @param uniformName Name of the variable.
  31989. * @param color3 Value to be set.
  31990. * @param alpha Alpha value to be set.
  31991. * @returns this effect.
  31992. */
  31993. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31994. /**
  31995. * Sets a Color4 on a uniform variable
  31996. * @param uniformName defines the name of the variable
  31997. * @param color4 defines the value to be set
  31998. * @returns this effect.
  31999. */
  32000. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  32001. /** Release all associated resources */
  32002. dispose(): void;
  32003. /**
  32004. * This function will add a new shader to the shader store
  32005. * @param name the name of the shader
  32006. * @param pixelShader optional pixel shader content
  32007. * @param vertexShader optional vertex shader content
  32008. */
  32009. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  32010. /**
  32011. * Store of each shader (The can be looked up using effect.key)
  32012. */
  32013. static ShadersStore: {
  32014. [key: string]: string;
  32015. };
  32016. /**
  32017. * Store of each included file for a shader (The can be looked up using effect.key)
  32018. */
  32019. static IncludesShadersStore: {
  32020. [key: string]: string;
  32021. };
  32022. /**
  32023. * Resets the cache of effects.
  32024. */
  32025. static ResetCache(): void;
  32026. }
  32027. }
  32028. declare module "babylonjs/Engines/engineCapabilities" {
  32029. /**
  32030. * Interface used to describe the capabilities of the engine relatively to the current browser
  32031. */
  32032. export interface EngineCapabilities {
  32033. /** Maximum textures units per fragment shader */
  32034. maxTexturesImageUnits: number;
  32035. /** Maximum texture units per vertex shader */
  32036. maxVertexTextureImageUnits: number;
  32037. /** Maximum textures units in the entire pipeline */
  32038. maxCombinedTexturesImageUnits: number;
  32039. /** Maximum texture size */
  32040. maxTextureSize: number;
  32041. /** Maximum texture samples */
  32042. maxSamples?: number;
  32043. /** Maximum cube texture size */
  32044. maxCubemapTextureSize: number;
  32045. /** Maximum render texture size */
  32046. maxRenderTextureSize: number;
  32047. /** Maximum number of vertex attributes */
  32048. maxVertexAttribs: number;
  32049. /** Maximum number of varyings */
  32050. maxVaryingVectors: number;
  32051. /** Maximum number of uniforms per vertex shader */
  32052. maxVertexUniformVectors: number;
  32053. /** Maximum number of uniforms per fragment shader */
  32054. maxFragmentUniformVectors: number;
  32055. /** Defines if standard derivates (dx/dy) are supported */
  32056. standardDerivatives: boolean;
  32057. /** Defines if s3tc texture compression is supported */
  32058. s3tc?: WEBGL_compressed_texture_s3tc;
  32059. /** Defines if pvrtc texture compression is supported */
  32060. pvrtc: any;
  32061. /** Defines if etc1 texture compression is supported */
  32062. etc1: any;
  32063. /** Defines if etc2 texture compression is supported */
  32064. etc2: any;
  32065. /** Defines if astc texture compression is supported */
  32066. astc: any;
  32067. /** Defines if float textures are supported */
  32068. textureFloat: boolean;
  32069. /** Defines if vertex array objects are supported */
  32070. vertexArrayObject: boolean;
  32071. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  32072. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  32073. /** Gets the maximum level of anisotropy supported */
  32074. maxAnisotropy: number;
  32075. /** Defines if instancing is supported */
  32076. instancedArrays: boolean;
  32077. /** Defines if 32 bits indices are supported */
  32078. uintIndices: boolean;
  32079. /** Defines if high precision shaders are supported */
  32080. highPrecisionShaderSupported: boolean;
  32081. /** Defines if depth reading in the fragment shader is supported */
  32082. fragmentDepthSupported: boolean;
  32083. /** Defines if float texture linear filtering is supported*/
  32084. textureFloatLinearFiltering: boolean;
  32085. /** Defines if rendering to float textures is supported */
  32086. textureFloatRender: boolean;
  32087. /** Defines if half float textures are supported*/
  32088. textureHalfFloat: boolean;
  32089. /** Defines if half float texture linear filtering is supported*/
  32090. textureHalfFloatLinearFiltering: boolean;
  32091. /** Defines if rendering to half float textures is supported */
  32092. textureHalfFloatRender: boolean;
  32093. /** Defines if textureLOD shader command is supported */
  32094. textureLOD: boolean;
  32095. /** Defines if draw buffers extension is supported */
  32096. drawBuffersExtension: boolean;
  32097. /** Defines if depth textures are supported */
  32098. depthTextureExtension: boolean;
  32099. /** Defines if float color buffer are supported */
  32100. colorBufferFloat: boolean;
  32101. /** Gets disjoint timer query extension (null if not supported) */
  32102. timerQuery?: EXT_disjoint_timer_query;
  32103. /** Defines if timestamp can be used with timer query */
  32104. canUseTimestampForTimerQuery: boolean;
  32105. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  32106. multiview?: any;
  32107. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  32108. oculusMultiview?: any;
  32109. /** Function used to let the system compiles shaders in background */
  32110. parallelShaderCompile?: {
  32111. COMPLETION_STATUS_KHR: number;
  32112. };
  32113. /** Max number of texture samples for MSAA */
  32114. maxMSAASamples: number;
  32115. /** Defines if the blend min max extension is supported */
  32116. blendMinMax: boolean;
  32117. }
  32118. }
  32119. declare module "babylonjs/States/depthCullingState" {
  32120. import { Nullable } from "babylonjs/types";
  32121. /**
  32122. * @hidden
  32123. **/
  32124. export class DepthCullingState {
  32125. private _isDepthTestDirty;
  32126. private _isDepthMaskDirty;
  32127. private _isDepthFuncDirty;
  32128. private _isCullFaceDirty;
  32129. private _isCullDirty;
  32130. private _isZOffsetDirty;
  32131. private _isFrontFaceDirty;
  32132. private _depthTest;
  32133. private _depthMask;
  32134. private _depthFunc;
  32135. private _cull;
  32136. private _cullFace;
  32137. private _zOffset;
  32138. private _frontFace;
  32139. /**
  32140. * Initializes the state.
  32141. */
  32142. constructor();
  32143. get isDirty(): boolean;
  32144. get zOffset(): number;
  32145. set zOffset(value: number);
  32146. get cullFace(): Nullable<number>;
  32147. set cullFace(value: Nullable<number>);
  32148. get cull(): Nullable<boolean>;
  32149. set cull(value: Nullable<boolean>);
  32150. get depthFunc(): Nullable<number>;
  32151. set depthFunc(value: Nullable<number>);
  32152. get depthMask(): boolean;
  32153. set depthMask(value: boolean);
  32154. get depthTest(): boolean;
  32155. set depthTest(value: boolean);
  32156. get frontFace(): Nullable<number>;
  32157. set frontFace(value: Nullable<number>);
  32158. reset(): void;
  32159. apply(gl: WebGLRenderingContext): void;
  32160. }
  32161. }
  32162. declare module "babylonjs/States/stencilState" {
  32163. /**
  32164. * @hidden
  32165. **/
  32166. export class StencilState {
  32167. /** 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 */
  32168. static readonly ALWAYS: number;
  32169. /** Passed to stencilOperation to specify that stencil value must be kept */
  32170. static readonly KEEP: number;
  32171. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32172. static readonly REPLACE: number;
  32173. private _isStencilTestDirty;
  32174. private _isStencilMaskDirty;
  32175. private _isStencilFuncDirty;
  32176. private _isStencilOpDirty;
  32177. private _stencilTest;
  32178. private _stencilMask;
  32179. private _stencilFunc;
  32180. private _stencilFuncRef;
  32181. private _stencilFuncMask;
  32182. private _stencilOpStencilFail;
  32183. private _stencilOpDepthFail;
  32184. private _stencilOpStencilDepthPass;
  32185. get isDirty(): boolean;
  32186. get stencilFunc(): number;
  32187. set stencilFunc(value: number);
  32188. get stencilFuncRef(): number;
  32189. set stencilFuncRef(value: number);
  32190. get stencilFuncMask(): number;
  32191. set stencilFuncMask(value: number);
  32192. get stencilOpStencilFail(): number;
  32193. set stencilOpStencilFail(value: number);
  32194. get stencilOpDepthFail(): number;
  32195. set stencilOpDepthFail(value: number);
  32196. get stencilOpStencilDepthPass(): number;
  32197. set stencilOpStencilDepthPass(value: number);
  32198. get stencilMask(): number;
  32199. set stencilMask(value: number);
  32200. get stencilTest(): boolean;
  32201. set stencilTest(value: boolean);
  32202. constructor();
  32203. reset(): void;
  32204. apply(gl: WebGLRenderingContext): void;
  32205. }
  32206. }
  32207. declare module "babylonjs/States/alphaCullingState" {
  32208. /**
  32209. * @hidden
  32210. **/
  32211. export class AlphaState {
  32212. private _isAlphaBlendDirty;
  32213. private _isBlendFunctionParametersDirty;
  32214. private _isBlendEquationParametersDirty;
  32215. private _isBlendConstantsDirty;
  32216. private _alphaBlend;
  32217. private _blendFunctionParameters;
  32218. private _blendEquationParameters;
  32219. private _blendConstants;
  32220. /**
  32221. * Initializes the state.
  32222. */
  32223. constructor();
  32224. get isDirty(): boolean;
  32225. get alphaBlend(): boolean;
  32226. set alphaBlend(value: boolean);
  32227. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  32228. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  32229. setAlphaEquationParameters(rgb: number, alpha: number): void;
  32230. reset(): void;
  32231. apply(gl: WebGLRenderingContext): void;
  32232. }
  32233. }
  32234. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  32235. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32236. /** @hidden */
  32237. export class WebGL2ShaderProcessor implements IShaderProcessor {
  32238. attributeProcessor(attribute: string): string;
  32239. varyingProcessor(varying: string, isFragment: boolean): string;
  32240. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  32241. }
  32242. }
  32243. declare module "babylonjs/Engines/instancingAttributeInfo" {
  32244. /**
  32245. * Interface for attribute information associated with buffer instanciation
  32246. */
  32247. export interface InstancingAttributeInfo {
  32248. /**
  32249. * Name of the GLSL attribute
  32250. * if attribute index is not specified, this is used to retrieve the index from the effect
  32251. */
  32252. attributeName: string;
  32253. /**
  32254. * Index/offset of the attribute in the vertex shader
  32255. * if not specified, this will be computes from the name.
  32256. */
  32257. index?: number;
  32258. /**
  32259. * size of the attribute, 1, 2, 3 or 4
  32260. */
  32261. attributeSize: number;
  32262. /**
  32263. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32264. */
  32265. offset: number;
  32266. /**
  32267. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32268. * default to 1
  32269. */
  32270. divisor?: number;
  32271. /**
  32272. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32273. * default is FLOAT
  32274. */
  32275. attributeType?: number;
  32276. /**
  32277. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32278. */
  32279. normalized?: boolean;
  32280. }
  32281. }
  32282. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32283. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32284. import { Nullable } from "babylonjs/types";
  32285. module "babylonjs/Engines/thinEngine" {
  32286. interface ThinEngine {
  32287. /**
  32288. * Update a video texture
  32289. * @param texture defines the texture to update
  32290. * @param video defines the video element to use
  32291. * @param invertY defines if data must be stored with Y axis inverted
  32292. */
  32293. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32294. }
  32295. }
  32296. }
  32297. declare module "babylonjs/Materials/Textures/videoTexture" {
  32298. import { Observable } from "babylonjs/Misc/observable";
  32299. import { Nullable } from "babylonjs/types";
  32300. import { Scene } from "babylonjs/scene";
  32301. import { Texture } from "babylonjs/Materials/Textures/texture";
  32302. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32303. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  32304. /**
  32305. * Settings for finer control over video usage
  32306. */
  32307. export interface VideoTextureSettings {
  32308. /**
  32309. * Applies `autoplay` to video, if specified
  32310. */
  32311. autoPlay?: boolean;
  32312. /**
  32313. * Applies `loop` to video, if specified
  32314. */
  32315. loop?: boolean;
  32316. /**
  32317. * Automatically updates internal texture from video at every frame in the render loop
  32318. */
  32319. autoUpdateTexture: boolean;
  32320. /**
  32321. * Image src displayed during the video loading or until the user interacts with the video.
  32322. */
  32323. poster?: string;
  32324. }
  32325. /**
  32326. * If you want to display a video in your scene, this is the special texture for that.
  32327. * This special texture works similar to other textures, with the exception of a few parameters.
  32328. * @see https://doc.babylonjs.com/how_to/video_texture
  32329. */
  32330. export class VideoTexture extends Texture {
  32331. /**
  32332. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32333. */
  32334. readonly autoUpdateTexture: boolean;
  32335. /**
  32336. * The video instance used by the texture internally
  32337. */
  32338. readonly video: HTMLVideoElement;
  32339. private _onUserActionRequestedObservable;
  32340. /**
  32341. * Event triggerd when a dom action is required by the user to play the video.
  32342. * This happens due to recent changes in browser policies preventing video to auto start.
  32343. */
  32344. get onUserActionRequestedObservable(): Observable<Texture>;
  32345. private _generateMipMaps;
  32346. private _engine;
  32347. private _stillImageCaptured;
  32348. private _displayingPosterTexture;
  32349. private _settings;
  32350. private _createInternalTextureOnEvent;
  32351. private _frameId;
  32352. private _currentSrc;
  32353. /**
  32354. * Creates a video texture.
  32355. * If you want to display a video in your scene, this is the special texture for that.
  32356. * This special texture works similar to other textures, with the exception of a few parameters.
  32357. * @see https://doc.babylonjs.com/how_to/video_texture
  32358. * @param name optional name, will detect from video source, if not defined
  32359. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32360. * @param scene is obviously the current scene.
  32361. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32362. * @param invertY is false by default but can be used to invert video on Y axis
  32363. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32364. * @param settings allows finer control over video usage
  32365. */
  32366. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32367. private _getName;
  32368. private _getVideo;
  32369. private _createInternalTexture;
  32370. private reset;
  32371. /**
  32372. * @hidden Internal method to initiate `update`.
  32373. */
  32374. _rebuild(): void;
  32375. /**
  32376. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32377. */
  32378. update(): void;
  32379. /**
  32380. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32381. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32382. */
  32383. updateTexture(isVisible: boolean): void;
  32384. protected _updateInternalTexture: () => void;
  32385. /**
  32386. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32387. * @param url New url.
  32388. */
  32389. updateURL(url: string): void;
  32390. /**
  32391. * Clones the texture.
  32392. * @returns the cloned texture
  32393. */
  32394. clone(): VideoTexture;
  32395. /**
  32396. * Dispose the texture and release its associated resources.
  32397. */
  32398. dispose(): void;
  32399. /**
  32400. * Creates a video texture straight from a stream.
  32401. * @param scene Define the scene the texture should be created in
  32402. * @param stream Define the stream the texture should be created from
  32403. * @returns The created video texture as a promise
  32404. */
  32405. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32406. /**
  32407. * Creates a video texture straight from your WebCam video feed.
  32408. * @param scene Define the scene the texture should be created in
  32409. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32410. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32411. * @returns The created video texture as a promise
  32412. */
  32413. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32414. minWidth: number;
  32415. maxWidth: number;
  32416. minHeight: number;
  32417. maxHeight: number;
  32418. deviceId: string;
  32419. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32420. /**
  32421. * Creates a video texture straight from your WebCam video feed.
  32422. * @param scene Define the scene the texture should be created in
  32423. * @param onReady Define a callback to triggered once the texture will be ready
  32424. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32425. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32426. */
  32427. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32428. minWidth: number;
  32429. maxWidth: number;
  32430. minHeight: number;
  32431. maxHeight: number;
  32432. deviceId: string;
  32433. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32434. }
  32435. }
  32436. declare module "babylonjs/Engines/thinEngine" {
  32437. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32438. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32439. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32440. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32441. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32442. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32443. import { Observable } from "babylonjs/Misc/observable";
  32444. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32445. import { StencilState } from "babylonjs/States/stencilState";
  32446. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32448. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32449. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32450. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32451. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32452. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32453. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32454. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32456. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32457. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32458. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32459. import { WebRequest } from "babylonjs/Misc/webRequest";
  32460. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32461. /**
  32462. * Defines the interface used by objects working like Scene
  32463. * @hidden
  32464. */
  32465. export interface ISceneLike {
  32466. _addPendingData(data: any): void;
  32467. _removePendingData(data: any): void;
  32468. offlineProvider: IOfflineProvider;
  32469. }
  32470. /** Interface defining initialization parameters for Engine class */
  32471. export interface EngineOptions extends WebGLContextAttributes {
  32472. /**
  32473. * Defines if the engine should no exceed a specified device ratio
  32474. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32475. */
  32476. limitDeviceRatio?: number;
  32477. /**
  32478. * Defines if webvr should be enabled automatically
  32479. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32480. */
  32481. autoEnableWebVR?: boolean;
  32482. /**
  32483. * Defines if webgl2 should be turned off even if supported
  32484. * @see http://doc.babylonjs.com/features/webgl2
  32485. */
  32486. disableWebGL2Support?: boolean;
  32487. /**
  32488. * Defines if webaudio should be initialized as well
  32489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32490. */
  32491. audioEngine?: boolean;
  32492. /**
  32493. * Defines if animations should run using a deterministic lock step
  32494. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32495. */
  32496. deterministicLockstep?: boolean;
  32497. /** Defines the maximum steps to use with deterministic lock step mode */
  32498. lockstepMaxSteps?: number;
  32499. /** Defines the seconds between each deterministic lock step */
  32500. timeStep?: number;
  32501. /**
  32502. * Defines that engine should ignore context lost events
  32503. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32504. */
  32505. doNotHandleContextLost?: boolean;
  32506. /**
  32507. * Defines that engine should ignore modifying touch action attribute and style
  32508. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32509. */
  32510. doNotHandleTouchAction?: boolean;
  32511. /**
  32512. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32513. */
  32514. useHighPrecisionFloats?: boolean;
  32515. }
  32516. /**
  32517. * The base engine class (root of all engines)
  32518. */
  32519. export class ThinEngine {
  32520. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32521. static ExceptionList: ({
  32522. key: string;
  32523. capture: string;
  32524. captureConstraint: number;
  32525. targets: string[];
  32526. } | {
  32527. key: string;
  32528. capture: null;
  32529. captureConstraint: null;
  32530. targets: string[];
  32531. })[];
  32532. /** @hidden */
  32533. static _TextureLoaders: IInternalTextureLoader[];
  32534. /**
  32535. * Returns the current npm package of the sdk
  32536. */
  32537. static get NpmPackage(): string;
  32538. /**
  32539. * Returns the current version of the framework
  32540. */
  32541. static get Version(): string;
  32542. /**
  32543. * Returns a string describing the current engine
  32544. */
  32545. get description(): string;
  32546. /**
  32547. * Gets or sets the epsilon value used by collision engine
  32548. */
  32549. static CollisionsEpsilon: number;
  32550. /**
  32551. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32552. */
  32553. static get ShadersRepository(): string;
  32554. static set ShadersRepository(value: string);
  32555. /** @hidden */
  32556. _shaderProcessor: IShaderProcessor;
  32557. /**
  32558. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32559. */
  32560. forcePOTTextures: boolean;
  32561. /**
  32562. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32563. */
  32564. isFullscreen: boolean;
  32565. /**
  32566. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32567. */
  32568. cullBackFaces: boolean;
  32569. /**
  32570. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32571. */
  32572. renderEvenInBackground: boolean;
  32573. /**
  32574. * Gets or sets a boolean indicating that cache can be kept between frames
  32575. */
  32576. preventCacheWipeBetweenFrames: boolean;
  32577. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32578. validateShaderPrograms: boolean;
  32579. /**
  32580. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32581. * This can provide greater z depth for distant objects.
  32582. */
  32583. useReverseDepthBuffer: boolean;
  32584. /**
  32585. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32586. */
  32587. disableUniformBuffers: boolean;
  32588. /** @hidden */
  32589. _uniformBuffers: UniformBuffer[];
  32590. /**
  32591. * Gets a boolean indicating that the engine supports uniform buffers
  32592. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32593. */
  32594. get supportsUniformBuffers(): boolean;
  32595. /** @hidden */
  32596. _gl: WebGLRenderingContext;
  32597. /** @hidden */
  32598. _webGLVersion: number;
  32599. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32600. protected _windowIsBackground: boolean;
  32601. protected _creationOptions: EngineOptions;
  32602. protected _highPrecisionShadersAllowed: boolean;
  32603. /** @hidden */
  32604. get _shouldUseHighPrecisionShader(): boolean;
  32605. /**
  32606. * Gets a boolean indicating that only power of 2 textures are supported
  32607. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32608. */
  32609. get needPOTTextures(): boolean;
  32610. /** @hidden */
  32611. _badOS: boolean;
  32612. /** @hidden */
  32613. _badDesktopOS: boolean;
  32614. private _hardwareScalingLevel;
  32615. /** @hidden */
  32616. _caps: EngineCapabilities;
  32617. private _isStencilEnable;
  32618. private _glVersion;
  32619. private _glRenderer;
  32620. private _glVendor;
  32621. /** @hidden */
  32622. _videoTextureSupported: boolean;
  32623. protected _renderingQueueLaunched: boolean;
  32624. protected _activeRenderLoops: (() => void)[];
  32625. /**
  32626. * Observable signaled when a context lost event is raised
  32627. */
  32628. onContextLostObservable: Observable<ThinEngine>;
  32629. /**
  32630. * Observable signaled when a context restored event is raised
  32631. */
  32632. onContextRestoredObservable: Observable<ThinEngine>;
  32633. private _onContextLost;
  32634. private _onContextRestored;
  32635. protected _contextWasLost: boolean;
  32636. /** @hidden */
  32637. _doNotHandleContextLost: boolean;
  32638. /**
  32639. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32641. */
  32642. get doNotHandleContextLost(): boolean;
  32643. set doNotHandleContextLost(value: boolean);
  32644. /**
  32645. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32646. */
  32647. disableVertexArrayObjects: boolean;
  32648. /** @hidden */
  32649. protected _colorWrite: boolean;
  32650. /** @hidden */
  32651. protected _colorWriteChanged: boolean;
  32652. /** @hidden */
  32653. protected _depthCullingState: DepthCullingState;
  32654. /** @hidden */
  32655. protected _stencilState: StencilState;
  32656. /** @hidden */
  32657. _alphaState: AlphaState;
  32658. /** @hidden */
  32659. _alphaMode: number;
  32660. /** @hidden */
  32661. _alphaEquation: number;
  32662. /** @hidden */
  32663. _internalTexturesCache: InternalTexture[];
  32664. /** @hidden */
  32665. protected _activeChannel: number;
  32666. private _currentTextureChannel;
  32667. /** @hidden */
  32668. protected _boundTexturesCache: {
  32669. [key: string]: Nullable<InternalTexture>;
  32670. };
  32671. /** @hidden */
  32672. protected _currentEffect: Nullable<Effect>;
  32673. /** @hidden */
  32674. protected _currentProgram: Nullable<WebGLProgram>;
  32675. private _compiledEffects;
  32676. private _vertexAttribArraysEnabled;
  32677. /** @hidden */
  32678. protected _cachedViewport: Nullable<IViewportLike>;
  32679. private _cachedVertexArrayObject;
  32680. /** @hidden */
  32681. protected _cachedVertexBuffers: any;
  32682. /** @hidden */
  32683. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32684. /** @hidden */
  32685. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32686. /** @hidden */
  32687. _currentRenderTarget: Nullable<InternalTexture>;
  32688. private _uintIndicesCurrentlySet;
  32689. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32690. /** @hidden */
  32691. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32692. private _currentBufferPointers;
  32693. private _currentInstanceLocations;
  32694. private _currentInstanceBuffers;
  32695. private _textureUnits;
  32696. /** @hidden */
  32697. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32698. /** @hidden */
  32699. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32700. /** @hidden */
  32701. _boundRenderFunction: any;
  32702. private _vaoRecordInProgress;
  32703. private _mustWipeVertexAttributes;
  32704. private _emptyTexture;
  32705. private _emptyCubeTexture;
  32706. private _emptyTexture3D;
  32707. private _emptyTexture2DArray;
  32708. /** @hidden */
  32709. _frameHandler: number;
  32710. private _nextFreeTextureSlots;
  32711. private _maxSimultaneousTextures;
  32712. private _activeRequests;
  32713. /** @hidden */
  32714. _transformTextureUrl: Nullable<(url: string) => string>;
  32715. protected get _supportsHardwareTextureRescaling(): boolean;
  32716. private _framebufferDimensionsObject;
  32717. /**
  32718. * sets the object from which width and height will be taken from when getting render width and height
  32719. * Will fallback to the gl object
  32720. * @param dimensions the framebuffer width and height that will be used.
  32721. */
  32722. set framebufferDimensionsObject(dimensions: Nullable<{
  32723. framebufferWidth: number;
  32724. framebufferHeight: number;
  32725. }>);
  32726. /**
  32727. * Gets the current viewport
  32728. */
  32729. get currentViewport(): Nullable<IViewportLike>;
  32730. /**
  32731. * Gets the default empty texture
  32732. */
  32733. get emptyTexture(): InternalTexture;
  32734. /**
  32735. * Gets the default empty 3D texture
  32736. */
  32737. get emptyTexture3D(): InternalTexture;
  32738. /**
  32739. * Gets the default empty 2D array texture
  32740. */
  32741. get emptyTexture2DArray(): InternalTexture;
  32742. /**
  32743. * Gets the default empty cube texture
  32744. */
  32745. get emptyCubeTexture(): InternalTexture;
  32746. /**
  32747. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32748. */
  32749. readonly premultipliedAlpha: boolean;
  32750. /**
  32751. * Observable event triggered before each texture is initialized
  32752. */
  32753. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32754. /**
  32755. * Creates a new engine
  32756. * @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
  32757. * @param antialias defines enable antialiasing (default: false)
  32758. * @param options defines further options to be sent to the getContext() function
  32759. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32760. */
  32761. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32762. private _rebuildInternalTextures;
  32763. private _rebuildEffects;
  32764. /**
  32765. * Gets a boolean indicating if all created effects are ready
  32766. * @returns true if all effects are ready
  32767. */
  32768. areAllEffectsReady(): boolean;
  32769. protected _rebuildBuffers(): void;
  32770. protected _initGLContext(): void;
  32771. /**
  32772. * Gets version of the current webGL context
  32773. */
  32774. get webGLVersion(): number;
  32775. /**
  32776. * Gets a string idenfifying the name of the class
  32777. * @returns "Engine" string
  32778. */
  32779. getClassName(): string;
  32780. /**
  32781. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32782. */
  32783. get isStencilEnable(): boolean;
  32784. /** @hidden */
  32785. _prepareWorkingCanvas(): void;
  32786. /**
  32787. * Reset the texture cache to empty state
  32788. */
  32789. resetTextureCache(): void;
  32790. /**
  32791. * Gets an object containing information about the current webGL context
  32792. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32793. */
  32794. getGlInfo(): {
  32795. vendor: string;
  32796. renderer: string;
  32797. version: string;
  32798. };
  32799. /**
  32800. * Defines the hardware scaling level.
  32801. * By default the hardware scaling level is computed from the window device ratio.
  32802. * 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.
  32803. * @param level defines the level to use
  32804. */
  32805. setHardwareScalingLevel(level: number): void;
  32806. /**
  32807. * Gets the current hardware scaling level.
  32808. * By default the hardware scaling level is computed from the window device ratio.
  32809. * 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.
  32810. * @returns a number indicating the current hardware scaling level
  32811. */
  32812. getHardwareScalingLevel(): number;
  32813. /**
  32814. * Gets the list of loaded textures
  32815. * @returns an array containing all loaded textures
  32816. */
  32817. getLoadedTexturesCache(): InternalTexture[];
  32818. /**
  32819. * Gets the object containing all engine capabilities
  32820. * @returns the EngineCapabilities object
  32821. */
  32822. getCaps(): EngineCapabilities;
  32823. /**
  32824. * stop executing a render loop function and remove it from the execution array
  32825. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32826. */
  32827. stopRenderLoop(renderFunction?: () => void): void;
  32828. /** @hidden */
  32829. _renderLoop(): void;
  32830. /**
  32831. * Gets the HTML canvas attached with the current webGL context
  32832. * @returns a HTML canvas
  32833. */
  32834. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32835. /**
  32836. * Gets host window
  32837. * @returns the host window object
  32838. */
  32839. getHostWindow(): Nullable<Window>;
  32840. /**
  32841. * Gets the current render width
  32842. * @param useScreen defines if screen size must be used (or the current render target if any)
  32843. * @returns a number defining the current render width
  32844. */
  32845. getRenderWidth(useScreen?: boolean): number;
  32846. /**
  32847. * Gets the current render height
  32848. * @param useScreen defines if screen size must be used (or the current render target if any)
  32849. * @returns a number defining the current render height
  32850. */
  32851. getRenderHeight(useScreen?: boolean): number;
  32852. /**
  32853. * Can be used to override the current requestAnimationFrame requester.
  32854. * @hidden
  32855. */
  32856. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32857. /**
  32858. * Register and execute a render loop. The engine can have more than one render function
  32859. * @param renderFunction defines the function to continuously execute
  32860. */
  32861. runRenderLoop(renderFunction: () => void): void;
  32862. /**
  32863. * Clear the current render buffer or the current render target (if any is set up)
  32864. * @param color defines the color to use
  32865. * @param backBuffer defines if the back buffer must be cleared
  32866. * @param depth defines if the depth buffer must be cleared
  32867. * @param stencil defines if the stencil buffer must be cleared
  32868. */
  32869. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32870. private _viewportCached;
  32871. /** @hidden */
  32872. _viewport(x: number, y: number, width: number, height: number): void;
  32873. /**
  32874. * Set the WebGL's viewport
  32875. * @param viewport defines the viewport element to be used
  32876. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32877. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32878. */
  32879. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32880. /**
  32881. * Begin a new frame
  32882. */
  32883. beginFrame(): void;
  32884. /**
  32885. * Enf the current frame
  32886. */
  32887. endFrame(): void;
  32888. /**
  32889. * Resize the view according to the canvas' size
  32890. */
  32891. resize(): void;
  32892. /**
  32893. * Force a specific size of the canvas
  32894. * @param width defines the new canvas' width
  32895. * @param height defines the new canvas' height
  32896. */
  32897. setSize(width: number, height: number): void;
  32898. /**
  32899. * Binds the frame buffer to the specified texture.
  32900. * @param texture The texture to render to or null for the default canvas
  32901. * @param faceIndex The face of the texture to render to in case of cube texture
  32902. * @param requiredWidth The width of the target to render to
  32903. * @param requiredHeight The height of the target to render to
  32904. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32905. * @param lodLevel defines the lod level to bind to the frame buffer
  32906. * @param layer defines the 2d array index to bind to frame buffer to
  32907. */
  32908. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32909. /** @hidden */
  32910. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32911. /**
  32912. * Unbind the current render target texture from the webGL context
  32913. * @param texture defines the render target texture to unbind
  32914. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32915. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32916. */
  32917. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32918. /**
  32919. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32920. */
  32921. flushFramebuffer(): void;
  32922. /**
  32923. * Unbind the current render target and bind the default framebuffer
  32924. */
  32925. restoreDefaultFramebuffer(): void;
  32926. /** @hidden */
  32927. protected _resetVertexBufferBinding(): void;
  32928. /**
  32929. * Creates a vertex buffer
  32930. * @param data the data for the vertex buffer
  32931. * @returns the new WebGL static buffer
  32932. */
  32933. createVertexBuffer(data: DataArray): DataBuffer;
  32934. private _createVertexBuffer;
  32935. /**
  32936. * Creates a dynamic vertex buffer
  32937. * @param data the data for the dynamic vertex buffer
  32938. * @returns the new WebGL dynamic buffer
  32939. */
  32940. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32941. protected _resetIndexBufferBinding(): void;
  32942. /**
  32943. * Creates a new index buffer
  32944. * @param indices defines the content of the index buffer
  32945. * @param updatable defines if the index buffer must be updatable
  32946. * @returns a new webGL buffer
  32947. */
  32948. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32949. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32950. /**
  32951. * Bind a webGL buffer to the webGL context
  32952. * @param buffer defines the buffer to bind
  32953. */
  32954. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32955. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32956. private bindBuffer;
  32957. /**
  32958. * update the bound buffer with the given data
  32959. * @param data defines the data to update
  32960. */
  32961. updateArrayBuffer(data: Float32Array): void;
  32962. private _vertexAttribPointer;
  32963. /** @hidden */
  32964. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32965. private _bindVertexBuffersAttributes;
  32966. /**
  32967. * Records a vertex array object
  32968. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32969. * @param vertexBuffers defines the list of vertex buffers to store
  32970. * @param indexBuffer defines the index buffer to store
  32971. * @param effect defines the effect to store
  32972. * @returns the new vertex array object
  32973. */
  32974. recordVertexArrayObject(vertexBuffers: {
  32975. [key: string]: VertexBuffer;
  32976. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32977. /**
  32978. * Bind a specific vertex array object
  32979. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32980. * @param vertexArrayObject defines the vertex array object to bind
  32981. * @param indexBuffer defines the index buffer to bind
  32982. */
  32983. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32984. /**
  32985. * Bind webGl buffers directly to the webGL context
  32986. * @param vertexBuffer defines the vertex buffer to bind
  32987. * @param indexBuffer defines the index buffer to bind
  32988. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32989. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32990. * @param effect defines the effect associated with the vertex buffer
  32991. */
  32992. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32993. private _unbindVertexArrayObject;
  32994. /**
  32995. * Bind a list of vertex buffers to the webGL context
  32996. * @param vertexBuffers defines the list of vertex buffers to bind
  32997. * @param indexBuffer defines the index buffer to bind
  32998. * @param effect defines the effect associated with the vertex buffers
  32999. */
  33000. bindBuffers(vertexBuffers: {
  33001. [key: string]: Nullable<VertexBuffer>;
  33002. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  33003. /**
  33004. * Unbind all instance attributes
  33005. */
  33006. unbindInstanceAttributes(): void;
  33007. /**
  33008. * Release and free the memory of a vertex array object
  33009. * @param vao defines the vertex array object to delete
  33010. */
  33011. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  33012. /** @hidden */
  33013. _releaseBuffer(buffer: DataBuffer): boolean;
  33014. protected _deleteBuffer(buffer: DataBuffer): void;
  33015. /**
  33016. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  33017. * @param instancesBuffer defines the webGL buffer to update and bind
  33018. * @param data defines the data to store in the buffer
  33019. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  33020. */
  33021. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  33022. /**
  33023. * Bind the content of a webGL buffer used with instantiation
  33024. * @param instancesBuffer defines the webGL buffer to bind
  33025. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  33026. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  33027. */
  33028. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  33029. /**
  33030. * Disable the instance attribute corresponding to the name in parameter
  33031. * @param name defines the name of the attribute to disable
  33032. */
  33033. disableInstanceAttributeByName(name: string): void;
  33034. /**
  33035. * Disable the instance attribute corresponding to the location in parameter
  33036. * @param attributeLocation defines the attribute location of the attribute to disable
  33037. */
  33038. disableInstanceAttribute(attributeLocation: number): void;
  33039. /**
  33040. * Disable the attribute corresponding to the location in parameter
  33041. * @param attributeLocation defines the attribute location of the attribute to disable
  33042. */
  33043. disableAttributeByIndex(attributeLocation: number): void;
  33044. /**
  33045. * Send a draw order
  33046. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33047. * @param indexStart defines the starting index
  33048. * @param indexCount defines the number of index to draw
  33049. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33050. */
  33051. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  33052. /**
  33053. * Draw a list of points
  33054. * @param verticesStart defines the index of first vertex to draw
  33055. * @param verticesCount defines the count of vertices to draw
  33056. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33057. */
  33058. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33059. /**
  33060. * Draw a list of unindexed primitives
  33061. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  33062. * @param verticesStart defines the index of first vertex to draw
  33063. * @param verticesCount defines the count of vertices to draw
  33064. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33065. */
  33066. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33067. /**
  33068. * Draw a list of indexed primitives
  33069. * @param fillMode defines the primitive to use
  33070. * @param indexStart defines the starting index
  33071. * @param indexCount defines the number of index to draw
  33072. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33073. */
  33074. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  33075. /**
  33076. * Draw a list of unindexed primitives
  33077. * @param fillMode defines the primitive to use
  33078. * @param verticesStart defines the index of first vertex to draw
  33079. * @param verticesCount defines the count of vertices to draw
  33080. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  33081. */
  33082. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  33083. private _drawMode;
  33084. /** @hidden */
  33085. protected _reportDrawCall(): void;
  33086. /** @hidden */
  33087. _releaseEffect(effect: Effect): void;
  33088. /** @hidden */
  33089. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33090. /**
  33091. * Create a new effect (used to store vertex/fragment shaders)
  33092. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  33093. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  33094. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  33095. * @param samplers defines an array of string used to represent textures
  33096. * @param defines defines the string containing the defines to use to compile the shaders
  33097. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33098. * @param onCompiled defines a function to call when the effect creation is successful
  33099. * @param onError defines a function to call when the effect creation has failed
  33100. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  33101. * @returns the new Effect
  33102. */
  33103. 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;
  33104. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  33105. private _compileShader;
  33106. private _compileRawShader;
  33107. /** @hidden */
  33108. _getShaderSource(shader: WebGLShader): Nullable<string>;
  33109. /**
  33110. * Directly creates a webGL program
  33111. * @param pipelineContext defines the pipeline context to attach to
  33112. * @param vertexCode defines the vertex shader code to use
  33113. * @param fragmentCode defines the fragment shader code to use
  33114. * @param context defines the webGL context to use (if not set, the current one will be used)
  33115. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33116. * @returns the new webGL program
  33117. */
  33118. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33119. /**
  33120. * Creates a webGL program
  33121. * @param pipelineContext defines the pipeline context to attach to
  33122. * @param vertexCode defines the vertex shader code to use
  33123. * @param fragmentCode defines the fragment shader code to use
  33124. * @param defines defines the string containing the defines to use to compile the shaders
  33125. * @param context defines the webGL context to use (if not set, the current one will be used)
  33126. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  33127. * @returns the new webGL program
  33128. */
  33129. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33130. /**
  33131. * Creates a new pipeline context
  33132. * @returns the new pipeline
  33133. */
  33134. createPipelineContext(): IPipelineContext;
  33135. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33136. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  33137. /** @hidden */
  33138. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  33139. /** @hidden */
  33140. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  33141. /** @hidden */
  33142. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  33143. /**
  33144. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  33145. * @param pipelineContext defines the pipeline context to use
  33146. * @param uniformsNames defines the list of uniform names
  33147. * @returns an array of webGL uniform locations
  33148. */
  33149. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  33150. /**
  33151. * Gets the lsit of active attributes for a given webGL program
  33152. * @param pipelineContext defines the pipeline context to use
  33153. * @param attributesNames defines the list of attribute names to get
  33154. * @returns an array of indices indicating the offset of each attribute
  33155. */
  33156. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  33157. /**
  33158. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  33159. * @param effect defines the effect to activate
  33160. */
  33161. enableEffect(effect: Nullable<Effect>): void;
  33162. /**
  33163. * Set the value of an uniform to a number (int)
  33164. * @param uniform defines the webGL uniform location where to store the value
  33165. * @param value defines the int number to store
  33166. */
  33167. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33168. /**
  33169. * Set the value of an uniform to an array of int32
  33170. * @param uniform defines the webGL uniform location where to store the value
  33171. * @param array defines the array of int32 to store
  33172. */
  33173. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33174. /**
  33175. * Set the value of an uniform to an array of int32 (stored as vec2)
  33176. * @param uniform defines the webGL uniform location where to store the value
  33177. * @param array defines the array of int32 to store
  33178. */
  33179. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33180. /**
  33181. * Set the value of an uniform to an array of int32 (stored as vec3)
  33182. * @param uniform defines the webGL uniform location where to store the value
  33183. * @param array defines the array of int32 to store
  33184. */
  33185. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33186. /**
  33187. * Set the value of an uniform to an array of int32 (stored as vec4)
  33188. * @param uniform defines the webGL uniform location where to store the value
  33189. * @param array defines the array of int32 to store
  33190. */
  33191. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  33192. /**
  33193. * Set the value of an uniform to an array of number
  33194. * @param uniform defines the webGL uniform location where to store the value
  33195. * @param array defines the array of number to store
  33196. */
  33197. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33198. /**
  33199. * Set the value of an uniform to an array of number (stored as vec2)
  33200. * @param uniform defines the webGL uniform location where to store the value
  33201. * @param array defines the array of number to store
  33202. */
  33203. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33204. /**
  33205. * Set the value of an uniform to an array of number (stored as vec3)
  33206. * @param uniform defines the webGL uniform location where to store the value
  33207. * @param array defines the array of number to store
  33208. */
  33209. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33210. /**
  33211. * Set the value of an uniform to an array of number (stored as vec4)
  33212. * @param uniform defines the webGL uniform location where to store the value
  33213. * @param array defines the array of number to store
  33214. */
  33215. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  33216. /**
  33217. * Set the value of an uniform to an array of float32 (stored as matrices)
  33218. * @param uniform defines the webGL uniform location where to store the value
  33219. * @param matrices defines the array of float32 to store
  33220. */
  33221. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  33222. /**
  33223. * Set the value of an uniform to a matrix (3x3)
  33224. * @param uniform defines the webGL uniform location where to store the value
  33225. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  33226. */
  33227. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33228. /**
  33229. * Set the value of an uniform to a matrix (2x2)
  33230. * @param uniform defines the webGL uniform location where to store the value
  33231. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  33232. */
  33233. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  33234. /**
  33235. * Set the value of an uniform to a number (float)
  33236. * @param uniform defines the webGL uniform location where to store the value
  33237. * @param value defines the float number to store
  33238. */
  33239. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  33240. /**
  33241. * Set the value of an uniform to a vec2
  33242. * @param uniform defines the webGL uniform location where to store the value
  33243. * @param x defines the 1st component of the value
  33244. * @param y defines the 2nd component of the value
  33245. */
  33246. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33247. /**
  33248. * Set the value of an uniform to a vec3
  33249. * @param uniform defines the webGL uniform location where to store the value
  33250. * @param x defines the 1st component of the value
  33251. * @param y defines the 2nd component of the value
  33252. * @param z defines the 3rd component of the value
  33253. */
  33254. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33255. /**
  33256. * Set the value of an uniform to a vec4
  33257. * @param uniform defines the webGL uniform location where to store the value
  33258. * @param x defines the 1st component of the value
  33259. * @param y defines the 2nd component of the value
  33260. * @param z defines the 3rd component of the value
  33261. * @param w defines the 4th component of the value
  33262. */
  33263. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33264. /**
  33265. * Apply all cached states (depth, culling, stencil and alpha)
  33266. */
  33267. applyStates(): void;
  33268. /**
  33269. * Enable or disable color writing
  33270. * @param enable defines the state to set
  33271. */
  33272. setColorWrite(enable: boolean): void;
  33273. /**
  33274. * Gets a boolean indicating if color writing is enabled
  33275. * @returns the current color writing state
  33276. */
  33277. getColorWrite(): boolean;
  33278. /**
  33279. * Gets the depth culling state manager
  33280. */
  33281. get depthCullingState(): DepthCullingState;
  33282. /**
  33283. * Gets the alpha state manager
  33284. */
  33285. get alphaState(): AlphaState;
  33286. /**
  33287. * Gets the stencil state manager
  33288. */
  33289. get stencilState(): StencilState;
  33290. /**
  33291. * Clears the list of texture accessible through engine.
  33292. * This can help preventing texture load conflict due to name collision.
  33293. */
  33294. clearInternalTexturesCache(): void;
  33295. /**
  33296. * Force the entire cache to be cleared
  33297. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33298. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33299. */
  33300. wipeCaches(bruteForce?: boolean): void;
  33301. /** @hidden */
  33302. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33303. min: number;
  33304. mag: number;
  33305. };
  33306. /** @hidden */
  33307. _createTexture(): WebGLTexture;
  33308. /**
  33309. * Usually called from Texture.ts.
  33310. * Passed information to create a WebGLTexture
  33311. * @param url defines a value which contains one of the following:
  33312. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33313. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33314. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33315. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33316. * @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)
  33317. * @param scene needed for loading to the correct scene
  33318. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33319. * @param onLoad optional callback to be called upon successful completion
  33320. * @param onError optional callback to be called upon failure
  33321. * @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
  33322. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33323. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33324. * @param forcedExtension defines the extension to use to pick the right loader
  33325. * @param mimeType defines an optional mime type
  33326. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33327. */
  33328. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  33329. /**
  33330. * Loads an image as an HTMLImageElement.
  33331. * @param input url string, ArrayBuffer, or Blob to load
  33332. * @param onLoad callback called when the image successfully loads
  33333. * @param onError callback called when the image fails to load
  33334. * @param offlineProvider offline provider for caching
  33335. * @param mimeType optional mime type
  33336. * @returns the HTMLImageElement of the loaded image
  33337. * @hidden
  33338. */
  33339. 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>;
  33340. /**
  33341. * @hidden
  33342. */
  33343. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33344. private _unpackFlipYCached;
  33345. /**
  33346. * In case you are sharing the context with other applications, it might
  33347. * be interested to not cache the unpack flip y state to ensure a consistent
  33348. * value would be set.
  33349. */
  33350. enableUnpackFlipYCached: boolean;
  33351. /** @hidden */
  33352. _unpackFlipY(value: boolean): void;
  33353. /** @hidden */
  33354. _getUnpackAlignement(): number;
  33355. private _getTextureTarget;
  33356. /**
  33357. * Update the sampling mode of a given texture
  33358. * @param samplingMode defines the required sampling mode
  33359. * @param texture defines the texture to update
  33360. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33361. */
  33362. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33363. /**
  33364. * Update the sampling mode of a given texture
  33365. * @param texture defines the texture to update
  33366. * @param wrapU defines the texture wrap mode of the u coordinates
  33367. * @param wrapV defines the texture wrap mode of the v coordinates
  33368. * @param wrapR defines the texture wrap mode of the r coordinates
  33369. */
  33370. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33371. /** @hidden */
  33372. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33373. width: number;
  33374. height: number;
  33375. layers?: number;
  33376. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33377. /** @hidden */
  33378. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33379. /** @hidden */
  33380. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33381. /**
  33382. * Update a portion of an internal texture
  33383. * @param texture defines the texture to update
  33384. * @param imageData defines the data to store into the texture
  33385. * @param xOffset defines the x coordinates of the update rectangle
  33386. * @param yOffset defines the y coordinates of the update rectangle
  33387. * @param width defines the width of the update rectangle
  33388. * @param height defines the height of the update rectangle
  33389. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33390. * @param lod defines the lod level to update (0 by default)
  33391. */
  33392. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33393. /** @hidden */
  33394. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33395. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33396. private _prepareWebGLTexture;
  33397. /** @hidden */
  33398. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33399. private _getDepthStencilBuffer;
  33400. /** @hidden */
  33401. _releaseFramebufferObjects(texture: InternalTexture): void;
  33402. /** @hidden */
  33403. _releaseTexture(texture: InternalTexture): void;
  33404. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33405. protected _setProgram(program: WebGLProgram): void;
  33406. protected _boundUniforms: {
  33407. [key: number]: WebGLUniformLocation;
  33408. };
  33409. /**
  33410. * Binds an effect to the webGL context
  33411. * @param effect defines the effect to bind
  33412. */
  33413. bindSamplers(effect: Effect): void;
  33414. private _activateCurrentTexture;
  33415. /** @hidden */
  33416. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33417. /** @hidden */
  33418. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33419. /**
  33420. * Unbind all textures from the webGL context
  33421. */
  33422. unbindAllTextures(): void;
  33423. /**
  33424. * Sets a texture to the according uniform.
  33425. * @param channel The texture channel
  33426. * @param uniform The uniform to set
  33427. * @param texture The texture to apply
  33428. */
  33429. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33430. private _bindSamplerUniformToChannel;
  33431. private _getTextureWrapMode;
  33432. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33433. /**
  33434. * Sets an array of texture to the webGL context
  33435. * @param channel defines the channel where the texture array must be set
  33436. * @param uniform defines the associated uniform location
  33437. * @param textures defines the array of textures to bind
  33438. */
  33439. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33440. /** @hidden */
  33441. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33442. private _setTextureParameterFloat;
  33443. private _setTextureParameterInteger;
  33444. /**
  33445. * Unbind all vertex attributes from the webGL context
  33446. */
  33447. unbindAllAttributes(): void;
  33448. /**
  33449. * 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
  33450. */
  33451. releaseEffects(): void;
  33452. /**
  33453. * Dispose and release all associated resources
  33454. */
  33455. dispose(): void;
  33456. /**
  33457. * Attach a new callback raised when context lost event is fired
  33458. * @param callback defines the callback to call
  33459. */
  33460. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33461. /**
  33462. * Attach a new callback raised when context restored event is fired
  33463. * @param callback defines the callback to call
  33464. */
  33465. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33466. /**
  33467. * Get the current error code of the webGL context
  33468. * @returns the error code
  33469. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33470. */
  33471. getError(): number;
  33472. private _canRenderToFloatFramebuffer;
  33473. private _canRenderToHalfFloatFramebuffer;
  33474. private _canRenderToFramebuffer;
  33475. /** @hidden */
  33476. _getWebGLTextureType(type: number): number;
  33477. /** @hidden */
  33478. _getInternalFormat(format: number): number;
  33479. /** @hidden */
  33480. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33481. /** @hidden */
  33482. _getRGBAMultiSampleBufferFormat(type: number): number;
  33483. /** @hidden */
  33484. _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;
  33485. /**
  33486. * Loads a file from a url
  33487. * @param url url to load
  33488. * @param onSuccess callback called when the file successfully loads
  33489. * @param onProgress callback called while file is loading (if the server supports this mode)
  33490. * @param offlineProvider defines the offline provider for caching
  33491. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33492. * @param onError callback called when the file fails to load
  33493. * @returns a file request object
  33494. * @hidden
  33495. */
  33496. 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;
  33497. /**
  33498. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33499. * @param x defines the x coordinate of the rectangle where pixels must be read
  33500. * @param y defines the y coordinate of the rectangle where pixels must be read
  33501. * @param width defines the width of the rectangle where pixels must be read
  33502. * @param height defines the height of the rectangle where pixels must be read
  33503. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33504. * @returns a Uint8Array containing RGBA colors
  33505. */
  33506. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33507. private static _isSupported;
  33508. /**
  33509. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33510. * @returns true if the engine can be created
  33511. * @ignorenaming
  33512. */
  33513. static isSupported(): boolean;
  33514. /**
  33515. * Find the next highest power of two.
  33516. * @param x Number to start search from.
  33517. * @return Next highest power of two.
  33518. */
  33519. static CeilingPOT(x: number): number;
  33520. /**
  33521. * Find the next lowest power of two.
  33522. * @param x Number to start search from.
  33523. * @return Next lowest power of two.
  33524. */
  33525. static FloorPOT(x: number): number;
  33526. /**
  33527. * Find the nearest power of two.
  33528. * @param x Number to start search from.
  33529. * @return Next nearest power of two.
  33530. */
  33531. static NearestPOT(x: number): number;
  33532. /**
  33533. * Get the closest exponent of two
  33534. * @param value defines the value to approximate
  33535. * @param max defines the maximum value to return
  33536. * @param mode defines how to define the closest value
  33537. * @returns closest exponent of two of the given value
  33538. */
  33539. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33540. /**
  33541. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33542. * @param func - the function to be called
  33543. * @param requester - the object that will request the next frame. Falls back to window.
  33544. * @returns frame number
  33545. */
  33546. static QueueNewFrame(func: () => void, requester?: any): number;
  33547. /**
  33548. * Gets host document
  33549. * @returns the host document object
  33550. */
  33551. getHostDocument(): Nullable<Document>;
  33552. }
  33553. }
  33554. declare module "babylonjs/Maths/sphericalPolynomial" {
  33555. import { Vector3 } from "babylonjs/Maths/math.vector";
  33556. import { Color3 } from "babylonjs/Maths/math.color";
  33557. /**
  33558. * Class representing spherical harmonics coefficients to the 3rd degree
  33559. */
  33560. export class SphericalHarmonics {
  33561. /**
  33562. * Defines whether or not the harmonics have been prescaled for rendering.
  33563. */
  33564. preScaled: boolean;
  33565. /**
  33566. * The l0,0 coefficients of the spherical harmonics
  33567. */
  33568. l00: Vector3;
  33569. /**
  33570. * The l1,-1 coefficients of the spherical harmonics
  33571. */
  33572. l1_1: Vector3;
  33573. /**
  33574. * The l1,0 coefficients of the spherical harmonics
  33575. */
  33576. l10: Vector3;
  33577. /**
  33578. * The l1,1 coefficients of the spherical harmonics
  33579. */
  33580. l11: Vector3;
  33581. /**
  33582. * The l2,-2 coefficients of the spherical harmonics
  33583. */
  33584. l2_2: Vector3;
  33585. /**
  33586. * The l2,-1 coefficients of the spherical harmonics
  33587. */
  33588. l2_1: Vector3;
  33589. /**
  33590. * The l2,0 coefficients of the spherical harmonics
  33591. */
  33592. l20: Vector3;
  33593. /**
  33594. * The l2,1 coefficients of the spherical harmonics
  33595. */
  33596. l21: Vector3;
  33597. /**
  33598. * The l2,2 coefficients of the spherical harmonics
  33599. */
  33600. l22: Vector3;
  33601. /**
  33602. * Adds a light to the spherical harmonics
  33603. * @param direction the direction of the light
  33604. * @param color the color of the light
  33605. * @param deltaSolidAngle the delta solid angle of the light
  33606. */
  33607. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33608. /**
  33609. * Scales the spherical harmonics by the given amount
  33610. * @param scale the amount to scale
  33611. */
  33612. scaleInPlace(scale: number): void;
  33613. /**
  33614. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33615. *
  33616. * ```
  33617. * E_lm = A_l * L_lm
  33618. * ```
  33619. *
  33620. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33621. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33622. * the scaling factors are given in equation 9.
  33623. */
  33624. convertIncidentRadianceToIrradiance(): void;
  33625. /**
  33626. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33627. *
  33628. * ```
  33629. * L = (1/pi) * E * rho
  33630. * ```
  33631. *
  33632. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33633. */
  33634. convertIrradianceToLambertianRadiance(): void;
  33635. /**
  33636. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33637. * required operations at run time.
  33638. *
  33639. * This is simply done by scaling back the SH with Ylm constants parameter.
  33640. * The trigonometric part being applied by the shader at run time.
  33641. */
  33642. preScaleForRendering(): void;
  33643. /**
  33644. * Constructs a spherical harmonics from an array.
  33645. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33646. * @returns the spherical harmonics
  33647. */
  33648. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33649. /**
  33650. * Gets the spherical harmonics from polynomial
  33651. * @param polynomial the spherical polynomial
  33652. * @returns the spherical harmonics
  33653. */
  33654. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33655. }
  33656. /**
  33657. * Class representing spherical polynomial coefficients to the 3rd degree
  33658. */
  33659. export class SphericalPolynomial {
  33660. private _harmonics;
  33661. /**
  33662. * The spherical harmonics used to create the polynomials.
  33663. */
  33664. get preScaledHarmonics(): SphericalHarmonics;
  33665. /**
  33666. * The x coefficients of the spherical polynomial
  33667. */
  33668. x: Vector3;
  33669. /**
  33670. * The y coefficients of the spherical polynomial
  33671. */
  33672. y: Vector3;
  33673. /**
  33674. * The z coefficients of the spherical polynomial
  33675. */
  33676. z: Vector3;
  33677. /**
  33678. * The xx coefficients of the spherical polynomial
  33679. */
  33680. xx: Vector3;
  33681. /**
  33682. * The yy coefficients of the spherical polynomial
  33683. */
  33684. yy: Vector3;
  33685. /**
  33686. * The zz coefficients of the spherical polynomial
  33687. */
  33688. zz: Vector3;
  33689. /**
  33690. * The xy coefficients of the spherical polynomial
  33691. */
  33692. xy: Vector3;
  33693. /**
  33694. * The yz coefficients of the spherical polynomial
  33695. */
  33696. yz: Vector3;
  33697. /**
  33698. * The zx coefficients of the spherical polynomial
  33699. */
  33700. zx: Vector3;
  33701. /**
  33702. * Adds an ambient color to the spherical polynomial
  33703. * @param color the color to add
  33704. */
  33705. addAmbient(color: Color3): void;
  33706. /**
  33707. * Scales the spherical polynomial by the given amount
  33708. * @param scale the amount to scale
  33709. */
  33710. scaleInPlace(scale: number): void;
  33711. /**
  33712. * Gets the spherical polynomial from harmonics
  33713. * @param harmonics the spherical harmonics
  33714. * @returns the spherical polynomial
  33715. */
  33716. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33717. /**
  33718. * Constructs a spherical polynomial from an array.
  33719. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33720. * @returns the spherical polynomial
  33721. */
  33722. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33723. }
  33724. }
  33725. declare module "babylonjs/Materials/Textures/internalTexture" {
  33726. import { Observable } from "babylonjs/Misc/observable";
  33727. import { Nullable, int } from "babylonjs/types";
  33728. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33729. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33730. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33731. /**
  33732. * Defines the source of the internal texture
  33733. */
  33734. export enum InternalTextureSource {
  33735. /**
  33736. * The source of the texture data is unknown
  33737. */
  33738. Unknown = 0,
  33739. /**
  33740. * Texture data comes from an URL
  33741. */
  33742. Url = 1,
  33743. /**
  33744. * Texture data is only used for temporary storage
  33745. */
  33746. Temp = 2,
  33747. /**
  33748. * Texture data comes from raw data (ArrayBuffer)
  33749. */
  33750. Raw = 3,
  33751. /**
  33752. * Texture content is dynamic (video or dynamic texture)
  33753. */
  33754. Dynamic = 4,
  33755. /**
  33756. * Texture content is generated by rendering to it
  33757. */
  33758. RenderTarget = 5,
  33759. /**
  33760. * Texture content is part of a multi render target process
  33761. */
  33762. MultiRenderTarget = 6,
  33763. /**
  33764. * Texture data comes from a cube data file
  33765. */
  33766. Cube = 7,
  33767. /**
  33768. * Texture data comes from a raw cube data
  33769. */
  33770. CubeRaw = 8,
  33771. /**
  33772. * Texture data come from a prefiltered cube data file
  33773. */
  33774. CubePrefiltered = 9,
  33775. /**
  33776. * Texture content is raw 3D data
  33777. */
  33778. Raw3D = 10,
  33779. /**
  33780. * Texture content is raw 2D array data
  33781. */
  33782. Raw2DArray = 11,
  33783. /**
  33784. * Texture content is a depth texture
  33785. */
  33786. Depth = 12,
  33787. /**
  33788. * Texture data comes from a raw cube data encoded with RGBD
  33789. */
  33790. CubeRawRGBD = 13
  33791. }
  33792. /**
  33793. * Class used to store data associated with WebGL texture data for the engine
  33794. * This class should not be used directly
  33795. */
  33796. export class InternalTexture {
  33797. /** @hidden */
  33798. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33799. /**
  33800. * Defines if the texture is ready
  33801. */
  33802. isReady: boolean;
  33803. /**
  33804. * Defines if the texture is a cube texture
  33805. */
  33806. isCube: boolean;
  33807. /**
  33808. * Defines if the texture contains 3D data
  33809. */
  33810. is3D: boolean;
  33811. /**
  33812. * Defines if the texture contains 2D array data
  33813. */
  33814. is2DArray: boolean;
  33815. /**
  33816. * Defines if the texture contains multiview data
  33817. */
  33818. isMultiview: boolean;
  33819. /**
  33820. * Gets the URL used to load this texture
  33821. */
  33822. url: string;
  33823. /**
  33824. * Gets the sampling mode of the texture
  33825. */
  33826. samplingMode: number;
  33827. /**
  33828. * Gets a boolean indicating if the texture needs mipmaps generation
  33829. */
  33830. generateMipMaps: boolean;
  33831. /**
  33832. * Gets the number of samples used by the texture (WebGL2+ only)
  33833. */
  33834. samples: number;
  33835. /**
  33836. * Gets the type of the texture (int, float...)
  33837. */
  33838. type: number;
  33839. /**
  33840. * Gets the format of the texture (RGB, RGBA...)
  33841. */
  33842. format: number;
  33843. /**
  33844. * Observable called when the texture is loaded
  33845. */
  33846. onLoadedObservable: Observable<InternalTexture>;
  33847. /**
  33848. * Gets the width of the texture
  33849. */
  33850. width: number;
  33851. /**
  33852. * Gets the height of the texture
  33853. */
  33854. height: number;
  33855. /**
  33856. * Gets the depth of the texture
  33857. */
  33858. depth: number;
  33859. /**
  33860. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33861. */
  33862. baseWidth: number;
  33863. /**
  33864. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33865. */
  33866. baseHeight: number;
  33867. /**
  33868. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33869. */
  33870. baseDepth: number;
  33871. /**
  33872. * Gets a boolean indicating if the texture is inverted on Y axis
  33873. */
  33874. invertY: boolean;
  33875. /** @hidden */
  33876. _invertVScale: boolean;
  33877. /** @hidden */
  33878. _associatedChannel: number;
  33879. /** @hidden */
  33880. _source: InternalTextureSource;
  33881. /** @hidden */
  33882. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33883. /** @hidden */
  33884. _bufferView: Nullable<ArrayBufferView>;
  33885. /** @hidden */
  33886. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33887. /** @hidden */
  33888. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33889. /** @hidden */
  33890. _size: number;
  33891. /** @hidden */
  33892. _extension: string;
  33893. /** @hidden */
  33894. _files: Nullable<string[]>;
  33895. /** @hidden */
  33896. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33897. /** @hidden */
  33898. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33899. /** @hidden */
  33900. _framebuffer: Nullable<WebGLFramebuffer>;
  33901. /** @hidden */
  33902. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33903. /** @hidden */
  33904. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33905. /** @hidden */
  33906. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33907. /** @hidden */
  33908. _attachments: Nullable<number[]>;
  33909. /** @hidden */
  33910. _cachedCoordinatesMode: Nullable<number>;
  33911. /** @hidden */
  33912. _cachedWrapU: Nullable<number>;
  33913. /** @hidden */
  33914. _cachedWrapV: Nullable<number>;
  33915. /** @hidden */
  33916. _cachedWrapR: Nullable<number>;
  33917. /** @hidden */
  33918. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33919. /** @hidden */
  33920. _isDisabled: boolean;
  33921. /** @hidden */
  33922. _compression: Nullable<string>;
  33923. /** @hidden */
  33924. _generateStencilBuffer: boolean;
  33925. /** @hidden */
  33926. _generateDepthBuffer: boolean;
  33927. /** @hidden */
  33928. _comparisonFunction: number;
  33929. /** @hidden */
  33930. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33931. /** @hidden */
  33932. _lodGenerationScale: number;
  33933. /** @hidden */
  33934. _lodGenerationOffset: number;
  33935. /** @hidden */
  33936. _depthStencilTexture: Nullable<InternalTexture>;
  33937. /** @hidden */
  33938. _colorTextureArray: Nullable<WebGLTexture>;
  33939. /** @hidden */
  33940. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33941. /** @hidden */
  33942. _lodTextureHigh: Nullable<BaseTexture>;
  33943. /** @hidden */
  33944. _lodTextureMid: Nullable<BaseTexture>;
  33945. /** @hidden */
  33946. _lodTextureLow: Nullable<BaseTexture>;
  33947. /** @hidden */
  33948. _isRGBD: boolean;
  33949. /** @hidden */
  33950. _linearSpecularLOD: boolean;
  33951. /** @hidden */
  33952. _irradianceTexture: Nullable<BaseTexture>;
  33953. /** @hidden */
  33954. _webGLTexture: Nullable<WebGLTexture>;
  33955. /** @hidden */
  33956. _references: number;
  33957. private _engine;
  33958. /**
  33959. * Gets the Engine the texture belongs to.
  33960. * @returns The babylon engine
  33961. */
  33962. getEngine(): ThinEngine;
  33963. /**
  33964. * Gets the data source type of the texture
  33965. */
  33966. get source(): InternalTextureSource;
  33967. /**
  33968. * Creates a new InternalTexture
  33969. * @param engine defines the engine to use
  33970. * @param source defines the type of data that will be used
  33971. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33972. */
  33973. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33974. /**
  33975. * Increments the number of references (ie. the number of Texture that point to it)
  33976. */
  33977. incrementReferences(): void;
  33978. /**
  33979. * Change the size of the texture (not the size of the content)
  33980. * @param width defines the new width
  33981. * @param height defines the new height
  33982. * @param depth defines the new depth (1 by default)
  33983. */
  33984. updateSize(width: int, height: int, depth?: int): void;
  33985. /** @hidden */
  33986. _rebuild(): void;
  33987. /** @hidden */
  33988. _swapAndDie(target: InternalTexture): void;
  33989. /**
  33990. * Dispose the current allocated resources
  33991. */
  33992. dispose(): void;
  33993. }
  33994. }
  33995. declare module "babylonjs/Audio/analyser" {
  33996. import { Scene } from "babylonjs/scene";
  33997. /**
  33998. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34000. */
  34001. export class Analyser {
  34002. /**
  34003. * Gets or sets the smoothing
  34004. * @ignorenaming
  34005. */
  34006. SMOOTHING: number;
  34007. /**
  34008. * Gets or sets the FFT table size
  34009. * @ignorenaming
  34010. */
  34011. FFT_SIZE: number;
  34012. /**
  34013. * Gets or sets the bar graph amplitude
  34014. * @ignorenaming
  34015. */
  34016. BARGRAPHAMPLITUDE: number;
  34017. /**
  34018. * Gets or sets the position of the debug canvas
  34019. * @ignorenaming
  34020. */
  34021. DEBUGCANVASPOS: {
  34022. x: number;
  34023. y: number;
  34024. };
  34025. /**
  34026. * Gets or sets the debug canvas size
  34027. * @ignorenaming
  34028. */
  34029. DEBUGCANVASSIZE: {
  34030. width: number;
  34031. height: number;
  34032. };
  34033. private _byteFreqs;
  34034. private _byteTime;
  34035. private _floatFreqs;
  34036. private _webAudioAnalyser;
  34037. private _debugCanvas;
  34038. private _debugCanvasContext;
  34039. private _scene;
  34040. private _registerFunc;
  34041. private _audioEngine;
  34042. /**
  34043. * Creates a new analyser
  34044. * @param scene defines hosting scene
  34045. */
  34046. constructor(scene: Scene);
  34047. /**
  34048. * Get the number of data values you will have to play with for the visualization
  34049. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  34050. * @returns a number
  34051. */
  34052. getFrequencyBinCount(): number;
  34053. /**
  34054. * Gets the current frequency data as a byte array
  34055. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34056. * @returns a Uint8Array
  34057. */
  34058. getByteFrequencyData(): Uint8Array;
  34059. /**
  34060. * Gets the current waveform as a byte array
  34061. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  34062. * @returns a Uint8Array
  34063. */
  34064. getByteTimeDomainData(): Uint8Array;
  34065. /**
  34066. * Gets the current frequency data as a float array
  34067. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  34068. * @returns a Float32Array
  34069. */
  34070. getFloatFrequencyData(): Float32Array;
  34071. /**
  34072. * Renders the debug canvas
  34073. */
  34074. drawDebugCanvas(): void;
  34075. /**
  34076. * Stops rendering the debug canvas and removes it
  34077. */
  34078. stopDebugCanvas(): void;
  34079. /**
  34080. * Connects two audio nodes
  34081. * @param inputAudioNode defines first node to connect
  34082. * @param outputAudioNode defines second node to connect
  34083. */
  34084. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  34085. /**
  34086. * Releases all associated resources
  34087. */
  34088. dispose(): void;
  34089. }
  34090. }
  34091. declare module "babylonjs/Audio/audioEngine" {
  34092. import { IDisposable } from "babylonjs/scene";
  34093. import { Analyser } from "babylonjs/Audio/analyser";
  34094. import { Nullable } from "babylonjs/types";
  34095. import { Observable } from "babylonjs/Misc/observable";
  34096. /**
  34097. * This represents an audio engine and it is responsible
  34098. * to play, synchronize and analyse sounds throughout the application.
  34099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34100. */
  34101. export interface IAudioEngine extends IDisposable {
  34102. /**
  34103. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34104. */
  34105. readonly canUseWebAudio: boolean;
  34106. /**
  34107. * Gets the current AudioContext if available.
  34108. */
  34109. readonly audioContext: Nullable<AudioContext>;
  34110. /**
  34111. * The master gain node defines the global audio volume of your audio engine.
  34112. */
  34113. readonly masterGain: GainNode;
  34114. /**
  34115. * Gets whether or not mp3 are supported by your browser.
  34116. */
  34117. readonly isMP3supported: boolean;
  34118. /**
  34119. * Gets whether or not ogg are supported by your browser.
  34120. */
  34121. readonly isOGGsupported: boolean;
  34122. /**
  34123. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34124. * @ignoreNaming
  34125. */
  34126. WarnedWebAudioUnsupported: boolean;
  34127. /**
  34128. * Defines if the audio engine relies on a custom unlocked button.
  34129. * In this case, the embedded button will not be displayed.
  34130. */
  34131. useCustomUnlockedButton: boolean;
  34132. /**
  34133. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  34134. */
  34135. readonly unlocked: boolean;
  34136. /**
  34137. * Event raised when audio has been unlocked on the browser.
  34138. */
  34139. onAudioUnlockedObservable: Observable<AudioEngine>;
  34140. /**
  34141. * Event raised when audio has been locked on the browser.
  34142. */
  34143. onAudioLockedObservable: Observable<AudioEngine>;
  34144. /**
  34145. * Flags the audio engine in Locked state.
  34146. * This happens due to new browser policies preventing audio to autoplay.
  34147. */
  34148. lock(): void;
  34149. /**
  34150. * Unlocks the audio engine once a user action has been done on the dom.
  34151. * This is helpful to resume play once browser policies have been satisfied.
  34152. */
  34153. unlock(): void;
  34154. /**
  34155. * Gets the global volume sets on the master gain.
  34156. * @returns the global volume if set or -1 otherwise
  34157. */
  34158. getGlobalVolume(): number;
  34159. /**
  34160. * Sets the global volume of your experience (sets on the master gain).
  34161. * @param newVolume Defines the new global volume of the application
  34162. */
  34163. setGlobalVolume(newVolume: number): void;
  34164. /**
  34165. * Connect the audio engine to an audio analyser allowing some amazing
  34166. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34168. * @param analyser The analyser to connect to the engine
  34169. */
  34170. connectToAnalyser(analyser: Analyser): void;
  34171. }
  34172. /**
  34173. * This represents the default audio engine used in babylon.
  34174. * It is responsible to play, synchronize and analyse sounds throughout the application.
  34175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34176. */
  34177. export class AudioEngine implements IAudioEngine {
  34178. private _audioContext;
  34179. private _audioContextInitialized;
  34180. private _muteButton;
  34181. private _hostElement;
  34182. /**
  34183. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  34184. */
  34185. canUseWebAudio: boolean;
  34186. /**
  34187. * The master gain node defines the global audio volume of your audio engine.
  34188. */
  34189. masterGain: GainNode;
  34190. /**
  34191. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34192. * @ignoreNaming
  34193. */
  34194. WarnedWebAudioUnsupported: boolean;
  34195. /**
  34196. * Gets whether or not mp3 are supported by your browser.
  34197. */
  34198. isMP3supported: boolean;
  34199. /**
  34200. * Gets whether or not ogg are supported by your browser.
  34201. */
  34202. isOGGsupported: boolean;
  34203. /**
  34204. * Gets whether audio has been unlocked on the device.
  34205. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34206. * a user interaction has happened.
  34207. */
  34208. unlocked: boolean;
  34209. /**
  34210. * Defines if the audio engine relies on a custom unlocked button.
  34211. * In this case, the embedded button will not be displayed.
  34212. */
  34213. useCustomUnlockedButton: boolean;
  34214. /**
  34215. * Event raised when audio has been unlocked on the browser.
  34216. */
  34217. onAudioUnlockedObservable: Observable<AudioEngine>;
  34218. /**
  34219. * Event raised when audio has been locked on the browser.
  34220. */
  34221. onAudioLockedObservable: Observable<AudioEngine>;
  34222. /**
  34223. * Gets the current AudioContext if available.
  34224. */
  34225. get audioContext(): Nullable<AudioContext>;
  34226. private _connectedAnalyser;
  34227. /**
  34228. * Instantiates a new audio engine.
  34229. *
  34230. * There should be only one per page as some browsers restrict the number
  34231. * of audio contexts you can create.
  34232. * @param hostElement defines the host element where to display the mute icon if necessary
  34233. */
  34234. constructor(hostElement?: Nullable<HTMLElement>);
  34235. /**
  34236. * Flags the audio engine in Locked state.
  34237. * This happens due to new browser policies preventing audio to autoplay.
  34238. */
  34239. lock(): void;
  34240. /**
  34241. * Unlocks the audio engine once a user action has been done on the dom.
  34242. * This is helpful to resume play once browser policies have been satisfied.
  34243. */
  34244. unlock(): void;
  34245. private _resumeAudioContext;
  34246. private _initializeAudioContext;
  34247. private _tryToRun;
  34248. private _triggerRunningState;
  34249. private _triggerSuspendedState;
  34250. private _displayMuteButton;
  34251. private _moveButtonToTopLeft;
  34252. private _onResize;
  34253. private _hideMuteButton;
  34254. /**
  34255. * Destroy and release the resources associated with the audio ccontext.
  34256. */
  34257. dispose(): void;
  34258. /**
  34259. * Gets the global volume sets on the master gain.
  34260. * @returns the global volume if set or -1 otherwise
  34261. */
  34262. getGlobalVolume(): number;
  34263. /**
  34264. * Sets the global volume of your experience (sets on the master gain).
  34265. * @param newVolume Defines the new global volume of the application
  34266. */
  34267. setGlobalVolume(newVolume: number): void;
  34268. /**
  34269. * Connect the audio engine to an audio analyser allowing some amazing
  34270. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34272. * @param analyser The analyser to connect to the engine
  34273. */
  34274. connectToAnalyser(analyser: Analyser): void;
  34275. }
  34276. }
  34277. declare module "babylonjs/Loading/loadingScreen" {
  34278. /**
  34279. * Interface used to present a loading screen while loading a scene
  34280. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34281. */
  34282. export interface ILoadingScreen {
  34283. /**
  34284. * Function called to display the loading screen
  34285. */
  34286. displayLoadingUI: () => void;
  34287. /**
  34288. * Function called to hide the loading screen
  34289. */
  34290. hideLoadingUI: () => void;
  34291. /**
  34292. * Gets or sets the color to use for the background
  34293. */
  34294. loadingUIBackgroundColor: string;
  34295. /**
  34296. * Gets or sets the text to display while loading
  34297. */
  34298. loadingUIText: string;
  34299. }
  34300. /**
  34301. * Class used for the default loading screen
  34302. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34303. */
  34304. export class DefaultLoadingScreen implements ILoadingScreen {
  34305. private _renderingCanvas;
  34306. private _loadingText;
  34307. private _loadingDivBackgroundColor;
  34308. private _loadingDiv;
  34309. private _loadingTextDiv;
  34310. /** Gets or sets the logo url to use for the default loading screen */
  34311. static DefaultLogoUrl: string;
  34312. /** Gets or sets the spinner url to use for the default loading screen */
  34313. static DefaultSpinnerUrl: string;
  34314. /**
  34315. * Creates a new default loading screen
  34316. * @param _renderingCanvas defines the canvas used to render the scene
  34317. * @param _loadingText defines the default text to display
  34318. * @param _loadingDivBackgroundColor defines the default background color
  34319. */
  34320. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34321. /**
  34322. * Function called to display the loading screen
  34323. */
  34324. displayLoadingUI(): void;
  34325. /**
  34326. * Function called to hide the loading screen
  34327. */
  34328. hideLoadingUI(): void;
  34329. /**
  34330. * Gets or sets the text to display while loading
  34331. */
  34332. set loadingUIText(text: string);
  34333. get loadingUIText(): string;
  34334. /**
  34335. * Gets or sets the color to use for the background
  34336. */
  34337. get loadingUIBackgroundColor(): string;
  34338. set loadingUIBackgroundColor(color: string);
  34339. private _resizeLoadingUI;
  34340. }
  34341. }
  34342. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34343. /**
  34344. * Interface for any object that can request an animation frame
  34345. */
  34346. export interface ICustomAnimationFrameRequester {
  34347. /**
  34348. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34349. */
  34350. renderFunction?: Function;
  34351. /**
  34352. * Called to request the next frame to render to
  34353. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34354. */
  34355. requestAnimationFrame: Function;
  34356. /**
  34357. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34358. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34359. */
  34360. requestID?: number;
  34361. }
  34362. }
  34363. declare module "babylonjs/Misc/performanceMonitor" {
  34364. /**
  34365. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34366. */
  34367. export class PerformanceMonitor {
  34368. private _enabled;
  34369. private _rollingFrameTime;
  34370. private _lastFrameTimeMs;
  34371. /**
  34372. * constructor
  34373. * @param frameSampleSize The number of samples required to saturate the sliding window
  34374. */
  34375. constructor(frameSampleSize?: number);
  34376. /**
  34377. * Samples current frame
  34378. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34379. */
  34380. sampleFrame(timeMs?: number): void;
  34381. /**
  34382. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34383. */
  34384. get averageFrameTime(): number;
  34385. /**
  34386. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34387. */
  34388. get averageFrameTimeVariance(): number;
  34389. /**
  34390. * Returns the frame time of the most recent frame
  34391. */
  34392. get instantaneousFrameTime(): number;
  34393. /**
  34394. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34395. */
  34396. get averageFPS(): number;
  34397. /**
  34398. * Returns the average framerate in frames per second using the most recent frame time
  34399. */
  34400. get instantaneousFPS(): number;
  34401. /**
  34402. * Returns true if enough samples have been taken to completely fill the sliding window
  34403. */
  34404. get isSaturated(): boolean;
  34405. /**
  34406. * Enables contributions to the sliding window sample set
  34407. */
  34408. enable(): void;
  34409. /**
  34410. * Disables contributions to the sliding window sample set
  34411. * Samples will not be interpolated over the disabled period
  34412. */
  34413. disable(): void;
  34414. /**
  34415. * Returns true if sampling is enabled
  34416. */
  34417. get isEnabled(): boolean;
  34418. /**
  34419. * Resets performance monitor
  34420. */
  34421. reset(): void;
  34422. }
  34423. /**
  34424. * RollingAverage
  34425. *
  34426. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34427. */
  34428. export class RollingAverage {
  34429. /**
  34430. * Current average
  34431. */
  34432. average: number;
  34433. /**
  34434. * Current variance
  34435. */
  34436. variance: number;
  34437. protected _samples: Array<number>;
  34438. protected _sampleCount: number;
  34439. protected _pos: number;
  34440. protected _m2: number;
  34441. /**
  34442. * constructor
  34443. * @param length The number of samples required to saturate the sliding window
  34444. */
  34445. constructor(length: number);
  34446. /**
  34447. * Adds a sample to the sample set
  34448. * @param v The sample value
  34449. */
  34450. add(v: number): void;
  34451. /**
  34452. * Returns previously added values or null if outside of history or outside the sliding window domain
  34453. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34454. * @return Value previously recorded with add() or null if outside of range
  34455. */
  34456. history(i: number): number;
  34457. /**
  34458. * Returns true if enough samples have been taken to completely fill the sliding window
  34459. * @return true if sample-set saturated
  34460. */
  34461. isSaturated(): boolean;
  34462. /**
  34463. * Resets the rolling average (equivalent to 0 samples taken so far)
  34464. */
  34465. reset(): void;
  34466. /**
  34467. * Wraps a value around the sample range boundaries
  34468. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34469. * @return Wrapped position in sample range
  34470. */
  34471. protected _wrapPosition(i: number): number;
  34472. }
  34473. }
  34474. declare module "babylonjs/Misc/perfCounter" {
  34475. /**
  34476. * This class is used to track a performance counter which is number based.
  34477. * The user has access to many properties which give statistics of different nature.
  34478. *
  34479. * The implementer can track two kinds of Performance Counter: time and count.
  34480. * 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.
  34481. * 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.
  34482. */
  34483. export class PerfCounter {
  34484. /**
  34485. * Gets or sets a global boolean to turn on and off all the counters
  34486. */
  34487. static Enabled: boolean;
  34488. /**
  34489. * Returns the smallest value ever
  34490. */
  34491. get min(): number;
  34492. /**
  34493. * Returns the biggest value ever
  34494. */
  34495. get max(): number;
  34496. /**
  34497. * Returns the average value since the performance counter is running
  34498. */
  34499. get average(): number;
  34500. /**
  34501. * Returns the average value of the last second the counter was monitored
  34502. */
  34503. get lastSecAverage(): number;
  34504. /**
  34505. * Returns the current value
  34506. */
  34507. get current(): number;
  34508. /**
  34509. * Gets the accumulated total
  34510. */
  34511. get total(): number;
  34512. /**
  34513. * Gets the total value count
  34514. */
  34515. get count(): number;
  34516. /**
  34517. * Creates a new counter
  34518. */
  34519. constructor();
  34520. /**
  34521. * Call this method to start monitoring a new frame.
  34522. * 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.
  34523. */
  34524. fetchNewFrame(): void;
  34525. /**
  34526. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34527. * @param newCount the count value to add to the monitored count
  34528. * @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.
  34529. */
  34530. addCount(newCount: number, fetchResult: boolean): void;
  34531. /**
  34532. * Start monitoring this performance counter
  34533. */
  34534. beginMonitoring(): void;
  34535. /**
  34536. * Compute the time lapsed since the previous beginMonitoring() call.
  34537. * @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
  34538. */
  34539. endMonitoring(newFrame?: boolean): void;
  34540. private _fetchResult;
  34541. private _startMonitoringTime;
  34542. private _min;
  34543. private _max;
  34544. private _average;
  34545. private _current;
  34546. private _totalValueCount;
  34547. private _totalAccumulated;
  34548. private _lastSecAverage;
  34549. private _lastSecAccumulated;
  34550. private _lastSecTime;
  34551. private _lastSecValueCount;
  34552. }
  34553. }
  34554. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34555. module "babylonjs/Engines/thinEngine" {
  34556. interface ThinEngine {
  34557. /**
  34558. * Sets alpha constants used by some alpha blending modes
  34559. * @param r defines the red component
  34560. * @param g defines the green component
  34561. * @param b defines the blue component
  34562. * @param a defines the alpha component
  34563. */
  34564. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34565. /**
  34566. * Sets the current alpha mode
  34567. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34568. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34569. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34570. */
  34571. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34572. /**
  34573. * Gets the current alpha mode
  34574. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34575. * @returns the current alpha mode
  34576. */
  34577. getAlphaMode(): number;
  34578. /**
  34579. * Sets the current alpha equation
  34580. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34581. */
  34582. setAlphaEquation(equation: number): void;
  34583. /**
  34584. * Gets the current alpha equation.
  34585. * @returns the current alpha equation
  34586. */
  34587. getAlphaEquation(): number;
  34588. }
  34589. }
  34590. }
  34591. declare module "babylonjs/Engines/engine" {
  34592. import { Observable } from "babylonjs/Misc/observable";
  34593. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34594. import { Scene } from "babylonjs/scene";
  34595. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34596. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34597. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34598. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34599. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34600. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34601. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34602. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34603. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34604. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34605. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34606. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34607. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34608. import "babylonjs/Engines/Extensions/engine.alpha";
  34609. import { Material } from "babylonjs/Materials/material";
  34610. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34611. /**
  34612. * Defines the interface used by display changed events
  34613. */
  34614. export interface IDisplayChangedEventArgs {
  34615. /** Gets the vrDisplay object (if any) */
  34616. vrDisplay: Nullable<any>;
  34617. /** Gets a boolean indicating if webVR is supported */
  34618. vrSupported: boolean;
  34619. }
  34620. /**
  34621. * Defines the interface used by objects containing a viewport (like a camera)
  34622. */
  34623. interface IViewportOwnerLike {
  34624. /**
  34625. * Gets or sets the viewport
  34626. */
  34627. viewport: IViewportLike;
  34628. }
  34629. /**
  34630. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34631. */
  34632. export class Engine extends ThinEngine {
  34633. /** Defines that alpha blending is disabled */
  34634. static readonly ALPHA_DISABLE: number;
  34635. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34636. static readonly ALPHA_ADD: number;
  34637. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34638. static readonly ALPHA_COMBINE: number;
  34639. /** Defines that alpha blending to DEST - SRC * DEST */
  34640. static readonly ALPHA_SUBTRACT: number;
  34641. /** Defines that alpha blending to SRC * DEST */
  34642. static readonly ALPHA_MULTIPLY: number;
  34643. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34644. static readonly ALPHA_MAXIMIZED: number;
  34645. /** Defines that alpha blending to SRC + DEST */
  34646. static readonly ALPHA_ONEONE: number;
  34647. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34648. static readonly ALPHA_PREMULTIPLIED: number;
  34649. /**
  34650. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34651. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34652. */
  34653. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34654. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34655. static readonly ALPHA_INTERPOLATE: number;
  34656. /**
  34657. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34658. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34659. */
  34660. static readonly ALPHA_SCREENMODE: number;
  34661. /** Defines that the ressource is not delayed*/
  34662. static readonly DELAYLOADSTATE_NONE: number;
  34663. /** Defines that the ressource was successfully delay loaded */
  34664. static readonly DELAYLOADSTATE_LOADED: number;
  34665. /** Defines that the ressource is currently delay loading */
  34666. static readonly DELAYLOADSTATE_LOADING: number;
  34667. /** Defines that the ressource is delayed and has not started loading */
  34668. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34669. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34670. static readonly NEVER: number;
  34671. /** 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 */
  34672. static readonly ALWAYS: number;
  34673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34674. static readonly LESS: number;
  34675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34676. static readonly EQUAL: number;
  34677. /** 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 */
  34678. static readonly LEQUAL: number;
  34679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34680. static readonly GREATER: number;
  34681. /** 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 */
  34682. static readonly GEQUAL: number;
  34683. /** 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 */
  34684. static readonly NOTEQUAL: number;
  34685. /** Passed to stencilOperation to specify that stencil value must be kept */
  34686. static readonly KEEP: number;
  34687. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34688. static readonly REPLACE: number;
  34689. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34690. static readonly INCR: number;
  34691. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34692. static readonly DECR: number;
  34693. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34694. static readonly INVERT: number;
  34695. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34696. static readonly INCR_WRAP: number;
  34697. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34698. static readonly DECR_WRAP: number;
  34699. /** Texture is not repeating outside of 0..1 UVs */
  34700. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34701. /** Texture is repeating outside of 0..1 UVs */
  34702. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34703. /** Texture is repeating and mirrored */
  34704. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34705. /** ALPHA */
  34706. static readonly TEXTUREFORMAT_ALPHA: number;
  34707. /** LUMINANCE */
  34708. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34709. /** LUMINANCE_ALPHA */
  34710. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34711. /** RGB */
  34712. static readonly TEXTUREFORMAT_RGB: number;
  34713. /** RGBA */
  34714. static readonly TEXTUREFORMAT_RGBA: number;
  34715. /** RED */
  34716. static readonly TEXTUREFORMAT_RED: number;
  34717. /** RED (2nd reference) */
  34718. static readonly TEXTUREFORMAT_R: number;
  34719. /** RG */
  34720. static readonly TEXTUREFORMAT_RG: number;
  34721. /** RED_INTEGER */
  34722. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34723. /** RED_INTEGER (2nd reference) */
  34724. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34725. /** RG_INTEGER */
  34726. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34727. /** RGB_INTEGER */
  34728. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34729. /** RGBA_INTEGER */
  34730. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34731. /** UNSIGNED_BYTE */
  34732. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34733. /** UNSIGNED_BYTE (2nd reference) */
  34734. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34735. /** FLOAT */
  34736. static readonly TEXTURETYPE_FLOAT: number;
  34737. /** HALF_FLOAT */
  34738. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34739. /** BYTE */
  34740. static readonly TEXTURETYPE_BYTE: number;
  34741. /** SHORT */
  34742. static readonly TEXTURETYPE_SHORT: number;
  34743. /** UNSIGNED_SHORT */
  34744. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34745. /** INT */
  34746. static readonly TEXTURETYPE_INT: number;
  34747. /** UNSIGNED_INT */
  34748. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34749. /** UNSIGNED_SHORT_4_4_4_4 */
  34750. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34751. /** UNSIGNED_SHORT_5_5_5_1 */
  34752. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34753. /** UNSIGNED_SHORT_5_6_5 */
  34754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34755. /** UNSIGNED_INT_2_10_10_10_REV */
  34756. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34757. /** UNSIGNED_INT_24_8 */
  34758. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34759. /** UNSIGNED_INT_10F_11F_11F_REV */
  34760. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34761. /** UNSIGNED_INT_5_9_9_9_REV */
  34762. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34763. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34764. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34765. /** nearest is mag = nearest and min = nearest and mip = linear */
  34766. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34767. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34768. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34769. /** Trilinear is mag = linear and min = linear and mip = linear */
  34770. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34771. /** nearest is mag = nearest and min = nearest and mip = linear */
  34772. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34774. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34775. /** Trilinear is mag = linear and min = linear and mip = linear */
  34776. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34777. /** mag = nearest and min = nearest and mip = nearest */
  34778. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34779. /** mag = nearest and min = linear and mip = nearest */
  34780. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34781. /** mag = nearest and min = linear and mip = linear */
  34782. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34783. /** mag = nearest and min = linear and mip = none */
  34784. static readonly TEXTURE_NEAREST_LINEAR: number;
  34785. /** mag = nearest and min = nearest and mip = none */
  34786. static readonly TEXTURE_NEAREST_NEAREST: number;
  34787. /** mag = linear and min = nearest and mip = nearest */
  34788. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34789. /** mag = linear and min = nearest and mip = linear */
  34790. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34791. /** mag = linear and min = linear and mip = none */
  34792. static readonly TEXTURE_LINEAR_LINEAR: number;
  34793. /** mag = linear and min = nearest and mip = none */
  34794. static readonly TEXTURE_LINEAR_NEAREST: number;
  34795. /** Explicit coordinates mode */
  34796. static readonly TEXTURE_EXPLICIT_MODE: number;
  34797. /** Spherical coordinates mode */
  34798. static readonly TEXTURE_SPHERICAL_MODE: number;
  34799. /** Planar coordinates mode */
  34800. static readonly TEXTURE_PLANAR_MODE: number;
  34801. /** Cubic coordinates mode */
  34802. static readonly TEXTURE_CUBIC_MODE: number;
  34803. /** Projection coordinates mode */
  34804. static readonly TEXTURE_PROJECTION_MODE: number;
  34805. /** Skybox coordinates mode */
  34806. static readonly TEXTURE_SKYBOX_MODE: number;
  34807. /** Inverse Cubic coordinates mode */
  34808. static readonly TEXTURE_INVCUBIC_MODE: number;
  34809. /** Equirectangular coordinates mode */
  34810. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34811. /** Equirectangular Fixed coordinates mode */
  34812. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34813. /** Equirectangular Fixed Mirrored coordinates mode */
  34814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34815. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34816. static readonly SCALEMODE_FLOOR: number;
  34817. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34818. static readonly SCALEMODE_NEAREST: number;
  34819. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34820. static readonly SCALEMODE_CEILING: number;
  34821. /**
  34822. * Returns the current npm package of the sdk
  34823. */
  34824. static get NpmPackage(): string;
  34825. /**
  34826. * Returns the current version of the framework
  34827. */
  34828. static get Version(): string;
  34829. /** Gets the list of created engines */
  34830. static get Instances(): Engine[];
  34831. /**
  34832. * Gets the latest created engine
  34833. */
  34834. static get LastCreatedEngine(): Nullable<Engine>;
  34835. /**
  34836. * Gets the latest created scene
  34837. */
  34838. static get LastCreatedScene(): Nullable<Scene>;
  34839. /**
  34840. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34841. * @param flag defines which part of the materials must be marked as dirty
  34842. * @param predicate defines a predicate used to filter which materials should be affected
  34843. */
  34844. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34845. /**
  34846. * Method called to create the default loading screen.
  34847. * This can be overriden in your own app.
  34848. * @param canvas The rendering canvas element
  34849. * @returns The loading screen
  34850. */
  34851. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34852. /**
  34853. * Method called to create the default rescale post process on each engine.
  34854. */
  34855. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34856. /**
  34857. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34858. **/
  34859. enableOfflineSupport: boolean;
  34860. /**
  34861. * 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)
  34862. **/
  34863. disableManifestCheck: boolean;
  34864. /**
  34865. * Gets the list of created scenes
  34866. */
  34867. scenes: Scene[];
  34868. /**
  34869. * Event raised when a new scene is created
  34870. */
  34871. onNewSceneAddedObservable: Observable<Scene>;
  34872. /**
  34873. * Gets the list of created postprocesses
  34874. */
  34875. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34876. /**
  34877. * Gets a boolean indicating if the pointer is currently locked
  34878. */
  34879. isPointerLock: boolean;
  34880. /**
  34881. * Observable event triggered each time the rendering canvas is resized
  34882. */
  34883. onResizeObservable: Observable<Engine>;
  34884. /**
  34885. * Observable event triggered each time the canvas loses focus
  34886. */
  34887. onCanvasBlurObservable: Observable<Engine>;
  34888. /**
  34889. * Observable event triggered each time the canvas gains focus
  34890. */
  34891. onCanvasFocusObservable: Observable<Engine>;
  34892. /**
  34893. * Observable event triggered each time the canvas receives pointerout event
  34894. */
  34895. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34896. /**
  34897. * Observable raised when the engine begins a new frame
  34898. */
  34899. onBeginFrameObservable: Observable<Engine>;
  34900. /**
  34901. * If set, will be used to request the next animation frame for the render loop
  34902. */
  34903. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34904. /**
  34905. * Observable raised when the engine ends the current frame
  34906. */
  34907. onEndFrameObservable: Observable<Engine>;
  34908. /**
  34909. * Observable raised when the engine is about to compile a shader
  34910. */
  34911. onBeforeShaderCompilationObservable: Observable<Engine>;
  34912. /**
  34913. * Observable raised when the engine has jsut compiled a shader
  34914. */
  34915. onAfterShaderCompilationObservable: Observable<Engine>;
  34916. /**
  34917. * Gets the audio engine
  34918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34919. * @ignorenaming
  34920. */
  34921. static audioEngine: IAudioEngine;
  34922. /**
  34923. * Default AudioEngine factory responsible of creating the Audio Engine.
  34924. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34925. */
  34926. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34927. /**
  34928. * Default offline support factory responsible of creating a tool used to store data locally.
  34929. * By default, this will create a Database object if the workload has been embedded.
  34930. */
  34931. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34932. private _loadingScreen;
  34933. private _pointerLockRequested;
  34934. private _dummyFramebuffer;
  34935. private _rescalePostProcess;
  34936. private _deterministicLockstep;
  34937. private _lockstepMaxSteps;
  34938. private _timeStep;
  34939. protected get _supportsHardwareTextureRescaling(): boolean;
  34940. private _fps;
  34941. private _deltaTime;
  34942. /** @hidden */
  34943. _drawCalls: PerfCounter;
  34944. /** 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 */
  34945. canvasTabIndex: number;
  34946. /**
  34947. * Turn this value on if you want to pause FPS computation when in background
  34948. */
  34949. disablePerformanceMonitorInBackground: boolean;
  34950. private _performanceMonitor;
  34951. /**
  34952. * Gets the performance monitor attached to this engine
  34953. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34954. */
  34955. get performanceMonitor(): PerformanceMonitor;
  34956. private _onFocus;
  34957. private _onBlur;
  34958. private _onCanvasPointerOut;
  34959. private _onCanvasBlur;
  34960. private _onCanvasFocus;
  34961. private _onFullscreenChange;
  34962. private _onPointerLockChange;
  34963. /**
  34964. * Gets the HTML element used to attach event listeners
  34965. * @returns a HTML element
  34966. */
  34967. getInputElement(): Nullable<HTMLElement>;
  34968. /**
  34969. * Creates a new engine
  34970. * @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
  34971. * @param antialias defines enable antialiasing (default: false)
  34972. * @param options defines further options to be sent to the getContext() function
  34973. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34974. */
  34975. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34976. /**
  34977. * Gets current aspect ratio
  34978. * @param viewportOwner defines the camera to use to get the aspect ratio
  34979. * @param useScreen defines if screen size must be used (or the current render target if any)
  34980. * @returns a number defining the aspect ratio
  34981. */
  34982. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34983. /**
  34984. * Gets current screen aspect ratio
  34985. * @returns a number defining the aspect ratio
  34986. */
  34987. getScreenAspectRatio(): number;
  34988. /**
  34989. * Gets the client rect of the HTML canvas attached with the current webGL context
  34990. * @returns a client rectanglee
  34991. */
  34992. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34993. /**
  34994. * Gets the client rect of the HTML element used for events
  34995. * @returns a client rectanglee
  34996. */
  34997. getInputElementClientRect(): Nullable<ClientRect>;
  34998. /**
  34999. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  35000. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35001. * @returns true if engine is in deterministic lock step mode
  35002. */
  35003. isDeterministicLockStep(): boolean;
  35004. /**
  35005. * Gets the max steps when engine is running in deterministic lock step
  35006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35007. * @returns the max steps
  35008. */
  35009. getLockstepMaxSteps(): number;
  35010. /**
  35011. * Returns the time in ms between steps when using deterministic lock step.
  35012. * @returns time step in (ms)
  35013. */
  35014. getTimeStep(): number;
  35015. /**
  35016. * Force the mipmap generation for the given render target texture
  35017. * @param texture defines the render target texture to use
  35018. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  35019. */
  35020. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  35021. /** States */
  35022. /**
  35023. * Set various states to the webGL context
  35024. * @param culling defines backface culling state
  35025. * @param zOffset defines the value to apply to zOffset (0 by default)
  35026. * @param force defines if states must be applied even if cache is up to date
  35027. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  35028. */
  35029. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  35030. /**
  35031. * Set the z offset to apply to current rendering
  35032. * @param value defines the offset to apply
  35033. */
  35034. setZOffset(value: number): void;
  35035. /**
  35036. * Gets the current value of the zOffset
  35037. * @returns the current zOffset state
  35038. */
  35039. getZOffset(): number;
  35040. /**
  35041. * Enable or disable depth buffering
  35042. * @param enable defines the state to set
  35043. */
  35044. setDepthBuffer(enable: boolean): void;
  35045. /**
  35046. * Gets a boolean indicating if depth writing is enabled
  35047. * @returns the current depth writing state
  35048. */
  35049. getDepthWrite(): boolean;
  35050. /**
  35051. * Enable or disable depth writing
  35052. * @param enable defines the state to set
  35053. */
  35054. setDepthWrite(enable: boolean): void;
  35055. /**
  35056. * Gets a boolean indicating if stencil buffer is enabled
  35057. * @returns the current stencil buffer state
  35058. */
  35059. getStencilBuffer(): boolean;
  35060. /**
  35061. * Enable or disable the stencil buffer
  35062. * @param enable defines if the stencil buffer must be enabled or disabled
  35063. */
  35064. setStencilBuffer(enable: boolean): void;
  35065. /**
  35066. * Gets the current stencil mask
  35067. * @returns a number defining the new stencil mask to use
  35068. */
  35069. getStencilMask(): number;
  35070. /**
  35071. * Sets the current stencil mask
  35072. * @param mask defines the new stencil mask to use
  35073. */
  35074. setStencilMask(mask: number): void;
  35075. /**
  35076. * Gets the current stencil function
  35077. * @returns a number defining the stencil function to use
  35078. */
  35079. getStencilFunction(): number;
  35080. /**
  35081. * Gets the current stencil reference value
  35082. * @returns a number defining the stencil reference value to use
  35083. */
  35084. getStencilFunctionReference(): number;
  35085. /**
  35086. * Gets the current stencil mask
  35087. * @returns a number defining the stencil mask to use
  35088. */
  35089. getStencilFunctionMask(): number;
  35090. /**
  35091. * Sets the current stencil function
  35092. * @param stencilFunc defines the new stencil function to use
  35093. */
  35094. setStencilFunction(stencilFunc: number): void;
  35095. /**
  35096. * Sets the current stencil reference
  35097. * @param reference defines the new stencil reference to use
  35098. */
  35099. setStencilFunctionReference(reference: number): void;
  35100. /**
  35101. * Sets the current stencil mask
  35102. * @param mask defines the new stencil mask to use
  35103. */
  35104. setStencilFunctionMask(mask: number): void;
  35105. /**
  35106. * Gets the current stencil operation when stencil fails
  35107. * @returns a number defining stencil operation to use when stencil fails
  35108. */
  35109. getStencilOperationFail(): number;
  35110. /**
  35111. * Gets the current stencil operation when depth fails
  35112. * @returns a number defining stencil operation to use when depth fails
  35113. */
  35114. getStencilOperationDepthFail(): number;
  35115. /**
  35116. * Gets the current stencil operation when stencil passes
  35117. * @returns a number defining stencil operation to use when stencil passes
  35118. */
  35119. getStencilOperationPass(): number;
  35120. /**
  35121. * Sets the stencil operation to use when stencil fails
  35122. * @param operation defines the stencil operation to use when stencil fails
  35123. */
  35124. setStencilOperationFail(operation: number): void;
  35125. /**
  35126. * Sets the stencil operation to use when depth fails
  35127. * @param operation defines the stencil operation to use when depth fails
  35128. */
  35129. setStencilOperationDepthFail(operation: number): void;
  35130. /**
  35131. * Sets the stencil operation to use when stencil passes
  35132. * @param operation defines the stencil operation to use when stencil passes
  35133. */
  35134. setStencilOperationPass(operation: number): void;
  35135. /**
  35136. * Sets a boolean indicating if the dithering state is enabled or disabled
  35137. * @param value defines the dithering state
  35138. */
  35139. setDitheringState(value: boolean): void;
  35140. /**
  35141. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  35142. * @param value defines the rasterizer state
  35143. */
  35144. setRasterizerState(value: boolean): void;
  35145. /**
  35146. * Gets the current depth function
  35147. * @returns a number defining the depth function
  35148. */
  35149. getDepthFunction(): Nullable<number>;
  35150. /**
  35151. * Sets the current depth function
  35152. * @param depthFunc defines the function to use
  35153. */
  35154. setDepthFunction(depthFunc: number): void;
  35155. /**
  35156. * Sets the current depth function to GREATER
  35157. */
  35158. setDepthFunctionToGreater(): void;
  35159. /**
  35160. * Sets the current depth function to GEQUAL
  35161. */
  35162. setDepthFunctionToGreaterOrEqual(): void;
  35163. /**
  35164. * Sets the current depth function to LESS
  35165. */
  35166. setDepthFunctionToLess(): void;
  35167. /**
  35168. * Sets the current depth function to LEQUAL
  35169. */
  35170. setDepthFunctionToLessOrEqual(): void;
  35171. private _cachedStencilBuffer;
  35172. private _cachedStencilFunction;
  35173. private _cachedStencilMask;
  35174. private _cachedStencilOperationPass;
  35175. private _cachedStencilOperationFail;
  35176. private _cachedStencilOperationDepthFail;
  35177. private _cachedStencilReference;
  35178. /**
  35179. * Caches the the state of the stencil buffer
  35180. */
  35181. cacheStencilState(): void;
  35182. /**
  35183. * Restores the state of the stencil buffer
  35184. */
  35185. restoreStencilState(): void;
  35186. /**
  35187. * Directly set the WebGL Viewport
  35188. * @param x defines the x coordinate of the viewport (in screen space)
  35189. * @param y defines the y coordinate of the viewport (in screen space)
  35190. * @param width defines the width of the viewport (in screen space)
  35191. * @param height defines the height of the viewport (in screen space)
  35192. * @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
  35193. */
  35194. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35195. /**
  35196. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35197. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35198. * @param y defines the y-coordinate of the corner of the clear rectangle
  35199. * @param width defines the width of the clear rectangle
  35200. * @param height defines the height of the clear rectangle
  35201. * @param clearColor defines the clear color
  35202. */
  35203. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35204. /**
  35205. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35206. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35207. * @param y defines the y-coordinate of the corner of the clear rectangle
  35208. * @param width defines the width of the clear rectangle
  35209. * @param height defines the height of the clear rectangle
  35210. */
  35211. enableScissor(x: number, y: number, width: number, height: number): void;
  35212. /**
  35213. * Disable previously set scissor test rectangle
  35214. */
  35215. disableScissor(): void;
  35216. protected _reportDrawCall(): void;
  35217. /**
  35218. * Initializes a webVR display and starts listening to display change events
  35219. * The onVRDisplayChangedObservable will be notified upon these changes
  35220. * @returns The onVRDisplayChangedObservable
  35221. */
  35222. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35223. /** @hidden */
  35224. _prepareVRComponent(): void;
  35225. /** @hidden */
  35226. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35227. /** @hidden */
  35228. _submitVRFrame(): void;
  35229. /**
  35230. * Call this function to leave webVR mode
  35231. * Will do nothing if webVR is not supported or if there is no webVR device
  35232. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35233. */
  35234. disableVR(): void;
  35235. /**
  35236. * Gets a boolean indicating that the system is in VR mode and is presenting
  35237. * @returns true if VR mode is engaged
  35238. */
  35239. isVRPresenting(): boolean;
  35240. /** @hidden */
  35241. _requestVRFrame(): void;
  35242. /** @hidden */
  35243. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35244. /**
  35245. * Gets the source code of the vertex shader associated with a specific webGL program
  35246. * @param program defines the program to use
  35247. * @returns a string containing the source code of the vertex shader associated with the program
  35248. */
  35249. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35250. /**
  35251. * Gets the source code of the fragment shader associated with a specific webGL program
  35252. * @param program defines the program to use
  35253. * @returns a string containing the source code of the fragment shader associated with the program
  35254. */
  35255. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35256. /**
  35257. * Sets a depth stencil texture from a render target to the according uniform.
  35258. * @param channel The texture channel
  35259. * @param uniform The uniform to set
  35260. * @param texture The render target texture containing the depth stencil texture to apply
  35261. */
  35262. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35263. /**
  35264. * Sets a texture to the webGL context from a postprocess
  35265. * @param channel defines the channel to use
  35266. * @param postProcess defines the source postprocess
  35267. */
  35268. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35269. /**
  35270. * Binds the output of the passed in post process to the texture channel specified
  35271. * @param channel The channel the texture should be bound to
  35272. * @param postProcess The post process which's output should be bound
  35273. */
  35274. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35275. protected _rebuildBuffers(): void;
  35276. /** @hidden */
  35277. _renderFrame(): void;
  35278. _renderLoop(): void;
  35279. /** @hidden */
  35280. _renderViews(): boolean;
  35281. /**
  35282. * Toggle full screen mode
  35283. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35284. */
  35285. switchFullscreen(requestPointerLock: boolean): void;
  35286. /**
  35287. * Enters full screen mode
  35288. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35289. */
  35290. enterFullscreen(requestPointerLock: boolean): void;
  35291. /**
  35292. * Exits full screen mode
  35293. */
  35294. exitFullscreen(): void;
  35295. /**
  35296. * Enters Pointerlock mode
  35297. */
  35298. enterPointerlock(): void;
  35299. /**
  35300. * Exits Pointerlock mode
  35301. */
  35302. exitPointerlock(): void;
  35303. /**
  35304. * Begin a new frame
  35305. */
  35306. beginFrame(): void;
  35307. /**
  35308. * Enf the current frame
  35309. */
  35310. endFrame(): void;
  35311. resize(): void;
  35312. /**
  35313. * Force a specific size of the canvas
  35314. * @param width defines the new canvas' width
  35315. * @param height defines the new canvas' height
  35316. */
  35317. setSize(width: number, height: number): void;
  35318. /**
  35319. * Updates a dynamic vertex buffer.
  35320. * @param vertexBuffer the vertex buffer to update
  35321. * @param data the data used to update the vertex buffer
  35322. * @param byteOffset the byte offset of the data
  35323. * @param byteLength the byte length of the data
  35324. */
  35325. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35326. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35327. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35328. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35329. _releaseTexture(texture: InternalTexture): void;
  35330. /**
  35331. * @hidden
  35332. * Rescales a texture
  35333. * @param source input texutre
  35334. * @param destination destination texture
  35335. * @param scene scene to use to render the resize
  35336. * @param internalFormat format to use when resizing
  35337. * @param onComplete callback to be called when resize has completed
  35338. */
  35339. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35340. /**
  35341. * Gets the current framerate
  35342. * @returns a number representing the framerate
  35343. */
  35344. getFps(): number;
  35345. /**
  35346. * Gets the time spent between current and previous frame
  35347. * @returns a number representing the delta time in ms
  35348. */
  35349. getDeltaTime(): number;
  35350. private _measureFps;
  35351. /** @hidden */
  35352. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35353. /**
  35354. * Update a dynamic index buffer
  35355. * @param indexBuffer defines the target index buffer
  35356. * @param indices defines the data to update
  35357. * @param offset defines the offset in the target index buffer where update should start
  35358. */
  35359. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35360. /**
  35361. * Updates the sample count of a render target texture
  35362. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35363. * @param texture defines the texture to update
  35364. * @param samples defines the sample count to set
  35365. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35366. */
  35367. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35368. /**
  35369. * Updates a depth texture Comparison Mode and Function.
  35370. * If the comparison Function is equal to 0, the mode will be set to none.
  35371. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35372. * @param texture The texture to set the comparison function for
  35373. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35374. */
  35375. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35376. /**
  35377. * Creates a webGL buffer to use with instanciation
  35378. * @param capacity defines the size of the buffer
  35379. * @returns the webGL buffer
  35380. */
  35381. createInstancesBuffer(capacity: number): DataBuffer;
  35382. /**
  35383. * Delete a webGL buffer used with instanciation
  35384. * @param buffer defines the webGL buffer to delete
  35385. */
  35386. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35387. private _clientWaitAsync;
  35388. /** @hidden */
  35389. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35390. /** @hidden */
  35391. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35392. dispose(): void;
  35393. private _disableTouchAction;
  35394. /**
  35395. * Display the loading screen
  35396. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35397. */
  35398. displayLoadingUI(): void;
  35399. /**
  35400. * Hide the loading screen
  35401. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35402. */
  35403. hideLoadingUI(): void;
  35404. /**
  35405. * Gets the current loading screen object
  35406. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35407. */
  35408. get loadingScreen(): ILoadingScreen;
  35409. /**
  35410. * Sets the current loading screen object
  35411. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35412. */
  35413. set loadingScreen(loadingScreen: ILoadingScreen);
  35414. /**
  35415. * Sets the current loading screen text
  35416. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35417. */
  35418. set loadingUIText(text: string);
  35419. /**
  35420. * Sets the current loading screen background color
  35421. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35422. */
  35423. set loadingUIBackgroundColor(color: string);
  35424. /** Pointerlock and fullscreen */
  35425. /**
  35426. * Ask the browser to promote the current element to pointerlock mode
  35427. * @param element defines the DOM element to promote
  35428. */
  35429. static _RequestPointerlock(element: HTMLElement): void;
  35430. /**
  35431. * Asks the browser to exit pointerlock mode
  35432. */
  35433. static _ExitPointerlock(): void;
  35434. /**
  35435. * Ask the browser to promote the current element to fullscreen rendering mode
  35436. * @param element defines the DOM element to promote
  35437. */
  35438. static _RequestFullscreen(element: HTMLElement): void;
  35439. /**
  35440. * Asks the browser to exit fullscreen mode
  35441. */
  35442. static _ExitFullscreen(): void;
  35443. }
  35444. }
  35445. declare module "babylonjs/Engines/engineStore" {
  35446. import { Nullable } from "babylonjs/types";
  35447. import { Engine } from "babylonjs/Engines/engine";
  35448. import { Scene } from "babylonjs/scene";
  35449. /**
  35450. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35451. * during the life time of the application.
  35452. */
  35453. export class EngineStore {
  35454. /** Gets the list of created engines */
  35455. static Instances: import("babylonjs/Engines/engine").Engine[];
  35456. /** @hidden */
  35457. static _LastCreatedScene: Nullable<Scene>;
  35458. /**
  35459. * Gets the latest created engine
  35460. */
  35461. static get LastCreatedEngine(): Nullable<Engine>;
  35462. /**
  35463. * Gets the latest created scene
  35464. */
  35465. static get LastCreatedScene(): Nullable<Scene>;
  35466. /**
  35467. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35468. * @ignorenaming
  35469. */
  35470. static UseFallbackTexture: boolean;
  35471. /**
  35472. * Texture content used if a texture cannot loaded
  35473. * @ignorenaming
  35474. */
  35475. static FallbackTexture: string;
  35476. }
  35477. }
  35478. declare module "babylonjs/Misc/promise" {
  35479. /**
  35480. * Helper class that provides a small promise polyfill
  35481. */
  35482. export class PromisePolyfill {
  35483. /**
  35484. * Static function used to check if the polyfill is required
  35485. * If this is the case then the function will inject the polyfill to window.Promise
  35486. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35487. */
  35488. static Apply(force?: boolean): void;
  35489. }
  35490. }
  35491. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35492. /**
  35493. * Interface for screenshot methods with describe argument called `size` as object with options
  35494. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35495. */
  35496. export interface IScreenshotSize {
  35497. /**
  35498. * number in pixels for canvas height
  35499. */
  35500. height?: number;
  35501. /**
  35502. * multiplier allowing render at a higher or lower resolution
  35503. * If value is defined then height and width will be ignored and taken from camera
  35504. */
  35505. precision?: number;
  35506. /**
  35507. * number in pixels for canvas width
  35508. */
  35509. width?: number;
  35510. }
  35511. }
  35512. declare module "babylonjs/Misc/tools" {
  35513. import { Nullable, float } from "babylonjs/types";
  35514. import { DomManagement } from "babylonjs/Misc/domManagement";
  35515. import { WebRequest } from "babylonjs/Misc/webRequest";
  35516. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35517. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35518. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35519. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35520. import { Camera } from "babylonjs/Cameras/camera";
  35521. import { Engine } from "babylonjs/Engines/engine";
  35522. interface IColor4Like {
  35523. r: float;
  35524. g: float;
  35525. b: float;
  35526. a: float;
  35527. }
  35528. /**
  35529. * Class containing a set of static utilities functions
  35530. */
  35531. export class Tools {
  35532. /**
  35533. * Gets or sets the base URL to use to load assets
  35534. */
  35535. static get BaseUrl(): string;
  35536. static set BaseUrl(value: string);
  35537. /**
  35538. * Enable/Disable Custom HTTP Request Headers globally.
  35539. * default = false
  35540. * @see CustomRequestHeaders
  35541. */
  35542. static UseCustomRequestHeaders: boolean;
  35543. /**
  35544. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35545. * i.e. when loading files, where the server/service expects an Authorization header
  35546. */
  35547. static CustomRequestHeaders: {
  35548. [key: string]: string;
  35549. };
  35550. /**
  35551. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35552. */
  35553. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35554. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35555. /**
  35556. * Default behaviour for cors in the application.
  35557. * It can be a string if the expected behavior is identical in the entire app.
  35558. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35559. */
  35560. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35561. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35562. /**
  35563. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35564. * @ignorenaming
  35565. */
  35566. static get UseFallbackTexture(): boolean;
  35567. static set UseFallbackTexture(value: boolean);
  35568. /**
  35569. * Use this object to register external classes like custom textures or material
  35570. * to allow the laoders to instantiate them
  35571. */
  35572. static get RegisteredExternalClasses(): {
  35573. [key: string]: Object;
  35574. };
  35575. static set RegisteredExternalClasses(classes: {
  35576. [key: string]: Object;
  35577. });
  35578. /**
  35579. * Texture content used if a texture cannot loaded
  35580. * @ignorenaming
  35581. */
  35582. static get fallbackTexture(): string;
  35583. static set fallbackTexture(value: string);
  35584. /**
  35585. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35586. * @param u defines the coordinate on X axis
  35587. * @param v defines the coordinate on Y axis
  35588. * @param width defines the width of the source data
  35589. * @param height defines the height of the source data
  35590. * @param pixels defines the source byte array
  35591. * @param color defines the output color
  35592. */
  35593. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35594. /**
  35595. * Interpolates between a and b via alpha
  35596. * @param a The lower value (returned when alpha = 0)
  35597. * @param b The upper value (returned when alpha = 1)
  35598. * @param alpha The interpolation-factor
  35599. * @return The mixed value
  35600. */
  35601. static Mix(a: number, b: number, alpha: number): number;
  35602. /**
  35603. * Tries to instantiate a new object from a given class name
  35604. * @param className defines the class name to instantiate
  35605. * @returns the new object or null if the system was not able to do the instantiation
  35606. */
  35607. static Instantiate(className: string): any;
  35608. /**
  35609. * Provides a slice function that will work even on IE
  35610. * @param data defines the array to slice
  35611. * @param start defines the start of the data (optional)
  35612. * @param end defines the end of the data (optional)
  35613. * @returns the new sliced array
  35614. */
  35615. static Slice<T>(data: T, start?: number, end?: number): T;
  35616. /**
  35617. * Polyfill for setImmediate
  35618. * @param action defines the action to execute after the current execution block
  35619. */
  35620. static SetImmediate(action: () => void): void;
  35621. /**
  35622. * Function indicating if a number is an exponent of 2
  35623. * @param value defines the value to test
  35624. * @returns true if the value is an exponent of 2
  35625. */
  35626. static IsExponentOfTwo(value: number): boolean;
  35627. private static _tmpFloatArray;
  35628. /**
  35629. * Returns the nearest 32-bit single precision float representation of a Number
  35630. * @param value A Number. If the parameter is of a different type, it will get converted
  35631. * to a number or to NaN if it cannot be converted
  35632. * @returns number
  35633. */
  35634. static FloatRound(value: number): number;
  35635. /**
  35636. * Extracts the filename from a path
  35637. * @param path defines the path to use
  35638. * @returns the filename
  35639. */
  35640. static GetFilename(path: string): string;
  35641. /**
  35642. * Extracts the "folder" part of a path (everything before the filename).
  35643. * @param uri The URI to extract the info from
  35644. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35645. * @returns The "folder" part of the path
  35646. */
  35647. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35648. /**
  35649. * Extracts text content from a DOM element hierarchy
  35650. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35651. */
  35652. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35653. /**
  35654. * Convert an angle in radians to degrees
  35655. * @param angle defines the angle to convert
  35656. * @returns the angle in degrees
  35657. */
  35658. static ToDegrees(angle: number): number;
  35659. /**
  35660. * Convert an angle in degrees to radians
  35661. * @param angle defines the angle to convert
  35662. * @returns the angle in radians
  35663. */
  35664. static ToRadians(angle: number): number;
  35665. /**
  35666. * Returns an array if obj is not an array
  35667. * @param obj defines the object to evaluate as an array
  35668. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35669. * @returns either obj directly if obj is an array or a new array containing obj
  35670. */
  35671. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35672. /**
  35673. * Gets the pointer prefix to use
  35674. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35675. */
  35676. static GetPointerPrefix(): string;
  35677. /**
  35678. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35679. * @param url define the url we are trying
  35680. * @param element define the dom element where to configure the cors policy
  35681. */
  35682. static SetCorsBehavior(url: string | string[], element: {
  35683. crossOrigin: string | null;
  35684. }): void;
  35685. /**
  35686. * Removes unwanted characters from an url
  35687. * @param url defines the url to clean
  35688. * @returns the cleaned url
  35689. */
  35690. static CleanUrl(url: string): string;
  35691. /**
  35692. * Gets or sets a function used to pre-process url before using them to load assets
  35693. */
  35694. static get PreprocessUrl(): (url: string) => string;
  35695. static set PreprocessUrl(processor: (url: string) => string);
  35696. /**
  35697. * Loads an image as an HTMLImageElement.
  35698. * @param input url string, ArrayBuffer, or Blob to load
  35699. * @param onLoad callback called when the image successfully loads
  35700. * @param onError callback called when the image fails to load
  35701. * @param offlineProvider offline provider for caching
  35702. * @param mimeType optional mime type
  35703. * @returns the HTMLImageElement of the loaded image
  35704. */
  35705. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35706. /**
  35707. * Loads a file from a url
  35708. * @param url url string, ArrayBuffer, or Blob to load
  35709. * @param onSuccess callback called when the file successfully loads
  35710. * @param onProgress callback called while file is loading (if the server supports this mode)
  35711. * @param offlineProvider defines the offline provider for caching
  35712. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35713. * @param onError callback called when the file fails to load
  35714. * @returns a file request object
  35715. */
  35716. 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;
  35717. /**
  35718. * Loads a file from a url
  35719. * @param url the file url to load
  35720. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35721. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35722. */
  35723. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35724. /**
  35725. * Load a script (identified by an url). When the url returns, the
  35726. * content of this file is added into a new script element, attached to the DOM (body element)
  35727. * @param scriptUrl defines the url of the script to laod
  35728. * @param onSuccess defines the callback called when the script is loaded
  35729. * @param onError defines the callback to call if an error occurs
  35730. * @param scriptId defines the id of the script element
  35731. */
  35732. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35733. /**
  35734. * Load an asynchronous script (identified by an url). When the url returns, the
  35735. * content of this file is added into a new script element, attached to the DOM (body element)
  35736. * @param scriptUrl defines the url of the script to laod
  35737. * @param scriptId defines the id of the script element
  35738. * @returns a promise request object
  35739. */
  35740. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35741. /**
  35742. * Loads a file from a blob
  35743. * @param fileToLoad defines the blob to use
  35744. * @param callback defines the callback to call when data is loaded
  35745. * @param progressCallback defines the callback to call during loading process
  35746. * @returns a file request object
  35747. */
  35748. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35749. /**
  35750. * Reads a file from a File object
  35751. * @param file defines the file to load
  35752. * @param onSuccess defines the callback to call when data is loaded
  35753. * @param onProgress defines the callback to call during loading process
  35754. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35755. * @param onError defines the callback to call when an error occurs
  35756. * @returns a file request object
  35757. */
  35758. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35759. /**
  35760. * Creates a data url from a given string content
  35761. * @param content defines the content to convert
  35762. * @returns the new data url link
  35763. */
  35764. static FileAsURL(content: string): string;
  35765. /**
  35766. * Format the given number to a specific decimal format
  35767. * @param value defines the number to format
  35768. * @param decimals defines the number of decimals to use
  35769. * @returns the formatted string
  35770. */
  35771. static Format(value: number, decimals?: number): string;
  35772. /**
  35773. * Tries to copy an object by duplicating every property
  35774. * @param source defines the source object
  35775. * @param destination defines the target object
  35776. * @param doNotCopyList defines a list of properties to avoid
  35777. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35778. */
  35779. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35780. /**
  35781. * Gets a boolean indicating if the given object has no own property
  35782. * @param obj defines the object to test
  35783. * @returns true if object has no own property
  35784. */
  35785. static IsEmpty(obj: any): boolean;
  35786. /**
  35787. * Function used to register events at window level
  35788. * @param windowElement defines the Window object to use
  35789. * @param events defines the events to register
  35790. */
  35791. static RegisterTopRootEvents(windowElement: Window, events: {
  35792. name: string;
  35793. handler: Nullable<(e: FocusEvent) => any>;
  35794. }[]): void;
  35795. /**
  35796. * Function used to unregister events from window level
  35797. * @param windowElement defines the Window object to use
  35798. * @param events defines the events to unregister
  35799. */
  35800. static UnregisterTopRootEvents(windowElement: Window, events: {
  35801. name: string;
  35802. handler: Nullable<(e: FocusEvent) => any>;
  35803. }[]): void;
  35804. /**
  35805. * @ignore
  35806. */
  35807. static _ScreenshotCanvas: HTMLCanvasElement;
  35808. /**
  35809. * Dumps the current bound framebuffer
  35810. * @param width defines the rendering width
  35811. * @param height defines the rendering height
  35812. * @param engine defines the hosting engine
  35813. * @param successCallback defines the callback triggered once the data are available
  35814. * @param mimeType defines the mime type of the result
  35815. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35816. */
  35817. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35818. /**
  35819. * Converts the canvas data to blob.
  35820. * This acts as a polyfill for browsers not supporting the to blob function.
  35821. * @param canvas Defines the canvas to extract the data from
  35822. * @param successCallback Defines the callback triggered once the data are available
  35823. * @param mimeType Defines the mime type of the result
  35824. */
  35825. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35826. /**
  35827. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35828. * @param successCallback defines the callback triggered once the data are available
  35829. * @param mimeType defines the mime type of the result
  35830. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35831. */
  35832. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35833. /**
  35834. * Downloads a blob in the browser
  35835. * @param blob defines the blob to download
  35836. * @param fileName defines the name of the downloaded file
  35837. */
  35838. static Download(blob: Blob, fileName: string): void;
  35839. /**
  35840. * Captures a screenshot of the current rendering
  35841. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35842. * @param engine defines the rendering engine
  35843. * @param camera defines the source camera
  35844. * @param size This parameter can be set to a single number or to an object with the
  35845. * following (optional) properties: precision, width, height. If a single number is passed,
  35846. * it will be used for both width and height. If an object is passed, the screenshot size
  35847. * will be derived from the parameters. The precision property is a multiplier allowing
  35848. * rendering at a higher or lower resolution
  35849. * @param successCallback defines the callback receives a single parameter which contains the
  35850. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35851. * src parameter of an <img> to display it
  35852. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35853. * Check your browser for supported MIME types
  35854. */
  35855. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35856. /**
  35857. * Captures a screenshot of the current rendering
  35858. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35859. * @param engine defines the rendering engine
  35860. * @param camera defines the source camera
  35861. * @param size This parameter can be set to a single number or to an object with the
  35862. * following (optional) properties: precision, width, height. If a single number is passed,
  35863. * it will be used for both width and height. If an object is passed, the screenshot size
  35864. * will be derived from the parameters. The precision property is a multiplier allowing
  35865. * rendering at a higher or lower resolution
  35866. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35867. * Check your browser for supported MIME types
  35868. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35869. * to the src parameter of an <img> to display it
  35870. */
  35871. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35872. /**
  35873. * Generates an image screenshot from the specified camera.
  35874. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35875. * @param engine The engine to use for rendering
  35876. * @param camera The camera to use for rendering
  35877. * @param size This parameter can be set to a single number or to an object with the
  35878. * following (optional) properties: precision, width, height. If a single number is passed,
  35879. * it will be used for both width and height. If an object is passed, the screenshot size
  35880. * will be derived from the parameters. The precision property is a multiplier allowing
  35881. * rendering at a higher or lower resolution
  35882. * @param successCallback The callback receives a single parameter which contains the
  35883. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35884. * src parameter of an <img> to display it
  35885. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35886. * Check your browser for supported MIME types
  35887. * @param samples Texture samples (default: 1)
  35888. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35889. * @param fileName A name for for the downloaded file.
  35890. */
  35891. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35892. /**
  35893. * Generates an image screenshot from the specified camera.
  35894. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35895. * @param engine The engine to use for rendering
  35896. * @param camera The camera to use for rendering
  35897. * @param size This parameter can be set to a single number or to an object with the
  35898. * following (optional) properties: precision, width, height. If a single number is passed,
  35899. * it will be used for both width and height. If an object is passed, the screenshot size
  35900. * will be derived from the parameters. The precision property is a multiplier allowing
  35901. * rendering at a higher or lower resolution
  35902. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35903. * Check your browser for supported MIME types
  35904. * @param samples Texture samples (default: 1)
  35905. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35906. * @param fileName A name for for the downloaded file.
  35907. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35908. * to the src parameter of an <img> to display it
  35909. */
  35910. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35911. /**
  35912. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35913. * Be aware Math.random() could cause collisions, but:
  35914. * "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"
  35915. * @returns a pseudo random id
  35916. */
  35917. static RandomId(): string;
  35918. /**
  35919. * Test if the given uri is a base64 string
  35920. * @param uri The uri to test
  35921. * @return True if the uri is a base64 string or false otherwise
  35922. */
  35923. static IsBase64(uri: string): boolean;
  35924. /**
  35925. * Decode the given base64 uri.
  35926. * @param uri The uri to decode
  35927. * @return The decoded base64 data.
  35928. */
  35929. static DecodeBase64(uri: string): ArrayBuffer;
  35930. /**
  35931. * Gets the absolute url.
  35932. * @param url the input url
  35933. * @return the absolute url
  35934. */
  35935. static GetAbsoluteUrl(url: string): string;
  35936. /**
  35937. * No log
  35938. */
  35939. static readonly NoneLogLevel: number;
  35940. /**
  35941. * Only message logs
  35942. */
  35943. static readonly MessageLogLevel: number;
  35944. /**
  35945. * Only warning logs
  35946. */
  35947. static readonly WarningLogLevel: number;
  35948. /**
  35949. * Only error logs
  35950. */
  35951. static readonly ErrorLogLevel: number;
  35952. /**
  35953. * All logs
  35954. */
  35955. static readonly AllLogLevel: number;
  35956. /**
  35957. * Gets a value indicating the number of loading errors
  35958. * @ignorenaming
  35959. */
  35960. static get errorsCount(): number;
  35961. /**
  35962. * Callback called when a new log is added
  35963. */
  35964. static OnNewCacheEntry: (entry: string) => void;
  35965. /**
  35966. * Log a message to the console
  35967. * @param message defines the message to log
  35968. */
  35969. static Log(message: string): void;
  35970. /**
  35971. * Write a warning message to the console
  35972. * @param message defines the message to log
  35973. */
  35974. static Warn(message: string): void;
  35975. /**
  35976. * Write an error message to the console
  35977. * @param message defines the message to log
  35978. */
  35979. static Error(message: string): void;
  35980. /**
  35981. * Gets current log cache (list of logs)
  35982. */
  35983. static get LogCache(): string;
  35984. /**
  35985. * Clears the log cache
  35986. */
  35987. static ClearLogCache(): void;
  35988. /**
  35989. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35990. */
  35991. static set LogLevels(level: number);
  35992. /**
  35993. * Checks if the window object exists
  35994. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35995. */
  35996. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35997. /**
  35998. * No performance log
  35999. */
  36000. static readonly PerformanceNoneLogLevel: number;
  36001. /**
  36002. * Use user marks to log performance
  36003. */
  36004. static readonly PerformanceUserMarkLogLevel: number;
  36005. /**
  36006. * Log performance to the console
  36007. */
  36008. static readonly PerformanceConsoleLogLevel: number;
  36009. private static _performance;
  36010. /**
  36011. * Sets the current performance log level
  36012. */
  36013. static set PerformanceLogLevel(level: number);
  36014. private static _StartPerformanceCounterDisabled;
  36015. private static _EndPerformanceCounterDisabled;
  36016. private static _StartUserMark;
  36017. private static _EndUserMark;
  36018. private static _StartPerformanceConsole;
  36019. private static _EndPerformanceConsole;
  36020. /**
  36021. * Starts a performance counter
  36022. */
  36023. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36024. /**
  36025. * Ends a specific performance coutner
  36026. */
  36027. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  36028. /**
  36029. * Gets either window.performance.now() if supported or Date.now() else
  36030. */
  36031. static get Now(): number;
  36032. /**
  36033. * This method will return the name of the class used to create the instance of the given object.
  36034. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  36035. * @param object the object to get the class name from
  36036. * @param isType defines if the object is actually a type
  36037. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  36038. */
  36039. static GetClassName(object: any, isType?: boolean): string;
  36040. /**
  36041. * Gets the first element of an array satisfying a given predicate
  36042. * @param array defines the array to browse
  36043. * @param predicate defines the predicate to use
  36044. * @returns null if not found or the element
  36045. */
  36046. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  36047. /**
  36048. * This method will return the name of the full name of the class, including its owning module (if any).
  36049. * 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).
  36050. * @param object the object to get the class name from
  36051. * @param isType defines if the object is actually a type
  36052. * @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.
  36053. * @ignorenaming
  36054. */
  36055. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  36056. /**
  36057. * Returns a promise that resolves after the given amount of time.
  36058. * @param delay Number of milliseconds to delay
  36059. * @returns Promise that resolves after the given amount of time
  36060. */
  36061. static DelayAsync(delay: number): Promise<void>;
  36062. /**
  36063. * Utility function to detect if the current user agent is Safari
  36064. * @returns whether or not the current user agent is safari
  36065. */
  36066. static IsSafari(): boolean;
  36067. }
  36068. /**
  36069. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  36070. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  36071. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  36072. * @param name The name of the class, case should be preserved
  36073. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  36074. */
  36075. export function className(name: string, module?: string): (target: Object) => void;
  36076. /**
  36077. * An implementation of a loop for asynchronous functions.
  36078. */
  36079. export class AsyncLoop {
  36080. /**
  36081. * Defines the number of iterations for the loop
  36082. */
  36083. iterations: number;
  36084. /**
  36085. * Defines the current index of the loop.
  36086. */
  36087. index: number;
  36088. private _done;
  36089. private _fn;
  36090. private _successCallback;
  36091. /**
  36092. * Constructor.
  36093. * @param iterations the number of iterations.
  36094. * @param func the function to run each iteration
  36095. * @param successCallback the callback that will be called upon succesful execution
  36096. * @param offset starting offset.
  36097. */
  36098. constructor(
  36099. /**
  36100. * Defines the number of iterations for the loop
  36101. */
  36102. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  36103. /**
  36104. * Execute the next iteration. Must be called after the last iteration was finished.
  36105. */
  36106. executeNext(): void;
  36107. /**
  36108. * Break the loop and run the success callback.
  36109. */
  36110. breakLoop(): void;
  36111. /**
  36112. * Create and run an async loop.
  36113. * @param iterations the number of iterations.
  36114. * @param fn the function to run each iteration
  36115. * @param successCallback the callback that will be called upon succesful execution
  36116. * @param offset starting offset.
  36117. * @returns the created async loop object
  36118. */
  36119. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  36120. /**
  36121. * A for-loop that will run a given number of iterations synchronous and the rest async.
  36122. * @param iterations total number of iterations
  36123. * @param syncedIterations number of synchronous iterations in each async iteration.
  36124. * @param fn the function to call each iteration.
  36125. * @param callback a success call back that will be called when iterating stops.
  36126. * @param breakFunction a break condition (optional)
  36127. * @param timeout timeout settings for the setTimeout function. default - 0.
  36128. * @returns the created async loop object
  36129. */
  36130. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  36131. }
  36132. }
  36133. declare module "babylonjs/Misc/stringDictionary" {
  36134. import { Nullable } from "babylonjs/types";
  36135. /**
  36136. * This class implement a typical dictionary using a string as key and the generic type T as value.
  36137. * The underlying implementation relies on an associative array to ensure the best performances.
  36138. * The value can be anything including 'null' but except 'undefined'
  36139. */
  36140. export class StringDictionary<T> {
  36141. /**
  36142. * This will clear this dictionary and copy the content from the 'source' one.
  36143. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  36144. * @param source the dictionary to take the content from and copy to this dictionary
  36145. */
  36146. copyFrom(source: StringDictionary<T>): void;
  36147. /**
  36148. * Get a value based from its key
  36149. * @param key the given key to get the matching value from
  36150. * @return the value if found, otherwise undefined is returned
  36151. */
  36152. get(key: string): T | undefined;
  36153. /**
  36154. * Get a value from its key or add it if it doesn't exist.
  36155. * This method will ensure you that a given key/data will be present in the dictionary.
  36156. * @param key the given key to get the matching value from
  36157. * @param factory the factory that will create the value if the key is not present in the dictionary.
  36158. * The factory will only be invoked if there's no data for the given key.
  36159. * @return the value corresponding to the key.
  36160. */
  36161. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  36162. /**
  36163. * Get a value from its key if present in the dictionary otherwise add it
  36164. * @param key the key to get the value from
  36165. * @param val if there's no such key/value pair in the dictionary add it with this value
  36166. * @return the value corresponding to the key
  36167. */
  36168. getOrAdd(key: string, val: T): T;
  36169. /**
  36170. * Check if there's a given key in the dictionary
  36171. * @param key the key to check for
  36172. * @return true if the key is present, false otherwise
  36173. */
  36174. contains(key: string): boolean;
  36175. /**
  36176. * Add a new key and its corresponding value
  36177. * @param key the key to add
  36178. * @param value the value corresponding to the key
  36179. * @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
  36180. */
  36181. add(key: string, value: T): boolean;
  36182. /**
  36183. * Update a specific value associated to a key
  36184. * @param key defines the key to use
  36185. * @param value defines the value to store
  36186. * @returns true if the value was updated (or false if the key was not found)
  36187. */
  36188. set(key: string, value: T): boolean;
  36189. /**
  36190. * Get the element of the given key and remove it from the dictionary
  36191. * @param key defines the key to search
  36192. * @returns the value associated with the key or null if not found
  36193. */
  36194. getAndRemove(key: string): Nullable<T>;
  36195. /**
  36196. * Remove a key/value from the dictionary.
  36197. * @param key the key to remove
  36198. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36199. */
  36200. remove(key: string): boolean;
  36201. /**
  36202. * Clear the whole content of the dictionary
  36203. */
  36204. clear(): void;
  36205. /**
  36206. * Gets the current count
  36207. */
  36208. get count(): number;
  36209. /**
  36210. * Execute a callback on each key/val of the dictionary.
  36211. * Note that you can remove any element in this dictionary in the callback implementation
  36212. * @param callback the callback to execute on a given key/value pair
  36213. */
  36214. forEach(callback: (key: string, val: T) => void): void;
  36215. /**
  36216. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36217. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36218. * Note that you can remove any element in this dictionary in the callback implementation
  36219. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36220. * @returns the first item
  36221. */
  36222. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36223. private _count;
  36224. private _data;
  36225. }
  36226. }
  36227. declare module "babylonjs/Collisions/collisionCoordinator" {
  36228. import { Nullable } from "babylonjs/types";
  36229. import { Scene } from "babylonjs/scene";
  36230. import { Vector3 } from "babylonjs/Maths/math.vector";
  36231. import { Collider } from "babylonjs/Collisions/collider";
  36232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36233. /** @hidden */
  36234. export interface ICollisionCoordinator {
  36235. createCollider(): Collider;
  36236. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36237. init(scene: Scene): void;
  36238. }
  36239. /** @hidden */
  36240. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36241. private _scene;
  36242. private _scaledPosition;
  36243. private _scaledVelocity;
  36244. private _finalPosition;
  36245. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36246. createCollider(): Collider;
  36247. init(scene: Scene): void;
  36248. private _collideWithWorld;
  36249. }
  36250. }
  36251. declare module "babylonjs/Inputs/scene.inputManager" {
  36252. import { Nullable } from "babylonjs/types";
  36253. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36254. import { Vector2 } from "babylonjs/Maths/math.vector";
  36255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36256. import { Scene } from "babylonjs/scene";
  36257. /**
  36258. * Class used to manage all inputs for the scene.
  36259. */
  36260. export class InputManager {
  36261. /** The distance in pixel that you have to move to prevent some events */
  36262. static DragMovementThreshold: number;
  36263. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36264. static LongPressDelay: number;
  36265. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36266. static DoubleClickDelay: number;
  36267. /** If you need to check double click without raising a single click at first click, enable this flag */
  36268. static ExclusiveDoubleClickMode: boolean;
  36269. private _wheelEventName;
  36270. private _onPointerMove;
  36271. private _onPointerDown;
  36272. private _onPointerUp;
  36273. private _initClickEvent;
  36274. private _initActionManager;
  36275. private _delayedSimpleClick;
  36276. private _delayedSimpleClickTimeout;
  36277. private _previousDelayedSimpleClickTimeout;
  36278. private _meshPickProceed;
  36279. private _previousButtonPressed;
  36280. private _currentPickResult;
  36281. private _previousPickResult;
  36282. private _totalPointersPressed;
  36283. private _doubleClickOccured;
  36284. private _pointerOverMesh;
  36285. private _pickedDownMesh;
  36286. private _pickedUpMesh;
  36287. private _pointerX;
  36288. private _pointerY;
  36289. private _unTranslatedPointerX;
  36290. private _unTranslatedPointerY;
  36291. private _startingPointerPosition;
  36292. private _previousStartingPointerPosition;
  36293. private _startingPointerTime;
  36294. private _previousStartingPointerTime;
  36295. private _pointerCaptures;
  36296. private _onKeyDown;
  36297. private _onKeyUp;
  36298. private _onCanvasFocusObserver;
  36299. private _onCanvasBlurObserver;
  36300. private _scene;
  36301. /**
  36302. * Creates a new InputManager
  36303. * @param scene defines the hosting scene
  36304. */
  36305. constructor(scene: Scene);
  36306. /**
  36307. * Gets the mesh that is currently under the pointer
  36308. */
  36309. get meshUnderPointer(): Nullable<AbstractMesh>;
  36310. /**
  36311. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36312. */
  36313. get unTranslatedPointer(): Vector2;
  36314. /**
  36315. * Gets or sets the current on-screen X position of the pointer
  36316. */
  36317. get pointerX(): number;
  36318. set pointerX(value: number);
  36319. /**
  36320. * Gets or sets the current on-screen Y position of the pointer
  36321. */
  36322. get pointerY(): number;
  36323. set pointerY(value: number);
  36324. private _updatePointerPosition;
  36325. private _processPointerMove;
  36326. private _setRayOnPointerInfo;
  36327. private _checkPrePointerObservable;
  36328. /**
  36329. * Use this method to simulate a pointer move on a mesh
  36330. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36331. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36332. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36333. */
  36334. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36335. /**
  36336. * Use this method to simulate a pointer down on a mesh
  36337. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36338. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36339. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36340. */
  36341. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36342. private _processPointerDown;
  36343. /** @hidden */
  36344. _isPointerSwiping(): boolean;
  36345. /**
  36346. * Use this method to simulate a pointer up on a mesh
  36347. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36348. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36349. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36350. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36351. */
  36352. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36353. private _processPointerUp;
  36354. /**
  36355. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36356. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36357. * @returns true if the pointer was captured
  36358. */
  36359. isPointerCaptured(pointerId?: number): boolean;
  36360. /**
  36361. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36362. * @param attachUp defines if you want to attach events to pointerup
  36363. * @param attachDown defines if you want to attach events to pointerdown
  36364. * @param attachMove defines if you want to attach events to pointermove
  36365. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36366. */
  36367. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36368. /**
  36369. * Detaches all event handlers
  36370. */
  36371. detachControl(): void;
  36372. /**
  36373. * Force the value of meshUnderPointer
  36374. * @param mesh defines the mesh to use
  36375. */
  36376. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36377. /**
  36378. * Gets the mesh under the pointer
  36379. * @returns a Mesh or null if no mesh is under the pointer
  36380. */
  36381. getPointerOverMesh(): Nullable<AbstractMesh>;
  36382. }
  36383. }
  36384. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36385. /**
  36386. * Helper class used to generate session unique ID
  36387. */
  36388. export class UniqueIdGenerator {
  36389. private static _UniqueIdCounter;
  36390. /**
  36391. * Gets an unique (relatively to the current scene) Id
  36392. */
  36393. static get UniqueId(): number;
  36394. }
  36395. }
  36396. declare module "babylonjs/Animations/animationGroup" {
  36397. import { Animatable } from "babylonjs/Animations/animatable";
  36398. import { Animation } from "babylonjs/Animations/animation";
  36399. import { Scene, IDisposable } from "babylonjs/scene";
  36400. import { Observable } from "babylonjs/Misc/observable";
  36401. import { Nullable } from "babylonjs/types";
  36402. import "babylonjs/Animations/animatable";
  36403. /**
  36404. * This class defines the direct association between an animation and a target
  36405. */
  36406. export class TargetedAnimation {
  36407. /**
  36408. * Animation to perform
  36409. */
  36410. animation: Animation;
  36411. /**
  36412. * Target to animate
  36413. */
  36414. target: any;
  36415. /**
  36416. * Serialize the object
  36417. * @returns the JSON object representing the current entity
  36418. */
  36419. serialize(): any;
  36420. }
  36421. /**
  36422. * Use this class to create coordinated animations on multiple targets
  36423. */
  36424. export class AnimationGroup implements IDisposable {
  36425. /** The name of the animation group */
  36426. name: string;
  36427. private _scene;
  36428. private _targetedAnimations;
  36429. private _animatables;
  36430. private _from;
  36431. private _to;
  36432. private _isStarted;
  36433. private _isPaused;
  36434. private _speedRatio;
  36435. private _loopAnimation;
  36436. private _isAdditive;
  36437. /**
  36438. * Gets or sets the unique id of the node
  36439. */
  36440. uniqueId: number;
  36441. /**
  36442. * This observable will notify when one animation have ended
  36443. */
  36444. onAnimationEndObservable: Observable<TargetedAnimation>;
  36445. /**
  36446. * Observer raised when one animation loops
  36447. */
  36448. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36449. /**
  36450. * Observer raised when all animations have looped
  36451. */
  36452. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36453. /**
  36454. * This observable will notify when all animations have ended.
  36455. */
  36456. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36457. /**
  36458. * This observable will notify when all animations have paused.
  36459. */
  36460. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36461. /**
  36462. * This observable will notify when all animations are playing.
  36463. */
  36464. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36465. /**
  36466. * Gets the first frame
  36467. */
  36468. get from(): number;
  36469. /**
  36470. * Gets the last frame
  36471. */
  36472. get to(): number;
  36473. /**
  36474. * Define if the animations are started
  36475. */
  36476. get isStarted(): boolean;
  36477. /**
  36478. * Gets a value indicating that the current group is playing
  36479. */
  36480. get isPlaying(): boolean;
  36481. /**
  36482. * Gets or sets the speed ratio to use for all animations
  36483. */
  36484. get speedRatio(): number;
  36485. /**
  36486. * Gets or sets the speed ratio to use for all animations
  36487. */
  36488. set speedRatio(value: number);
  36489. /**
  36490. * Gets or sets if all animations should loop or not
  36491. */
  36492. get loopAnimation(): boolean;
  36493. set loopAnimation(value: boolean);
  36494. /**
  36495. * Gets or sets if all animations should be evaluated additively
  36496. */
  36497. get isAdditive(): boolean;
  36498. set isAdditive(value: boolean);
  36499. /**
  36500. * Gets the targeted animations for this animation group
  36501. */
  36502. get targetedAnimations(): Array<TargetedAnimation>;
  36503. /**
  36504. * returning the list of animatables controlled by this animation group.
  36505. */
  36506. get animatables(): Array<Animatable>;
  36507. /**
  36508. * Instantiates a new Animation Group.
  36509. * This helps managing several animations at once.
  36510. * @see http://doc.babylonjs.com/how_to/group
  36511. * @param name Defines the name of the group
  36512. * @param scene Defines the scene the group belongs to
  36513. */
  36514. constructor(
  36515. /** The name of the animation group */
  36516. name: string, scene?: Nullable<Scene>);
  36517. /**
  36518. * Add an animation (with its target) in the group
  36519. * @param animation defines the animation we want to add
  36520. * @param target defines the target of the animation
  36521. * @returns the TargetedAnimation object
  36522. */
  36523. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36524. /**
  36525. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36526. * It can add constant keys at begin or end
  36527. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36528. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36529. * @returns the animation group
  36530. */
  36531. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36532. private _animationLoopCount;
  36533. private _animationLoopFlags;
  36534. private _processLoop;
  36535. /**
  36536. * Start all animations on given targets
  36537. * @param loop defines if animations must loop
  36538. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36539. * @param from defines the from key (optional)
  36540. * @param to defines the to key (optional)
  36541. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36542. * @returns the current animation group
  36543. */
  36544. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36545. /**
  36546. * Pause all animations
  36547. * @returns the animation group
  36548. */
  36549. pause(): AnimationGroup;
  36550. /**
  36551. * Play all animations to initial state
  36552. * This function will start() the animations if they were not started or will restart() them if they were paused
  36553. * @param loop defines if animations must loop
  36554. * @returns the animation group
  36555. */
  36556. play(loop?: boolean): AnimationGroup;
  36557. /**
  36558. * Reset all animations to initial state
  36559. * @returns the animation group
  36560. */
  36561. reset(): AnimationGroup;
  36562. /**
  36563. * Restart animations from key 0
  36564. * @returns the animation group
  36565. */
  36566. restart(): AnimationGroup;
  36567. /**
  36568. * Stop all animations
  36569. * @returns the animation group
  36570. */
  36571. stop(): AnimationGroup;
  36572. /**
  36573. * Set animation weight for all animatables
  36574. * @param weight defines the weight to use
  36575. * @return the animationGroup
  36576. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36577. */
  36578. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36579. /**
  36580. * Synchronize and normalize all animatables with a source animatable
  36581. * @param root defines the root animatable to synchronize with
  36582. * @return the animationGroup
  36583. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36584. */
  36585. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36586. /**
  36587. * Goes to a specific frame in this animation group
  36588. * @param frame the frame number to go to
  36589. * @return the animationGroup
  36590. */
  36591. goToFrame(frame: number): AnimationGroup;
  36592. /**
  36593. * Dispose all associated resources
  36594. */
  36595. dispose(): void;
  36596. private _checkAnimationGroupEnded;
  36597. /**
  36598. * Clone the current animation group and returns a copy
  36599. * @param newName defines the name of the new group
  36600. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36601. * @returns the new aniamtion group
  36602. */
  36603. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36604. /**
  36605. * Serializes the animationGroup to an object
  36606. * @returns Serialized object
  36607. */
  36608. serialize(): any;
  36609. /**
  36610. * Returns a new AnimationGroup object parsed from the source provided.
  36611. * @param parsedAnimationGroup defines the source
  36612. * @param scene defines the scene that will receive the animationGroup
  36613. * @returns a new AnimationGroup
  36614. */
  36615. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36616. /**
  36617. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36618. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36619. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36620. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36621. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36622. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36623. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36624. */
  36625. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36626. /**
  36627. * Returns the string "AnimationGroup"
  36628. * @returns "AnimationGroup"
  36629. */
  36630. getClassName(): string;
  36631. /**
  36632. * Creates a detailled string about the object
  36633. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36634. * @returns a string representing the object
  36635. */
  36636. toString(fullDetails?: boolean): string;
  36637. }
  36638. }
  36639. declare module "babylonjs/scene" {
  36640. import { Nullable } from "babylonjs/types";
  36641. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36642. import { Observable } from "babylonjs/Misc/observable";
  36643. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36644. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36645. import { Geometry } from "babylonjs/Meshes/geometry";
  36646. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36647. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36649. import { Mesh } from "babylonjs/Meshes/mesh";
  36650. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36651. import { Bone } from "babylonjs/Bones/bone";
  36652. import { Skeleton } from "babylonjs/Bones/skeleton";
  36653. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36654. import { Camera } from "babylonjs/Cameras/camera";
  36655. import { AbstractScene } from "babylonjs/abstractScene";
  36656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36657. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36658. import { Material } from "babylonjs/Materials/material";
  36659. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36660. import { Effect } from "babylonjs/Materials/effect";
  36661. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36662. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36663. import { Light } from "babylonjs/Lights/light";
  36664. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36665. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36666. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36667. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36668. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36669. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36670. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36671. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36672. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36673. import { Engine } from "babylonjs/Engines/engine";
  36674. import { Node } from "babylonjs/node";
  36675. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36676. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36677. import { WebRequest } from "babylonjs/Misc/webRequest";
  36678. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36679. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36680. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36681. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36682. import { Plane } from "babylonjs/Maths/math.plane";
  36683. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36684. import { Ray } from "babylonjs/Culling/ray";
  36685. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36686. import { Animation } from "babylonjs/Animations/animation";
  36687. import { Animatable } from "babylonjs/Animations/animatable";
  36688. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36689. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36690. import { Collider } from "babylonjs/Collisions/collider";
  36691. /**
  36692. * Define an interface for all classes that will hold resources
  36693. */
  36694. export interface IDisposable {
  36695. /**
  36696. * Releases all held resources
  36697. */
  36698. dispose(): void;
  36699. }
  36700. /** Interface defining initialization parameters for Scene class */
  36701. export interface SceneOptions {
  36702. /**
  36703. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36704. * It will improve performance when the number of geometries becomes important.
  36705. */
  36706. useGeometryUniqueIdsMap?: boolean;
  36707. /**
  36708. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36709. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36710. */
  36711. useMaterialMeshMap?: boolean;
  36712. /**
  36713. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36714. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36715. */
  36716. useClonedMeshMap?: boolean;
  36717. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36718. virtual?: boolean;
  36719. }
  36720. /**
  36721. * Represents a scene to be rendered by the engine.
  36722. * @see http://doc.babylonjs.com/features/scene
  36723. */
  36724. export class Scene extends AbstractScene implements IAnimatable {
  36725. /** The fog is deactivated */
  36726. static readonly FOGMODE_NONE: number;
  36727. /** The fog density is following an exponential function */
  36728. static readonly FOGMODE_EXP: number;
  36729. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36730. static readonly FOGMODE_EXP2: number;
  36731. /** The fog density is following a linear function. */
  36732. static readonly FOGMODE_LINEAR: number;
  36733. /**
  36734. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36736. */
  36737. static MinDeltaTime: number;
  36738. /**
  36739. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36741. */
  36742. static MaxDeltaTime: number;
  36743. /**
  36744. * Factory used to create the default material.
  36745. * @param name The name of the material to create
  36746. * @param scene The scene to create the material for
  36747. * @returns The default material
  36748. */
  36749. static DefaultMaterialFactory(scene: Scene): Material;
  36750. /**
  36751. * Factory used to create the a collision coordinator.
  36752. * @returns The collision coordinator
  36753. */
  36754. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36755. /** @hidden */
  36756. _inputManager: InputManager;
  36757. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36758. cameraToUseForPointers: Nullable<Camera>;
  36759. /** @hidden */
  36760. readonly _isScene: boolean;
  36761. /** @hidden */
  36762. _blockEntityCollection: boolean;
  36763. /**
  36764. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36765. */
  36766. autoClear: boolean;
  36767. /**
  36768. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36769. */
  36770. autoClearDepthAndStencil: boolean;
  36771. /**
  36772. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36773. */
  36774. clearColor: Color4;
  36775. /**
  36776. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36777. */
  36778. ambientColor: Color3;
  36779. /**
  36780. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36781. * It should only be one of the following (if not the default embedded one):
  36782. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36783. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36784. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36785. * The material properties need to be setup according to the type of texture in use.
  36786. */
  36787. environmentBRDFTexture: BaseTexture;
  36788. /** @hidden */
  36789. protected _environmentTexture: Nullable<BaseTexture>;
  36790. /**
  36791. * Texture used in all pbr material as the reflection texture.
  36792. * As in the majority of the scene they are the same (exception for multi room and so on),
  36793. * this is easier to reference from here than from all the materials.
  36794. */
  36795. get environmentTexture(): Nullable<BaseTexture>;
  36796. /**
  36797. * Texture used in all pbr material as the reflection texture.
  36798. * As in the majority of the scene they are the same (exception for multi room and so on),
  36799. * this is easier to set here than in all the materials.
  36800. */
  36801. set environmentTexture(value: Nullable<BaseTexture>);
  36802. /** @hidden */
  36803. protected _environmentIntensity: number;
  36804. /**
  36805. * Intensity of the environment in all pbr material.
  36806. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36807. * As in the majority of the scene they are the same (exception for multi room and so on),
  36808. * this is easier to reference from here than from all the materials.
  36809. */
  36810. get environmentIntensity(): number;
  36811. /**
  36812. * Intensity of the environment in all pbr material.
  36813. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36814. * As in the majority of the scene they are the same (exception for multi room and so on),
  36815. * this is easier to set here than in all the materials.
  36816. */
  36817. set environmentIntensity(value: number);
  36818. /** @hidden */
  36819. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36820. /**
  36821. * Default image processing configuration used either in the rendering
  36822. * Forward main pass or through the imageProcessingPostProcess if present.
  36823. * As in the majority of the scene they are the same (exception for multi camera),
  36824. * this is easier to reference from here than from all the materials and post process.
  36825. *
  36826. * No setter as we it is a shared configuration, you can set the values instead.
  36827. */
  36828. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36829. private _forceWireframe;
  36830. /**
  36831. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36832. */
  36833. set forceWireframe(value: boolean);
  36834. get forceWireframe(): boolean;
  36835. private _skipFrustumClipping;
  36836. /**
  36837. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36838. */
  36839. set skipFrustumClipping(value: boolean);
  36840. get skipFrustumClipping(): boolean;
  36841. private _forcePointsCloud;
  36842. /**
  36843. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36844. */
  36845. set forcePointsCloud(value: boolean);
  36846. get forcePointsCloud(): boolean;
  36847. /**
  36848. * Gets or sets the active clipplane 1
  36849. */
  36850. clipPlane: Nullable<Plane>;
  36851. /**
  36852. * Gets or sets the active clipplane 2
  36853. */
  36854. clipPlane2: Nullable<Plane>;
  36855. /**
  36856. * Gets or sets the active clipplane 3
  36857. */
  36858. clipPlane3: Nullable<Plane>;
  36859. /**
  36860. * Gets or sets the active clipplane 4
  36861. */
  36862. clipPlane4: Nullable<Plane>;
  36863. /**
  36864. * Gets or sets the active clipplane 5
  36865. */
  36866. clipPlane5: Nullable<Plane>;
  36867. /**
  36868. * Gets or sets the active clipplane 6
  36869. */
  36870. clipPlane6: Nullable<Plane>;
  36871. /**
  36872. * Gets or sets a boolean indicating if animations are enabled
  36873. */
  36874. animationsEnabled: boolean;
  36875. private _animationPropertiesOverride;
  36876. /**
  36877. * Gets or sets the animation properties override
  36878. */
  36879. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36880. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36881. /**
  36882. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36883. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36884. */
  36885. useConstantAnimationDeltaTime: boolean;
  36886. /**
  36887. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36888. * Please note that it requires to run a ray cast through the scene on every frame
  36889. */
  36890. constantlyUpdateMeshUnderPointer: boolean;
  36891. /**
  36892. * Defines the HTML cursor to use when hovering over interactive elements
  36893. */
  36894. hoverCursor: string;
  36895. /**
  36896. * Defines the HTML default cursor to use (empty by default)
  36897. */
  36898. defaultCursor: string;
  36899. /**
  36900. * Defines whether cursors are handled by the scene.
  36901. */
  36902. doNotHandleCursors: boolean;
  36903. /**
  36904. * This is used to call preventDefault() on pointer down
  36905. * in order to block unwanted artifacts like system double clicks
  36906. */
  36907. preventDefaultOnPointerDown: boolean;
  36908. /**
  36909. * This is used to call preventDefault() on pointer up
  36910. * in order to block unwanted artifacts like system double clicks
  36911. */
  36912. preventDefaultOnPointerUp: boolean;
  36913. /**
  36914. * Gets or sets user defined metadata
  36915. */
  36916. metadata: any;
  36917. /**
  36918. * For internal use only. Please do not use.
  36919. */
  36920. reservedDataStore: any;
  36921. /**
  36922. * Gets the name of the plugin used to load this scene (null by default)
  36923. */
  36924. loadingPluginName: string;
  36925. /**
  36926. * Use this array to add regular expressions used to disable offline support for specific urls
  36927. */
  36928. disableOfflineSupportExceptionRules: RegExp[];
  36929. /**
  36930. * An event triggered when the scene is disposed.
  36931. */
  36932. onDisposeObservable: Observable<Scene>;
  36933. private _onDisposeObserver;
  36934. /** Sets a function to be executed when this scene is disposed. */
  36935. set onDispose(callback: () => void);
  36936. /**
  36937. * An event triggered before rendering the scene (right after animations and physics)
  36938. */
  36939. onBeforeRenderObservable: Observable<Scene>;
  36940. private _onBeforeRenderObserver;
  36941. /** Sets a function to be executed before rendering this scene */
  36942. set beforeRender(callback: Nullable<() => void>);
  36943. /**
  36944. * An event triggered after rendering the scene
  36945. */
  36946. onAfterRenderObservable: Observable<Scene>;
  36947. /**
  36948. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36949. */
  36950. onAfterRenderCameraObservable: Observable<Camera>;
  36951. private _onAfterRenderObserver;
  36952. /** Sets a function to be executed after rendering this scene */
  36953. set afterRender(callback: Nullable<() => void>);
  36954. /**
  36955. * An event triggered before animating the scene
  36956. */
  36957. onBeforeAnimationsObservable: Observable<Scene>;
  36958. /**
  36959. * An event triggered after animations processing
  36960. */
  36961. onAfterAnimationsObservable: Observable<Scene>;
  36962. /**
  36963. * An event triggered before draw calls are ready to be sent
  36964. */
  36965. onBeforeDrawPhaseObservable: Observable<Scene>;
  36966. /**
  36967. * An event triggered after draw calls have been sent
  36968. */
  36969. onAfterDrawPhaseObservable: Observable<Scene>;
  36970. /**
  36971. * An event triggered when the scene is ready
  36972. */
  36973. onReadyObservable: Observable<Scene>;
  36974. /**
  36975. * An event triggered before rendering a camera
  36976. */
  36977. onBeforeCameraRenderObservable: Observable<Camera>;
  36978. private _onBeforeCameraRenderObserver;
  36979. /** Sets a function to be executed before rendering a camera*/
  36980. set beforeCameraRender(callback: () => void);
  36981. /**
  36982. * An event triggered after rendering a camera
  36983. */
  36984. onAfterCameraRenderObservable: Observable<Camera>;
  36985. private _onAfterCameraRenderObserver;
  36986. /** Sets a function to be executed after rendering a camera*/
  36987. set afterCameraRender(callback: () => void);
  36988. /**
  36989. * An event triggered when active meshes evaluation is about to start
  36990. */
  36991. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36992. /**
  36993. * An event triggered when active meshes evaluation is done
  36994. */
  36995. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36996. /**
  36997. * An event triggered when particles rendering is about to start
  36998. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36999. */
  37000. onBeforeParticlesRenderingObservable: Observable<Scene>;
  37001. /**
  37002. * An event triggered when particles rendering is done
  37003. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  37004. */
  37005. onAfterParticlesRenderingObservable: Observable<Scene>;
  37006. /**
  37007. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  37008. */
  37009. onDataLoadedObservable: Observable<Scene>;
  37010. /**
  37011. * An event triggered when a camera is created
  37012. */
  37013. onNewCameraAddedObservable: Observable<Camera>;
  37014. /**
  37015. * An event triggered when a camera is removed
  37016. */
  37017. onCameraRemovedObservable: Observable<Camera>;
  37018. /**
  37019. * An event triggered when a light is created
  37020. */
  37021. onNewLightAddedObservable: Observable<Light>;
  37022. /**
  37023. * An event triggered when a light is removed
  37024. */
  37025. onLightRemovedObservable: Observable<Light>;
  37026. /**
  37027. * An event triggered when a geometry is created
  37028. */
  37029. onNewGeometryAddedObservable: Observable<Geometry>;
  37030. /**
  37031. * An event triggered when a geometry is removed
  37032. */
  37033. onGeometryRemovedObservable: Observable<Geometry>;
  37034. /**
  37035. * An event triggered when a transform node is created
  37036. */
  37037. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  37038. /**
  37039. * An event triggered when a transform node is removed
  37040. */
  37041. onTransformNodeRemovedObservable: Observable<TransformNode>;
  37042. /**
  37043. * An event triggered when a mesh is created
  37044. */
  37045. onNewMeshAddedObservable: Observable<AbstractMesh>;
  37046. /**
  37047. * An event triggered when a mesh is removed
  37048. */
  37049. onMeshRemovedObservable: Observable<AbstractMesh>;
  37050. /**
  37051. * An event triggered when a skeleton is created
  37052. */
  37053. onNewSkeletonAddedObservable: Observable<Skeleton>;
  37054. /**
  37055. * An event triggered when a skeleton is removed
  37056. */
  37057. onSkeletonRemovedObservable: Observable<Skeleton>;
  37058. /**
  37059. * An event triggered when a material is created
  37060. */
  37061. onNewMaterialAddedObservable: Observable<Material>;
  37062. /**
  37063. * An event triggered when a material is removed
  37064. */
  37065. onMaterialRemovedObservable: Observable<Material>;
  37066. /**
  37067. * An event triggered when a texture is created
  37068. */
  37069. onNewTextureAddedObservable: Observable<BaseTexture>;
  37070. /**
  37071. * An event triggered when a texture is removed
  37072. */
  37073. onTextureRemovedObservable: Observable<BaseTexture>;
  37074. /**
  37075. * An event triggered when render targets are about to be rendered
  37076. * Can happen multiple times per frame.
  37077. */
  37078. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  37079. /**
  37080. * An event triggered when render targets were rendered.
  37081. * Can happen multiple times per frame.
  37082. */
  37083. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  37084. /**
  37085. * An event triggered before calculating deterministic simulation step
  37086. */
  37087. onBeforeStepObservable: Observable<Scene>;
  37088. /**
  37089. * An event triggered after calculating deterministic simulation step
  37090. */
  37091. onAfterStepObservable: Observable<Scene>;
  37092. /**
  37093. * An event triggered when the activeCamera property is updated
  37094. */
  37095. onActiveCameraChanged: Observable<Scene>;
  37096. /**
  37097. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  37098. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37099. * 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)
  37100. */
  37101. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37102. /**
  37103. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  37104. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  37105. * 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)
  37106. */
  37107. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  37108. /**
  37109. * This Observable will when a mesh has been imported into the scene.
  37110. */
  37111. onMeshImportedObservable: Observable<AbstractMesh>;
  37112. /**
  37113. * This Observable will when an animation file has been imported into the scene.
  37114. */
  37115. onAnimationFileImportedObservable: Observable<Scene>;
  37116. /**
  37117. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  37118. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  37119. */
  37120. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  37121. /** @hidden */
  37122. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  37123. /**
  37124. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  37125. */
  37126. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  37127. /**
  37128. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  37129. */
  37130. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  37131. /**
  37132. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  37133. */
  37134. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  37135. /** Callback called when a pointer move is detected */
  37136. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37137. /** Callback called when a pointer down is detected */
  37138. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  37139. /** Callback called when a pointer up is detected */
  37140. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  37141. /** Callback called when a pointer pick is detected */
  37142. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  37143. /**
  37144. * 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).
  37145. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  37146. */
  37147. onPrePointerObservable: Observable<PointerInfoPre>;
  37148. /**
  37149. * Observable event triggered each time an input event is received from the rendering canvas
  37150. */
  37151. onPointerObservable: Observable<PointerInfo>;
  37152. /**
  37153. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  37154. */
  37155. get unTranslatedPointer(): Vector2;
  37156. /**
  37157. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  37158. */
  37159. static get DragMovementThreshold(): number;
  37160. static set DragMovementThreshold(value: number);
  37161. /**
  37162. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  37163. */
  37164. static get LongPressDelay(): number;
  37165. static set LongPressDelay(value: number);
  37166. /**
  37167. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  37168. */
  37169. static get DoubleClickDelay(): number;
  37170. static set DoubleClickDelay(value: number);
  37171. /** If you need to check double click without raising a single click at first click, enable this flag */
  37172. static get ExclusiveDoubleClickMode(): boolean;
  37173. static set ExclusiveDoubleClickMode(value: boolean);
  37174. /** @hidden */
  37175. _mirroredCameraPosition: Nullable<Vector3>;
  37176. /**
  37177. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  37178. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  37179. */
  37180. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  37181. /**
  37182. * Observable event triggered each time an keyboard event is received from the hosting window
  37183. */
  37184. onKeyboardObservable: Observable<KeyboardInfo>;
  37185. private _useRightHandedSystem;
  37186. /**
  37187. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37188. */
  37189. set useRightHandedSystem(value: boolean);
  37190. get useRightHandedSystem(): boolean;
  37191. private _timeAccumulator;
  37192. private _currentStepId;
  37193. private _currentInternalStep;
  37194. /**
  37195. * Sets the step Id used by deterministic lock step
  37196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37197. * @param newStepId defines the step Id
  37198. */
  37199. setStepId(newStepId: number): void;
  37200. /**
  37201. * Gets the step Id used by deterministic lock step
  37202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37203. * @returns the step Id
  37204. */
  37205. getStepId(): number;
  37206. /**
  37207. * Gets the internal step used by deterministic lock step
  37208. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37209. * @returns the internal step
  37210. */
  37211. getInternalStep(): number;
  37212. private _fogEnabled;
  37213. /**
  37214. * Gets or sets a boolean indicating if fog is enabled on this scene
  37215. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37216. * (Default is true)
  37217. */
  37218. set fogEnabled(value: boolean);
  37219. get fogEnabled(): boolean;
  37220. private _fogMode;
  37221. /**
  37222. * Gets or sets the fog mode to use
  37223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37224. * | mode | value |
  37225. * | --- | --- |
  37226. * | FOGMODE_NONE | 0 |
  37227. * | FOGMODE_EXP | 1 |
  37228. * | FOGMODE_EXP2 | 2 |
  37229. * | FOGMODE_LINEAR | 3 |
  37230. */
  37231. set fogMode(value: number);
  37232. get fogMode(): number;
  37233. /**
  37234. * Gets or sets the fog color to use
  37235. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37236. * (Default is Color3(0.2, 0.2, 0.3))
  37237. */
  37238. fogColor: Color3;
  37239. /**
  37240. * Gets or sets the fog density to use
  37241. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37242. * (Default is 0.1)
  37243. */
  37244. fogDensity: number;
  37245. /**
  37246. * Gets or sets the fog start distance to use
  37247. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37248. * (Default is 0)
  37249. */
  37250. fogStart: number;
  37251. /**
  37252. * Gets or sets the fog end distance to use
  37253. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37254. * (Default is 1000)
  37255. */
  37256. fogEnd: number;
  37257. private _shadowsEnabled;
  37258. /**
  37259. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37260. */
  37261. set shadowsEnabled(value: boolean);
  37262. get shadowsEnabled(): boolean;
  37263. private _lightsEnabled;
  37264. /**
  37265. * Gets or sets a boolean indicating if lights are enabled on this scene
  37266. */
  37267. set lightsEnabled(value: boolean);
  37268. get lightsEnabled(): boolean;
  37269. /** All of the active cameras added to this scene. */
  37270. activeCameras: Camera[];
  37271. /** @hidden */
  37272. _activeCamera: Nullable<Camera>;
  37273. /** Gets or sets the current active camera */
  37274. get activeCamera(): Nullable<Camera>;
  37275. set activeCamera(value: Nullable<Camera>);
  37276. private _defaultMaterial;
  37277. /** The default material used on meshes when no material is affected */
  37278. get defaultMaterial(): Material;
  37279. /** The default material used on meshes when no material is affected */
  37280. set defaultMaterial(value: Material);
  37281. private _texturesEnabled;
  37282. /**
  37283. * Gets or sets a boolean indicating if textures are enabled on this scene
  37284. */
  37285. set texturesEnabled(value: boolean);
  37286. get texturesEnabled(): boolean;
  37287. /**
  37288. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  37289. */
  37290. physicsEnabled: boolean;
  37291. /**
  37292. * Gets or sets a boolean indicating if particles are enabled on this scene
  37293. */
  37294. particlesEnabled: boolean;
  37295. /**
  37296. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37297. */
  37298. spritesEnabled: boolean;
  37299. private _skeletonsEnabled;
  37300. /**
  37301. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37302. */
  37303. set skeletonsEnabled(value: boolean);
  37304. get skeletonsEnabled(): boolean;
  37305. /**
  37306. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37307. */
  37308. lensFlaresEnabled: boolean;
  37309. /**
  37310. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37311. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37312. */
  37313. collisionsEnabled: boolean;
  37314. private _collisionCoordinator;
  37315. /** @hidden */
  37316. get collisionCoordinator(): ICollisionCoordinator;
  37317. /**
  37318. * Defines the gravity applied to this scene (used only for collisions)
  37319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37320. */
  37321. gravity: Vector3;
  37322. /**
  37323. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37324. */
  37325. postProcessesEnabled: boolean;
  37326. /**
  37327. * The list of postprocesses added to the scene
  37328. */
  37329. postProcesses: PostProcess[];
  37330. /**
  37331. * Gets the current postprocess manager
  37332. */
  37333. postProcessManager: PostProcessManager;
  37334. /**
  37335. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37336. */
  37337. renderTargetsEnabled: boolean;
  37338. /**
  37339. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37340. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37341. */
  37342. dumpNextRenderTargets: boolean;
  37343. /**
  37344. * The list of user defined render targets added to the scene
  37345. */
  37346. customRenderTargets: RenderTargetTexture[];
  37347. /**
  37348. * Defines if texture loading must be delayed
  37349. * If true, textures will only be loaded when they need to be rendered
  37350. */
  37351. useDelayedTextureLoading: boolean;
  37352. /**
  37353. * Gets the list of meshes imported to the scene through SceneLoader
  37354. */
  37355. importedMeshesFiles: String[];
  37356. /**
  37357. * Gets or sets a boolean indicating if probes are enabled on this scene
  37358. */
  37359. probesEnabled: boolean;
  37360. /**
  37361. * Gets or sets the current offline provider to use to store scene data
  37362. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37363. */
  37364. offlineProvider: IOfflineProvider;
  37365. /**
  37366. * Gets or sets the action manager associated with the scene
  37367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37368. */
  37369. actionManager: AbstractActionManager;
  37370. private _meshesForIntersections;
  37371. /**
  37372. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37373. */
  37374. proceduralTexturesEnabled: boolean;
  37375. private _engine;
  37376. private _totalVertices;
  37377. /** @hidden */
  37378. _activeIndices: PerfCounter;
  37379. /** @hidden */
  37380. _activeParticles: PerfCounter;
  37381. /** @hidden */
  37382. _activeBones: PerfCounter;
  37383. private _animationRatio;
  37384. /** @hidden */
  37385. _animationTimeLast: number;
  37386. /** @hidden */
  37387. _animationTime: number;
  37388. /**
  37389. * Gets or sets a general scale for animation speed
  37390. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37391. */
  37392. animationTimeScale: number;
  37393. /** @hidden */
  37394. _cachedMaterial: Nullable<Material>;
  37395. /** @hidden */
  37396. _cachedEffect: Nullable<Effect>;
  37397. /** @hidden */
  37398. _cachedVisibility: Nullable<number>;
  37399. private _renderId;
  37400. private _frameId;
  37401. private _executeWhenReadyTimeoutId;
  37402. private _intermediateRendering;
  37403. private _viewUpdateFlag;
  37404. private _projectionUpdateFlag;
  37405. /** @hidden */
  37406. _toBeDisposed: Nullable<IDisposable>[];
  37407. private _activeRequests;
  37408. /** @hidden */
  37409. _pendingData: any[];
  37410. private _isDisposed;
  37411. /**
  37412. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37413. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37414. */
  37415. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37416. private _activeMeshes;
  37417. private _processedMaterials;
  37418. private _renderTargets;
  37419. /** @hidden */
  37420. _activeParticleSystems: SmartArray<IParticleSystem>;
  37421. private _activeSkeletons;
  37422. private _softwareSkinnedMeshes;
  37423. private _renderingManager;
  37424. /** @hidden */
  37425. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37426. private _transformMatrix;
  37427. private _sceneUbo;
  37428. /** @hidden */
  37429. _viewMatrix: Matrix;
  37430. private _projectionMatrix;
  37431. /** @hidden */
  37432. _forcedViewPosition: Nullable<Vector3>;
  37433. /** @hidden */
  37434. _frustumPlanes: Plane[];
  37435. /**
  37436. * Gets the list of frustum planes (built from the active camera)
  37437. */
  37438. get frustumPlanes(): Plane[];
  37439. /**
  37440. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37441. * This is useful if there are more lights that the maximum simulteanous authorized
  37442. */
  37443. requireLightSorting: boolean;
  37444. /** @hidden */
  37445. readonly useMaterialMeshMap: boolean;
  37446. /** @hidden */
  37447. readonly useClonedMeshMap: boolean;
  37448. private _externalData;
  37449. private _uid;
  37450. /**
  37451. * @hidden
  37452. * Backing store of defined scene components.
  37453. */
  37454. _components: ISceneComponent[];
  37455. /**
  37456. * @hidden
  37457. * Backing store of defined scene components.
  37458. */
  37459. _serializableComponents: ISceneSerializableComponent[];
  37460. /**
  37461. * List of components to register on the next registration step.
  37462. */
  37463. private _transientComponents;
  37464. /**
  37465. * Registers the transient components if needed.
  37466. */
  37467. private _registerTransientComponents;
  37468. /**
  37469. * @hidden
  37470. * Add a component to the scene.
  37471. * Note that the ccomponent could be registered on th next frame if this is called after
  37472. * the register component stage.
  37473. * @param component Defines the component to add to the scene
  37474. */
  37475. _addComponent(component: ISceneComponent): void;
  37476. /**
  37477. * @hidden
  37478. * Gets a component from the scene.
  37479. * @param name defines the name of the component to retrieve
  37480. * @returns the component or null if not present
  37481. */
  37482. _getComponent(name: string): Nullable<ISceneComponent>;
  37483. /**
  37484. * @hidden
  37485. * Defines the actions happening before camera updates.
  37486. */
  37487. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37488. /**
  37489. * @hidden
  37490. * Defines the actions happening before clear the canvas.
  37491. */
  37492. _beforeClearStage: Stage<SimpleStageAction>;
  37493. /**
  37494. * @hidden
  37495. * Defines the actions when collecting render targets for the frame.
  37496. */
  37497. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37498. /**
  37499. * @hidden
  37500. * Defines the actions happening for one camera in the frame.
  37501. */
  37502. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37503. /**
  37504. * @hidden
  37505. * Defines the actions happening during the per mesh ready checks.
  37506. */
  37507. _isReadyForMeshStage: Stage<MeshStageAction>;
  37508. /**
  37509. * @hidden
  37510. * Defines the actions happening before evaluate active mesh checks.
  37511. */
  37512. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37513. /**
  37514. * @hidden
  37515. * Defines the actions happening during the evaluate sub mesh checks.
  37516. */
  37517. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37518. /**
  37519. * @hidden
  37520. * Defines the actions happening during the active mesh stage.
  37521. */
  37522. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37523. /**
  37524. * @hidden
  37525. * Defines the actions happening during the per camera render target step.
  37526. */
  37527. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37528. /**
  37529. * @hidden
  37530. * Defines the actions happening just before the active camera is drawing.
  37531. */
  37532. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37533. /**
  37534. * @hidden
  37535. * Defines the actions happening just before a render target is drawing.
  37536. */
  37537. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37538. /**
  37539. * @hidden
  37540. * Defines the actions happening just before a rendering group is drawing.
  37541. */
  37542. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37543. /**
  37544. * @hidden
  37545. * Defines the actions happening just before a mesh is drawing.
  37546. */
  37547. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37548. /**
  37549. * @hidden
  37550. * Defines the actions happening just after a mesh has been drawn.
  37551. */
  37552. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37553. /**
  37554. * @hidden
  37555. * Defines the actions happening just after a rendering group has been drawn.
  37556. */
  37557. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37558. /**
  37559. * @hidden
  37560. * Defines the actions happening just after the active camera has been drawn.
  37561. */
  37562. _afterCameraDrawStage: Stage<CameraStageAction>;
  37563. /**
  37564. * @hidden
  37565. * Defines the actions happening just after a render target has been drawn.
  37566. */
  37567. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37568. /**
  37569. * @hidden
  37570. * Defines the actions happening just after rendering all cameras and computing intersections.
  37571. */
  37572. _afterRenderStage: Stage<SimpleStageAction>;
  37573. /**
  37574. * @hidden
  37575. * Defines the actions happening when a pointer move event happens.
  37576. */
  37577. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37578. /**
  37579. * @hidden
  37580. * Defines the actions happening when a pointer down event happens.
  37581. */
  37582. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37583. /**
  37584. * @hidden
  37585. * Defines the actions happening when a pointer up event happens.
  37586. */
  37587. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37588. /**
  37589. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37590. */
  37591. private geometriesByUniqueId;
  37592. /**
  37593. * Creates a new Scene
  37594. * @param engine defines the engine to use to render this scene
  37595. * @param options defines the scene options
  37596. */
  37597. constructor(engine: Engine, options?: SceneOptions);
  37598. /**
  37599. * Gets a string idenfifying the name of the class
  37600. * @returns "Scene" string
  37601. */
  37602. getClassName(): string;
  37603. private _defaultMeshCandidates;
  37604. /**
  37605. * @hidden
  37606. */
  37607. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37608. private _defaultSubMeshCandidates;
  37609. /**
  37610. * @hidden
  37611. */
  37612. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37613. /**
  37614. * Sets the default candidate providers for the scene.
  37615. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37616. * and getCollidingSubMeshCandidates to their default function
  37617. */
  37618. setDefaultCandidateProviders(): void;
  37619. /**
  37620. * Gets the mesh that is currently under the pointer
  37621. */
  37622. get meshUnderPointer(): Nullable<AbstractMesh>;
  37623. /**
  37624. * Gets or sets the current on-screen X position of the pointer
  37625. */
  37626. get pointerX(): number;
  37627. set pointerX(value: number);
  37628. /**
  37629. * Gets or sets the current on-screen Y position of the pointer
  37630. */
  37631. get pointerY(): number;
  37632. set pointerY(value: number);
  37633. /**
  37634. * Gets the cached material (ie. the latest rendered one)
  37635. * @returns the cached material
  37636. */
  37637. getCachedMaterial(): Nullable<Material>;
  37638. /**
  37639. * Gets the cached effect (ie. the latest rendered one)
  37640. * @returns the cached effect
  37641. */
  37642. getCachedEffect(): Nullable<Effect>;
  37643. /**
  37644. * Gets the cached visibility state (ie. the latest rendered one)
  37645. * @returns the cached visibility state
  37646. */
  37647. getCachedVisibility(): Nullable<number>;
  37648. /**
  37649. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37650. * @param material defines the current material
  37651. * @param effect defines the current effect
  37652. * @param visibility defines the current visibility state
  37653. * @returns true if one parameter is not cached
  37654. */
  37655. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37656. /**
  37657. * Gets the engine associated with the scene
  37658. * @returns an Engine
  37659. */
  37660. getEngine(): Engine;
  37661. /**
  37662. * Gets the total number of vertices rendered per frame
  37663. * @returns the total number of vertices rendered per frame
  37664. */
  37665. getTotalVertices(): number;
  37666. /**
  37667. * Gets the performance counter for total vertices
  37668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37669. */
  37670. get totalVerticesPerfCounter(): PerfCounter;
  37671. /**
  37672. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37673. * @returns the total number of active indices rendered per frame
  37674. */
  37675. getActiveIndices(): number;
  37676. /**
  37677. * Gets the performance counter for active indices
  37678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37679. */
  37680. get totalActiveIndicesPerfCounter(): PerfCounter;
  37681. /**
  37682. * Gets the total number of active particles rendered per frame
  37683. * @returns the total number of active particles rendered per frame
  37684. */
  37685. getActiveParticles(): number;
  37686. /**
  37687. * Gets the performance counter for active particles
  37688. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37689. */
  37690. get activeParticlesPerfCounter(): PerfCounter;
  37691. /**
  37692. * Gets the total number of active bones rendered per frame
  37693. * @returns the total number of active bones rendered per frame
  37694. */
  37695. getActiveBones(): number;
  37696. /**
  37697. * Gets the performance counter for active bones
  37698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37699. */
  37700. get activeBonesPerfCounter(): PerfCounter;
  37701. /**
  37702. * Gets the array of active meshes
  37703. * @returns an array of AbstractMesh
  37704. */
  37705. getActiveMeshes(): SmartArray<AbstractMesh>;
  37706. /**
  37707. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37708. * @returns a number
  37709. */
  37710. getAnimationRatio(): number;
  37711. /**
  37712. * Gets an unique Id for the current render phase
  37713. * @returns a number
  37714. */
  37715. getRenderId(): number;
  37716. /**
  37717. * Gets an unique Id for the current frame
  37718. * @returns a number
  37719. */
  37720. getFrameId(): number;
  37721. /** Call this function if you want to manually increment the render Id*/
  37722. incrementRenderId(): void;
  37723. private _createUbo;
  37724. /**
  37725. * Use this method to simulate a pointer move on a mesh
  37726. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37727. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37728. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37729. * @returns the current scene
  37730. */
  37731. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37732. /**
  37733. * Use this method to simulate a pointer down on a mesh
  37734. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37735. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37736. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37737. * @returns the current scene
  37738. */
  37739. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37740. /**
  37741. * Use this method to simulate a pointer up on a mesh
  37742. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37743. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37744. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37745. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37746. * @returns the current scene
  37747. */
  37748. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37749. /**
  37750. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37751. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37752. * @returns true if the pointer was captured
  37753. */
  37754. isPointerCaptured(pointerId?: number): boolean;
  37755. /**
  37756. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37757. * @param attachUp defines if you want to attach events to pointerup
  37758. * @param attachDown defines if you want to attach events to pointerdown
  37759. * @param attachMove defines if you want to attach events to pointermove
  37760. */
  37761. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37762. /** Detaches all event handlers*/
  37763. detachControl(): void;
  37764. /**
  37765. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37766. * Delay loaded resources are not taking in account
  37767. * @return true if all required resources are ready
  37768. */
  37769. isReady(): boolean;
  37770. /** Resets all cached information relative to material (including effect and visibility) */
  37771. resetCachedMaterial(): void;
  37772. /**
  37773. * Registers a function to be called before every frame render
  37774. * @param func defines the function to register
  37775. */
  37776. registerBeforeRender(func: () => void): void;
  37777. /**
  37778. * Unregisters a function called before every frame render
  37779. * @param func defines the function to unregister
  37780. */
  37781. unregisterBeforeRender(func: () => void): void;
  37782. /**
  37783. * Registers a function to be called after every frame render
  37784. * @param func defines the function to register
  37785. */
  37786. registerAfterRender(func: () => void): void;
  37787. /**
  37788. * Unregisters a function called after every frame render
  37789. * @param func defines the function to unregister
  37790. */
  37791. unregisterAfterRender(func: () => void): void;
  37792. private _executeOnceBeforeRender;
  37793. /**
  37794. * The provided function will run before render once and will be disposed afterwards.
  37795. * A timeout delay can be provided so that the function will be executed in N ms.
  37796. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37797. * @param func The function to be executed.
  37798. * @param timeout optional delay in ms
  37799. */
  37800. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37801. /** @hidden */
  37802. _addPendingData(data: any): void;
  37803. /** @hidden */
  37804. _removePendingData(data: any): void;
  37805. /**
  37806. * Returns the number of items waiting to be loaded
  37807. * @returns the number of items waiting to be loaded
  37808. */
  37809. getWaitingItemsCount(): number;
  37810. /**
  37811. * Returns a boolean indicating if the scene is still loading data
  37812. */
  37813. get isLoading(): boolean;
  37814. /**
  37815. * Registers a function to be executed when the scene is ready
  37816. * @param {Function} func - the function to be executed
  37817. */
  37818. executeWhenReady(func: () => void): void;
  37819. /**
  37820. * Returns a promise that resolves when the scene is ready
  37821. * @returns A promise that resolves when the scene is ready
  37822. */
  37823. whenReadyAsync(): Promise<void>;
  37824. /** @hidden */
  37825. _checkIsReady(): void;
  37826. /**
  37827. * Gets all animatable attached to the scene
  37828. */
  37829. get animatables(): Animatable[];
  37830. /**
  37831. * Resets the last animation time frame.
  37832. * Useful to override when animations start running when loading a scene for the first time.
  37833. */
  37834. resetLastAnimationTimeFrame(): void;
  37835. /**
  37836. * Gets the current view matrix
  37837. * @returns a Matrix
  37838. */
  37839. getViewMatrix(): Matrix;
  37840. /**
  37841. * Gets the current projection matrix
  37842. * @returns a Matrix
  37843. */
  37844. getProjectionMatrix(): Matrix;
  37845. /**
  37846. * Gets the current transform matrix
  37847. * @returns a Matrix made of View * Projection
  37848. */
  37849. getTransformMatrix(): Matrix;
  37850. /**
  37851. * Sets the current transform matrix
  37852. * @param viewL defines the View matrix to use
  37853. * @param projectionL defines the Projection matrix to use
  37854. * @param viewR defines the right View matrix to use (if provided)
  37855. * @param projectionR defines the right Projection matrix to use (if provided)
  37856. */
  37857. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37858. /**
  37859. * Gets the uniform buffer used to store scene data
  37860. * @returns a UniformBuffer
  37861. */
  37862. getSceneUniformBuffer(): UniformBuffer;
  37863. /**
  37864. * Gets an unique (relatively to the current scene) Id
  37865. * @returns an unique number for the scene
  37866. */
  37867. getUniqueId(): number;
  37868. /**
  37869. * Add a mesh to the list of scene's meshes
  37870. * @param newMesh defines the mesh to add
  37871. * @param recursive if all child meshes should also be added to the scene
  37872. */
  37873. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37874. /**
  37875. * Remove a mesh for the list of scene's meshes
  37876. * @param toRemove defines the mesh to remove
  37877. * @param recursive if all child meshes should also be removed from the scene
  37878. * @returns the index where the mesh was in the mesh list
  37879. */
  37880. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37881. /**
  37882. * Add a transform node to the list of scene's transform nodes
  37883. * @param newTransformNode defines the transform node to add
  37884. */
  37885. addTransformNode(newTransformNode: TransformNode): void;
  37886. /**
  37887. * Remove a transform node for the list of scene's transform nodes
  37888. * @param toRemove defines the transform node to remove
  37889. * @returns the index where the transform node was in the transform node list
  37890. */
  37891. removeTransformNode(toRemove: TransformNode): number;
  37892. /**
  37893. * Remove a skeleton for the list of scene's skeletons
  37894. * @param toRemove defines the skeleton to remove
  37895. * @returns the index where the skeleton was in the skeleton list
  37896. */
  37897. removeSkeleton(toRemove: Skeleton): number;
  37898. /**
  37899. * Remove a morph target for the list of scene's morph targets
  37900. * @param toRemove defines the morph target to remove
  37901. * @returns the index where the morph target was in the morph target list
  37902. */
  37903. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37904. /**
  37905. * Remove a light for the list of scene's lights
  37906. * @param toRemove defines the light to remove
  37907. * @returns the index where the light was in the light list
  37908. */
  37909. removeLight(toRemove: Light): number;
  37910. /**
  37911. * Remove a camera for the list of scene's cameras
  37912. * @param toRemove defines the camera to remove
  37913. * @returns the index where the camera was in the camera list
  37914. */
  37915. removeCamera(toRemove: Camera): number;
  37916. /**
  37917. * Remove a particle system for the list of scene's particle systems
  37918. * @param toRemove defines the particle system to remove
  37919. * @returns the index where the particle system was in the particle system list
  37920. */
  37921. removeParticleSystem(toRemove: IParticleSystem): number;
  37922. /**
  37923. * Remove a animation for the list of scene's animations
  37924. * @param toRemove defines the animation to remove
  37925. * @returns the index where the animation was in the animation list
  37926. */
  37927. removeAnimation(toRemove: Animation): number;
  37928. /**
  37929. * Will stop the animation of the given target
  37930. * @param target - the target
  37931. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37932. * @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)
  37933. */
  37934. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37935. /**
  37936. * Removes the given animation group from this scene.
  37937. * @param toRemove The animation group to remove
  37938. * @returns The index of the removed animation group
  37939. */
  37940. removeAnimationGroup(toRemove: AnimationGroup): number;
  37941. /**
  37942. * Removes the given multi-material from this scene.
  37943. * @param toRemove The multi-material to remove
  37944. * @returns The index of the removed multi-material
  37945. */
  37946. removeMultiMaterial(toRemove: MultiMaterial): number;
  37947. /**
  37948. * Removes the given material from this scene.
  37949. * @param toRemove The material to remove
  37950. * @returns The index of the removed material
  37951. */
  37952. removeMaterial(toRemove: Material): number;
  37953. /**
  37954. * Removes the given action manager from this scene.
  37955. * @param toRemove The action manager to remove
  37956. * @returns The index of the removed action manager
  37957. */
  37958. removeActionManager(toRemove: AbstractActionManager): number;
  37959. /**
  37960. * Removes the given texture from this scene.
  37961. * @param toRemove The texture to remove
  37962. * @returns The index of the removed texture
  37963. */
  37964. removeTexture(toRemove: BaseTexture): number;
  37965. /**
  37966. * Adds the given light to this scene
  37967. * @param newLight The light to add
  37968. */
  37969. addLight(newLight: Light): void;
  37970. /**
  37971. * Sorts the list list based on light priorities
  37972. */
  37973. sortLightsByPriority(): void;
  37974. /**
  37975. * Adds the given camera to this scene
  37976. * @param newCamera The camera to add
  37977. */
  37978. addCamera(newCamera: Camera): void;
  37979. /**
  37980. * Adds the given skeleton to this scene
  37981. * @param newSkeleton The skeleton to add
  37982. */
  37983. addSkeleton(newSkeleton: Skeleton): void;
  37984. /**
  37985. * Adds the given particle system to this scene
  37986. * @param newParticleSystem The particle system to add
  37987. */
  37988. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37989. /**
  37990. * Adds the given animation to this scene
  37991. * @param newAnimation The animation to add
  37992. */
  37993. addAnimation(newAnimation: Animation): void;
  37994. /**
  37995. * Adds the given animation group to this scene.
  37996. * @param newAnimationGroup The animation group to add
  37997. */
  37998. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37999. /**
  38000. * Adds the given multi-material to this scene
  38001. * @param newMultiMaterial The multi-material to add
  38002. */
  38003. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  38004. /**
  38005. * Adds the given material to this scene
  38006. * @param newMaterial The material to add
  38007. */
  38008. addMaterial(newMaterial: Material): void;
  38009. /**
  38010. * Adds the given morph target to this scene
  38011. * @param newMorphTargetManager The morph target to add
  38012. */
  38013. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  38014. /**
  38015. * Adds the given geometry to this scene
  38016. * @param newGeometry The geometry to add
  38017. */
  38018. addGeometry(newGeometry: Geometry): void;
  38019. /**
  38020. * Adds the given action manager to this scene
  38021. * @param newActionManager The action manager to add
  38022. */
  38023. addActionManager(newActionManager: AbstractActionManager): void;
  38024. /**
  38025. * Adds the given texture to this scene.
  38026. * @param newTexture The texture to add
  38027. */
  38028. addTexture(newTexture: BaseTexture): void;
  38029. /**
  38030. * Switch active camera
  38031. * @param newCamera defines the new active camera
  38032. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  38033. */
  38034. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  38035. /**
  38036. * sets the active camera of the scene using its ID
  38037. * @param id defines the camera's ID
  38038. * @return the new active camera or null if none found.
  38039. */
  38040. setActiveCameraByID(id: string): Nullable<Camera>;
  38041. /**
  38042. * sets the active camera of the scene using its name
  38043. * @param name defines the camera's name
  38044. * @returns the new active camera or null if none found.
  38045. */
  38046. setActiveCameraByName(name: string): Nullable<Camera>;
  38047. /**
  38048. * get an animation group using its name
  38049. * @param name defines the material's name
  38050. * @return the animation group or null if none found.
  38051. */
  38052. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  38053. /**
  38054. * Get a material using its unique id
  38055. * @param uniqueId defines the material's unique id
  38056. * @return the material or null if none found.
  38057. */
  38058. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  38059. /**
  38060. * get a material using its id
  38061. * @param id defines the material's ID
  38062. * @return the material or null if none found.
  38063. */
  38064. getMaterialByID(id: string): Nullable<Material>;
  38065. /**
  38066. * Gets a the last added material using a given id
  38067. * @param id defines the material's ID
  38068. * @return the last material with the given id or null if none found.
  38069. */
  38070. getLastMaterialByID(id: string): Nullable<Material>;
  38071. /**
  38072. * Gets a material using its name
  38073. * @param name defines the material's name
  38074. * @return the material or null if none found.
  38075. */
  38076. getMaterialByName(name: string): Nullable<Material>;
  38077. /**
  38078. * Get a texture using its unique id
  38079. * @param uniqueId defines the texture's unique id
  38080. * @return the texture or null if none found.
  38081. */
  38082. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  38083. /**
  38084. * Gets a camera using its id
  38085. * @param id defines the id to look for
  38086. * @returns the camera or null if not found
  38087. */
  38088. getCameraByID(id: string): Nullable<Camera>;
  38089. /**
  38090. * Gets a camera using its unique id
  38091. * @param uniqueId defines the unique id to look for
  38092. * @returns the camera or null if not found
  38093. */
  38094. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  38095. /**
  38096. * Gets a camera using its name
  38097. * @param name defines the camera's name
  38098. * @return the camera or null if none found.
  38099. */
  38100. getCameraByName(name: string): Nullable<Camera>;
  38101. /**
  38102. * Gets a bone using its id
  38103. * @param id defines the bone's id
  38104. * @return the bone or null if not found
  38105. */
  38106. getBoneByID(id: string): Nullable<Bone>;
  38107. /**
  38108. * Gets a bone using its id
  38109. * @param name defines the bone's name
  38110. * @return the bone or null if not found
  38111. */
  38112. getBoneByName(name: string): Nullable<Bone>;
  38113. /**
  38114. * Gets a light node using its name
  38115. * @param name defines the the light's name
  38116. * @return the light or null if none found.
  38117. */
  38118. getLightByName(name: string): Nullable<Light>;
  38119. /**
  38120. * Gets a light node using its id
  38121. * @param id defines the light's id
  38122. * @return the light or null if none found.
  38123. */
  38124. getLightByID(id: string): Nullable<Light>;
  38125. /**
  38126. * Gets a light node using its scene-generated unique ID
  38127. * @param uniqueId defines the light's unique id
  38128. * @return the light or null if none found.
  38129. */
  38130. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  38131. /**
  38132. * Gets a particle system by id
  38133. * @param id defines the particle system id
  38134. * @return the corresponding system or null if none found
  38135. */
  38136. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  38137. /**
  38138. * Gets a geometry using its ID
  38139. * @param id defines the geometry's id
  38140. * @return the geometry or null if none found.
  38141. */
  38142. getGeometryByID(id: string): Nullable<Geometry>;
  38143. private _getGeometryByUniqueID;
  38144. /**
  38145. * Add a new geometry to this scene
  38146. * @param geometry defines the geometry to be added to the scene.
  38147. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  38148. * @return a boolean defining if the geometry was added or not
  38149. */
  38150. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  38151. /**
  38152. * Removes an existing geometry
  38153. * @param geometry defines the geometry to be removed from the scene
  38154. * @return a boolean defining if the geometry was removed or not
  38155. */
  38156. removeGeometry(geometry: Geometry): boolean;
  38157. /**
  38158. * Gets the list of geometries attached to the scene
  38159. * @returns an array of Geometry
  38160. */
  38161. getGeometries(): Geometry[];
  38162. /**
  38163. * Gets the first added mesh found of a given ID
  38164. * @param id defines the id to search for
  38165. * @return the mesh found or null if not found at all
  38166. */
  38167. getMeshByID(id: string): Nullable<AbstractMesh>;
  38168. /**
  38169. * Gets a list of meshes using their id
  38170. * @param id defines the id to search for
  38171. * @returns a list of meshes
  38172. */
  38173. getMeshesByID(id: string): Array<AbstractMesh>;
  38174. /**
  38175. * Gets the first added transform node found of a given ID
  38176. * @param id defines the id to search for
  38177. * @return the found transform node or null if not found at all.
  38178. */
  38179. getTransformNodeByID(id: string): Nullable<TransformNode>;
  38180. /**
  38181. * Gets a transform node with its auto-generated unique id
  38182. * @param uniqueId efines the unique id to search for
  38183. * @return the found transform node or null if not found at all.
  38184. */
  38185. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  38186. /**
  38187. * Gets a list of transform nodes using their id
  38188. * @param id defines the id to search for
  38189. * @returns a list of transform nodes
  38190. */
  38191. getTransformNodesByID(id: string): Array<TransformNode>;
  38192. /**
  38193. * Gets a mesh with its auto-generated unique id
  38194. * @param uniqueId defines the unique id to search for
  38195. * @return the found mesh or null if not found at all.
  38196. */
  38197. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38198. /**
  38199. * Gets a the last added mesh using a given id
  38200. * @param id defines the id to search for
  38201. * @return the found mesh or null if not found at all.
  38202. */
  38203. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38204. /**
  38205. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38206. * @param id defines the id to search for
  38207. * @return the found node or null if not found at all
  38208. */
  38209. getLastEntryByID(id: string): Nullable<Node>;
  38210. /**
  38211. * Gets a node (Mesh, Camera, Light) using a given id
  38212. * @param id defines the id to search for
  38213. * @return the found node or null if not found at all
  38214. */
  38215. getNodeByID(id: string): Nullable<Node>;
  38216. /**
  38217. * Gets a node (Mesh, Camera, Light) using a given name
  38218. * @param name defines the name to search for
  38219. * @return the found node or null if not found at all.
  38220. */
  38221. getNodeByName(name: string): Nullable<Node>;
  38222. /**
  38223. * Gets a mesh using a given name
  38224. * @param name defines the name to search for
  38225. * @return the found mesh or null if not found at all.
  38226. */
  38227. getMeshByName(name: string): Nullable<AbstractMesh>;
  38228. /**
  38229. * Gets a transform node using a given name
  38230. * @param name defines the name to search for
  38231. * @return the found transform node or null if not found at all.
  38232. */
  38233. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38234. /**
  38235. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38236. * @param id defines the id to search for
  38237. * @return the found skeleton or null if not found at all.
  38238. */
  38239. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38240. /**
  38241. * Gets a skeleton using a given auto generated unique id
  38242. * @param uniqueId defines the unique id to search for
  38243. * @return the found skeleton or null if not found at all.
  38244. */
  38245. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38246. /**
  38247. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38248. * @param id defines the id to search for
  38249. * @return the found skeleton or null if not found at all.
  38250. */
  38251. getSkeletonById(id: string): Nullable<Skeleton>;
  38252. /**
  38253. * Gets a skeleton using a given name
  38254. * @param name defines the name to search for
  38255. * @return the found skeleton or null if not found at all.
  38256. */
  38257. getSkeletonByName(name: string): Nullable<Skeleton>;
  38258. /**
  38259. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38260. * @param id defines the id to search for
  38261. * @return the found morph target manager or null if not found at all.
  38262. */
  38263. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38264. /**
  38265. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38266. * @param id defines the id to search for
  38267. * @return the found morph target or null if not found at all.
  38268. */
  38269. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38270. /**
  38271. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  38272. * @param name defines the name to search for
  38273. * @return the found morph target or null if not found at all.
  38274. */
  38275. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  38276. /**
  38277. * Gets a boolean indicating if the given mesh is active
  38278. * @param mesh defines the mesh to look for
  38279. * @returns true if the mesh is in the active list
  38280. */
  38281. isActiveMesh(mesh: AbstractMesh): boolean;
  38282. /**
  38283. * Return a unique id as a string which can serve as an identifier for the scene
  38284. */
  38285. get uid(): string;
  38286. /**
  38287. * Add an externaly attached data from its key.
  38288. * This method call will fail and return false, if such key already exists.
  38289. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38290. * @param key the unique key that identifies the data
  38291. * @param data the data object to associate to the key for this Engine instance
  38292. * @return true if no such key were already present and the data was added successfully, false otherwise
  38293. */
  38294. addExternalData<T>(key: string, data: T): boolean;
  38295. /**
  38296. * Get an externaly attached data from its key
  38297. * @param key the unique key that identifies the data
  38298. * @return the associated data, if present (can be null), or undefined if not present
  38299. */
  38300. getExternalData<T>(key: string): Nullable<T>;
  38301. /**
  38302. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38303. * @param key the unique key that identifies the data
  38304. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38305. * @return the associated data, can be null if the factory returned null.
  38306. */
  38307. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38308. /**
  38309. * Remove an externaly attached data from the Engine instance
  38310. * @param key the unique key that identifies the data
  38311. * @return true if the data was successfully removed, false if it doesn't exist
  38312. */
  38313. removeExternalData(key: string): boolean;
  38314. private _evaluateSubMesh;
  38315. /**
  38316. * Clear the processed materials smart array preventing retention point in material dispose.
  38317. */
  38318. freeProcessedMaterials(): void;
  38319. private _preventFreeActiveMeshesAndRenderingGroups;
  38320. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38321. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38322. * when disposing several meshes in a row or a hierarchy of meshes.
  38323. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38324. */
  38325. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38326. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38327. /**
  38328. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38329. */
  38330. freeActiveMeshes(): void;
  38331. /**
  38332. * Clear the info related to rendering groups preventing retention points during dispose.
  38333. */
  38334. freeRenderingGroups(): void;
  38335. /** @hidden */
  38336. _isInIntermediateRendering(): boolean;
  38337. /**
  38338. * Lambda returning the list of potentially active meshes.
  38339. */
  38340. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38341. /**
  38342. * Lambda returning the list of potentially active sub meshes.
  38343. */
  38344. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38345. /**
  38346. * Lambda returning the list of potentially intersecting sub meshes.
  38347. */
  38348. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38349. /**
  38350. * Lambda returning the list of potentially colliding sub meshes.
  38351. */
  38352. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38353. private _activeMeshesFrozen;
  38354. private _skipEvaluateActiveMeshesCompletely;
  38355. /**
  38356. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38357. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38358. * @returns the current scene
  38359. */
  38360. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38361. /**
  38362. * Use this function to restart evaluating active meshes on every frame
  38363. * @returns the current scene
  38364. */
  38365. unfreezeActiveMeshes(): Scene;
  38366. private _evaluateActiveMeshes;
  38367. private _activeMesh;
  38368. /**
  38369. * Update the transform matrix to update from the current active camera
  38370. * @param force defines a boolean used to force the update even if cache is up to date
  38371. */
  38372. updateTransformMatrix(force?: boolean): void;
  38373. private _bindFrameBuffer;
  38374. /** @hidden */
  38375. _allowPostProcessClearColor: boolean;
  38376. /** @hidden */
  38377. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38378. private _processSubCameras;
  38379. private _checkIntersections;
  38380. /** @hidden */
  38381. _advancePhysicsEngineStep(step: number): void;
  38382. /**
  38383. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38384. */
  38385. getDeterministicFrameTime: () => number;
  38386. /** @hidden */
  38387. _animate(): void;
  38388. /** Execute all animations (for a frame) */
  38389. animate(): void;
  38390. /**
  38391. * Render the scene
  38392. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38393. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38394. */
  38395. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38396. /**
  38397. * Freeze all materials
  38398. * A frozen material will not be updatable but should be faster to render
  38399. */
  38400. freezeMaterials(): void;
  38401. /**
  38402. * Unfreeze all materials
  38403. * A frozen material will not be updatable but should be faster to render
  38404. */
  38405. unfreezeMaterials(): void;
  38406. /**
  38407. * Releases all held ressources
  38408. */
  38409. dispose(): void;
  38410. /**
  38411. * Gets if the scene is already disposed
  38412. */
  38413. get isDisposed(): boolean;
  38414. /**
  38415. * Call this function to reduce memory footprint of the scene.
  38416. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38417. */
  38418. clearCachedVertexData(): void;
  38419. /**
  38420. * This function will remove the local cached buffer data from texture.
  38421. * It will save memory but will prevent the texture from being rebuilt
  38422. */
  38423. cleanCachedTextureBuffer(): void;
  38424. /**
  38425. * Get the world extend vectors with an optional filter
  38426. *
  38427. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38428. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38429. */
  38430. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38431. min: Vector3;
  38432. max: Vector3;
  38433. };
  38434. /**
  38435. * Creates a ray that can be used to pick in the scene
  38436. * @param x defines the x coordinate of the origin (on-screen)
  38437. * @param y defines the y coordinate of the origin (on-screen)
  38438. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38439. * @param camera defines the camera to use for the picking
  38440. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38441. * @returns a Ray
  38442. */
  38443. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38444. /**
  38445. * Creates a ray that can be used to pick in the scene
  38446. * @param x defines the x coordinate of the origin (on-screen)
  38447. * @param y defines the y coordinate of the origin (on-screen)
  38448. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38449. * @param result defines the ray where to store the picking ray
  38450. * @param camera defines the camera to use for the picking
  38451. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38452. * @returns the current scene
  38453. */
  38454. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38455. /**
  38456. * Creates a ray that can be used to pick in the scene
  38457. * @param x defines the x coordinate of the origin (on-screen)
  38458. * @param y defines the y coordinate of the origin (on-screen)
  38459. * @param camera defines the camera to use for the picking
  38460. * @returns a Ray
  38461. */
  38462. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38463. /**
  38464. * Creates a ray that can be used to pick in the scene
  38465. * @param x defines the x coordinate of the origin (on-screen)
  38466. * @param y defines the y coordinate of the origin (on-screen)
  38467. * @param result defines the ray where to store the picking ray
  38468. * @param camera defines the camera to use for the picking
  38469. * @returns the current scene
  38470. */
  38471. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38472. /** Launch a ray to try to pick a mesh in the scene
  38473. * @param x position on screen
  38474. * @param y position on screen
  38475. * @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
  38476. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38477. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38479. * @returns a PickingInfo
  38480. */
  38481. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38482. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  38483. * @param x position on screen
  38484. * @param y position on screen
  38485. * @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
  38486. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38487. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38488. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  38489. */
  38490. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  38491. /** Use the given ray to pick a mesh in the scene
  38492. * @param ray The ray to use to pick meshes
  38493. * @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
  38494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  38495. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38496. * @returns a PickingInfo
  38497. */
  38498. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38499. /**
  38500. * Launch a ray to try to pick a mesh in the scene
  38501. * @param x X position on screen
  38502. * @param y Y position on screen
  38503. * @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
  38504. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38505. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38506. * @returns an array of PickingInfo
  38507. */
  38508. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38509. /**
  38510. * Launch a ray to try to pick a mesh in the scene
  38511. * @param ray Ray to use
  38512. * @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
  38513. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38514. * @returns an array of PickingInfo
  38515. */
  38516. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38517. /**
  38518. * Force the value of meshUnderPointer
  38519. * @param mesh defines the mesh to use
  38520. */
  38521. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38522. /**
  38523. * Gets the mesh under the pointer
  38524. * @returns a Mesh or null if no mesh is under the pointer
  38525. */
  38526. getPointerOverMesh(): Nullable<AbstractMesh>;
  38527. /** @hidden */
  38528. _rebuildGeometries(): void;
  38529. /** @hidden */
  38530. _rebuildTextures(): void;
  38531. private _getByTags;
  38532. /**
  38533. * Get a list of meshes by tags
  38534. * @param tagsQuery defines the tags query to use
  38535. * @param forEach defines a predicate used to filter results
  38536. * @returns an array of Mesh
  38537. */
  38538. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38539. /**
  38540. * Get a list of cameras by tags
  38541. * @param tagsQuery defines the tags query to use
  38542. * @param forEach defines a predicate used to filter results
  38543. * @returns an array of Camera
  38544. */
  38545. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38546. /**
  38547. * Get a list of lights by tags
  38548. * @param tagsQuery defines the tags query to use
  38549. * @param forEach defines a predicate used to filter results
  38550. * @returns an array of Light
  38551. */
  38552. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38553. /**
  38554. * Get a list of materials by tags
  38555. * @param tagsQuery defines the tags query to use
  38556. * @param forEach defines a predicate used to filter results
  38557. * @returns an array of Material
  38558. */
  38559. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38560. /**
  38561. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38562. * This allowed control for front to back rendering or reversly depending of the special needs.
  38563. *
  38564. * @param renderingGroupId The rendering group id corresponding to its index
  38565. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38566. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38567. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38568. */
  38569. 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;
  38570. /**
  38571. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38572. *
  38573. * @param renderingGroupId The rendering group id corresponding to its index
  38574. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38575. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38576. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38577. */
  38578. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38579. /**
  38580. * Gets the current auto clear configuration for one rendering group of the rendering
  38581. * manager.
  38582. * @param index the rendering group index to get the information for
  38583. * @returns The auto clear setup for the requested rendering group
  38584. */
  38585. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38586. private _blockMaterialDirtyMechanism;
  38587. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38588. get blockMaterialDirtyMechanism(): boolean;
  38589. set blockMaterialDirtyMechanism(value: boolean);
  38590. /**
  38591. * Will flag all materials as dirty to trigger new shader compilation
  38592. * @param flag defines the flag used to specify which material part must be marked as dirty
  38593. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38594. */
  38595. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38596. /** @hidden */
  38597. _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;
  38598. /** @hidden */
  38599. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38600. /** @hidden */
  38601. _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;
  38602. /** @hidden */
  38603. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38604. /** @hidden */
  38605. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38606. /** @hidden */
  38607. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38608. }
  38609. }
  38610. declare module "babylonjs/assetContainer" {
  38611. import { AbstractScene } from "babylonjs/abstractScene";
  38612. import { Scene } from "babylonjs/scene";
  38613. import { Mesh } from "babylonjs/Meshes/mesh";
  38614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38615. import { Skeleton } from "babylonjs/Bones/skeleton";
  38616. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38617. import { Animatable } from "babylonjs/Animations/animatable";
  38618. import { Nullable } from "babylonjs/types";
  38619. import { Node } from "babylonjs/node";
  38620. /**
  38621. * Set of assets to keep when moving a scene into an asset container.
  38622. */
  38623. export class KeepAssets extends AbstractScene {
  38624. }
  38625. /**
  38626. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38627. */
  38628. export class InstantiatedEntries {
  38629. /**
  38630. * List of new root nodes (eg. nodes with no parent)
  38631. */
  38632. rootNodes: TransformNode[];
  38633. /**
  38634. * List of new skeletons
  38635. */
  38636. skeletons: Skeleton[];
  38637. /**
  38638. * List of new animation groups
  38639. */
  38640. animationGroups: AnimationGroup[];
  38641. }
  38642. /**
  38643. * Container with a set of assets that can be added or removed from a scene.
  38644. */
  38645. export class AssetContainer extends AbstractScene {
  38646. private _wasAddedToScene;
  38647. /**
  38648. * The scene the AssetContainer belongs to.
  38649. */
  38650. scene: Scene;
  38651. /**
  38652. * Instantiates an AssetContainer.
  38653. * @param scene The scene the AssetContainer belongs to.
  38654. */
  38655. constructor(scene: Scene);
  38656. /**
  38657. * Instantiate or clone all meshes and add the new ones to the scene.
  38658. * Skeletons and animation groups will all be cloned
  38659. * @param nameFunction defines an optional function used to get new names for clones
  38660. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38661. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38662. */
  38663. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38664. /**
  38665. * Adds all the assets from the container to the scene.
  38666. */
  38667. addAllToScene(): void;
  38668. /**
  38669. * Removes all the assets in the container from the scene
  38670. */
  38671. removeAllFromScene(): void;
  38672. /**
  38673. * Disposes all the assets in the container
  38674. */
  38675. dispose(): void;
  38676. private _moveAssets;
  38677. /**
  38678. * Removes all the assets contained in the scene and adds them to the container.
  38679. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38680. */
  38681. moveAllFromScene(keepAssets?: KeepAssets): void;
  38682. /**
  38683. * 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.
  38684. * @returns the root mesh
  38685. */
  38686. createRootMesh(): Mesh;
  38687. /**
  38688. * Merge animations (direct and animation groups) from this asset container into a scene
  38689. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38690. * @param animatables set of animatables to retarget to a node from the scene
  38691. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38692. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  38693. */
  38694. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  38695. }
  38696. }
  38697. declare module "babylonjs/abstractScene" {
  38698. import { Scene } from "babylonjs/scene";
  38699. import { Nullable } from "babylonjs/types";
  38700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38701. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38702. import { Geometry } from "babylonjs/Meshes/geometry";
  38703. import { Skeleton } from "babylonjs/Bones/skeleton";
  38704. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38705. import { AssetContainer } from "babylonjs/assetContainer";
  38706. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38707. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38709. import { Material } from "babylonjs/Materials/material";
  38710. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38711. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38712. import { Camera } from "babylonjs/Cameras/camera";
  38713. import { Light } from "babylonjs/Lights/light";
  38714. import { Node } from "babylonjs/node";
  38715. import { Animation } from "babylonjs/Animations/animation";
  38716. /**
  38717. * Defines how the parser contract is defined.
  38718. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38719. */
  38720. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38721. /**
  38722. * Defines how the individual parser contract is defined.
  38723. * These parser can parse an individual asset
  38724. */
  38725. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38726. /**
  38727. * Base class of the scene acting as a container for the different elements composing a scene.
  38728. * This class is dynamically extended by the different components of the scene increasing
  38729. * flexibility and reducing coupling
  38730. */
  38731. export abstract class AbstractScene {
  38732. /**
  38733. * Stores the list of available parsers in the application.
  38734. */
  38735. private static _BabylonFileParsers;
  38736. /**
  38737. * Stores the list of available individual parsers in the application.
  38738. */
  38739. private static _IndividualBabylonFileParsers;
  38740. /**
  38741. * Adds a parser in the list of available ones
  38742. * @param name Defines the name of the parser
  38743. * @param parser Defines the parser to add
  38744. */
  38745. static AddParser(name: string, parser: BabylonFileParser): void;
  38746. /**
  38747. * Gets a general parser from the list of avaialble ones
  38748. * @param name Defines the name of the parser
  38749. * @returns the requested parser or null
  38750. */
  38751. static GetParser(name: string): Nullable<BabylonFileParser>;
  38752. /**
  38753. * Adds n individual parser in the list of available ones
  38754. * @param name Defines the name of the parser
  38755. * @param parser Defines the parser to add
  38756. */
  38757. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38758. /**
  38759. * Gets an individual parser from the list of avaialble ones
  38760. * @param name Defines the name of the parser
  38761. * @returns the requested parser or null
  38762. */
  38763. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38764. /**
  38765. * Parser json data and populate both a scene and its associated container object
  38766. * @param jsonData Defines the data to parse
  38767. * @param scene Defines the scene to parse the data for
  38768. * @param container Defines the container attached to the parsing sequence
  38769. * @param rootUrl Defines the root url of the data
  38770. */
  38771. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38772. /**
  38773. * Gets the list of root nodes (ie. nodes with no parent)
  38774. */
  38775. rootNodes: Node[];
  38776. /** All of the cameras added to this scene
  38777. * @see http://doc.babylonjs.com/babylon101/cameras
  38778. */
  38779. cameras: Camera[];
  38780. /**
  38781. * All of the lights added to this scene
  38782. * @see http://doc.babylonjs.com/babylon101/lights
  38783. */
  38784. lights: Light[];
  38785. /**
  38786. * All of the (abstract) meshes added to this scene
  38787. */
  38788. meshes: AbstractMesh[];
  38789. /**
  38790. * The list of skeletons added to the scene
  38791. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38792. */
  38793. skeletons: Skeleton[];
  38794. /**
  38795. * All of the particle systems added to this scene
  38796. * @see http://doc.babylonjs.com/babylon101/particles
  38797. */
  38798. particleSystems: IParticleSystem[];
  38799. /**
  38800. * Gets a list of Animations associated with the scene
  38801. */
  38802. animations: Animation[];
  38803. /**
  38804. * All of the animation groups added to this scene
  38805. * @see http://doc.babylonjs.com/how_to/group
  38806. */
  38807. animationGroups: AnimationGroup[];
  38808. /**
  38809. * All of the multi-materials added to this scene
  38810. * @see http://doc.babylonjs.com/how_to/multi_materials
  38811. */
  38812. multiMaterials: MultiMaterial[];
  38813. /**
  38814. * All of the materials added to this scene
  38815. * In the context of a Scene, it is not supposed to be modified manually.
  38816. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38817. * Note also that the order of the Material within the array is not significant and might change.
  38818. * @see http://doc.babylonjs.com/babylon101/materials
  38819. */
  38820. materials: Material[];
  38821. /**
  38822. * The list of morph target managers added to the scene
  38823. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38824. */
  38825. morphTargetManagers: MorphTargetManager[];
  38826. /**
  38827. * The list of geometries used in the scene.
  38828. */
  38829. geometries: Geometry[];
  38830. /**
  38831. * All of the tranform nodes added to this scene
  38832. * In the context of a Scene, it is not supposed to be modified manually.
  38833. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38834. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38835. * @see http://doc.babylonjs.com/how_to/transformnode
  38836. */
  38837. transformNodes: TransformNode[];
  38838. /**
  38839. * ActionManagers available on the scene.
  38840. */
  38841. actionManagers: AbstractActionManager[];
  38842. /**
  38843. * Textures to keep.
  38844. */
  38845. textures: BaseTexture[];
  38846. /**
  38847. * Environment texture for the scene
  38848. */
  38849. environmentTexture: Nullable<BaseTexture>;
  38850. /**
  38851. * @returns all meshes, lights, cameras, transformNodes and bones
  38852. */
  38853. getNodes(): Array<Node>;
  38854. }
  38855. }
  38856. declare module "babylonjs/Audio/sound" {
  38857. import { Observable } from "babylonjs/Misc/observable";
  38858. import { Vector3 } from "babylonjs/Maths/math.vector";
  38859. import { Nullable } from "babylonjs/types";
  38860. import { Scene } from "babylonjs/scene";
  38861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38862. /**
  38863. * Interface used to define options for Sound class
  38864. */
  38865. export interface ISoundOptions {
  38866. /**
  38867. * Does the sound autoplay once loaded.
  38868. */
  38869. autoplay?: boolean;
  38870. /**
  38871. * Does the sound loop after it finishes playing once.
  38872. */
  38873. loop?: boolean;
  38874. /**
  38875. * Sound's volume
  38876. */
  38877. volume?: number;
  38878. /**
  38879. * Is it a spatial sound?
  38880. */
  38881. spatialSound?: boolean;
  38882. /**
  38883. * Maximum distance to hear that sound
  38884. */
  38885. maxDistance?: number;
  38886. /**
  38887. * Uses user defined attenuation function
  38888. */
  38889. useCustomAttenuation?: boolean;
  38890. /**
  38891. * Define the roll off factor of spatial sounds.
  38892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38893. */
  38894. rolloffFactor?: number;
  38895. /**
  38896. * Define the reference distance the sound should be heard perfectly.
  38897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38898. */
  38899. refDistance?: number;
  38900. /**
  38901. * Define the distance attenuation model the sound will follow.
  38902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38903. */
  38904. distanceModel?: string;
  38905. /**
  38906. * Defines the playback speed (1 by default)
  38907. */
  38908. playbackRate?: number;
  38909. /**
  38910. * Defines if the sound is from a streaming source
  38911. */
  38912. streaming?: boolean;
  38913. /**
  38914. * Defines an optional length (in seconds) inside the sound file
  38915. */
  38916. length?: number;
  38917. /**
  38918. * Defines an optional offset (in seconds) inside the sound file
  38919. */
  38920. offset?: number;
  38921. /**
  38922. * If true, URLs will not be required to state the audio file codec to use.
  38923. */
  38924. skipCodecCheck?: boolean;
  38925. }
  38926. /**
  38927. * Defines a sound that can be played in the application.
  38928. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38930. */
  38931. export class Sound {
  38932. /**
  38933. * The name of the sound in the scene.
  38934. */
  38935. name: string;
  38936. /**
  38937. * Does the sound autoplay once loaded.
  38938. */
  38939. autoplay: boolean;
  38940. /**
  38941. * Does the sound loop after it finishes playing once.
  38942. */
  38943. loop: boolean;
  38944. /**
  38945. * Does the sound use a custom attenuation curve to simulate the falloff
  38946. * happening when the source gets further away from the camera.
  38947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38948. */
  38949. useCustomAttenuation: boolean;
  38950. /**
  38951. * The sound track id this sound belongs to.
  38952. */
  38953. soundTrackId: number;
  38954. /**
  38955. * Is this sound currently played.
  38956. */
  38957. isPlaying: boolean;
  38958. /**
  38959. * Is this sound currently paused.
  38960. */
  38961. isPaused: boolean;
  38962. /**
  38963. * Does this sound enables spatial sound.
  38964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38965. */
  38966. spatialSound: boolean;
  38967. /**
  38968. * Define the reference distance the sound should be heard perfectly.
  38969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38970. */
  38971. refDistance: number;
  38972. /**
  38973. * Define the roll off factor of spatial sounds.
  38974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38975. */
  38976. rolloffFactor: number;
  38977. /**
  38978. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38980. */
  38981. maxDistance: number;
  38982. /**
  38983. * Define the distance attenuation model the sound will follow.
  38984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38985. */
  38986. distanceModel: string;
  38987. /**
  38988. * @hidden
  38989. * Back Compat
  38990. **/
  38991. onended: () => any;
  38992. /**
  38993. * Observable event when the current playing sound finishes.
  38994. */
  38995. onEndedObservable: Observable<Sound>;
  38996. private _panningModel;
  38997. private _playbackRate;
  38998. private _streaming;
  38999. private _startTime;
  39000. private _startOffset;
  39001. private _position;
  39002. /** @hidden */
  39003. _positionInEmitterSpace: boolean;
  39004. private _localDirection;
  39005. private _volume;
  39006. private _isReadyToPlay;
  39007. private _isDirectional;
  39008. private _readyToPlayCallback;
  39009. private _audioBuffer;
  39010. private _soundSource;
  39011. private _streamingSource;
  39012. private _soundPanner;
  39013. private _soundGain;
  39014. private _inputAudioNode;
  39015. private _outputAudioNode;
  39016. private _coneInnerAngle;
  39017. private _coneOuterAngle;
  39018. private _coneOuterGain;
  39019. private _scene;
  39020. private _connectedTransformNode;
  39021. private _customAttenuationFunction;
  39022. private _registerFunc;
  39023. private _isOutputConnected;
  39024. private _htmlAudioElement;
  39025. private _urlType;
  39026. private _length?;
  39027. private _offset?;
  39028. /** @hidden */
  39029. static _SceneComponentInitialization: (scene: Scene) => void;
  39030. /**
  39031. * Create a sound and attach it to a scene
  39032. * @param name Name of your sound
  39033. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  39034. * @param scene defines the scene the sound belongs to
  39035. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  39036. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  39037. */
  39038. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  39039. /**
  39040. * Release the sound and its associated resources
  39041. */
  39042. dispose(): void;
  39043. /**
  39044. * Gets if the sounds is ready to be played or not.
  39045. * @returns true if ready, otherwise false
  39046. */
  39047. isReady(): boolean;
  39048. private _soundLoaded;
  39049. /**
  39050. * Sets the data of the sound from an audiobuffer
  39051. * @param audioBuffer The audioBuffer containing the data
  39052. */
  39053. setAudioBuffer(audioBuffer: AudioBuffer): void;
  39054. /**
  39055. * Updates the current sounds options such as maxdistance, loop...
  39056. * @param options A JSON object containing values named as the object properties
  39057. */
  39058. updateOptions(options: ISoundOptions): void;
  39059. private _createSpatialParameters;
  39060. private _updateSpatialParameters;
  39061. /**
  39062. * Switch the panning model to HRTF:
  39063. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39065. */
  39066. switchPanningModelToHRTF(): void;
  39067. /**
  39068. * Switch the panning model to Equal Power:
  39069. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39071. */
  39072. switchPanningModelToEqualPower(): void;
  39073. private _switchPanningModel;
  39074. /**
  39075. * Connect this sound to a sound track audio node like gain...
  39076. * @param soundTrackAudioNode the sound track audio node to connect to
  39077. */
  39078. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  39079. /**
  39080. * Transform this sound into a directional source
  39081. * @param coneInnerAngle Size of the inner cone in degree
  39082. * @param coneOuterAngle Size of the outer cone in degree
  39083. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  39084. */
  39085. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  39086. /**
  39087. * Gets or sets the inner angle for the directional cone.
  39088. */
  39089. get directionalConeInnerAngle(): number;
  39090. /**
  39091. * Gets or sets the inner angle for the directional cone.
  39092. */
  39093. set directionalConeInnerAngle(value: number);
  39094. /**
  39095. * Gets or sets the outer angle for the directional cone.
  39096. */
  39097. get directionalConeOuterAngle(): number;
  39098. /**
  39099. * Gets or sets the outer angle for the directional cone.
  39100. */
  39101. set directionalConeOuterAngle(value: number);
  39102. /**
  39103. * Sets the position of the emitter if spatial sound is enabled
  39104. * @param newPosition Defines the new posisiton
  39105. */
  39106. setPosition(newPosition: Vector3): void;
  39107. /**
  39108. * Sets the local direction of the emitter if spatial sound is enabled
  39109. * @param newLocalDirection Defines the new local direction
  39110. */
  39111. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  39112. private _updateDirection;
  39113. /** @hidden */
  39114. updateDistanceFromListener(): void;
  39115. /**
  39116. * Sets a new custom attenuation function for the sound.
  39117. * @param callback Defines the function used for the attenuation
  39118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  39119. */
  39120. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  39121. /**
  39122. * Play the sound
  39123. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  39124. * @param offset (optional) Start the sound at a specific time in seconds
  39125. * @param length (optional) Sound duration (in seconds)
  39126. */
  39127. play(time?: number, offset?: number, length?: number): void;
  39128. private _onended;
  39129. /**
  39130. * Stop the sound
  39131. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  39132. */
  39133. stop(time?: number): void;
  39134. /**
  39135. * Put the sound in pause
  39136. */
  39137. pause(): void;
  39138. /**
  39139. * Sets a dedicated volume for this sounds
  39140. * @param newVolume Define the new volume of the sound
  39141. * @param time Define time for gradual change to new volume
  39142. */
  39143. setVolume(newVolume: number, time?: number): void;
  39144. /**
  39145. * Set the sound play back rate
  39146. * @param newPlaybackRate Define the playback rate the sound should be played at
  39147. */
  39148. setPlaybackRate(newPlaybackRate: number): void;
  39149. /**
  39150. * Gets the volume of the sound.
  39151. * @returns the volume of the sound
  39152. */
  39153. getVolume(): number;
  39154. /**
  39155. * Attach the sound to a dedicated mesh
  39156. * @param transformNode The transform node to connect the sound with
  39157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39158. */
  39159. attachToMesh(transformNode: TransformNode): void;
  39160. /**
  39161. * Detach the sound from the previously attached mesh
  39162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  39163. */
  39164. detachFromMesh(): void;
  39165. private _onRegisterAfterWorldMatrixUpdate;
  39166. /**
  39167. * Clone the current sound in the scene.
  39168. * @returns the new sound clone
  39169. */
  39170. clone(): Nullable<Sound>;
  39171. /**
  39172. * Gets the current underlying audio buffer containing the data
  39173. * @returns the audio buffer
  39174. */
  39175. getAudioBuffer(): Nullable<AudioBuffer>;
  39176. /**
  39177. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  39178. * @returns the source node
  39179. */
  39180. getSoundSource(): Nullable<AudioBufferSourceNode>;
  39181. /**
  39182. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  39183. * @returns the gain node
  39184. */
  39185. getSoundGain(): Nullable<GainNode>;
  39186. /**
  39187. * Serializes the Sound in a JSON representation
  39188. * @returns the JSON representation of the sound
  39189. */
  39190. serialize(): any;
  39191. /**
  39192. * Parse a JSON representation of a sound to innstantiate in a given scene
  39193. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  39194. * @param scene Define the scene the new parsed sound should be created in
  39195. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  39196. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  39197. * @returns the newly parsed sound
  39198. */
  39199. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  39200. }
  39201. }
  39202. declare module "babylonjs/Actions/directAudioActions" {
  39203. import { Action } from "babylonjs/Actions/action";
  39204. import { Condition } from "babylonjs/Actions/condition";
  39205. import { Sound } from "babylonjs/Audio/sound";
  39206. /**
  39207. * This defines an action helpful to play a defined sound on a triggered action.
  39208. */
  39209. export class PlaySoundAction extends Action {
  39210. private _sound;
  39211. /**
  39212. * Instantiate the action
  39213. * @param triggerOptions defines the trigger options
  39214. * @param sound defines the sound to play
  39215. * @param condition defines the trigger related conditions
  39216. */
  39217. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39218. /** @hidden */
  39219. _prepare(): void;
  39220. /**
  39221. * Execute the action and play the sound.
  39222. */
  39223. execute(): void;
  39224. /**
  39225. * Serializes the actions and its related information.
  39226. * @param parent defines the object to serialize in
  39227. * @returns the serialized object
  39228. */
  39229. serialize(parent: any): any;
  39230. }
  39231. /**
  39232. * This defines an action helpful to stop a defined sound on a triggered action.
  39233. */
  39234. export class StopSoundAction extends Action {
  39235. private _sound;
  39236. /**
  39237. * Instantiate the action
  39238. * @param triggerOptions defines the trigger options
  39239. * @param sound defines the sound to stop
  39240. * @param condition defines the trigger related conditions
  39241. */
  39242. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39243. /** @hidden */
  39244. _prepare(): void;
  39245. /**
  39246. * Execute the action and stop the sound.
  39247. */
  39248. execute(): void;
  39249. /**
  39250. * Serializes the actions and its related information.
  39251. * @param parent defines the object to serialize in
  39252. * @returns the serialized object
  39253. */
  39254. serialize(parent: any): any;
  39255. }
  39256. }
  39257. declare module "babylonjs/Actions/interpolateValueAction" {
  39258. import { Action } from "babylonjs/Actions/action";
  39259. import { Condition } from "babylonjs/Actions/condition";
  39260. import { Observable } from "babylonjs/Misc/observable";
  39261. /**
  39262. * This defines an action responsible to change the value of a property
  39263. * by interpolating between its current value and the newly set one once triggered.
  39264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39265. */
  39266. export class InterpolateValueAction extends Action {
  39267. /**
  39268. * Defines the path of the property where the value should be interpolated
  39269. */
  39270. propertyPath: string;
  39271. /**
  39272. * Defines the target value at the end of the interpolation.
  39273. */
  39274. value: any;
  39275. /**
  39276. * Defines the time it will take for the property to interpolate to the value.
  39277. */
  39278. duration: number;
  39279. /**
  39280. * Defines if the other scene animations should be stopped when the action has been triggered
  39281. */
  39282. stopOtherAnimations?: boolean;
  39283. /**
  39284. * Defines a callback raised once the interpolation animation has been done.
  39285. */
  39286. onInterpolationDone?: () => void;
  39287. /**
  39288. * Observable triggered once the interpolation animation has been done.
  39289. */
  39290. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39291. private _target;
  39292. private _effectiveTarget;
  39293. private _property;
  39294. /**
  39295. * Instantiate the action
  39296. * @param triggerOptions defines the trigger options
  39297. * @param target defines the object containing the value to interpolate
  39298. * @param propertyPath defines the path to the property in the target object
  39299. * @param value defines the target value at the end of the interpolation
  39300. * @param duration deines the time it will take for the property to interpolate to the value.
  39301. * @param condition defines the trigger related conditions
  39302. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39303. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39304. */
  39305. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39306. /** @hidden */
  39307. _prepare(): void;
  39308. /**
  39309. * Execute the action starts the value interpolation.
  39310. */
  39311. execute(): void;
  39312. /**
  39313. * Serializes the actions and its related information.
  39314. * @param parent defines the object to serialize in
  39315. * @returns the serialized object
  39316. */
  39317. serialize(parent: any): any;
  39318. }
  39319. }
  39320. declare module "babylonjs/Actions/index" {
  39321. export * from "babylonjs/Actions/abstractActionManager";
  39322. export * from "babylonjs/Actions/action";
  39323. export * from "babylonjs/Actions/actionEvent";
  39324. export * from "babylonjs/Actions/actionManager";
  39325. export * from "babylonjs/Actions/condition";
  39326. export * from "babylonjs/Actions/directActions";
  39327. export * from "babylonjs/Actions/directAudioActions";
  39328. export * from "babylonjs/Actions/interpolateValueAction";
  39329. }
  39330. declare module "babylonjs/Animations/index" {
  39331. export * from "babylonjs/Animations/animatable";
  39332. export * from "babylonjs/Animations/animation";
  39333. export * from "babylonjs/Animations/animationGroup";
  39334. export * from "babylonjs/Animations/animationPropertiesOverride";
  39335. export * from "babylonjs/Animations/easing";
  39336. export * from "babylonjs/Animations/runtimeAnimation";
  39337. export * from "babylonjs/Animations/animationEvent";
  39338. export * from "babylonjs/Animations/animationGroup";
  39339. export * from "babylonjs/Animations/animationKey";
  39340. export * from "babylonjs/Animations/animationRange";
  39341. export * from "babylonjs/Animations/animatable.interface";
  39342. }
  39343. declare module "babylonjs/Audio/soundTrack" {
  39344. import { Sound } from "babylonjs/Audio/sound";
  39345. import { Analyser } from "babylonjs/Audio/analyser";
  39346. import { Scene } from "babylonjs/scene";
  39347. /**
  39348. * Options allowed during the creation of a sound track.
  39349. */
  39350. export interface ISoundTrackOptions {
  39351. /**
  39352. * The volume the sound track should take during creation
  39353. */
  39354. volume?: number;
  39355. /**
  39356. * Define if the sound track is the main sound track of the scene
  39357. */
  39358. mainTrack?: boolean;
  39359. }
  39360. /**
  39361. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39362. * It will be also used in a future release to apply effects on a specific track.
  39363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39364. */
  39365. export class SoundTrack {
  39366. /**
  39367. * The unique identifier of the sound track in the scene.
  39368. */
  39369. id: number;
  39370. /**
  39371. * The list of sounds included in the sound track.
  39372. */
  39373. soundCollection: Array<Sound>;
  39374. private _outputAudioNode;
  39375. private _scene;
  39376. private _connectedAnalyser;
  39377. private _options;
  39378. private _isInitialized;
  39379. /**
  39380. * Creates a new sound track.
  39381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39382. * @param scene Define the scene the sound track belongs to
  39383. * @param options
  39384. */
  39385. constructor(scene: Scene, options?: ISoundTrackOptions);
  39386. private _initializeSoundTrackAudioGraph;
  39387. /**
  39388. * Release the sound track and its associated resources
  39389. */
  39390. dispose(): void;
  39391. /**
  39392. * Adds a sound to this sound track
  39393. * @param sound define the cound to add
  39394. * @ignoreNaming
  39395. */
  39396. AddSound(sound: Sound): void;
  39397. /**
  39398. * Removes a sound to this sound track
  39399. * @param sound define the cound to remove
  39400. * @ignoreNaming
  39401. */
  39402. RemoveSound(sound: Sound): void;
  39403. /**
  39404. * Set a global volume for the full sound track.
  39405. * @param newVolume Define the new volume of the sound track
  39406. */
  39407. setVolume(newVolume: number): void;
  39408. /**
  39409. * Switch the panning model to HRTF:
  39410. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39412. */
  39413. switchPanningModelToHRTF(): void;
  39414. /**
  39415. * Switch the panning model to Equal Power:
  39416. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39418. */
  39419. switchPanningModelToEqualPower(): void;
  39420. /**
  39421. * Connect the sound track to an audio analyser allowing some amazing
  39422. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39424. * @param analyser The analyser to connect to the engine
  39425. */
  39426. connectToAnalyser(analyser: Analyser): void;
  39427. }
  39428. }
  39429. declare module "babylonjs/Audio/audioSceneComponent" {
  39430. import { Sound } from "babylonjs/Audio/sound";
  39431. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39432. import { Nullable } from "babylonjs/types";
  39433. import { Vector3 } from "babylonjs/Maths/math.vector";
  39434. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39435. import { Scene } from "babylonjs/scene";
  39436. import { AbstractScene } from "babylonjs/abstractScene";
  39437. import "babylonjs/Audio/audioEngine";
  39438. module "babylonjs/abstractScene" {
  39439. interface AbstractScene {
  39440. /**
  39441. * The list of sounds used in the scene.
  39442. */
  39443. sounds: Nullable<Array<Sound>>;
  39444. }
  39445. }
  39446. module "babylonjs/scene" {
  39447. interface Scene {
  39448. /**
  39449. * @hidden
  39450. * Backing field
  39451. */
  39452. _mainSoundTrack: SoundTrack;
  39453. /**
  39454. * The main sound track played by the scene.
  39455. * It cotains your primary collection of sounds.
  39456. */
  39457. mainSoundTrack: SoundTrack;
  39458. /**
  39459. * The list of sound tracks added to the scene
  39460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39461. */
  39462. soundTracks: Nullable<Array<SoundTrack>>;
  39463. /**
  39464. * Gets a sound using a given name
  39465. * @param name defines the name to search for
  39466. * @return the found sound or null if not found at all.
  39467. */
  39468. getSoundByName(name: string): Nullable<Sound>;
  39469. /**
  39470. * Gets or sets if audio support is enabled
  39471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39472. */
  39473. audioEnabled: boolean;
  39474. /**
  39475. * Gets or sets if audio will be output to headphones
  39476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39477. */
  39478. headphone: boolean;
  39479. /**
  39480. * Gets or sets custom audio listener position provider
  39481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39482. */
  39483. audioListenerPositionProvider: Nullable<() => Vector3>;
  39484. /**
  39485. * Gets or sets a refresh rate when using 3D audio positioning
  39486. */
  39487. audioPositioningRefreshRate: number;
  39488. }
  39489. }
  39490. /**
  39491. * Defines the sound scene component responsible to manage any sounds
  39492. * in a given scene.
  39493. */
  39494. export class AudioSceneComponent implements ISceneSerializableComponent {
  39495. /**
  39496. * The component name helpfull to identify the component in the list of scene components.
  39497. */
  39498. readonly name: string;
  39499. /**
  39500. * The scene the component belongs to.
  39501. */
  39502. scene: Scene;
  39503. private _audioEnabled;
  39504. /**
  39505. * Gets whether audio is enabled or not.
  39506. * Please use related enable/disable method to switch state.
  39507. */
  39508. get audioEnabled(): boolean;
  39509. private _headphone;
  39510. /**
  39511. * Gets whether audio is outputing to headphone or not.
  39512. * Please use the according Switch methods to change output.
  39513. */
  39514. get headphone(): boolean;
  39515. /**
  39516. * Gets or sets a refresh rate when using 3D audio positioning
  39517. */
  39518. audioPositioningRefreshRate: number;
  39519. private _audioListenerPositionProvider;
  39520. /**
  39521. * Gets the current audio listener position provider
  39522. */
  39523. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39524. /**
  39525. * Sets a custom listener position for all sounds in the scene
  39526. * By default, this is the position of the first active camera
  39527. */
  39528. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39529. /**
  39530. * Creates a new instance of the component for the given scene
  39531. * @param scene Defines the scene to register the component in
  39532. */
  39533. constructor(scene: Scene);
  39534. /**
  39535. * Registers the component in a given scene
  39536. */
  39537. register(): void;
  39538. /**
  39539. * Rebuilds the elements related to this component in case of
  39540. * context lost for instance.
  39541. */
  39542. rebuild(): void;
  39543. /**
  39544. * Serializes the component data to the specified json object
  39545. * @param serializationObject The object to serialize to
  39546. */
  39547. serialize(serializationObject: any): void;
  39548. /**
  39549. * Adds all the elements from the container to the scene
  39550. * @param container the container holding the elements
  39551. */
  39552. addFromContainer(container: AbstractScene): void;
  39553. /**
  39554. * Removes all the elements in the container from the scene
  39555. * @param container contains the elements to remove
  39556. * @param dispose if the removed element should be disposed (default: false)
  39557. */
  39558. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39559. /**
  39560. * Disposes the component and the associated ressources.
  39561. */
  39562. dispose(): void;
  39563. /**
  39564. * Disables audio in the associated scene.
  39565. */
  39566. disableAudio(): void;
  39567. /**
  39568. * Enables audio in the associated scene.
  39569. */
  39570. enableAudio(): void;
  39571. /**
  39572. * Switch audio to headphone output.
  39573. */
  39574. switchAudioModeForHeadphones(): void;
  39575. /**
  39576. * Switch audio to normal speakers.
  39577. */
  39578. switchAudioModeForNormalSpeakers(): void;
  39579. private _cachedCameraDirection;
  39580. private _cachedCameraPosition;
  39581. private _lastCheck;
  39582. private _afterRender;
  39583. }
  39584. }
  39585. declare module "babylonjs/Audio/weightedsound" {
  39586. import { Sound } from "babylonjs/Audio/sound";
  39587. /**
  39588. * Wraps one or more Sound objects and selects one with random weight for playback.
  39589. */
  39590. export class WeightedSound {
  39591. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39592. loop: boolean;
  39593. private _coneInnerAngle;
  39594. private _coneOuterAngle;
  39595. private _volume;
  39596. /** A Sound is currently playing. */
  39597. isPlaying: boolean;
  39598. /** A Sound is currently paused. */
  39599. isPaused: boolean;
  39600. private _sounds;
  39601. private _weights;
  39602. private _currentIndex?;
  39603. /**
  39604. * Creates a new WeightedSound from the list of sounds given.
  39605. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39606. * @param sounds Array of Sounds that will be selected from.
  39607. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39608. */
  39609. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39610. /**
  39611. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39612. */
  39613. get directionalConeInnerAngle(): number;
  39614. /**
  39615. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39616. */
  39617. set directionalConeInnerAngle(value: number);
  39618. /**
  39619. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39620. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39621. */
  39622. get directionalConeOuterAngle(): number;
  39623. /**
  39624. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39625. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39626. */
  39627. set directionalConeOuterAngle(value: number);
  39628. /**
  39629. * Playback volume.
  39630. */
  39631. get volume(): number;
  39632. /**
  39633. * Playback volume.
  39634. */
  39635. set volume(value: number);
  39636. private _onended;
  39637. /**
  39638. * Suspend playback
  39639. */
  39640. pause(): void;
  39641. /**
  39642. * Stop playback
  39643. */
  39644. stop(): void;
  39645. /**
  39646. * Start playback.
  39647. * @param startOffset Position the clip head at a specific time in seconds.
  39648. */
  39649. play(startOffset?: number): void;
  39650. }
  39651. }
  39652. declare module "babylonjs/Audio/index" {
  39653. export * from "babylonjs/Audio/analyser";
  39654. export * from "babylonjs/Audio/audioEngine";
  39655. export * from "babylonjs/Audio/audioSceneComponent";
  39656. export * from "babylonjs/Audio/sound";
  39657. export * from "babylonjs/Audio/soundTrack";
  39658. export * from "babylonjs/Audio/weightedsound";
  39659. }
  39660. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39661. import { Behavior } from "babylonjs/Behaviors/behavior";
  39662. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39663. import { BackEase } from "babylonjs/Animations/easing";
  39664. /**
  39665. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39666. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39667. */
  39668. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39669. /**
  39670. * Gets the name of the behavior.
  39671. */
  39672. get name(): string;
  39673. /**
  39674. * The easing function used by animations
  39675. */
  39676. static EasingFunction: BackEase;
  39677. /**
  39678. * The easing mode used by animations
  39679. */
  39680. static EasingMode: number;
  39681. /**
  39682. * The duration of the animation, in milliseconds
  39683. */
  39684. transitionDuration: number;
  39685. /**
  39686. * Length of the distance animated by the transition when lower radius is reached
  39687. */
  39688. lowerRadiusTransitionRange: number;
  39689. /**
  39690. * Length of the distance animated by the transition when upper radius is reached
  39691. */
  39692. upperRadiusTransitionRange: number;
  39693. private _autoTransitionRange;
  39694. /**
  39695. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39696. */
  39697. get autoTransitionRange(): boolean;
  39698. /**
  39699. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39700. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39701. */
  39702. set autoTransitionRange(value: boolean);
  39703. private _attachedCamera;
  39704. private _onAfterCheckInputsObserver;
  39705. private _onMeshTargetChangedObserver;
  39706. /**
  39707. * Initializes the behavior.
  39708. */
  39709. init(): void;
  39710. /**
  39711. * Attaches the behavior to its arc rotate camera.
  39712. * @param camera Defines the camera to attach the behavior to
  39713. */
  39714. attach(camera: ArcRotateCamera): void;
  39715. /**
  39716. * Detaches the behavior from its current arc rotate camera.
  39717. */
  39718. detach(): void;
  39719. private _radiusIsAnimating;
  39720. private _radiusBounceTransition;
  39721. private _animatables;
  39722. private _cachedWheelPrecision;
  39723. /**
  39724. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39725. * @param radiusLimit The limit to check against.
  39726. * @return Bool to indicate if at limit.
  39727. */
  39728. private _isRadiusAtLimit;
  39729. /**
  39730. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39731. * @param radiusDelta The delta by which to animate to. Can be negative.
  39732. */
  39733. private _applyBoundRadiusAnimation;
  39734. /**
  39735. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39736. */
  39737. protected _clearAnimationLocks(): void;
  39738. /**
  39739. * Stops and removes all animations that have been applied to the camera
  39740. */
  39741. stopAllAnimations(): void;
  39742. }
  39743. }
  39744. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39745. import { Behavior } from "babylonjs/Behaviors/behavior";
  39746. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39747. import { ExponentialEase } from "babylonjs/Animations/easing";
  39748. import { Nullable } from "babylonjs/types";
  39749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39750. import { Vector3 } from "babylonjs/Maths/math.vector";
  39751. /**
  39752. * 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.
  39753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39754. */
  39755. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39756. /**
  39757. * Gets the name of the behavior.
  39758. */
  39759. get name(): string;
  39760. private _mode;
  39761. private _radiusScale;
  39762. private _positionScale;
  39763. private _defaultElevation;
  39764. private _elevationReturnTime;
  39765. private _elevationReturnWaitTime;
  39766. private _zoomStopsAnimation;
  39767. private _framingTime;
  39768. /**
  39769. * The easing function used by animations
  39770. */
  39771. static EasingFunction: ExponentialEase;
  39772. /**
  39773. * The easing mode used by animations
  39774. */
  39775. static EasingMode: number;
  39776. /**
  39777. * Sets the current mode used by the behavior
  39778. */
  39779. set mode(mode: number);
  39780. /**
  39781. * Gets current mode used by the behavior.
  39782. */
  39783. get mode(): number;
  39784. /**
  39785. * Sets the scale applied to the radius (1 by default)
  39786. */
  39787. set radiusScale(radius: number);
  39788. /**
  39789. * Gets the scale applied to the radius
  39790. */
  39791. get radiusScale(): number;
  39792. /**
  39793. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39794. */
  39795. set positionScale(scale: number);
  39796. /**
  39797. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39798. */
  39799. get positionScale(): number;
  39800. /**
  39801. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39802. * behaviour is triggered, in radians.
  39803. */
  39804. set defaultElevation(elevation: number);
  39805. /**
  39806. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39807. * behaviour is triggered, in radians.
  39808. */
  39809. get defaultElevation(): number;
  39810. /**
  39811. * Sets the time (in milliseconds) taken to return to the default beta position.
  39812. * Negative value indicates camera should not return to default.
  39813. */
  39814. set elevationReturnTime(speed: number);
  39815. /**
  39816. * Gets the time (in milliseconds) taken to return to the default beta position.
  39817. * Negative value indicates camera should not return to default.
  39818. */
  39819. get elevationReturnTime(): number;
  39820. /**
  39821. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39822. */
  39823. set elevationReturnWaitTime(time: number);
  39824. /**
  39825. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39826. */
  39827. get elevationReturnWaitTime(): number;
  39828. /**
  39829. * Sets the flag that indicates if user zooming should stop animation.
  39830. */
  39831. set zoomStopsAnimation(flag: boolean);
  39832. /**
  39833. * Gets the flag that indicates if user zooming should stop animation.
  39834. */
  39835. get zoomStopsAnimation(): boolean;
  39836. /**
  39837. * Sets the transition time when framing the mesh, in milliseconds
  39838. */
  39839. set framingTime(time: number);
  39840. /**
  39841. * Gets the transition time when framing the mesh, in milliseconds
  39842. */
  39843. get framingTime(): number;
  39844. /**
  39845. * Define if the behavior should automatically change the configured
  39846. * camera limits and sensibilities.
  39847. */
  39848. autoCorrectCameraLimitsAndSensibility: boolean;
  39849. private _onPrePointerObservableObserver;
  39850. private _onAfterCheckInputsObserver;
  39851. private _onMeshTargetChangedObserver;
  39852. private _attachedCamera;
  39853. private _isPointerDown;
  39854. private _lastInteractionTime;
  39855. /**
  39856. * Initializes the behavior.
  39857. */
  39858. init(): void;
  39859. /**
  39860. * Attaches the behavior to its arc rotate camera.
  39861. * @param camera Defines the camera to attach the behavior to
  39862. */
  39863. attach(camera: ArcRotateCamera): void;
  39864. /**
  39865. * Detaches the behavior from its current arc rotate camera.
  39866. */
  39867. detach(): void;
  39868. private _animatables;
  39869. private _betaIsAnimating;
  39870. private _betaTransition;
  39871. private _radiusTransition;
  39872. private _vectorTransition;
  39873. /**
  39874. * Targets the given mesh and updates zoom level accordingly.
  39875. * @param mesh The mesh to target.
  39876. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39877. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39878. */
  39879. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39880. /**
  39881. * Targets the given mesh with its children and updates zoom level accordingly.
  39882. * @param mesh The mesh to target.
  39883. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39884. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39885. */
  39886. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39887. /**
  39888. * Targets the given meshes with their children and updates zoom level accordingly.
  39889. * @param meshes The mesh to target.
  39890. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39891. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39892. */
  39893. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39894. /**
  39895. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39896. * @param minimumWorld Determines the smaller position of the bounding box extend
  39897. * @param maximumWorld Determines the bigger position of the bounding box extend
  39898. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39899. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39900. */
  39901. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39902. /**
  39903. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39904. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39905. * frustum width.
  39906. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39907. * to fully enclose the mesh in the viewing frustum.
  39908. */
  39909. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39910. /**
  39911. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39912. * is automatically returned to its default position (expected to be above ground plane).
  39913. */
  39914. private _maintainCameraAboveGround;
  39915. /**
  39916. * Returns the frustum slope based on the canvas ratio and camera FOV
  39917. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39918. */
  39919. private _getFrustumSlope;
  39920. /**
  39921. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39922. */
  39923. private _clearAnimationLocks;
  39924. /**
  39925. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39926. */
  39927. private _applyUserInteraction;
  39928. /**
  39929. * Stops and removes all animations that have been applied to the camera
  39930. */
  39931. stopAllAnimations(): void;
  39932. /**
  39933. * Gets a value indicating if the user is moving the camera
  39934. */
  39935. get isUserIsMoving(): boolean;
  39936. /**
  39937. * The camera can move all the way towards the mesh.
  39938. */
  39939. static IgnoreBoundsSizeMode: number;
  39940. /**
  39941. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39942. */
  39943. static FitFrustumSidesMode: number;
  39944. }
  39945. }
  39946. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39947. import { Nullable } from "babylonjs/types";
  39948. import { Camera } from "babylonjs/Cameras/camera";
  39949. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39950. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39951. /**
  39952. * Base class for Camera Pointer Inputs.
  39953. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39954. * for example usage.
  39955. */
  39956. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39957. /**
  39958. * Defines the camera the input is attached to.
  39959. */
  39960. abstract camera: Camera;
  39961. /**
  39962. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39963. */
  39964. protected _altKey: boolean;
  39965. protected _ctrlKey: boolean;
  39966. protected _metaKey: boolean;
  39967. protected _shiftKey: boolean;
  39968. /**
  39969. * Which mouse buttons were pressed at time of last mouse event.
  39970. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39971. */
  39972. protected _buttonsPressed: number;
  39973. /**
  39974. * Defines the buttons associated with the input to handle camera move.
  39975. */
  39976. buttons: number[];
  39977. /**
  39978. * Attach the input controls to a specific dom element to get the input from.
  39979. * @param element Defines the element the controls should be listened from
  39980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39981. */
  39982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39983. /**
  39984. * Detach the current controls from the specified dom element.
  39985. * @param element Defines the element to stop listening the inputs from
  39986. */
  39987. detachControl(element: Nullable<HTMLElement>): void;
  39988. /**
  39989. * Gets the class name of the current input.
  39990. * @returns the class name
  39991. */
  39992. getClassName(): string;
  39993. /**
  39994. * Get the friendly name associated with the input class.
  39995. * @returns the input friendly name
  39996. */
  39997. getSimpleName(): string;
  39998. /**
  39999. * Called on pointer POINTERDOUBLETAP event.
  40000. * Override this method to provide functionality on POINTERDOUBLETAP event.
  40001. */
  40002. protected onDoubleTap(type: string): void;
  40003. /**
  40004. * Called on pointer POINTERMOVE event if only a single touch is active.
  40005. * Override this method to provide functionality.
  40006. */
  40007. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40008. /**
  40009. * Called on pointer POINTERMOVE event if multiple touches are active.
  40010. * Override this method to provide functionality.
  40011. */
  40012. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40013. /**
  40014. * Called on JS contextmenu event.
  40015. * Override this method to provide functionality.
  40016. */
  40017. protected onContextMenu(evt: PointerEvent): void;
  40018. /**
  40019. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40020. * press.
  40021. * Override this method to provide functionality.
  40022. */
  40023. protected onButtonDown(evt: PointerEvent): void;
  40024. /**
  40025. * Called each time a new POINTERUP event occurs. Ie, for each button
  40026. * release.
  40027. * Override this method to provide functionality.
  40028. */
  40029. protected onButtonUp(evt: PointerEvent): void;
  40030. /**
  40031. * Called when window becomes inactive.
  40032. * Override this method to provide functionality.
  40033. */
  40034. protected onLostFocus(): void;
  40035. private _pointerInput;
  40036. private _observer;
  40037. private _onLostFocus;
  40038. private pointA;
  40039. private pointB;
  40040. }
  40041. }
  40042. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  40043. import { Nullable } from "babylonjs/types";
  40044. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40045. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40046. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40047. /**
  40048. * Manage the pointers inputs to control an arc rotate camera.
  40049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40050. */
  40051. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  40052. /**
  40053. * Defines the camera the input is attached to.
  40054. */
  40055. camera: ArcRotateCamera;
  40056. /**
  40057. * Gets the class name of the current input.
  40058. * @returns the class name
  40059. */
  40060. getClassName(): string;
  40061. /**
  40062. * Defines the buttons associated with the input to handle camera move.
  40063. */
  40064. buttons: number[];
  40065. /**
  40066. * Defines the pointer angular sensibility along the X axis or how fast is
  40067. * the camera rotating.
  40068. */
  40069. angularSensibilityX: number;
  40070. /**
  40071. * Defines the pointer angular sensibility along the Y axis or how fast is
  40072. * the camera rotating.
  40073. */
  40074. angularSensibilityY: number;
  40075. /**
  40076. * Defines the pointer pinch precision or how fast is the camera zooming.
  40077. */
  40078. pinchPrecision: number;
  40079. /**
  40080. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40081. * from 0.
  40082. * It defines the percentage of current camera.radius to use as delta when
  40083. * pinch zoom is used.
  40084. */
  40085. pinchDeltaPercentage: number;
  40086. /**
  40087. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40088. * that any object in the plane at the camera's target point will scale
  40089. * perfectly with finger motion.
  40090. * Overrides pinchDeltaPercentage and pinchPrecision.
  40091. */
  40092. useNaturalPinchZoom: boolean;
  40093. /**
  40094. * Defines the pointer panning sensibility or how fast is the camera moving.
  40095. */
  40096. panningSensibility: number;
  40097. /**
  40098. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40099. */
  40100. multiTouchPanning: boolean;
  40101. /**
  40102. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  40103. * zoom (pinch) through multitouch.
  40104. */
  40105. multiTouchPanAndZoom: boolean;
  40106. /**
  40107. * Revers pinch action direction.
  40108. */
  40109. pinchInwards: boolean;
  40110. private _isPanClick;
  40111. private _twoFingerActivityCount;
  40112. private _isPinching;
  40113. /**
  40114. * Called on pointer POINTERMOVE event if only a single touch is active.
  40115. */
  40116. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40117. /**
  40118. * Called on pointer POINTERDOUBLETAP event.
  40119. */
  40120. protected onDoubleTap(type: string): void;
  40121. /**
  40122. * Called on pointer POINTERMOVE event if multiple touches are active.
  40123. */
  40124. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40125. /**
  40126. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  40127. * press.
  40128. */
  40129. protected onButtonDown(evt: PointerEvent): void;
  40130. /**
  40131. * Called each time a new POINTERUP event occurs. Ie, for each button
  40132. * release.
  40133. */
  40134. protected onButtonUp(evt: PointerEvent): void;
  40135. /**
  40136. * Called when window becomes inactive.
  40137. */
  40138. protected onLostFocus(): void;
  40139. }
  40140. }
  40141. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  40142. import { Nullable } from "babylonjs/types";
  40143. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40144. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40145. /**
  40146. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40148. */
  40149. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40150. /**
  40151. * Defines the camera the input is attached to.
  40152. */
  40153. camera: ArcRotateCamera;
  40154. /**
  40155. * Defines the list of key codes associated with the up action (increase alpha)
  40156. */
  40157. keysUp: number[];
  40158. /**
  40159. * Defines the list of key codes associated with the down action (decrease alpha)
  40160. */
  40161. keysDown: number[];
  40162. /**
  40163. * Defines the list of key codes associated with the left action (increase beta)
  40164. */
  40165. keysLeft: number[];
  40166. /**
  40167. * Defines the list of key codes associated with the right action (decrease beta)
  40168. */
  40169. keysRight: number[];
  40170. /**
  40171. * Defines the list of key codes associated with the reset action.
  40172. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40173. */
  40174. keysReset: number[];
  40175. /**
  40176. * Defines the panning sensibility of the inputs.
  40177. * (How fast is the camera panning)
  40178. */
  40179. panningSensibility: number;
  40180. /**
  40181. * Defines the zooming sensibility of the inputs.
  40182. * (How fast is the camera zooming)
  40183. */
  40184. zoomingSensibility: number;
  40185. /**
  40186. * Defines whether maintaining the alt key down switch the movement mode from
  40187. * orientation to zoom.
  40188. */
  40189. useAltToZoom: boolean;
  40190. /**
  40191. * Rotation speed of the camera
  40192. */
  40193. angularSpeed: number;
  40194. private _keys;
  40195. private _ctrlPressed;
  40196. private _altPressed;
  40197. private _onCanvasBlurObserver;
  40198. private _onKeyboardObserver;
  40199. private _engine;
  40200. private _scene;
  40201. /**
  40202. * Attach the input controls to a specific dom element to get the input from.
  40203. * @param element Defines the element the controls should be listened from
  40204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40205. */
  40206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40207. /**
  40208. * Detach the current controls from the specified dom element.
  40209. * @param element Defines the element to stop listening the inputs from
  40210. */
  40211. detachControl(element: Nullable<HTMLElement>): void;
  40212. /**
  40213. * Update the current camera state depending on the inputs that have been used this frame.
  40214. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40215. */
  40216. checkInputs(): void;
  40217. /**
  40218. * Gets the class name of the current intput.
  40219. * @returns the class name
  40220. */
  40221. getClassName(): string;
  40222. /**
  40223. * Get the friendly name associated with the input class.
  40224. * @returns the input friendly name
  40225. */
  40226. getSimpleName(): string;
  40227. }
  40228. }
  40229. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40230. import { Nullable } from "babylonjs/types";
  40231. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40232. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40233. /**
  40234. * Manage the mouse wheel inputs to control an arc rotate camera.
  40235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40236. */
  40237. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40238. /**
  40239. * Defines the camera the input is attached to.
  40240. */
  40241. camera: ArcRotateCamera;
  40242. /**
  40243. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40244. */
  40245. wheelPrecision: number;
  40246. /**
  40247. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40248. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40249. */
  40250. wheelDeltaPercentage: number;
  40251. private _wheel;
  40252. private _observer;
  40253. private computeDeltaFromMouseWheelLegacyEvent;
  40254. /**
  40255. * Attach the input controls to a specific dom element to get the input from.
  40256. * @param element Defines the element the controls should be listened from
  40257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40258. */
  40259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40260. /**
  40261. * Detach the current controls from the specified dom element.
  40262. * @param element Defines the element to stop listening the inputs from
  40263. */
  40264. detachControl(element: Nullable<HTMLElement>): void;
  40265. /**
  40266. * Gets the class name of the current intput.
  40267. * @returns the class name
  40268. */
  40269. getClassName(): string;
  40270. /**
  40271. * Get the friendly name associated with the input class.
  40272. * @returns the input friendly name
  40273. */
  40274. getSimpleName(): string;
  40275. }
  40276. }
  40277. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40278. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40279. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40280. /**
  40281. * Default Inputs manager for the ArcRotateCamera.
  40282. * It groups all the default supported inputs for ease of use.
  40283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40284. */
  40285. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40286. /**
  40287. * Instantiates a new ArcRotateCameraInputsManager.
  40288. * @param camera Defines the camera the inputs belong to
  40289. */
  40290. constructor(camera: ArcRotateCamera);
  40291. /**
  40292. * Add mouse wheel input support to the input manager.
  40293. * @returns the current input manager
  40294. */
  40295. addMouseWheel(): ArcRotateCameraInputsManager;
  40296. /**
  40297. * Add pointers input support to the input manager.
  40298. * @returns the current input manager
  40299. */
  40300. addPointers(): ArcRotateCameraInputsManager;
  40301. /**
  40302. * Add keyboard input support to the input manager.
  40303. * @returns the current input manager
  40304. */
  40305. addKeyboard(): ArcRotateCameraInputsManager;
  40306. }
  40307. }
  40308. declare module "babylonjs/Cameras/arcRotateCamera" {
  40309. import { Observable } from "babylonjs/Misc/observable";
  40310. import { Nullable } from "babylonjs/types";
  40311. import { Scene } from "babylonjs/scene";
  40312. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40314. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40315. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40316. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40317. import { Camera } from "babylonjs/Cameras/camera";
  40318. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40319. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40320. import { Collider } from "babylonjs/Collisions/collider";
  40321. /**
  40322. * This represents an orbital type of camera.
  40323. *
  40324. * 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.
  40325. * 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.
  40326. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40327. */
  40328. export class ArcRotateCamera extends TargetCamera {
  40329. /**
  40330. * Defines the rotation angle of the camera along the longitudinal axis.
  40331. */
  40332. alpha: number;
  40333. /**
  40334. * Defines the rotation angle of the camera along the latitudinal axis.
  40335. */
  40336. beta: number;
  40337. /**
  40338. * Defines the radius of the camera from it s target point.
  40339. */
  40340. radius: number;
  40341. protected _target: Vector3;
  40342. protected _targetHost: Nullable<AbstractMesh>;
  40343. /**
  40344. * Defines the target point of the camera.
  40345. * The camera looks towards it form the radius distance.
  40346. */
  40347. get target(): Vector3;
  40348. set target(value: Vector3);
  40349. /**
  40350. * Define the current local position of the camera in the scene
  40351. */
  40352. get position(): Vector3;
  40353. set position(newPosition: Vector3);
  40354. protected _upVector: Vector3;
  40355. protected _upToYMatrix: Matrix;
  40356. protected _YToUpMatrix: Matrix;
  40357. /**
  40358. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40359. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40360. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40361. */
  40362. set upVector(vec: Vector3);
  40363. get upVector(): Vector3;
  40364. /**
  40365. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40366. */
  40367. setMatUp(): void;
  40368. /**
  40369. * Current inertia value on the longitudinal axis.
  40370. * The bigger this number the longer it will take for the camera to stop.
  40371. */
  40372. inertialAlphaOffset: number;
  40373. /**
  40374. * Current inertia value on the latitudinal axis.
  40375. * The bigger this number the longer it will take for the camera to stop.
  40376. */
  40377. inertialBetaOffset: number;
  40378. /**
  40379. * Current inertia value on the radius axis.
  40380. * The bigger this number the longer it will take for the camera to stop.
  40381. */
  40382. inertialRadiusOffset: number;
  40383. /**
  40384. * Minimum allowed angle on the longitudinal axis.
  40385. * This can help limiting how the Camera is able to move in the scene.
  40386. */
  40387. lowerAlphaLimit: Nullable<number>;
  40388. /**
  40389. * Maximum allowed angle on the longitudinal axis.
  40390. * This can help limiting how the Camera is able to move in the scene.
  40391. */
  40392. upperAlphaLimit: Nullable<number>;
  40393. /**
  40394. * Minimum allowed angle on the latitudinal axis.
  40395. * This can help limiting how the Camera is able to move in the scene.
  40396. */
  40397. lowerBetaLimit: number;
  40398. /**
  40399. * Maximum allowed angle on the latitudinal axis.
  40400. * This can help limiting how the Camera is able to move in the scene.
  40401. */
  40402. upperBetaLimit: number;
  40403. /**
  40404. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40405. * This can help limiting how the Camera is able to move in the scene.
  40406. */
  40407. lowerRadiusLimit: Nullable<number>;
  40408. /**
  40409. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40410. * This can help limiting how the Camera is able to move in the scene.
  40411. */
  40412. upperRadiusLimit: Nullable<number>;
  40413. /**
  40414. * Defines the current inertia value used during panning of the camera along the X axis.
  40415. */
  40416. inertialPanningX: number;
  40417. /**
  40418. * Defines the current inertia value used during panning of the camera along the Y axis.
  40419. */
  40420. inertialPanningY: number;
  40421. /**
  40422. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40423. * Basically if your fingers moves away from more than this distance you will be considered
  40424. * in pinch mode.
  40425. */
  40426. pinchToPanMaxDistance: number;
  40427. /**
  40428. * Defines the maximum distance the camera can pan.
  40429. * This could help keeping the cammera always in your scene.
  40430. */
  40431. panningDistanceLimit: Nullable<number>;
  40432. /**
  40433. * Defines the target of the camera before paning.
  40434. */
  40435. panningOriginTarget: Vector3;
  40436. /**
  40437. * Defines the value of the inertia used during panning.
  40438. * 0 would mean stop inertia and one would mean no decelleration at all.
  40439. */
  40440. panningInertia: number;
  40441. /**
  40442. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40443. */
  40444. get angularSensibilityX(): number;
  40445. set angularSensibilityX(value: number);
  40446. /**
  40447. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40448. */
  40449. get angularSensibilityY(): number;
  40450. set angularSensibilityY(value: number);
  40451. /**
  40452. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40453. */
  40454. get pinchPrecision(): number;
  40455. set pinchPrecision(value: number);
  40456. /**
  40457. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40458. * It will be used instead of pinchDeltaPrecision if different from 0.
  40459. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40460. */
  40461. get pinchDeltaPercentage(): number;
  40462. set pinchDeltaPercentage(value: number);
  40463. /**
  40464. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40465. * and pinch delta percentage.
  40466. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40467. * that any object in the plane at the camera's target point will scale
  40468. * perfectly with finger motion.
  40469. */
  40470. get useNaturalPinchZoom(): boolean;
  40471. set useNaturalPinchZoom(value: boolean);
  40472. /**
  40473. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40474. */
  40475. get panningSensibility(): number;
  40476. set panningSensibility(value: number);
  40477. /**
  40478. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40479. */
  40480. get keysUp(): number[];
  40481. set keysUp(value: number[]);
  40482. /**
  40483. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40484. */
  40485. get keysDown(): number[];
  40486. set keysDown(value: number[]);
  40487. /**
  40488. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40489. */
  40490. get keysLeft(): number[];
  40491. set keysLeft(value: number[]);
  40492. /**
  40493. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40494. */
  40495. get keysRight(): number[];
  40496. set keysRight(value: number[]);
  40497. /**
  40498. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40499. */
  40500. get wheelPrecision(): number;
  40501. set wheelPrecision(value: number);
  40502. /**
  40503. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40504. * It will be used instead of pinchDeltaPrecision if different from 0.
  40505. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40506. */
  40507. get wheelDeltaPercentage(): number;
  40508. set wheelDeltaPercentage(value: number);
  40509. /**
  40510. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40511. */
  40512. zoomOnFactor: number;
  40513. /**
  40514. * Defines a screen offset for the camera position.
  40515. */
  40516. targetScreenOffset: Vector2;
  40517. /**
  40518. * Allows the camera to be completely reversed.
  40519. * If false the camera can not arrive upside down.
  40520. */
  40521. allowUpsideDown: boolean;
  40522. /**
  40523. * Define if double tap/click is used to restore the previously saved state of the camera.
  40524. */
  40525. useInputToRestoreState: boolean;
  40526. /** @hidden */
  40527. _viewMatrix: Matrix;
  40528. /** @hidden */
  40529. _useCtrlForPanning: boolean;
  40530. /** @hidden */
  40531. _panningMouseButton: number;
  40532. /**
  40533. * Defines the input associated to the camera.
  40534. */
  40535. inputs: ArcRotateCameraInputsManager;
  40536. /** @hidden */
  40537. _reset: () => void;
  40538. /**
  40539. * Defines the allowed panning axis.
  40540. */
  40541. panningAxis: Vector3;
  40542. protected _localDirection: Vector3;
  40543. protected _transformedDirection: Vector3;
  40544. private _bouncingBehavior;
  40545. /**
  40546. * Gets the bouncing behavior of the camera if it has been enabled.
  40547. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40548. */
  40549. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40550. /**
  40551. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40552. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40553. */
  40554. get useBouncingBehavior(): boolean;
  40555. set useBouncingBehavior(value: boolean);
  40556. private _framingBehavior;
  40557. /**
  40558. * Gets the framing behavior of the camera if it has been enabled.
  40559. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40560. */
  40561. get framingBehavior(): Nullable<FramingBehavior>;
  40562. /**
  40563. * Defines if the framing behavior of the camera is enabled on the camera.
  40564. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40565. */
  40566. get useFramingBehavior(): boolean;
  40567. set useFramingBehavior(value: boolean);
  40568. private _autoRotationBehavior;
  40569. /**
  40570. * Gets the auto rotation behavior of the camera if it has been enabled.
  40571. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40572. */
  40573. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40574. /**
  40575. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40576. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40577. */
  40578. get useAutoRotationBehavior(): boolean;
  40579. set useAutoRotationBehavior(value: boolean);
  40580. /**
  40581. * Observable triggered when the mesh target has been changed on the camera.
  40582. */
  40583. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40584. /**
  40585. * Event raised when the camera is colliding with a mesh.
  40586. */
  40587. onCollide: (collidedMesh: AbstractMesh) => void;
  40588. /**
  40589. * Defines whether the camera should check collision with the objects oh the scene.
  40590. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40591. */
  40592. checkCollisions: boolean;
  40593. /**
  40594. * Defines the collision radius of the camera.
  40595. * This simulates a sphere around the camera.
  40596. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40597. */
  40598. collisionRadius: Vector3;
  40599. protected _collider: Collider;
  40600. protected _previousPosition: Vector3;
  40601. protected _collisionVelocity: Vector3;
  40602. protected _newPosition: Vector3;
  40603. protected _previousAlpha: number;
  40604. protected _previousBeta: number;
  40605. protected _previousRadius: number;
  40606. protected _collisionTriggered: boolean;
  40607. protected _targetBoundingCenter: Nullable<Vector3>;
  40608. private _computationVector;
  40609. /**
  40610. * Instantiates a new ArcRotateCamera in a given scene
  40611. * @param name Defines the name of the camera
  40612. * @param alpha Defines the camera rotation along the logitudinal axis
  40613. * @param beta Defines the camera rotation along the latitudinal axis
  40614. * @param radius Defines the camera distance from its target
  40615. * @param target Defines the camera target
  40616. * @param scene Defines the scene the camera belongs to
  40617. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40618. */
  40619. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40620. /** @hidden */
  40621. _initCache(): void;
  40622. /** @hidden */
  40623. _updateCache(ignoreParentClass?: boolean): void;
  40624. protected _getTargetPosition(): Vector3;
  40625. private _storedAlpha;
  40626. private _storedBeta;
  40627. private _storedRadius;
  40628. private _storedTarget;
  40629. private _storedTargetScreenOffset;
  40630. /**
  40631. * Stores the current state of the camera (alpha, beta, radius and target)
  40632. * @returns the camera itself
  40633. */
  40634. storeState(): Camera;
  40635. /**
  40636. * @hidden
  40637. * Restored camera state. You must call storeState() first
  40638. */
  40639. _restoreStateValues(): boolean;
  40640. /** @hidden */
  40641. _isSynchronizedViewMatrix(): boolean;
  40642. /**
  40643. * Attached controls to the current camera.
  40644. * @param element Defines the element the controls should be listened from
  40645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40646. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40647. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40648. */
  40649. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40650. /**
  40651. * Detach the current controls from the camera.
  40652. * The camera will stop reacting to inputs.
  40653. * @param element Defines the element to stop listening the inputs from
  40654. */
  40655. detachControl(element: HTMLElement): void;
  40656. /** @hidden */
  40657. _checkInputs(): void;
  40658. protected _checkLimits(): void;
  40659. /**
  40660. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40661. */
  40662. rebuildAnglesAndRadius(): void;
  40663. /**
  40664. * Use a position to define the current camera related information like alpha, beta and radius
  40665. * @param position Defines the position to set the camera at
  40666. */
  40667. setPosition(position: Vector3): void;
  40668. /**
  40669. * Defines the target the camera should look at.
  40670. * This will automatically adapt alpha beta and radius to fit within the new target.
  40671. * @param target Defines the new target as a Vector or a mesh
  40672. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40673. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40674. */
  40675. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40676. /** @hidden */
  40677. _getViewMatrix(): Matrix;
  40678. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40679. /**
  40680. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40681. * @param meshes Defines the mesh to zoom on
  40682. * @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)
  40683. */
  40684. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40685. /**
  40686. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40687. * The target will be changed but the radius
  40688. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40689. * @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)
  40690. */
  40691. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40692. min: Vector3;
  40693. max: Vector3;
  40694. distance: number;
  40695. }, doNotUpdateMaxZ?: boolean): void;
  40696. /**
  40697. * @override
  40698. * Override Camera.createRigCamera
  40699. */
  40700. createRigCamera(name: string, cameraIndex: number): Camera;
  40701. /**
  40702. * @hidden
  40703. * @override
  40704. * Override Camera._updateRigCameras
  40705. */
  40706. _updateRigCameras(): void;
  40707. /**
  40708. * Destroy the camera and release the current resources hold by it.
  40709. */
  40710. dispose(): void;
  40711. /**
  40712. * Gets the current object class name.
  40713. * @return the class name
  40714. */
  40715. getClassName(): string;
  40716. }
  40717. }
  40718. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40719. import { Behavior } from "babylonjs/Behaviors/behavior";
  40720. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40721. /**
  40722. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40723. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40724. */
  40725. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40726. /**
  40727. * Gets the name of the behavior.
  40728. */
  40729. get name(): string;
  40730. private _zoomStopsAnimation;
  40731. private _idleRotationSpeed;
  40732. private _idleRotationWaitTime;
  40733. private _idleRotationSpinupTime;
  40734. /**
  40735. * Sets the flag that indicates if user zooming should stop animation.
  40736. */
  40737. set zoomStopsAnimation(flag: boolean);
  40738. /**
  40739. * Gets the flag that indicates if user zooming should stop animation.
  40740. */
  40741. get zoomStopsAnimation(): boolean;
  40742. /**
  40743. * Sets the default speed at which the camera rotates around the model.
  40744. */
  40745. set idleRotationSpeed(speed: number);
  40746. /**
  40747. * Gets the default speed at which the camera rotates around the model.
  40748. */
  40749. get idleRotationSpeed(): number;
  40750. /**
  40751. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40752. */
  40753. set idleRotationWaitTime(time: number);
  40754. /**
  40755. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40756. */
  40757. get idleRotationWaitTime(): number;
  40758. /**
  40759. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40760. */
  40761. set idleRotationSpinupTime(time: number);
  40762. /**
  40763. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40764. */
  40765. get idleRotationSpinupTime(): number;
  40766. /**
  40767. * Gets a value indicating if the camera is currently rotating because of this behavior
  40768. */
  40769. get rotationInProgress(): boolean;
  40770. private _onPrePointerObservableObserver;
  40771. private _onAfterCheckInputsObserver;
  40772. private _attachedCamera;
  40773. private _isPointerDown;
  40774. private _lastFrameTime;
  40775. private _lastInteractionTime;
  40776. private _cameraRotationSpeed;
  40777. /**
  40778. * Initializes the behavior.
  40779. */
  40780. init(): void;
  40781. /**
  40782. * Attaches the behavior to its arc rotate camera.
  40783. * @param camera Defines the camera to attach the behavior to
  40784. */
  40785. attach(camera: ArcRotateCamera): void;
  40786. /**
  40787. * Detaches the behavior from its current arc rotate camera.
  40788. */
  40789. detach(): void;
  40790. /**
  40791. * Returns true if user is scrolling.
  40792. * @return true if user is scrolling.
  40793. */
  40794. private _userIsZooming;
  40795. private _lastFrameRadius;
  40796. private _shouldAnimationStopForInteraction;
  40797. /**
  40798. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40799. */
  40800. private _applyUserInteraction;
  40801. private _userIsMoving;
  40802. }
  40803. }
  40804. declare module "babylonjs/Behaviors/Cameras/index" {
  40805. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40806. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40807. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40808. }
  40809. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40810. import { Mesh } from "babylonjs/Meshes/mesh";
  40811. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40812. import { Behavior } from "babylonjs/Behaviors/behavior";
  40813. /**
  40814. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40815. */
  40816. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40817. private ui;
  40818. /**
  40819. * The name of the behavior
  40820. */
  40821. name: string;
  40822. /**
  40823. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40824. */
  40825. distanceAwayFromFace: number;
  40826. /**
  40827. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40828. */
  40829. distanceAwayFromBottomOfFace: number;
  40830. private _faceVectors;
  40831. private _target;
  40832. private _scene;
  40833. private _onRenderObserver;
  40834. private _tmpMatrix;
  40835. private _tmpVector;
  40836. /**
  40837. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40838. * @param ui The transform node that should be attched to the mesh
  40839. */
  40840. constructor(ui: TransformNode);
  40841. /**
  40842. * Initializes the behavior
  40843. */
  40844. init(): void;
  40845. private _closestFace;
  40846. private _zeroVector;
  40847. private _lookAtTmpMatrix;
  40848. private _lookAtToRef;
  40849. /**
  40850. * Attaches the AttachToBoxBehavior to the passed in mesh
  40851. * @param target The mesh that the specified node will be attached to
  40852. */
  40853. attach(target: Mesh): void;
  40854. /**
  40855. * Detaches the behavior from the mesh
  40856. */
  40857. detach(): void;
  40858. }
  40859. }
  40860. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40861. import { Behavior } from "babylonjs/Behaviors/behavior";
  40862. import { Mesh } from "babylonjs/Meshes/mesh";
  40863. /**
  40864. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40865. */
  40866. export class FadeInOutBehavior implements Behavior<Mesh> {
  40867. /**
  40868. * Time in milliseconds to delay before fading in (Default: 0)
  40869. */
  40870. delay: number;
  40871. /**
  40872. * Time in milliseconds for the mesh to fade in (Default: 300)
  40873. */
  40874. fadeInTime: number;
  40875. private _millisecondsPerFrame;
  40876. private _hovered;
  40877. private _hoverValue;
  40878. private _ownerNode;
  40879. /**
  40880. * Instatiates the FadeInOutBehavior
  40881. */
  40882. constructor();
  40883. /**
  40884. * The name of the behavior
  40885. */
  40886. get name(): string;
  40887. /**
  40888. * Initializes the behavior
  40889. */
  40890. init(): void;
  40891. /**
  40892. * Attaches the fade behavior on the passed in mesh
  40893. * @param ownerNode The mesh that will be faded in/out once attached
  40894. */
  40895. attach(ownerNode: Mesh): void;
  40896. /**
  40897. * Detaches the behavior from the mesh
  40898. */
  40899. detach(): void;
  40900. /**
  40901. * Triggers the mesh to begin fading in or out
  40902. * @param value if the object should fade in or out (true to fade in)
  40903. */
  40904. fadeIn(value: boolean): void;
  40905. private _update;
  40906. private _setAllVisibility;
  40907. }
  40908. }
  40909. declare module "babylonjs/Misc/pivotTools" {
  40910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40911. /**
  40912. * Class containing a set of static utilities functions for managing Pivots
  40913. * @hidden
  40914. */
  40915. export class PivotTools {
  40916. private static _PivotCached;
  40917. private static _OldPivotPoint;
  40918. private static _PivotTranslation;
  40919. private static _PivotTmpVector;
  40920. /** @hidden */
  40921. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40922. /** @hidden */
  40923. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40924. }
  40925. }
  40926. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40927. import { Scene } from "babylonjs/scene";
  40928. import { Vector4 } from "babylonjs/Maths/math.vector";
  40929. import { Mesh } from "babylonjs/Meshes/mesh";
  40930. import { Nullable } from "babylonjs/types";
  40931. import { Plane } from "babylonjs/Maths/math.plane";
  40932. /**
  40933. * Class containing static functions to help procedurally build meshes
  40934. */
  40935. export class PlaneBuilder {
  40936. /**
  40937. * Creates a plane mesh
  40938. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40939. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40940. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40944. * @param name defines the name of the mesh
  40945. * @param options defines the options used to create the mesh
  40946. * @param scene defines the hosting scene
  40947. * @returns the plane mesh
  40948. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40949. */
  40950. static CreatePlane(name: string, options: {
  40951. size?: number;
  40952. width?: number;
  40953. height?: number;
  40954. sideOrientation?: number;
  40955. frontUVs?: Vector4;
  40956. backUVs?: Vector4;
  40957. updatable?: boolean;
  40958. sourcePlane?: Plane;
  40959. }, scene?: Nullable<Scene>): Mesh;
  40960. }
  40961. }
  40962. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40963. import { Behavior } from "babylonjs/Behaviors/behavior";
  40964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40965. import { Observable } from "babylonjs/Misc/observable";
  40966. import { Vector3 } from "babylonjs/Maths/math.vector";
  40967. import { Ray } from "babylonjs/Culling/ray";
  40968. import "babylonjs/Meshes/Builders/planeBuilder";
  40969. /**
  40970. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40971. */
  40972. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40973. private static _AnyMouseID;
  40974. /**
  40975. * Abstract mesh the behavior is set on
  40976. */
  40977. attachedNode: AbstractMesh;
  40978. private _dragPlane;
  40979. private _scene;
  40980. private _pointerObserver;
  40981. private _beforeRenderObserver;
  40982. private static _planeScene;
  40983. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40984. /**
  40985. * 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)
  40986. */
  40987. maxDragAngle: number;
  40988. /**
  40989. * @hidden
  40990. */
  40991. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40992. /**
  40993. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40994. */
  40995. currentDraggingPointerID: number;
  40996. /**
  40997. * The last position where the pointer hit the drag plane in world space
  40998. */
  40999. lastDragPosition: Vector3;
  41000. /**
  41001. * If the behavior is currently in a dragging state
  41002. */
  41003. dragging: boolean;
  41004. /**
  41005. * 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)
  41006. */
  41007. dragDeltaRatio: number;
  41008. /**
  41009. * If the drag plane orientation should be updated during the dragging (Default: true)
  41010. */
  41011. updateDragPlane: boolean;
  41012. private _debugMode;
  41013. private _moving;
  41014. /**
  41015. * Fires each time the attached mesh is dragged with the pointer
  41016. * * delta between last drag position and current drag position in world space
  41017. * * dragDistance along the drag axis
  41018. * * dragPlaneNormal normal of the current drag plane used during the drag
  41019. * * dragPlanePoint in world space where the drag intersects the drag plane
  41020. */
  41021. onDragObservable: Observable<{
  41022. delta: Vector3;
  41023. dragPlanePoint: Vector3;
  41024. dragPlaneNormal: Vector3;
  41025. dragDistance: number;
  41026. pointerId: number;
  41027. }>;
  41028. /**
  41029. * Fires each time a drag begins (eg. mouse down on mesh)
  41030. */
  41031. onDragStartObservable: Observable<{
  41032. dragPlanePoint: Vector3;
  41033. pointerId: number;
  41034. }>;
  41035. /**
  41036. * Fires each time a drag ends (eg. mouse release after drag)
  41037. */
  41038. onDragEndObservable: Observable<{
  41039. dragPlanePoint: Vector3;
  41040. pointerId: number;
  41041. }>;
  41042. /**
  41043. * If the attached mesh should be moved when dragged
  41044. */
  41045. moveAttached: boolean;
  41046. /**
  41047. * If the drag behavior will react to drag events (Default: true)
  41048. */
  41049. enabled: boolean;
  41050. /**
  41051. * If pointer events should start and release the drag (Default: true)
  41052. */
  41053. startAndReleaseDragOnPointerEvents: boolean;
  41054. /**
  41055. * If camera controls should be detached during the drag
  41056. */
  41057. detachCameraControls: boolean;
  41058. /**
  41059. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41060. */
  41061. useObjectOrientationForDragging: boolean;
  41062. private _options;
  41063. /**
  41064. * Gets the options used by the behavior
  41065. */
  41066. get options(): {
  41067. dragAxis?: Vector3;
  41068. dragPlaneNormal?: Vector3;
  41069. };
  41070. /**
  41071. * Sets the options used by the behavior
  41072. */
  41073. set options(options: {
  41074. dragAxis?: Vector3;
  41075. dragPlaneNormal?: Vector3;
  41076. });
  41077. /**
  41078. * Creates a pointer drag behavior that can be attached to a mesh
  41079. * @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)
  41080. */
  41081. constructor(options?: {
  41082. dragAxis?: Vector3;
  41083. dragPlaneNormal?: Vector3;
  41084. });
  41085. /**
  41086. * Predicate to determine if it is valid to move the object to a new position when it is moved
  41087. */
  41088. validateDrag: (targetPosition: Vector3) => boolean;
  41089. /**
  41090. * The name of the behavior
  41091. */
  41092. get name(): string;
  41093. /**
  41094. * Initializes the behavior
  41095. */
  41096. init(): void;
  41097. private _tmpVector;
  41098. private _alternatePickedPoint;
  41099. private _worldDragAxis;
  41100. private _targetPosition;
  41101. private _attachedElement;
  41102. /**
  41103. * Attaches the drag behavior the passed in mesh
  41104. * @param ownerNode The mesh that will be dragged around once attached
  41105. * @param predicate Predicate to use for pick filtering
  41106. */
  41107. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  41108. /**
  41109. * Force relase the drag action by code.
  41110. */
  41111. releaseDrag(): void;
  41112. private _startDragRay;
  41113. private _lastPointerRay;
  41114. /**
  41115. * Simulates the start of a pointer drag event on the behavior
  41116. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41117. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41118. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41119. */
  41120. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41121. private _startDrag;
  41122. private _dragDelta;
  41123. private _moveDrag;
  41124. private _pickWithRayOnDragPlane;
  41125. private _pointA;
  41126. private _pointB;
  41127. private _pointC;
  41128. private _lineA;
  41129. private _lineB;
  41130. private _localAxis;
  41131. private _lookAt;
  41132. private _updateDragPlanePosition;
  41133. /**
  41134. * Detaches the behavior from the mesh
  41135. */
  41136. detach(): void;
  41137. }
  41138. }
  41139. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  41140. import { Mesh } from "babylonjs/Meshes/mesh";
  41141. import { Behavior } from "babylonjs/Behaviors/behavior";
  41142. /**
  41143. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41144. */
  41145. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41146. private _dragBehaviorA;
  41147. private _dragBehaviorB;
  41148. private _startDistance;
  41149. private _initialScale;
  41150. private _targetScale;
  41151. private _ownerNode;
  41152. private _sceneRenderObserver;
  41153. /**
  41154. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41155. */
  41156. constructor();
  41157. /**
  41158. * The name of the behavior
  41159. */
  41160. get name(): string;
  41161. /**
  41162. * Initializes the behavior
  41163. */
  41164. init(): void;
  41165. private _getCurrentDistance;
  41166. /**
  41167. * Attaches the scale behavior the passed in mesh
  41168. * @param ownerNode The mesh that will be scaled around once attached
  41169. */
  41170. attach(ownerNode: Mesh): void;
  41171. /**
  41172. * Detaches the behavior from the mesh
  41173. */
  41174. detach(): void;
  41175. }
  41176. }
  41177. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  41178. import { Behavior } from "babylonjs/Behaviors/behavior";
  41179. import { Mesh } from "babylonjs/Meshes/mesh";
  41180. import { Observable } from "babylonjs/Misc/observable";
  41181. /**
  41182. * 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
  41183. */
  41184. export class SixDofDragBehavior implements Behavior<Mesh> {
  41185. private static _virtualScene;
  41186. private _ownerNode;
  41187. private _sceneRenderObserver;
  41188. private _scene;
  41189. private _targetPosition;
  41190. private _virtualOriginMesh;
  41191. private _virtualDragMesh;
  41192. private _pointerObserver;
  41193. private _moving;
  41194. private _startingOrientation;
  41195. private _attachedElement;
  41196. /**
  41197. * 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)
  41198. */
  41199. private zDragFactor;
  41200. /**
  41201. * If the object should rotate to face the drag origin
  41202. */
  41203. rotateDraggedObject: boolean;
  41204. /**
  41205. * If the behavior is currently in a dragging state
  41206. */
  41207. dragging: boolean;
  41208. /**
  41209. * 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)
  41210. */
  41211. dragDeltaRatio: number;
  41212. /**
  41213. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41214. */
  41215. currentDraggingPointerID: number;
  41216. /**
  41217. * If camera controls should be detached during the drag
  41218. */
  41219. detachCameraControls: boolean;
  41220. /**
  41221. * Fires each time a drag starts
  41222. */
  41223. onDragStartObservable: Observable<{}>;
  41224. /**
  41225. * Fires each time a drag ends (eg. mouse release after drag)
  41226. */
  41227. onDragEndObservable: Observable<{}>;
  41228. /**
  41229. * 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
  41230. */
  41231. constructor();
  41232. /**
  41233. * The name of the behavior
  41234. */
  41235. get name(): string;
  41236. /**
  41237. * Initializes the behavior
  41238. */
  41239. init(): void;
  41240. /**
  41241. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41242. */
  41243. private get _pointerCamera();
  41244. /**
  41245. * Attaches the scale behavior the passed in mesh
  41246. * @param ownerNode The mesh that will be scaled around once attached
  41247. */
  41248. attach(ownerNode: Mesh): void;
  41249. /**
  41250. * Detaches the behavior from the mesh
  41251. */
  41252. detach(): void;
  41253. }
  41254. }
  41255. declare module "babylonjs/Behaviors/Meshes/index" {
  41256. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41257. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41258. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41259. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41260. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41261. }
  41262. declare module "babylonjs/Behaviors/index" {
  41263. export * from "babylonjs/Behaviors/behavior";
  41264. export * from "babylonjs/Behaviors/Cameras/index";
  41265. export * from "babylonjs/Behaviors/Meshes/index";
  41266. }
  41267. declare module "babylonjs/Bones/boneIKController" {
  41268. import { Bone } from "babylonjs/Bones/bone";
  41269. import { Vector3 } from "babylonjs/Maths/math.vector";
  41270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41271. import { Nullable } from "babylonjs/types";
  41272. /**
  41273. * Class used to apply inverse kinematics to bones
  41274. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41275. */
  41276. export class BoneIKController {
  41277. private static _tmpVecs;
  41278. private static _tmpQuat;
  41279. private static _tmpMats;
  41280. /**
  41281. * Gets or sets the target mesh
  41282. */
  41283. targetMesh: AbstractMesh;
  41284. /** Gets or sets the mesh used as pole */
  41285. poleTargetMesh: AbstractMesh;
  41286. /**
  41287. * Gets or sets the bone used as pole
  41288. */
  41289. poleTargetBone: Nullable<Bone>;
  41290. /**
  41291. * Gets or sets the target position
  41292. */
  41293. targetPosition: Vector3;
  41294. /**
  41295. * Gets or sets the pole target position
  41296. */
  41297. poleTargetPosition: Vector3;
  41298. /**
  41299. * Gets or sets the pole target local offset
  41300. */
  41301. poleTargetLocalOffset: Vector3;
  41302. /**
  41303. * Gets or sets the pole angle
  41304. */
  41305. poleAngle: number;
  41306. /**
  41307. * Gets or sets the mesh associated with the controller
  41308. */
  41309. mesh: AbstractMesh;
  41310. /**
  41311. * 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)
  41312. */
  41313. slerpAmount: number;
  41314. private _bone1Quat;
  41315. private _bone1Mat;
  41316. private _bone2Ang;
  41317. private _bone1;
  41318. private _bone2;
  41319. private _bone1Length;
  41320. private _bone2Length;
  41321. private _maxAngle;
  41322. private _maxReach;
  41323. private _rightHandedSystem;
  41324. private _bendAxis;
  41325. private _slerping;
  41326. private _adjustRoll;
  41327. /**
  41328. * Gets or sets maximum allowed angle
  41329. */
  41330. get maxAngle(): number;
  41331. set maxAngle(value: number);
  41332. /**
  41333. * Creates a new BoneIKController
  41334. * @param mesh defines the mesh to control
  41335. * @param bone defines the bone to control
  41336. * @param options defines options to set up the controller
  41337. */
  41338. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41339. targetMesh?: AbstractMesh;
  41340. poleTargetMesh?: AbstractMesh;
  41341. poleTargetBone?: Bone;
  41342. poleTargetLocalOffset?: Vector3;
  41343. poleAngle?: number;
  41344. bendAxis?: Vector3;
  41345. maxAngle?: number;
  41346. slerpAmount?: number;
  41347. });
  41348. private _setMaxAngle;
  41349. /**
  41350. * Force the controller to update the bones
  41351. */
  41352. update(): void;
  41353. }
  41354. }
  41355. declare module "babylonjs/Bones/boneLookController" {
  41356. import { Vector3 } from "babylonjs/Maths/math.vector";
  41357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41358. import { Bone } from "babylonjs/Bones/bone";
  41359. import { Space } from "babylonjs/Maths/math.axis";
  41360. /**
  41361. * Class used to make a bone look toward a point in space
  41362. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41363. */
  41364. export class BoneLookController {
  41365. private static _tmpVecs;
  41366. private static _tmpQuat;
  41367. private static _tmpMats;
  41368. /**
  41369. * The target Vector3 that the bone will look at
  41370. */
  41371. target: Vector3;
  41372. /**
  41373. * The mesh that the bone is attached to
  41374. */
  41375. mesh: AbstractMesh;
  41376. /**
  41377. * The bone that will be looking to the target
  41378. */
  41379. bone: Bone;
  41380. /**
  41381. * The up axis of the coordinate system that is used when the bone is rotated
  41382. */
  41383. upAxis: Vector3;
  41384. /**
  41385. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41386. */
  41387. upAxisSpace: Space;
  41388. /**
  41389. * Used to make an adjustment to the yaw of the bone
  41390. */
  41391. adjustYaw: number;
  41392. /**
  41393. * Used to make an adjustment to the pitch of the bone
  41394. */
  41395. adjustPitch: number;
  41396. /**
  41397. * Used to make an adjustment to the roll of the bone
  41398. */
  41399. adjustRoll: number;
  41400. /**
  41401. * 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)
  41402. */
  41403. slerpAmount: number;
  41404. private _minYaw;
  41405. private _maxYaw;
  41406. private _minPitch;
  41407. private _maxPitch;
  41408. private _minYawSin;
  41409. private _minYawCos;
  41410. private _maxYawSin;
  41411. private _maxYawCos;
  41412. private _midYawConstraint;
  41413. private _minPitchTan;
  41414. private _maxPitchTan;
  41415. private _boneQuat;
  41416. private _slerping;
  41417. private _transformYawPitch;
  41418. private _transformYawPitchInv;
  41419. private _firstFrameSkipped;
  41420. private _yawRange;
  41421. private _fowardAxis;
  41422. /**
  41423. * Gets or sets the minimum yaw angle that the bone can look to
  41424. */
  41425. get minYaw(): number;
  41426. set minYaw(value: number);
  41427. /**
  41428. * Gets or sets the maximum yaw angle that the bone can look to
  41429. */
  41430. get maxYaw(): number;
  41431. set maxYaw(value: number);
  41432. /**
  41433. * Gets or sets the minimum pitch angle that the bone can look to
  41434. */
  41435. get minPitch(): number;
  41436. set minPitch(value: number);
  41437. /**
  41438. * Gets or sets the maximum pitch angle that the bone can look to
  41439. */
  41440. get maxPitch(): number;
  41441. set maxPitch(value: number);
  41442. /**
  41443. * Create a BoneLookController
  41444. * @param mesh the mesh that the bone belongs to
  41445. * @param bone the bone that will be looking to the target
  41446. * @param target the target Vector3 to look at
  41447. * @param options optional settings:
  41448. * * maxYaw: the maximum angle the bone will yaw to
  41449. * * minYaw: the minimum angle the bone will yaw to
  41450. * * maxPitch: the maximum angle the bone will pitch to
  41451. * * minPitch: the minimum angle the bone will yaw to
  41452. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41453. * * upAxis: the up axis of the coordinate system
  41454. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41455. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41456. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41457. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41458. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41459. * * adjustRoll: used to make an adjustment to the roll of the bone
  41460. **/
  41461. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41462. maxYaw?: number;
  41463. minYaw?: number;
  41464. maxPitch?: number;
  41465. minPitch?: number;
  41466. slerpAmount?: number;
  41467. upAxis?: Vector3;
  41468. upAxisSpace?: Space;
  41469. yawAxis?: Vector3;
  41470. pitchAxis?: Vector3;
  41471. adjustYaw?: number;
  41472. adjustPitch?: number;
  41473. adjustRoll?: number;
  41474. });
  41475. /**
  41476. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41477. */
  41478. update(): void;
  41479. private _getAngleDiff;
  41480. private _getAngleBetween;
  41481. private _isAngleBetween;
  41482. }
  41483. }
  41484. declare module "babylonjs/Bones/index" {
  41485. export * from "babylonjs/Bones/bone";
  41486. export * from "babylonjs/Bones/boneIKController";
  41487. export * from "babylonjs/Bones/boneLookController";
  41488. export * from "babylonjs/Bones/skeleton";
  41489. }
  41490. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41491. import { Nullable } from "babylonjs/types";
  41492. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41493. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41494. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41495. /**
  41496. * Manage the gamepad inputs to control an arc rotate camera.
  41497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41498. */
  41499. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41500. /**
  41501. * Defines the camera the input is attached to.
  41502. */
  41503. camera: ArcRotateCamera;
  41504. /**
  41505. * Defines the gamepad the input is gathering event from.
  41506. */
  41507. gamepad: Nullable<Gamepad>;
  41508. /**
  41509. * Defines the gamepad rotation sensiblity.
  41510. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41511. */
  41512. gamepadRotationSensibility: number;
  41513. /**
  41514. * Defines the gamepad move sensiblity.
  41515. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41516. */
  41517. gamepadMoveSensibility: number;
  41518. private _yAxisScale;
  41519. /**
  41520. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41521. */
  41522. get invertYAxis(): boolean;
  41523. set invertYAxis(value: boolean);
  41524. private _onGamepadConnectedObserver;
  41525. private _onGamepadDisconnectedObserver;
  41526. /**
  41527. * Attach the input controls to a specific dom element to get the input from.
  41528. * @param element Defines the element the controls should be listened from
  41529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41530. */
  41531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41532. /**
  41533. * Detach the current controls from the specified dom element.
  41534. * @param element Defines the element to stop listening the inputs from
  41535. */
  41536. detachControl(element: Nullable<HTMLElement>): void;
  41537. /**
  41538. * Update the current camera state depending on the inputs that have been used this frame.
  41539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41540. */
  41541. checkInputs(): void;
  41542. /**
  41543. * Gets the class name of the current intput.
  41544. * @returns the class name
  41545. */
  41546. getClassName(): string;
  41547. /**
  41548. * Get the friendly name associated with the input class.
  41549. * @returns the input friendly name
  41550. */
  41551. getSimpleName(): string;
  41552. }
  41553. }
  41554. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41555. import { Nullable } from "babylonjs/types";
  41556. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41557. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41558. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41559. interface ArcRotateCameraInputsManager {
  41560. /**
  41561. * Add orientation input support to the input manager.
  41562. * @returns the current input manager
  41563. */
  41564. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41565. }
  41566. }
  41567. /**
  41568. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41569. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41570. */
  41571. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41572. /**
  41573. * Defines the camera the input is attached to.
  41574. */
  41575. camera: ArcRotateCamera;
  41576. /**
  41577. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41578. */
  41579. alphaCorrection: number;
  41580. /**
  41581. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41582. */
  41583. gammaCorrection: number;
  41584. private _alpha;
  41585. private _gamma;
  41586. private _dirty;
  41587. private _deviceOrientationHandler;
  41588. /**
  41589. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41590. */
  41591. constructor();
  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. /** @hidden */
  41599. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41600. /**
  41601. * Update the current camera state depending on the inputs that have been used this frame.
  41602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41603. */
  41604. checkInputs(): void;
  41605. /**
  41606. * Detach the current controls from the specified dom element.
  41607. * @param element Defines the element to stop listening the inputs from
  41608. */
  41609. detachControl(element: Nullable<HTMLElement>): void;
  41610. /**
  41611. * Gets the class name of the current intput.
  41612. * @returns the class name
  41613. */
  41614. getClassName(): string;
  41615. /**
  41616. * Get the friendly name associated with the input class.
  41617. * @returns the input friendly name
  41618. */
  41619. getSimpleName(): string;
  41620. }
  41621. }
  41622. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41623. import { Nullable } from "babylonjs/types";
  41624. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41625. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41626. /**
  41627. * Listen to mouse events to control the camera.
  41628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41629. */
  41630. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41631. /**
  41632. * Defines the camera the input is attached to.
  41633. */
  41634. camera: FlyCamera;
  41635. /**
  41636. * Defines if touch is enabled. (Default is true.)
  41637. */
  41638. touchEnabled: boolean;
  41639. /**
  41640. * Defines the buttons associated with the input to handle camera rotation.
  41641. */
  41642. buttons: number[];
  41643. /**
  41644. * Assign buttons for Yaw control.
  41645. */
  41646. buttonsYaw: number[];
  41647. /**
  41648. * Assign buttons for Pitch control.
  41649. */
  41650. buttonsPitch: number[];
  41651. /**
  41652. * Assign buttons for Roll control.
  41653. */
  41654. buttonsRoll: number[];
  41655. /**
  41656. * Detect if any button is being pressed while mouse is moved.
  41657. * -1 = Mouse locked.
  41658. * 0 = Left button.
  41659. * 1 = Middle Button.
  41660. * 2 = Right Button.
  41661. */
  41662. activeButton: number;
  41663. /**
  41664. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41665. * Higher values reduce its sensitivity.
  41666. */
  41667. angularSensibility: number;
  41668. private _mousemoveCallback;
  41669. private _observer;
  41670. private _rollObserver;
  41671. private previousPosition;
  41672. private noPreventDefault;
  41673. private element;
  41674. /**
  41675. * Listen to mouse events to control the camera.
  41676. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41678. */
  41679. constructor(touchEnabled?: boolean);
  41680. /**
  41681. * Attach the mouse control to the HTML DOM element.
  41682. * @param element Defines the element that listens to the input events.
  41683. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41684. */
  41685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41686. /**
  41687. * Detach the current controls from the specified dom element.
  41688. * @param element Defines the element to stop listening the inputs from
  41689. */
  41690. detachControl(element: Nullable<HTMLElement>): void;
  41691. /**
  41692. * Gets the class name of the current input.
  41693. * @returns the class name.
  41694. */
  41695. getClassName(): string;
  41696. /**
  41697. * Get the friendly name associated with the input class.
  41698. * @returns the input's friendly name.
  41699. */
  41700. getSimpleName(): string;
  41701. private _pointerInput;
  41702. private _onMouseMove;
  41703. /**
  41704. * Rotate camera by mouse offset.
  41705. */
  41706. private rotateCamera;
  41707. }
  41708. }
  41709. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41710. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41711. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41712. /**
  41713. * Default Inputs manager for the FlyCamera.
  41714. * It groups all the default supported inputs for ease of use.
  41715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41716. */
  41717. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41718. /**
  41719. * Instantiates a new FlyCameraInputsManager.
  41720. * @param camera Defines the camera the inputs belong to.
  41721. */
  41722. constructor(camera: FlyCamera);
  41723. /**
  41724. * Add keyboard input support to the input manager.
  41725. * @returns the new FlyCameraKeyboardMoveInput().
  41726. */
  41727. addKeyboard(): FlyCameraInputsManager;
  41728. /**
  41729. * Add mouse input support to the input manager.
  41730. * @param touchEnabled Enable touch screen support.
  41731. * @returns the new FlyCameraMouseInput().
  41732. */
  41733. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41734. }
  41735. }
  41736. declare module "babylonjs/Cameras/flyCamera" {
  41737. import { Scene } from "babylonjs/scene";
  41738. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41740. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41741. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41742. /**
  41743. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41744. * such as in a 3D Space Shooter or a Flight Simulator.
  41745. */
  41746. export class FlyCamera extends TargetCamera {
  41747. /**
  41748. * Define the collision ellipsoid of the camera.
  41749. * This is helpful for simulating a camera body, like a player's body.
  41750. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41751. */
  41752. ellipsoid: Vector3;
  41753. /**
  41754. * Define an offset for the position of the ellipsoid around the camera.
  41755. * This can be helpful if the camera is attached away from the player's body center,
  41756. * such as at its head.
  41757. */
  41758. ellipsoidOffset: Vector3;
  41759. /**
  41760. * Enable or disable collisions of the camera with the rest of the scene objects.
  41761. */
  41762. checkCollisions: boolean;
  41763. /**
  41764. * Enable or disable gravity on the camera.
  41765. */
  41766. applyGravity: boolean;
  41767. /**
  41768. * Define the current direction the camera is moving to.
  41769. */
  41770. cameraDirection: Vector3;
  41771. /**
  41772. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41773. * This overrides and empties cameraRotation.
  41774. */
  41775. rotationQuaternion: Quaternion;
  41776. /**
  41777. * Track Roll to maintain the wanted Rolling when looking around.
  41778. */
  41779. _trackRoll: number;
  41780. /**
  41781. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41782. */
  41783. rollCorrect: number;
  41784. /**
  41785. * Mimic a banked turn, Rolling the camera when Yawing.
  41786. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41787. */
  41788. bankedTurn: boolean;
  41789. /**
  41790. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41791. */
  41792. bankedTurnLimit: number;
  41793. /**
  41794. * Value of 0 disables the banked Roll.
  41795. * Value of 1 is equal to the Yaw angle in radians.
  41796. */
  41797. bankedTurnMultiplier: number;
  41798. /**
  41799. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41800. */
  41801. inputs: FlyCameraInputsManager;
  41802. /**
  41803. * Gets the input sensibility for mouse input.
  41804. * Higher values reduce sensitivity.
  41805. */
  41806. get angularSensibility(): number;
  41807. /**
  41808. * Sets the input sensibility for a mouse input.
  41809. * Higher values reduce sensitivity.
  41810. */
  41811. set angularSensibility(value: number);
  41812. /**
  41813. * Get the keys for camera movement forward.
  41814. */
  41815. get keysForward(): number[];
  41816. /**
  41817. * Set the keys for camera movement forward.
  41818. */
  41819. set keysForward(value: number[]);
  41820. /**
  41821. * Get the keys for camera movement backward.
  41822. */
  41823. get keysBackward(): number[];
  41824. set keysBackward(value: number[]);
  41825. /**
  41826. * Get the keys for camera movement up.
  41827. */
  41828. get keysUp(): number[];
  41829. /**
  41830. * Set the keys for camera movement up.
  41831. */
  41832. set keysUp(value: number[]);
  41833. /**
  41834. * Get the keys for camera movement down.
  41835. */
  41836. get keysDown(): number[];
  41837. /**
  41838. * Set the keys for camera movement down.
  41839. */
  41840. set keysDown(value: number[]);
  41841. /**
  41842. * Get the keys for camera movement left.
  41843. */
  41844. get keysLeft(): number[];
  41845. /**
  41846. * Set the keys for camera movement left.
  41847. */
  41848. set keysLeft(value: number[]);
  41849. /**
  41850. * Set the keys for camera movement right.
  41851. */
  41852. get keysRight(): number[];
  41853. /**
  41854. * Set the keys for camera movement right.
  41855. */
  41856. set keysRight(value: number[]);
  41857. /**
  41858. * Event raised when the camera collides with a mesh in the scene.
  41859. */
  41860. onCollide: (collidedMesh: AbstractMesh) => void;
  41861. private _collider;
  41862. private _needMoveForGravity;
  41863. private _oldPosition;
  41864. private _diffPosition;
  41865. private _newPosition;
  41866. /** @hidden */
  41867. _localDirection: Vector3;
  41868. /** @hidden */
  41869. _transformedDirection: Vector3;
  41870. /**
  41871. * Instantiates a FlyCamera.
  41872. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41873. * such as in a 3D Space Shooter or a Flight Simulator.
  41874. * @param name Define the name of the camera in the scene.
  41875. * @param position Define the starting position of the camera in the scene.
  41876. * @param scene Define the scene the camera belongs to.
  41877. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41878. */
  41879. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41880. /**
  41881. * Attach a control to the HTML DOM element.
  41882. * @param element Defines the element that listens to the input events.
  41883. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41884. */
  41885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41886. /**
  41887. * Detach a control from the HTML DOM element.
  41888. * The camera will stop reacting to that input.
  41889. * @param element Defines the element that listens to the input events.
  41890. */
  41891. detachControl(element: HTMLElement): void;
  41892. private _collisionMask;
  41893. /**
  41894. * Get the mask that the camera ignores in collision events.
  41895. */
  41896. get collisionMask(): number;
  41897. /**
  41898. * Set the mask that the camera ignores in collision events.
  41899. */
  41900. set collisionMask(mask: number);
  41901. /** @hidden */
  41902. _collideWithWorld(displacement: Vector3): void;
  41903. /** @hidden */
  41904. private _onCollisionPositionChange;
  41905. /** @hidden */
  41906. _checkInputs(): void;
  41907. /** @hidden */
  41908. _decideIfNeedsToMove(): boolean;
  41909. /** @hidden */
  41910. _updatePosition(): void;
  41911. /**
  41912. * Restore the Roll to its target value at the rate specified.
  41913. * @param rate - Higher means slower restoring.
  41914. * @hidden
  41915. */
  41916. restoreRoll(rate: number): void;
  41917. /**
  41918. * Destroy the camera and release the current resources held by it.
  41919. */
  41920. dispose(): void;
  41921. /**
  41922. * Get the current object class name.
  41923. * @returns the class name.
  41924. */
  41925. getClassName(): string;
  41926. }
  41927. }
  41928. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41929. import { Nullable } from "babylonjs/types";
  41930. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41931. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41932. /**
  41933. * Listen to keyboard events to control the camera.
  41934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41935. */
  41936. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41937. /**
  41938. * Defines the camera the input is attached to.
  41939. */
  41940. camera: FlyCamera;
  41941. /**
  41942. * The list of keyboard keys used to control the forward move of the camera.
  41943. */
  41944. keysForward: number[];
  41945. /**
  41946. * The list of keyboard keys used to control the backward move of the camera.
  41947. */
  41948. keysBackward: number[];
  41949. /**
  41950. * The list of keyboard keys used to control the forward move of the camera.
  41951. */
  41952. keysUp: number[];
  41953. /**
  41954. * The list of keyboard keys used to control the backward move of the camera.
  41955. */
  41956. keysDown: number[];
  41957. /**
  41958. * The list of keyboard keys used to control the right strafe move of the camera.
  41959. */
  41960. keysRight: number[];
  41961. /**
  41962. * The list of keyboard keys used to control the left strafe move of the camera.
  41963. */
  41964. keysLeft: number[];
  41965. private _keys;
  41966. private _onCanvasBlurObserver;
  41967. private _onKeyboardObserver;
  41968. private _engine;
  41969. private _scene;
  41970. /**
  41971. * Attach the input controls to a specific dom element to get the input from.
  41972. * @param element Defines the element the controls should be listened from
  41973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41974. */
  41975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41976. /**
  41977. * Detach the current controls from the specified dom element.
  41978. * @param element Defines the element to stop listening the inputs from
  41979. */
  41980. detachControl(element: Nullable<HTMLElement>): void;
  41981. /**
  41982. * Gets the class name of the current intput.
  41983. * @returns the class name
  41984. */
  41985. getClassName(): string;
  41986. /** @hidden */
  41987. _onLostFocus(e: FocusEvent): void;
  41988. /**
  41989. * Get the friendly name associated with the input class.
  41990. * @returns the input friendly name
  41991. */
  41992. getSimpleName(): string;
  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. }
  42000. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  42001. import { Nullable } from "babylonjs/types";
  42002. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42003. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42004. /**
  42005. * Manage the mouse wheel inputs to control a follow camera.
  42006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42007. */
  42008. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  42009. /**
  42010. * Defines the camera the input is attached to.
  42011. */
  42012. camera: FollowCamera;
  42013. /**
  42014. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  42015. */
  42016. axisControlRadius: boolean;
  42017. /**
  42018. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  42019. */
  42020. axisControlHeight: boolean;
  42021. /**
  42022. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  42023. */
  42024. axisControlRotation: boolean;
  42025. /**
  42026. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  42027. * relation to mouseWheel events.
  42028. */
  42029. wheelPrecision: number;
  42030. /**
  42031. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42032. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42033. */
  42034. wheelDeltaPercentage: number;
  42035. private _wheel;
  42036. private _observer;
  42037. /**
  42038. * Attach the input controls to a specific dom element to get the input from.
  42039. * @param element Defines the element the controls should be listened from
  42040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42041. */
  42042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42043. /**
  42044. * Detach the current controls from the specified dom element.
  42045. * @param element Defines the element to stop listening the inputs from
  42046. */
  42047. detachControl(element: Nullable<HTMLElement>): void;
  42048. /**
  42049. * Gets the class name of the current intput.
  42050. * @returns the class name
  42051. */
  42052. getClassName(): string;
  42053. /**
  42054. * Get the friendly name associated with the input class.
  42055. * @returns the input friendly name
  42056. */
  42057. getSimpleName(): string;
  42058. }
  42059. }
  42060. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  42061. import { Nullable } from "babylonjs/types";
  42062. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42063. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42064. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42065. /**
  42066. * Manage the pointers inputs to control an follow camera.
  42067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42068. */
  42069. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  42070. /**
  42071. * Defines the camera the input is attached to.
  42072. */
  42073. camera: FollowCamera;
  42074. /**
  42075. * Gets the class name of the current input.
  42076. * @returns the class name
  42077. */
  42078. getClassName(): string;
  42079. /**
  42080. * Defines the pointer angular sensibility along the X axis or how fast is
  42081. * the camera rotating.
  42082. * A negative number will reverse the axis direction.
  42083. */
  42084. angularSensibilityX: number;
  42085. /**
  42086. * Defines the pointer angular sensibility along the Y axis or how fast is
  42087. * the camera rotating.
  42088. * A negative number will reverse the axis direction.
  42089. */
  42090. angularSensibilityY: number;
  42091. /**
  42092. * Defines the pointer pinch precision or how fast is the camera zooming.
  42093. * A negative number will reverse the axis direction.
  42094. */
  42095. pinchPrecision: number;
  42096. /**
  42097. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42098. * from 0.
  42099. * It defines the percentage of current camera.radius to use as delta when
  42100. * pinch zoom is used.
  42101. */
  42102. pinchDeltaPercentage: number;
  42103. /**
  42104. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  42105. */
  42106. axisXControlRadius: boolean;
  42107. /**
  42108. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  42109. */
  42110. axisXControlHeight: boolean;
  42111. /**
  42112. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  42113. */
  42114. axisXControlRotation: boolean;
  42115. /**
  42116. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  42117. */
  42118. axisYControlRadius: boolean;
  42119. /**
  42120. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  42121. */
  42122. axisYControlHeight: boolean;
  42123. /**
  42124. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  42125. */
  42126. axisYControlRotation: boolean;
  42127. /**
  42128. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  42129. */
  42130. axisPinchControlRadius: boolean;
  42131. /**
  42132. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  42133. */
  42134. axisPinchControlHeight: boolean;
  42135. /**
  42136. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  42137. */
  42138. axisPinchControlRotation: boolean;
  42139. /**
  42140. * Log error messages if basic misconfiguration has occurred.
  42141. */
  42142. warningEnable: boolean;
  42143. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42144. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42145. private _warningCounter;
  42146. private _warning;
  42147. }
  42148. }
  42149. declare module "babylonjs/Cameras/followCameraInputsManager" {
  42150. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  42151. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42152. /**
  42153. * Default Inputs manager for the FollowCamera.
  42154. * It groups all the default supported inputs for ease of use.
  42155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42156. */
  42157. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  42158. /**
  42159. * Instantiates a new FollowCameraInputsManager.
  42160. * @param camera Defines the camera the inputs belong to
  42161. */
  42162. constructor(camera: FollowCamera);
  42163. /**
  42164. * Add keyboard input support to the input manager.
  42165. * @returns the current input manager
  42166. */
  42167. addKeyboard(): FollowCameraInputsManager;
  42168. /**
  42169. * Add mouse wheel input support to the input manager.
  42170. * @returns the current input manager
  42171. */
  42172. addMouseWheel(): FollowCameraInputsManager;
  42173. /**
  42174. * Add pointers input support to the input manager.
  42175. * @returns the current input manager
  42176. */
  42177. addPointers(): FollowCameraInputsManager;
  42178. /**
  42179. * Add orientation input support to the input manager.
  42180. * @returns the current input manager
  42181. */
  42182. addVRDeviceOrientation(): FollowCameraInputsManager;
  42183. }
  42184. }
  42185. declare module "babylonjs/Cameras/followCamera" {
  42186. import { Nullable } from "babylonjs/types";
  42187. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  42188. import { Scene } from "babylonjs/scene";
  42189. import { Vector3 } from "babylonjs/Maths/math.vector";
  42190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42191. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  42192. /**
  42193. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  42194. * an arc rotate version arcFollowCamera are available.
  42195. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42196. */
  42197. export class FollowCamera extends TargetCamera {
  42198. /**
  42199. * Distance the follow camera should follow an object at
  42200. */
  42201. radius: number;
  42202. /**
  42203. * Minimum allowed distance of the camera to the axis of rotation
  42204. * (The camera can not get closer).
  42205. * This can help limiting how the Camera is able to move in the scene.
  42206. */
  42207. lowerRadiusLimit: Nullable<number>;
  42208. /**
  42209. * Maximum allowed distance of the camera to the axis of rotation
  42210. * (The camera can not get further).
  42211. * This can help limiting how the Camera is able to move in the scene.
  42212. */
  42213. upperRadiusLimit: Nullable<number>;
  42214. /**
  42215. * Define a rotation offset between the camera and the object it follows
  42216. */
  42217. rotationOffset: number;
  42218. /**
  42219. * Minimum allowed angle to camera position relative to target object.
  42220. * This can help limiting how the Camera is able to move in the scene.
  42221. */
  42222. lowerRotationOffsetLimit: Nullable<number>;
  42223. /**
  42224. * Maximum allowed angle to camera position relative to target object.
  42225. * This can help limiting how the Camera is able to move in the scene.
  42226. */
  42227. upperRotationOffsetLimit: Nullable<number>;
  42228. /**
  42229. * Define a height offset between the camera and the object it follows.
  42230. * It can help following an object from the top (like a car chaing a plane)
  42231. */
  42232. heightOffset: number;
  42233. /**
  42234. * Minimum allowed height of camera position relative to target object.
  42235. * This can help limiting how the Camera is able to move in the scene.
  42236. */
  42237. lowerHeightOffsetLimit: Nullable<number>;
  42238. /**
  42239. * Maximum allowed height of camera position relative to target object.
  42240. * This can help limiting how the Camera is able to move in the scene.
  42241. */
  42242. upperHeightOffsetLimit: Nullable<number>;
  42243. /**
  42244. * Define how fast the camera can accelerate to follow it s target.
  42245. */
  42246. cameraAcceleration: number;
  42247. /**
  42248. * Define the speed limit of the camera following an object.
  42249. */
  42250. maxCameraSpeed: number;
  42251. /**
  42252. * Define the target of the camera.
  42253. */
  42254. lockedTarget: Nullable<AbstractMesh>;
  42255. /**
  42256. * Defines the input associated with the camera.
  42257. */
  42258. inputs: FollowCameraInputsManager;
  42259. /**
  42260. * Instantiates the follow camera.
  42261. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42262. * @param name Define the name of the camera in the scene
  42263. * @param position Define the position of the camera
  42264. * @param scene Define the scene the camera belong to
  42265. * @param lockedTarget Define the target of the camera
  42266. */
  42267. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42268. private _follow;
  42269. /**
  42270. * Attached controls to the current camera.
  42271. * @param element Defines the element the controls should be listened from
  42272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42273. */
  42274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42275. /**
  42276. * Detach the current controls from the camera.
  42277. * The camera will stop reacting to inputs.
  42278. * @param element Defines the element to stop listening the inputs from
  42279. */
  42280. detachControl(element: HTMLElement): void;
  42281. /** @hidden */
  42282. _checkInputs(): void;
  42283. private _checkLimits;
  42284. /**
  42285. * Gets the camera class name.
  42286. * @returns the class name
  42287. */
  42288. getClassName(): string;
  42289. }
  42290. /**
  42291. * Arc Rotate version of the follow camera.
  42292. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42293. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42294. */
  42295. export class ArcFollowCamera extends TargetCamera {
  42296. /** The longitudinal angle of the camera */
  42297. alpha: number;
  42298. /** The latitudinal angle of the camera */
  42299. beta: number;
  42300. /** The radius of the camera from its target */
  42301. radius: number;
  42302. /** Define the camera target (the messh it should follow) */
  42303. target: Nullable<AbstractMesh>;
  42304. private _cartesianCoordinates;
  42305. /**
  42306. * Instantiates a new ArcFollowCamera
  42307. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42308. * @param name Define the name of the camera
  42309. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42310. * @param beta Define the rotation angle of the camera around the elevation axis
  42311. * @param radius Define the radius of the camera from its target point
  42312. * @param target Define the target of the camera
  42313. * @param scene Define the scene the camera belongs to
  42314. */
  42315. constructor(name: string,
  42316. /** The longitudinal angle of the camera */
  42317. alpha: number,
  42318. /** The latitudinal angle of the camera */
  42319. beta: number,
  42320. /** The radius of the camera from its target */
  42321. radius: number,
  42322. /** Define the camera target (the messh it should follow) */
  42323. target: Nullable<AbstractMesh>, scene: Scene);
  42324. private _follow;
  42325. /** @hidden */
  42326. _checkInputs(): void;
  42327. /**
  42328. * Returns the class name of the object.
  42329. * It is mostly used internally for serialization purposes.
  42330. */
  42331. getClassName(): string;
  42332. }
  42333. }
  42334. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42335. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42336. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42337. import { Nullable } from "babylonjs/types";
  42338. /**
  42339. * Manage the keyboard inputs to control the movement of a follow camera.
  42340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42341. */
  42342. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42343. /**
  42344. * Defines the camera the input is attached to.
  42345. */
  42346. camera: FollowCamera;
  42347. /**
  42348. * Defines the list of key codes associated with the up action (increase heightOffset)
  42349. */
  42350. keysHeightOffsetIncr: number[];
  42351. /**
  42352. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42353. */
  42354. keysHeightOffsetDecr: number[];
  42355. /**
  42356. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42357. */
  42358. keysHeightOffsetModifierAlt: boolean;
  42359. /**
  42360. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42361. */
  42362. keysHeightOffsetModifierCtrl: boolean;
  42363. /**
  42364. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42365. */
  42366. keysHeightOffsetModifierShift: boolean;
  42367. /**
  42368. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42369. */
  42370. keysRotationOffsetIncr: number[];
  42371. /**
  42372. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42373. */
  42374. keysRotationOffsetDecr: number[];
  42375. /**
  42376. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42377. */
  42378. keysRotationOffsetModifierAlt: boolean;
  42379. /**
  42380. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42381. */
  42382. keysRotationOffsetModifierCtrl: boolean;
  42383. /**
  42384. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42385. */
  42386. keysRotationOffsetModifierShift: boolean;
  42387. /**
  42388. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42389. */
  42390. keysRadiusIncr: number[];
  42391. /**
  42392. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42393. */
  42394. keysRadiusDecr: number[];
  42395. /**
  42396. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42397. */
  42398. keysRadiusModifierAlt: boolean;
  42399. /**
  42400. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42401. */
  42402. keysRadiusModifierCtrl: boolean;
  42403. /**
  42404. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42405. */
  42406. keysRadiusModifierShift: boolean;
  42407. /**
  42408. * Defines the rate of change of heightOffset.
  42409. */
  42410. heightSensibility: number;
  42411. /**
  42412. * Defines the rate of change of rotationOffset.
  42413. */
  42414. rotationSensibility: number;
  42415. /**
  42416. * Defines the rate of change of radius.
  42417. */
  42418. radiusSensibility: number;
  42419. private _keys;
  42420. private _ctrlPressed;
  42421. private _altPressed;
  42422. private _shiftPressed;
  42423. private _onCanvasBlurObserver;
  42424. private _onKeyboardObserver;
  42425. private _engine;
  42426. private _scene;
  42427. /**
  42428. * Attach the input controls to a specific dom element to get the input from.
  42429. * @param element Defines the element the controls should be listened from
  42430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42431. */
  42432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42433. /**
  42434. * Detach the current controls from the specified dom element.
  42435. * @param element Defines the element to stop listening the inputs from
  42436. */
  42437. detachControl(element: Nullable<HTMLElement>): void;
  42438. /**
  42439. * Update the current camera state depending on the inputs that have been used this frame.
  42440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42441. */
  42442. checkInputs(): void;
  42443. /**
  42444. * Gets the class name of the current input.
  42445. * @returns the class name
  42446. */
  42447. getClassName(): string;
  42448. /**
  42449. * Get the friendly name associated with the input class.
  42450. * @returns the input friendly name
  42451. */
  42452. getSimpleName(): string;
  42453. /**
  42454. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42455. * allow modification of the heightOffset value.
  42456. */
  42457. private _modifierHeightOffset;
  42458. /**
  42459. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42460. * allow modification of the rotationOffset value.
  42461. */
  42462. private _modifierRotationOffset;
  42463. /**
  42464. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42465. * allow modification of the radius value.
  42466. */
  42467. private _modifierRadius;
  42468. }
  42469. }
  42470. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42471. import { Nullable } from "babylonjs/types";
  42472. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42473. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42474. import { Observable } from "babylonjs/Misc/observable";
  42475. module "babylonjs/Cameras/freeCameraInputsManager" {
  42476. interface FreeCameraInputsManager {
  42477. /**
  42478. * @hidden
  42479. */
  42480. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42481. /**
  42482. * Add orientation input support to the input manager.
  42483. * @returns the current input manager
  42484. */
  42485. addDeviceOrientation(): FreeCameraInputsManager;
  42486. }
  42487. }
  42488. /**
  42489. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42490. * Screen rotation is taken into account.
  42491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42492. */
  42493. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42494. private _camera;
  42495. private _screenOrientationAngle;
  42496. private _constantTranform;
  42497. private _screenQuaternion;
  42498. private _alpha;
  42499. private _beta;
  42500. private _gamma;
  42501. /**
  42502. * Can be used to detect if a device orientation sensor is available on a device
  42503. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42504. * @returns a promise that will resolve on orientation change
  42505. */
  42506. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42507. /**
  42508. * @hidden
  42509. */
  42510. _onDeviceOrientationChangedObservable: Observable<void>;
  42511. /**
  42512. * Instantiates a new input
  42513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42514. */
  42515. constructor();
  42516. /**
  42517. * Define the camera controlled by the input.
  42518. */
  42519. get camera(): FreeCamera;
  42520. set camera(camera: FreeCamera);
  42521. /**
  42522. * Attach the input controls to a specific dom element to get the input from.
  42523. * @param element Defines the element the controls should be listened from
  42524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42525. */
  42526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42527. private _orientationChanged;
  42528. private _deviceOrientation;
  42529. /**
  42530. * Detach the current controls from the specified dom element.
  42531. * @param element Defines the element to stop listening the inputs from
  42532. */
  42533. detachControl(element: Nullable<HTMLElement>): void;
  42534. /**
  42535. * Update the current camera state depending on the inputs that have been used this frame.
  42536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42537. */
  42538. checkInputs(): void;
  42539. /**
  42540. * Gets the class name of the current intput.
  42541. * @returns the class name
  42542. */
  42543. getClassName(): string;
  42544. /**
  42545. * Get the friendly name associated with the input class.
  42546. * @returns the input friendly name
  42547. */
  42548. getSimpleName(): string;
  42549. }
  42550. }
  42551. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42552. import { Nullable } from "babylonjs/types";
  42553. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42554. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42555. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42556. /**
  42557. * Manage the gamepad inputs to control a free camera.
  42558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42559. */
  42560. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42561. /**
  42562. * Define the camera the input is attached to.
  42563. */
  42564. camera: FreeCamera;
  42565. /**
  42566. * Define the Gamepad controlling the input
  42567. */
  42568. gamepad: Nullable<Gamepad>;
  42569. /**
  42570. * Defines the gamepad rotation sensiblity.
  42571. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42572. */
  42573. gamepadAngularSensibility: number;
  42574. /**
  42575. * Defines the gamepad move sensiblity.
  42576. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42577. */
  42578. gamepadMoveSensibility: number;
  42579. private _yAxisScale;
  42580. /**
  42581. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42582. */
  42583. get invertYAxis(): boolean;
  42584. set invertYAxis(value: boolean);
  42585. private _onGamepadConnectedObserver;
  42586. private _onGamepadDisconnectedObserver;
  42587. private _cameraTransform;
  42588. private _deltaTransform;
  42589. private _vector3;
  42590. private _vector2;
  42591. /**
  42592. * Attach the input controls to a specific dom element to get the input from.
  42593. * @param element Defines the element the controls should be listened from
  42594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42595. */
  42596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42597. /**
  42598. * Detach the current controls from the specified dom element.
  42599. * @param element Defines the element to stop listening the inputs from
  42600. */
  42601. detachControl(element: Nullable<HTMLElement>): void;
  42602. /**
  42603. * Update the current camera state depending on the inputs that have been used this frame.
  42604. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42605. */
  42606. checkInputs(): void;
  42607. /**
  42608. * Gets the class name of the current intput.
  42609. * @returns the class name
  42610. */
  42611. getClassName(): string;
  42612. /**
  42613. * Get the friendly name associated with the input class.
  42614. * @returns the input friendly name
  42615. */
  42616. getSimpleName(): string;
  42617. }
  42618. }
  42619. declare module "babylonjs/Misc/virtualJoystick" {
  42620. import { Nullable } from "babylonjs/types";
  42621. import { Vector3 } from "babylonjs/Maths/math.vector";
  42622. /**
  42623. * Defines the potential axis of a Joystick
  42624. */
  42625. export enum JoystickAxis {
  42626. /** X axis */
  42627. X = 0,
  42628. /** Y axis */
  42629. Y = 1,
  42630. /** Z axis */
  42631. Z = 2
  42632. }
  42633. /**
  42634. * Class used to define virtual joystick (used in touch mode)
  42635. */
  42636. export class VirtualJoystick {
  42637. /**
  42638. * Gets or sets a boolean indicating that left and right values must be inverted
  42639. */
  42640. reverseLeftRight: boolean;
  42641. /**
  42642. * Gets or sets a boolean indicating that up and down values must be inverted
  42643. */
  42644. reverseUpDown: boolean;
  42645. /**
  42646. * Gets the offset value for the position (ie. the change of the position value)
  42647. */
  42648. deltaPosition: Vector3;
  42649. /**
  42650. * Gets a boolean indicating if the virtual joystick was pressed
  42651. */
  42652. pressed: boolean;
  42653. /**
  42654. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42655. */
  42656. static Canvas: Nullable<HTMLCanvasElement>;
  42657. private static _globalJoystickIndex;
  42658. private static vjCanvasContext;
  42659. private static vjCanvasWidth;
  42660. private static vjCanvasHeight;
  42661. private static halfWidth;
  42662. private _action;
  42663. private _axisTargetedByLeftAndRight;
  42664. private _axisTargetedByUpAndDown;
  42665. private _joystickSensibility;
  42666. private _inversedSensibility;
  42667. private _joystickPointerID;
  42668. private _joystickColor;
  42669. private _joystickPointerPos;
  42670. private _joystickPreviousPointerPos;
  42671. private _joystickPointerStartPos;
  42672. private _deltaJoystickVector;
  42673. private _leftJoystick;
  42674. private _touches;
  42675. private _onPointerDownHandlerRef;
  42676. private _onPointerMoveHandlerRef;
  42677. private _onPointerUpHandlerRef;
  42678. private _onResize;
  42679. /**
  42680. * Creates a new virtual joystick
  42681. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42682. */
  42683. constructor(leftJoystick?: boolean);
  42684. /**
  42685. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42686. * @param newJoystickSensibility defines the new sensibility
  42687. */
  42688. setJoystickSensibility(newJoystickSensibility: number): void;
  42689. private _onPointerDown;
  42690. private _onPointerMove;
  42691. private _onPointerUp;
  42692. /**
  42693. * Change the color of the virtual joystick
  42694. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42695. */
  42696. setJoystickColor(newColor: string): void;
  42697. /**
  42698. * Defines a callback to call when the joystick is touched
  42699. * @param action defines the callback
  42700. */
  42701. setActionOnTouch(action: () => any): void;
  42702. /**
  42703. * Defines which axis you'd like to control for left & right
  42704. * @param axis defines the axis to use
  42705. */
  42706. setAxisForLeftRight(axis: JoystickAxis): void;
  42707. /**
  42708. * Defines which axis you'd like to control for up & down
  42709. * @param axis defines the axis to use
  42710. */
  42711. setAxisForUpDown(axis: JoystickAxis): void;
  42712. private _drawVirtualJoystick;
  42713. /**
  42714. * Release internal HTML canvas
  42715. */
  42716. releaseCanvas(): void;
  42717. }
  42718. }
  42719. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42720. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42721. import { Nullable } from "babylonjs/types";
  42722. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42723. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42724. module "babylonjs/Cameras/freeCameraInputsManager" {
  42725. interface FreeCameraInputsManager {
  42726. /**
  42727. * Add virtual joystick input support to the input manager.
  42728. * @returns the current input manager
  42729. */
  42730. addVirtualJoystick(): FreeCameraInputsManager;
  42731. }
  42732. }
  42733. /**
  42734. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42736. */
  42737. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42738. /**
  42739. * Defines the camera the input is attached to.
  42740. */
  42741. camera: FreeCamera;
  42742. private _leftjoystick;
  42743. private _rightjoystick;
  42744. /**
  42745. * Gets the left stick of the virtual joystick.
  42746. * @returns The virtual Joystick
  42747. */
  42748. getLeftJoystick(): VirtualJoystick;
  42749. /**
  42750. * Gets the right stick of the virtual joystick.
  42751. * @returns The virtual Joystick
  42752. */
  42753. getRightJoystick(): VirtualJoystick;
  42754. /**
  42755. * Update the current camera state depending on the inputs that have been used this frame.
  42756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42757. */
  42758. checkInputs(): void;
  42759. /**
  42760. * Attach the input controls to a specific dom element to get the input from.
  42761. * @param element Defines the element the controls should be listened from
  42762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42763. */
  42764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42765. /**
  42766. * Detach the current controls from the specified dom element.
  42767. * @param element Defines the element to stop listening the inputs from
  42768. */
  42769. detachControl(element: Nullable<HTMLElement>): void;
  42770. /**
  42771. * Gets the class name of the current intput.
  42772. * @returns the class name
  42773. */
  42774. getClassName(): string;
  42775. /**
  42776. * Get the friendly name associated with the input class.
  42777. * @returns the input friendly name
  42778. */
  42779. getSimpleName(): string;
  42780. }
  42781. }
  42782. declare module "babylonjs/Cameras/Inputs/index" {
  42783. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42784. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42785. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42786. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42787. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42788. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42789. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42790. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42791. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42792. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42793. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42794. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42795. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42796. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42797. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42798. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42799. }
  42800. declare module "babylonjs/Cameras/touchCamera" {
  42801. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42802. import { Scene } from "babylonjs/scene";
  42803. import { Vector3 } from "babylonjs/Maths/math.vector";
  42804. /**
  42805. * This represents a FPS type of camera controlled by touch.
  42806. * This is like a universal camera minus the Gamepad controls.
  42807. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42808. */
  42809. export class TouchCamera extends FreeCamera {
  42810. /**
  42811. * Defines the touch sensibility for rotation.
  42812. * The higher the faster.
  42813. */
  42814. get touchAngularSensibility(): number;
  42815. set touchAngularSensibility(value: number);
  42816. /**
  42817. * Defines the touch sensibility for move.
  42818. * The higher the faster.
  42819. */
  42820. get touchMoveSensibility(): number;
  42821. set touchMoveSensibility(value: number);
  42822. /**
  42823. * Instantiates a new touch camera.
  42824. * This represents a FPS type of camera controlled by touch.
  42825. * This is like a universal camera minus the Gamepad controls.
  42826. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42827. * @param name Define the name of the camera in the scene
  42828. * @param position Define the start position of the camera in the scene
  42829. * @param scene Define the scene the camera belongs to
  42830. */
  42831. constructor(name: string, position: Vector3, scene: Scene);
  42832. /**
  42833. * Gets the current object class name.
  42834. * @return the class name
  42835. */
  42836. getClassName(): string;
  42837. /** @hidden */
  42838. _setupInputs(): void;
  42839. }
  42840. }
  42841. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42842. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42843. import { Scene } from "babylonjs/scene";
  42844. import { Vector3 } from "babylonjs/Maths/math.vector";
  42845. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42846. import { Axis } from "babylonjs/Maths/math.axis";
  42847. /**
  42848. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42849. * being tilted forward or back and left or right.
  42850. */
  42851. export class DeviceOrientationCamera extends FreeCamera {
  42852. private _initialQuaternion;
  42853. private _quaternionCache;
  42854. private _tmpDragQuaternion;
  42855. private _disablePointerInputWhenUsingDeviceOrientation;
  42856. /**
  42857. * Creates a new device orientation camera
  42858. * @param name The name of the camera
  42859. * @param position The start position camera
  42860. * @param scene The scene the camera belongs to
  42861. */
  42862. constructor(name: string, position: Vector3, scene: Scene);
  42863. /**
  42864. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42865. */
  42866. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42867. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42868. private _dragFactor;
  42869. /**
  42870. * Enabled turning on the y axis when the orientation sensor is active
  42871. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42872. */
  42873. enableHorizontalDragging(dragFactor?: number): void;
  42874. /**
  42875. * Gets the current instance class name ("DeviceOrientationCamera").
  42876. * This helps avoiding instanceof at run time.
  42877. * @returns the class name
  42878. */
  42879. getClassName(): string;
  42880. /**
  42881. * @hidden
  42882. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42883. */
  42884. _checkInputs(): void;
  42885. /**
  42886. * Reset the camera to its default orientation on the specified axis only.
  42887. * @param axis The axis to reset
  42888. */
  42889. resetToCurrentRotation(axis?: Axis): void;
  42890. }
  42891. }
  42892. declare module "babylonjs/Gamepads/xboxGamepad" {
  42893. import { Observable } from "babylonjs/Misc/observable";
  42894. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42895. /**
  42896. * Defines supported buttons for XBox360 compatible gamepads
  42897. */
  42898. export enum Xbox360Button {
  42899. /** A */
  42900. A = 0,
  42901. /** B */
  42902. B = 1,
  42903. /** X */
  42904. X = 2,
  42905. /** Y */
  42906. Y = 3,
  42907. /** Left button */
  42908. LB = 4,
  42909. /** Right button */
  42910. RB = 5,
  42911. /** Back */
  42912. Back = 8,
  42913. /** Start */
  42914. Start = 9,
  42915. /** Left stick */
  42916. LeftStick = 10,
  42917. /** Right stick */
  42918. RightStick = 11
  42919. }
  42920. /** Defines values for XBox360 DPad */
  42921. export enum Xbox360Dpad {
  42922. /** Up */
  42923. Up = 12,
  42924. /** Down */
  42925. Down = 13,
  42926. /** Left */
  42927. Left = 14,
  42928. /** Right */
  42929. Right = 15
  42930. }
  42931. /**
  42932. * Defines a XBox360 gamepad
  42933. */
  42934. export class Xbox360Pad extends Gamepad {
  42935. private _leftTrigger;
  42936. private _rightTrigger;
  42937. private _onlefttriggerchanged;
  42938. private _onrighttriggerchanged;
  42939. private _onbuttondown;
  42940. private _onbuttonup;
  42941. private _ondpaddown;
  42942. private _ondpadup;
  42943. /** Observable raised when a button is pressed */
  42944. onButtonDownObservable: Observable<Xbox360Button>;
  42945. /** Observable raised when a button is released */
  42946. onButtonUpObservable: Observable<Xbox360Button>;
  42947. /** Observable raised when a pad is pressed */
  42948. onPadDownObservable: Observable<Xbox360Dpad>;
  42949. /** Observable raised when a pad is released */
  42950. onPadUpObservable: Observable<Xbox360Dpad>;
  42951. private _buttonA;
  42952. private _buttonB;
  42953. private _buttonX;
  42954. private _buttonY;
  42955. private _buttonBack;
  42956. private _buttonStart;
  42957. private _buttonLB;
  42958. private _buttonRB;
  42959. private _buttonLeftStick;
  42960. private _buttonRightStick;
  42961. private _dPadUp;
  42962. private _dPadDown;
  42963. private _dPadLeft;
  42964. private _dPadRight;
  42965. private _isXboxOnePad;
  42966. /**
  42967. * Creates a new XBox360 gamepad object
  42968. * @param id defines the id of this gamepad
  42969. * @param index defines its index
  42970. * @param gamepad defines the internal HTML gamepad object
  42971. * @param xboxOne defines if it is a XBox One gamepad
  42972. */
  42973. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42974. /**
  42975. * Defines the callback to call when left trigger is pressed
  42976. * @param callback defines the callback to use
  42977. */
  42978. onlefttriggerchanged(callback: (value: number) => void): void;
  42979. /**
  42980. * Defines the callback to call when right trigger is pressed
  42981. * @param callback defines the callback to use
  42982. */
  42983. onrighttriggerchanged(callback: (value: number) => void): void;
  42984. /**
  42985. * Gets the left trigger value
  42986. */
  42987. get leftTrigger(): number;
  42988. /**
  42989. * Sets the left trigger value
  42990. */
  42991. set leftTrigger(newValue: number);
  42992. /**
  42993. * Gets the right trigger value
  42994. */
  42995. get rightTrigger(): number;
  42996. /**
  42997. * Sets the right trigger value
  42998. */
  42999. set rightTrigger(newValue: number);
  43000. /**
  43001. * Defines the callback to call when a button is pressed
  43002. * @param callback defines the callback to use
  43003. */
  43004. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  43005. /**
  43006. * Defines the callback to call when a button is released
  43007. * @param callback defines the callback to use
  43008. */
  43009. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  43010. /**
  43011. * Defines the callback to call when a pad is pressed
  43012. * @param callback defines the callback to use
  43013. */
  43014. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  43015. /**
  43016. * Defines the callback to call when a pad is released
  43017. * @param callback defines the callback to use
  43018. */
  43019. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  43020. private _setButtonValue;
  43021. private _setDPadValue;
  43022. /**
  43023. * Gets the value of the `A` button
  43024. */
  43025. get buttonA(): number;
  43026. /**
  43027. * Sets the value of the `A` button
  43028. */
  43029. set buttonA(value: number);
  43030. /**
  43031. * Gets the value of the `B` button
  43032. */
  43033. get buttonB(): number;
  43034. /**
  43035. * Sets the value of the `B` button
  43036. */
  43037. set buttonB(value: number);
  43038. /**
  43039. * Gets the value of the `X` button
  43040. */
  43041. get buttonX(): number;
  43042. /**
  43043. * Sets the value of the `X` button
  43044. */
  43045. set buttonX(value: number);
  43046. /**
  43047. * Gets the value of the `Y` button
  43048. */
  43049. get buttonY(): number;
  43050. /**
  43051. * Sets the value of the `Y` button
  43052. */
  43053. set buttonY(value: number);
  43054. /**
  43055. * Gets the value of the `Start` button
  43056. */
  43057. get buttonStart(): number;
  43058. /**
  43059. * Sets the value of the `Start` button
  43060. */
  43061. set buttonStart(value: number);
  43062. /**
  43063. * Gets the value of the `Back` button
  43064. */
  43065. get buttonBack(): number;
  43066. /**
  43067. * Sets the value of the `Back` button
  43068. */
  43069. set buttonBack(value: number);
  43070. /**
  43071. * Gets the value of the `Left` button
  43072. */
  43073. get buttonLB(): number;
  43074. /**
  43075. * Sets the value of the `Left` button
  43076. */
  43077. set buttonLB(value: number);
  43078. /**
  43079. * Gets the value of the `Right` button
  43080. */
  43081. get buttonRB(): number;
  43082. /**
  43083. * Sets the value of the `Right` button
  43084. */
  43085. set buttonRB(value: number);
  43086. /**
  43087. * Gets the value of the Left joystick
  43088. */
  43089. get buttonLeftStick(): number;
  43090. /**
  43091. * Sets the value of the Left joystick
  43092. */
  43093. set buttonLeftStick(value: number);
  43094. /**
  43095. * Gets the value of the Right joystick
  43096. */
  43097. get buttonRightStick(): number;
  43098. /**
  43099. * Sets the value of the Right joystick
  43100. */
  43101. set buttonRightStick(value: number);
  43102. /**
  43103. * Gets the value of D-pad up
  43104. */
  43105. get dPadUp(): number;
  43106. /**
  43107. * Sets the value of D-pad up
  43108. */
  43109. set dPadUp(value: number);
  43110. /**
  43111. * Gets the value of D-pad down
  43112. */
  43113. get dPadDown(): number;
  43114. /**
  43115. * Sets the value of D-pad down
  43116. */
  43117. set dPadDown(value: number);
  43118. /**
  43119. * Gets the value of D-pad left
  43120. */
  43121. get dPadLeft(): number;
  43122. /**
  43123. * Sets the value of D-pad left
  43124. */
  43125. set dPadLeft(value: number);
  43126. /**
  43127. * Gets the value of D-pad right
  43128. */
  43129. get dPadRight(): number;
  43130. /**
  43131. * Sets the value of D-pad right
  43132. */
  43133. set dPadRight(value: number);
  43134. /**
  43135. * Force the gamepad to synchronize with device values
  43136. */
  43137. update(): void;
  43138. /**
  43139. * Disposes the gamepad
  43140. */
  43141. dispose(): void;
  43142. }
  43143. }
  43144. declare module "babylonjs/Gamepads/dualShockGamepad" {
  43145. import { Observable } from "babylonjs/Misc/observable";
  43146. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43147. /**
  43148. * Defines supported buttons for DualShock compatible gamepads
  43149. */
  43150. export enum DualShockButton {
  43151. /** Cross */
  43152. Cross = 0,
  43153. /** Circle */
  43154. Circle = 1,
  43155. /** Square */
  43156. Square = 2,
  43157. /** Triangle */
  43158. Triangle = 3,
  43159. /** L1 */
  43160. L1 = 4,
  43161. /** R1 */
  43162. R1 = 5,
  43163. /** Share */
  43164. Share = 8,
  43165. /** Options */
  43166. Options = 9,
  43167. /** Left stick */
  43168. LeftStick = 10,
  43169. /** Right stick */
  43170. RightStick = 11
  43171. }
  43172. /** Defines values for DualShock DPad */
  43173. export enum DualShockDpad {
  43174. /** Up */
  43175. Up = 12,
  43176. /** Down */
  43177. Down = 13,
  43178. /** Left */
  43179. Left = 14,
  43180. /** Right */
  43181. Right = 15
  43182. }
  43183. /**
  43184. * Defines a DualShock gamepad
  43185. */
  43186. export class DualShockPad extends Gamepad {
  43187. private _leftTrigger;
  43188. private _rightTrigger;
  43189. private _onlefttriggerchanged;
  43190. private _onrighttriggerchanged;
  43191. private _onbuttondown;
  43192. private _onbuttonup;
  43193. private _ondpaddown;
  43194. private _ondpadup;
  43195. /** Observable raised when a button is pressed */
  43196. onButtonDownObservable: Observable<DualShockButton>;
  43197. /** Observable raised when a button is released */
  43198. onButtonUpObservable: Observable<DualShockButton>;
  43199. /** Observable raised when a pad is pressed */
  43200. onPadDownObservable: Observable<DualShockDpad>;
  43201. /** Observable raised when a pad is released */
  43202. onPadUpObservable: Observable<DualShockDpad>;
  43203. private _buttonCross;
  43204. private _buttonCircle;
  43205. private _buttonSquare;
  43206. private _buttonTriangle;
  43207. private _buttonShare;
  43208. private _buttonOptions;
  43209. private _buttonL1;
  43210. private _buttonR1;
  43211. private _buttonLeftStick;
  43212. private _buttonRightStick;
  43213. private _dPadUp;
  43214. private _dPadDown;
  43215. private _dPadLeft;
  43216. private _dPadRight;
  43217. /**
  43218. * Creates a new DualShock gamepad object
  43219. * @param id defines the id of this gamepad
  43220. * @param index defines its index
  43221. * @param gamepad defines the internal HTML gamepad object
  43222. */
  43223. constructor(id: string, index: number, gamepad: any);
  43224. /**
  43225. * Defines the callback to call when left trigger is pressed
  43226. * @param callback defines the callback to use
  43227. */
  43228. onlefttriggerchanged(callback: (value: number) => void): void;
  43229. /**
  43230. * Defines the callback to call when right trigger is pressed
  43231. * @param callback defines the callback to use
  43232. */
  43233. onrighttriggerchanged(callback: (value: number) => void): void;
  43234. /**
  43235. * Gets the left trigger value
  43236. */
  43237. get leftTrigger(): number;
  43238. /**
  43239. * Sets the left trigger value
  43240. */
  43241. set leftTrigger(newValue: number);
  43242. /**
  43243. * Gets the right trigger value
  43244. */
  43245. get rightTrigger(): number;
  43246. /**
  43247. * Sets the right trigger value
  43248. */
  43249. set rightTrigger(newValue: number);
  43250. /**
  43251. * Defines the callback to call when a button is pressed
  43252. * @param callback defines the callback to use
  43253. */
  43254. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43255. /**
  43256. * Defines the callback to call when a button is released
  43257. * @param callback defines the callback to use
  43258. */
  43259. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43260. /**
  43261. * Defines the callback to call when a pad is pressed
  43262. * @param callback defines the callback to use
  43263. */
  43264. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43265. /**
  43266. * Defines the callback to call when a pad is released
  43267. * @param callback defines the callback to use
  43268. */
  43269. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43270. private _setButtonValue;
  43271. private _setDPadValue;
  43272. /**
  43273. * Gets the value of the `Cross` button
  43274. */
  43275. get buttonCross(): number;
  43276. /**
  43277. * Sets the value of the `Cross` button
  43278. */
  43279. set buttonCross(value: number);
  43280. /**
  43281. * Gets the value of the `Circle` button
  43282. */
  43283. get buttonCircle(): number;
  43284. /**
  43285. * Sets the value of the `Circle` button
  43286. */
  43287. set buttonCircle(value: number);
  43288. /**
  43289. * Gets the value of the `Square` button
  43290. */
  43291. get buttonSquare(): number;
  43292. /**
  43293. * Sets the value of the `Square` button
  43294. */
  43295. set buttonSquare(value: number);
  43296. /**
  43297. * Gets the value of the `Triangle` button
  43298. */
  43299. get buttonTriangle(): number;
  43300. /**
  43301. * Sets the value of the `Triangle` button
  43302. */
  43303. set buttonTriangle(value: number);
  43304. /**
  43305. * Gets the value of the `Options` button
  43306. */
  43307. get buttonOptions(): number;
  43308. /**
  43309. * Sets the value of the `Options` button
  43310. */
  43311. set buttonOptions(value: number);
  43312. /**
  43313. * Gets the value of the `Share` button
  43314. */
  43315. get buttonShare(): number;
  43316. /**
  43317. * Sets the value of the `Share` button
  43318. */
  43319. set buttonShare(value: number);
  43320. /**
  43321. * Gets the value of the `L1` button
  43322. */
  43323. get buttonL1(): number;
  43324. /**
  43325. * Sets the value of the `L1` button
  43326. */
  43327. set buttonL1(value: number);
  43328. /**
  43329. * Gets the value of the `R1` button
  43330. */
  43331. get buttonR1(): number;
  43332. /**
  43333. * Sets the value of the `R1` button
  43334. */
  43335. set buttonR1(value: number);
  43336. /**
  43337. * Gets the value of the Left joystick
  43338. */
  43339. get buttonLeftStick(): number;
  43340. /**
  43341. * Sets the value of the Left joystick
  43342. */
  43343. set buttonLeftStick(value: number);
  43344. /**
  43345. * Gets the value of the Right joystick
  43346. */
  43347. get buttonRightStick(): number;
  43348. /**
  43349. * Sets the value of the Right joystick
  43350. */
  43351. set buttonRightStick(value: number);
  43352. /**
  43353. * Gets the value of D-pad up
  43354. */
  43355. get dPadUp(): number;
  43356. /**
  43357. * Sets the value of D-pad up
  43358. */
  43359. set dPadUp(value: number);
  43360. /**
  43361. * Gets the value of D-pad down
  43362. */
  43363. get dPadDown(): number;
  43364. /**
  43365. * Sets the value of D-pad down
  43366. */
  43367. set dPadDown(value: number);
  43368. /**
  43369. * Gets the value of D-pad left
  43370. */
  43371. get dPadLeft(): number;
  43372. /**
  43373. * Sets the value of D-pad left
  43374. */
  43375. set dPadLeft(value: number);
  43376. /**
  43377. * Gets the value of D-pad right
  43378. */
  43379. get dPadRight(): number;
  43380. /**
  43381. * Sets the value of D-pad right
  43382. */
  43383. set dPadRight(value: number);
  43384. /**
  43385. * Force the gamepad to synchronize with device values
  43386. */
  43387. update(): void;
  43388. /**
  43389. * Disposes the gamepad
  43390. */
  43391. dispose(): void;
  43392. }
  43393. }
  43394. declare module "babylonjs/Gamepads/gamepadManager" {
  43395. import { Observable } from "babylonjs/Misc/observable";
  43396. import { Nullable } from "babylonjs/types";
  43397. import { Scene } from "babylonjs/scene";
  43398. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43399. /**
  43400. * Manager for handling gamepads
  43401. */
  43402. export class GamepadManager {
  43403. private _scene?;
  43404. private _babylonGamepads;
  43405. private _oneGamepadConnected;
  43406. /** @hidden */
  43407. _isMonitoring: boolean;
  43408. private _gamepadEventSupported;
  43409. private _gamepadSupport?;
  43410. /**
  43411. * observable to be triggered when the gamepad controller has been connected
  43412. */
  43413. onGamepadConnectedObservable: Observable<Gamepad>;
  43414. /**
  43415. * observable to be triggered when the gamepad controller has been disconnected
  43416. */
  43417. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43418. private _onGamepadConnectedEvent;
  43419. private _onGamepadDisconnectedEvent;
  43420. /**
  43421. * Initializes the gamepad manager
  43422. * @param _scene BabylonJS scene
  43423. */
  43424. constructor(_scene?: Scene | undefined);
  43425. /**
  43426. * The gamepads in the game pad manager
  43427. */
  43428. get gamepads(): Gamepad[];
  43429. /**
  43430. * Get the gamepad controllers based on type
  43431. * @param type The type of gamepad controller
  43432. * @returns Nullable gamepad
  43433. */
  43434. getGamepadByType(type?: number): Nullable<Gamepad>;
  43435. /**
  43436. * Disposes the gamepad manager
  43437. */
  43438. dispose(): void;
  43439. private _addNewGamepad;
  43440. private _startMonitoringGamepads;
  43441. private _stopMonitoringGamepads;
  43442. /** @hidden */
  43443. _checkGamepadsStatus(): void;
  43444. private _updateGamepadObjects;
  43445. }
  43446. }
  43447. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43448. import { Nullable } from "babylonjs/types";
  43449. import { Scene } from "babylonjs/scene";
  43450. import { ISceneComponent } from "babylonjs/sceneComponent";
  43451. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43452. module "babylonjs/scene" {
  43453. interface Scene {
  43454. /** @hidden */
  43455. _gamepadManager: Nullable<GamepadManager>;
  43456. /**
  43457. * Gets the gamepad manager associated with the scene
  43458. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43459. */
  43460. gamepadManager: GamepadManager;
  43461. }
  43462. }
  43463. module "babylonjs/Cameras/freeCameraInputsManager" {
  43464. /**
  43465. * Interface representing a free camera inputs manager
  43466. */
  43467. interface FreeCameraInputsManager {
  43468. /**
  43469. * Adds gamepad input support to the FreeCameraInputsManager.
  43470. * @returns the FreeCameraInputsManager
  43471. */
  43472. addGamepad(): FreeCameraInputsManager;
  43473. }
  43474. }
  43475. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43476. /**
  43477. * Interface representing an arc rotate camera inputs manager
  43478. */
  43479. interface ArcRotateCameraInputsManager {
  43480. /**
  43481. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43482. * @returns the camera inputs manager
  43483. */
  43484. addGamepad(): ArcRotateCameraInputsManager;
  43485. }
  43486. }
  43487. /**
  43488. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43489. */
  43490. export class GamepadSystemSceneComponent implements ISceneComponent {
  43491. /**
  43492. * The component name helpfull to identify the component in the list of scene components.
  43493. */
  43494. readonly name: string;
  43495. /**
  43496. * The scene the component belongs to.
  43497. */
  43498. scene: Scene;
  43499. /**
  43500. * Creates a new instance of the component for the given scene
  43501. * @param scene Defines the scene to register the component in
  43502. */
  43503. constructor(scene: Scene);
  43504. /**
  43505. * Registers the component in a given scene
  43506. */
  43507. register(): void;
  43508. /**
  43509. * Rebuilds the elements related to this component in case of
  43510. * context lost for instance.
  43511. */
  43512. rebuild(): void;
  43513. /**
  43514. * Disposes the component and the associated ressources
  43515. */
  43516. dispose(): void;
  43517. private _beforeCameraUpdate;
  43518. }
  43519. }
  43520. declare module "babylonjs/Cameras/universalCamera" {
  43521. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43522. import { Scene } from "babylonjs/scene";
  43523. import { Vector3 } from "babylonjs/Maths/math.vector";
  43524. import "babylonjs/Gamepads/gamepadSceneComponent";
  43525. /**
  43526. * 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,
  43527. * which still works and will still be found in many Playgrounds.
  43528. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43529. */
  43530. export class UniversalCamera extends TouchCamera {
  43531. /**
  43532. * Defines the gamepad rotation sensiblity.
  43533. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43534. */
  43535. get gamepadAngularSensibility(): number;
  43536. set gamepadAngularSensibility(value: number);
  43537. /**
  43538. * Defines the gamepad move sensiblity.
  43539. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43540. */
  43541. get gamepadMoveSensibility(): number;
  43542. set gamepadMoveSensibility(value: number);
  43543. /**
  43544. * 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,
  43545. * which still works and will still be found in many Playgrounds.
  43546. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43547. * @param name Define the name of the camera in the scene
  43548. * @param position Define the start position of the camera in the scene
  43549. * @param scene Define the scene the camera belongs to
  43550. */
  43551. constructor(name: string, position: Vector3, scene: Scene);
  43552. /**
  43553. * Gets the current object class name.
  43554. * @return the class name
  43555. */
  43556. getClassName(): string;
  43557. }
  43558. }
  43559. declare module "babylonjs/Cameras/gamepadCamera" {
  43560. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43561. import { Scene } from "babylonjs/scene";
  43562. import { Vector3 } from "babylonjs/Maths/math.vector";
  43563. /**
  43564. * This represents a FPS type of camera. This is only here for back compat purpose.
  43565. * Please use the UniversalCamera instead as both are identical.
  43566. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43567. */
  43568. export class GamepadCamera extends UniversalCamera {
  43569. /**
  43570. * Instantiates a new Gamepad Camera
  43571. * This represents a FPS type of camera. This is only here for back compat purpose.
  43572. * Please use the UniversalCamera instead as both are identical.
  43573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43574. * @param name Define the name of the camera in the scene
  43575. * @param position Define the start position of the camera in the scene
  43576. * @param scene Define the scene the camera belongs to
  43577. */
  43578. constructor(name: string, position: Vector3, scene: Scene);
  43579. /**
  43580. * Gets the current object class name.
  43581. * @return the class name
  43582. */
  43583. getClassName(): string;
  43584. }
  43585. }
  43586. declare module "babylonjs/Shaders/pass.fragment" {
  43587. /** @hidden */
  43588. export var passPixelShader: {
  43589. name: string;
  43590. shader: string;
  43591. };
  43592. }
  43593. declare module "babylonjs/Shaders/passCube.fragment" {
  43594. /** @hidden */
  43595. export var passCubePixelShader: {
  43596. name: string;
  43597. shader: string;
  43598. };
  43599. }
  43600. declare module "babylonjs/PostProcesses/passPostProcess" {
  43601. import { Nullable } from "babylonjs/types";
  43602. import { Camera } from "babylonjs/Cameras/camera";
  43603. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43604. import { Engine } from "babylonjs/Engines/engine";
  43605. import "babylonjs/Shaders/pass.fragment";
  43606. import "babylonjs/Shaders/passCube.fragment";
  43607. /**
  43608. * PassPostProcess which produces an output the same as it's input
  43609. */
  43610. export class PassPostProcess extends PostProcess {
  43611. /**
  43612. * Creates the PassPostProcess
  43613. * @param name The name of the effect.
  43614. * @param options The required width/height ratio to downsize to before computing the render pass.
  43615. * @param camera The camera to apply the render pass to.
  43616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43617. * @param engine The engine which the post process will be applied. (default: current engine)
  43618. * @param reusable If the post process can be reused on the same frame. (default: false)
  43619. * @param textureType The type of texture to be used when performing the post processing.
  43620. * @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)
  43621. */
  43622. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43623. }
  43624. /**
  43625. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43626. */
  43627. export class PassCubePostProcess extends PostProcess {
  43628. private _face;
  43629. /**
  43630. * Gets or sets the cube face to display.
  43631. * * 0 is +X
  43632. * * 1 is -X
  43633. * * 2 is +Y
  43634. * * 3 is -Y
  43635. * * 4 is +Z
  43636. * * 5 is -Z
  43637. */
  43638. get face(): number;
  43639. set face(value: number);
  43640. /**
  43641. * Creates the PassCubePostProcess
  43642. * @param name The name of the effect.
  43643. * @param options The required width/height ratio to downsize to before computing the render pass.
  43644. * @param camera The camera to apply the render pass to.
  43645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43646. * @param engine The engine which the post process will be applied. (default: current engine)
  43647. * @param reusable If the post process can be reused on the same frame. (default: false)
  43648. * @param textureType The type of texture to be used when performing the post processing.
  43649. * @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)
  43650. */
  43651. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43652. }
  43653. }
  43654. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43655. /** @hidden */
  43656. export var anaglyphPixelShader: {
  43657. name: string;
  43658. shader: string;
  43659. };
  43660. }
  43661. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43662. import { Engine } from "babylonjs/Engines/engine";
  43663. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43664. import { Camera } from "babylonjs/Cameras/camera";
  43665. import "babylonjs/Shaders/anaglyph.fragment";
  43666. /**
  43667. * Postprocess used to generate anaglyphic rendering
  43668. */
  43669. export class AnaglyphPostProcess extends PostProcess {
  43670. private _passedProcess;
  43671. /**
  43672. * Creates a new AnaglyphPostProcess
  43673. * @param name defines postprocess name
  43674. * @param options defines creation options or target ratio scale
  43675. * @param rigCameras defines cameras using this postprocess
  43676. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43677. * @param engine defines hosting engine
  43678. * @param reusable defines if the postprocess will be reused multiple times per frame
  43679. */
  43680. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43681. }
  43682. }
  43683. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43684. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43685. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43686. import { Scene } from "babylonjs/scene";
  43687. import { Vector3 } from "babylonjs/Maths/math.vector";
  43688. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43689. /**
  43690. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43691. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43692. */
  43693. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43694. /**
  43695. * Creates a new AnaglyphArcRotateCamera
  43696. * @param name defines camera name
  43697. * @param alpha defines alpha angle (in radians)
  43698. * @param beta defines beta angle (in radians)
  43699. * @param radius defines radius
  43700. * @param target defines camera target
  43701. * @param interaxialDistance defines distance between each color axis
  43702. * @param scene defines the hosting scene
  43703. */
  43704. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43705. /**
  43706. * Gets camera class name
  43707. * @returns AnaglyphArcRotateCamera
  43708. */
  43709. getClassName(): string;
  43710. }
  43711. }
  43712. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43713. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43714. import { Scene } from "babylonjs/scene";
  43715. import { Vector3 } from "babylonjs/Maths/math.vector";
  43716. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43717. /**
  43718. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43719. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43720. */
  43721. export class AnaglyphFreeCamera extends FreeCamera {
  43722. /**
  43723. * Creates a new AnaglyphFreeCamera
  43724. * @param name defines camera name
  43725. * @param position defines initial position
  43726. * @param interaxialDistance defines distance between each color axis
  43727. * @param scene defines the hosting scene
  43728. */
  43729. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43730. /**
  43731. * Gets camera class name
  43732. * @returns AnaglyphFreeCamera
  43733. */
  43734. getClassName(): string;
  43735. }
  43736. }
  43737. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43738. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43739. import { Scene } from "babylonjs/scene";
  43740. import { Vector3 } from "babylonjs/Maths/math.vector";
  43741. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43742. /**
  43743. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43744. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43745. */
  43746. export class AnaglyphGamepadCamera extends GamepadCamera {
  43747. /**
  43748. * Creates a new AnaglyphGamepadCamera
  43749. * @param name defines camera name
  43750. * @param position defines initial position
  43751. * @param interaxialDistance defines distance between each color axis
  43752. * @param scene defines the hosting scene
  43753. */
  43754. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43755. /**
  43756. * Gets camera class name
  43757. * @returns AnaglyphGamepadCamera
  43758. */
  43759. getClassName(): string;
  43760. }
  43761. }
  43762. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43763. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43764. import { Scene } from "babylonjs/scene";
  43765. import { Vector3 } from "babylonjs/Maths/math.vector";
  43766. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43767. /**
  43768. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43769. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43770. */
  43771. export class AnaglyphUniversalCamera extends UniversalCamera {
  43772. /**
  43773. * Creates a new AnaglyphUniversalCamera
  43774. * @param name defines camera name
  43775. * @param position defines initial position
  43776. * @param interaxialDistance defines distance between each color axis
  43777. * @param scene defines the hosting scene
  43778. */
  43779. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43780. /**
  43781. * Gets camera class name
  43782. * @returns AnaglyphUniversalCamera
  43783. */
  43784. getClassName(): string;
  43785. }
  43786. }
  43787. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43788. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43789. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43790. import { Scene } from "babylonjs/scene";
  43791. import { Vector3 } from "babylonjs/Maths/math.vector";
  43792. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43793. /**
  43794. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43795. * @see http://doc.babylonjs.com/features/cameras
  43796. */
  43797. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43798. /**
  43799. * Creates a new StereoscopicArcRotateCamera
  43800. * @param name defines camera name
  43801. * @param alpha defines alpha angle (in radians)
  43802. * @param beta defines beta angle (in radians)
  43803. * @param radius defines radius
  43804. * @param target defines camera target
  43805. * @param interaxialDistance defines distance between each color axis
  43806. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43807. * @param scene defines the hosting scene
  43808. */
  43809. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43810. /**
  43811. * Gets camera class name
  43812. * @returns StereoscopicArcRotateCamera
  43813. */
  43814. getClassName(): string;
  43815. }
  43816. }
  43817. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43818. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43819. import { Scene } from "babylonjs/scene";
  43820. import { Vector3 } from "babylonjs/Maths/math.vector";
  43821. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43822. /**
  43823. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43824. * @see http://doc.babylonjs.com/features/cameras
  43825. */
  43826. export class StereoscopicFreeCamera extends FreeCamera {
  43827. /**
  43828. * Creates a new StereoscopicFreeCamera
  43829. * @param name defines camera name
  43830. * @param position defines initial position
  43831. * @param interaxialDistance defines distance between each color axis
  43832. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43833. * @param scene defines the hosting scene
  43834. */
  43835. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43836. /**
  43837. * Gets camera class name
  43838. * @returns StereoscopicFreeCamera
  43839. */
  43840. getClassName(): string;
  43841. }
  43842. }
  43843. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43844. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43845. import { Scene } from "babylonjs/scene";
  43846. import { Vector3 } from "babylonjs/Maths/math.vector";
  43847. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43848. /**
  43849. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43850. * @see http://doc.babylonjs.com/features/cameras
  43851. */
  43852. export class StereoscopicGamepadCamera extends GamepadCamera {
  43853. /**
  43854. * Creates a new StereoscopicGamepadCamera
  43855. * @param name defines camera name
  43856. * @param position defines initial position
  43857. * @param interaxialDistance defines distance between each color axis
  43858. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43859. * @param scene defines the hosting scene
  43860. */
  43861. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43862. /**
  43863. * Gets camera class name
  43864. * @returns StereoscopicGamepadCamera
  43865. */
  43866. getClassName(): string;
  43867. }
  43868. }
  43869. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43870. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43871. import { Scene } from "babylonjs/scene";
  43872. import { Vector3 } from "babylonjs/Maths/math.vector";
  43873. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43874. /**
  43875. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43876. * @see http://doc.babylonjs.com/features/cameras
  43877. */
  43878. export class StereoscopicUniversalCamera extends UniversalCamera {
  43879. /**
  43880. * Creates a new StereoscopicUniversalCamera
  43881. * @param name defines camera name
  43882. * @param position defines initial position
  43883. * @param interaxialDistance defines distance between each color axis
  43884. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43885. * @param scene defines the hosting scene
  43886. */
  43887. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43888. /**
  43889. * Gets camera class name
  43890. * @returns StereoscopicUniversalCamera
  43891. */
  43892. getClassName(): string;
  43893. }
  43894. }
  43895. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43896. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43897. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43898. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43899. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43900. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43901. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43902. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43903. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43904. }
  43905. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43907. import { Scene } from "babylonjs/scene";
  43908. import { Vector3 } from "babylonjs/Maths/math.vector";
  43909. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43910. /**
  43911. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43912. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43913. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43914. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43915. */
  43916. export class VirtualJoysticksCamera extends FreeCamera {
  43917. /**
  43918. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43919. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43920. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43921. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43922. * @param name Define the name of the camera in the scene
  43923. * @param position Define the start position of the camera in the scene
  43924. * @param scene Define the scene the camera belongs to
  43925. */
  43926. constructor(name: string, position: Vector3, scene: Scene);
  43927. /**
  43928. * Gets the current object class name.
  43929. * @return the class name
  43930. */
  43931. getClassName(): string;
  43932. }
  43933. }
  43934. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43935. import { Matrix } from "babylonjs/Maths/math.vector";
  43936. /**
  43937. * This represents all the required metrics to create a VR camera.
  43938. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43939. */
  43940. export class VRCameraMetrics {
  43941. /**
  43942. * Define the horizontal resolution off the screen.
  43943. */
  43944. hResolution: number;
  43945. /**
  43946. * Define the vertical resolution off the screen.
  43947. */
  43948. vResolution: number;
  43949. /**
  43950. * Define the horizontal screen size.
  43951. */
  43952. hScreenSize: number;
  43953. /**
  43954. * Define the vertical screen size.
  43955. */
  43956. vScreenSize: number;
  43957. /**
  43958. * Define the vertical screen center position.
  43959. */
  43960. vScreenCenter: number;
  43961. /**
  43962. * Define the distance of the eyes to the screen.
  43963. */
  43964. eyeToScreenDistance: number;
  43965. /**
  43966. * Define the distance between both lenses
  43967. */
  43968. lensSeparationDistance: number;
  43969. /**
  43970. * Define the distance between both viewer's eyes.
  43971. */
  43972. interpupillaryDistance: number;
  43973. /**
  43974. * Define the distortion factor of the VR postprocess.
  43975. * Please, touch with care.
  43976. */
  43977. distortionK: number[];
  43978. /**
  43979. * Define the chromatic aberration correction factors for the VR post process.
  43980. */
  43981. chromaAbCorrection: number[];
  43982. /**
  43983. * Define the scale factor of the post process.
  43984. * The smaller the better but the slower.
  43985. */
  43986. postProcessScaleFactor: number;
  43987. /**
  43988. * Define an offset for the lens center.
  43989. */
  43990. lensCenterOffset: number;
  43991. /**
  43992. * Define if the current vr camera should compensate the distortion of the lense or not.
  43993. */
  43994. compensateDistortion: boolean;
  43995. /**
  43996. * Defines if multiview should be enabled when rendering (Default: false)
  43997. */
  43998. multiviewEnabled: boolean;
  43999. /**
  44000. * Gets the rendering aspect ratio based on the provided resolutions.
  44001. */
  44002. get aspectRatio(): number;
  44003. /**
  44004. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  44005. */
  44006. get aspectRatioFov(): number;
  44007. /**
  44008. * @hidden
  44009. */
  44010. get leftHMatrix(): Matrix;
  44011. /**
  44012. * @hidden
  44013. */
  44014. get rightHMatrix(): Matrix;
  44015. /**
  44016. * @hidden
  44017. */
  44018. get leftPreViewMatrix(): Matrix;
  44019. /**
  44020. * @hidden
  44021. */
  44022. get rightPreViewMatrix(): Matrix;
  44023. /**
  44024. * Get the default VRMetrics based on the most generic setup.
  44025. * @returns the default vr metrics
  44026. */
  44027. static GetDefault(): VRCameraMetrics;
  44028. }
  44029. }
  44030. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  44031. /** @hidden */
  44032. export var vrDistortionCorrectionPixelShader: {
  44033. name: string;
  44034. shader: string;
  44035. };
  44036. }
  44037. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  44038. import { Camera } from "babylonjs/Cameras/camera";
  44039. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44040. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44041. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  44042. /**
  44043. * VRDistortionCorrectionPostProcess used for mobile VR
  44044. */
  44045. export class VRDistortionCorrectionPostProcess extends PostProcess {
  44046. private _isRightEye;
  44047. private _distortionFactors;
  44048. private _postProcessScaleFactor;
  44049. private _lensCenterOffset;
  44050. private _scaleIn;
  44051. private _scaleFactor;
  44052. private _lensCenter;
  44053. /**
  44054. * Initializes the VRDistortionCorrectionPostProcess
  44055. * @param name The name of the effect.
  44056. * @param camera The camera to apply the render pass to.
  44057. * @param isRightEye If this is for the right eye distortion
  44058. * @param vrMetrics All the required metrics for the VR camera
  44059. */
  44060. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  44061. }
  44062. }
  44063. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  44064. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  44065. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44066. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44067. import { Scene } from "babylonjs/scene";
  44068. import { Vector3 } from "babylonjs/Maths/math.vector";
  44069. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  44070. import "babylonjs/Cameras/RigModes/vrRigMode";
  44071. /**
  44072. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  44073. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44074. */
  44075. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  44076. /**
  44077. * Creates a new VRDeviceOrientationArcRotateCamera
  44078. * @param name defines camera name
  44079. * @param alpha defines the camera rotation along the logitudinal axis
  44080. * @param beta defines the camera rotation along the latitudinal axis
  44081. * @param radius defines the camera distance from its target
  44082. * @param target defines the camera target
  44083. * @param scene defines the scene the camera belongs to
  44084. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44085. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44086. */
  44087. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44088. /**
  44089. * Gets camera class name
  44090. * @returns VRDeviceOrientationArcRotateCamera
  44091. */
  44092. getClassName(): string;
  44093. }
  44094. }
  44095. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  44096. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44097. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44098. import { Scene } from "babylonjs/scene";
  44099. import { Vector3 } from "babylonjs/Maths/math.vector";
  44100. import "babylonjs/Cameras/RigModes/vrRigMode";
  44101. /**
  44102. * Camera used to simulate VR rendering (based on FreeCamera)
  44103. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44104. */
  44105. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  44106. /**
  44107. * Creates a new VRDeviceOrientationFreeCamera
  44108. * @param name defines camera name
  44109. * @param position defines the start position of the camera
  44110. * @param scene defines the scene the camera belongs to
  44111. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44112. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44113. */
  44114. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44115. /**
  44116. * Gets camera class name
  44117. * @returns VRDeviceOrientationFreeCamera
  44118. */
  44119. getClassName(): string;
  44120. }
  44121. }
  44122. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  44123. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44124. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44125. import { Scene } from "babylonjs/scene";
  44126. import { Vector3 } from "babylonjs/Maths/math.vector";
  44127. import "babylonjs/Gamepads/gamepadSceneComponent";
  44128. /**
  44129. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  44130. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  44131. */
  44132. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  44133. /**
  44134. * Creates a new VRDeviceOrientationGamepadCamera
  44135. * @param name defines camera name
  44136. * @param position defines the start position of the camera
  44137. * @param scene defines the scene the camera belongs to
  44138. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  44139. * @param vrCameraMetrics defines the vr metrics associated to the camera
  44140. */
  44141. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  44142. /**
  44143. * Gets camera class name
  44144. * @returns VRDeviceOrientationGamepadCamera
  44145. */
  44146. getClassName(): string;
  44147. }
  44148. }
  44149. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  44150. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44151. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44152. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44153. /** @hidden */
  44154. export var imageProcessingPixelShader: {
  44155. name: string;
  44156. shader: string;
  44157. };
  44158. }
  44159. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44160. import { Nullable } from "babylonjs/types";
  44161. import { Color4 } from "babylonjs/Maths/math.color";
  44162. import { Camera } from "babylonjs/Cameras/camera";
  44163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44164. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44165. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44166. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44167. import { Engine } from "babylonjs/Engines/engine";
  44168. import "babylonjs/Shaders/imageProcessing.fragment";
  44169. import "babylonjs/Shaders/postprocess.vertex";
  44170. /**
  44171. * ImageProcessingPostProcess
  44172. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44173. */
  44174. export class ImageProcessingPostProcess extends PostProcess {
  44175. /**
  44176. * Default configuration related to image processing available in the PBR Material.
  44177. */
  44178. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44179. /**
  44180. * Gets the image processing configuration used either in this material.
  44181. */
  44182. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44183. /**
  44184. * Sets the Default image processing configuration used either in the this material.
  44185. *
  44186. * If sets to null, the scene one is in use.
  44187. */
  44188. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44189. /**
  44190. * Keep track of the image processing observer to allow dispose and replace.
  44191. */
  44192. private _imageProcessingObserver;
  44193. /**
  44194. * Attaches a new image processing configuration to the PBR Material.
  44195. * @param configuration
  44196. */
  44197. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44198. /**
  44199. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44200. */
  44201. get colorCurves(): Nullable<ColorCurves>;
  44202. /**
  44203. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44204. */
  44205. set colorCurves(value: Nullable<ColorCurves>);
  44206. /**
  44207. * Gets wether the color curves effect is enabled.
  44208. */
  44209. get colorCurvesEnabled(): boolean;
  44210. /**
  44211. * Sets wether the color curves effect is enabled.
  44212. */
  44213. set colorCurvesEnabled(value: boolean);
  44214. /**
  44215. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44216. */
  44217. get colorGradingTexture(): Nullable<BaseTexture>;
  44218. /**
  44219. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44220. */
  44221. set colorGradingTexture(value: Nullable<BaseTexture>);
  44222. /**
  44223. * Gets wether the color grading effect is enabled.
  44224. */
  44225. get colorGradingEnabled(): boolean;
  44226. /**
  44227. * Gets wether the color grading effect is enabled.
  44228. */
  44229. set colorGradingEnabled(value: boolean);
  44230. /**
  44231. * Gets exposure used in the effect.
  44232. */
  44233. get exposure(): number;
  44234. /**
  44235. * Sets exposure used in the effect.
  44236. */
  44237. set exposure(value: number);
  44238. /**
  44239. * Gets wether tonemapping is enabled or not.
  44240. */
  44241. get toneMappingEnabled(): boolean;
  44242. /**
  44243. * Sets wether tonemapping is enabled or not
  44244. */
  44245. set toneMappingEnabled(value: boolean);
  44246. /**
  44247. * Gets the type of tone mapping effect.
  44248. */
  44249. get toneMappingType(): number;
  44250. /**
  44251. * Sets the type of tone mapping effect.
  44252. */
  44253. set toneMappingType(value: number);
  44254. /**
  44255. * Gets contrast used in the effect.
  44256. */
  44257. get contrast(): number;
  44258. /**
  44259. * Sets contrast used in the effect.
  44260. */
  44261. set contrast(value: number);
  44262. /**
  44263. * Gets Vignette stretch size.
  44264. */
  44265. get vignetteStretch(): number;
  44266. /**
  44267. * Sets Vignette stretch size.
  44268. */
  44269. set vignetteStretch(value: number);
  44270. /**
  44271. * Gets Vignette centre X Offset.
  44272. */
  44273. get vignetteCentreX(): number;
  44274. /**
  44275. * Sets Vignette centre X Offset.
  44276. */
  44277. set vignetteCentreX(value: number);
  44278. /**
  44279. * Gets Vignette centre Y Offset.
  44280. */
  44281. get vignetteCentreY(): number;
  44282. /**
  44283. * Sets Vignette centre Y Offset.
  44284. */
  44285. set vignetteCentreY(value: number);
  44286. /**
  44287. * Gets Vignette weight or intensity of the vignette effect.
  44288. */
  44289. get vignetteWeight(): number;
  44290. /**
  44291. * Sets Vignette weight or intensity of the vignette effect.
  44292. */
  44293. set vignetteWeight(value: number);
  44294. /**
  44295. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44296. * if vignetteEnabled is set to true.
  44297. */
  44298. get vignetteColor(): Color4;
  44299. /**
  44300. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44301. * if vignetteEnabled is set to true.
  44302. */
  44303. set vignetteColor(value: Color4);
  44304. /**
  44305. * Gets Camera field of view used by the Vignette effect.
  44306. */
  44307. get vignetteCameraFov(): number;
  44308. /**
  44309. * Sets Camera field of view used by the Vignette effect.
  44310. */
  44311. set vignetteCameraFov(value: number);
  44312. /**
  44313. * Gets the vignette blend mode allowing different kind of effect.
  44314. */
  44315. get vignetteBlendMode(): number;
  44316. /**
  44317. * Sets the vignette blend mode allowing different kind of effect.
  44318. */
  44319. set vignetteBlendMode(value: number);
  44320. /**
  44321. * Gets wether the vignette effect is enabled.
  44322. */
  44323. get vignetteEnabled(): boolean;
  44324. /**
  44325. * Sets wether the vignette effect is enabled.
  44326. */
  44327. set vignetteEnabled(value: boolean);
  44328. private _fromLinearSpace;
  44329. /**
  44330. * Gets wether the input of the processing is in Gamma or Linear Space.
  44331. */
  44332. get fromLinearSpace(): boolean;
  44333. /**
  44334. * Sets wether the input of the processing is in Gamma or Linear Space.
  44335. */
  44336. set fromLinearSpace(value: boolean);
  44337. /**
  44338. * Defines cache preventing GC.
  44339. */
  44340. private _defines;
  44341. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44342. /**
  44343. * "ImageProcessingPostProcess"
  44344. * @returns "ImageProcessingPostProcess"
  44345. */
  44346. getClassName(): string;
  44347. protected _updateParameters(): void;
  44348. dispose(camera?: Camera): void;
  44349. }
  44350. }
  44351. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44352. import { Scene } from "babylonjs/scene";
  44353. import { Color3 } from "babylonjs/Maths/math.color";
  44354. import { Mesh } from "babylonjs/Meshes/mesh";
  44355. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44356. import { Nullable } from "babylonjs/types";
  44357. /**
  44358. * Class containing static functions to help procedurally build meshes
  44359. */
  44360. export class GroundBuilder {
  44361. /**
  44362. * Creates a ground mesh
  44363. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44364. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44366. * @param name defines the name of the mesh
  44367. * @param options defines the options used to create the mesh
  44368. * @param scene defines the hosting scene
  44369. * @returns the ground mesh
  44370. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44371. */
  44372. static CreateGround(name: string, options: {
  44373. width?: number;
  44374. height?: number;
  44375. subdivisions?: number;
  44376. subdivisionsX?: number;
  44377. subdivisionsY?: number;
  44378. updatable?: boolean;
  44379. }, scene: any): Mesh;
  44380. /**
  44381. * Creates a tiled ground mesh
  44382. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44383. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44384. * * 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
  44385. * * 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
  44386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44387. * @param name defines the name of the mesh
  44388. * @param options defines the options used to create the mesh
  44389. * @param scene defines the hosting scene
  44390. * @returns the tiled ground mesh
  44391. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44392. */
  44393. static CreateTiledGround(name: string, options: {
  44394. xmin: number;
  44395. zmin: number;
  44396. xmax: number;
  44397. zmax: number;
  44398. subdivisions?: {
  44399. w: number;
  44400. h: number;
  44401. };
  44402. precision?: {
  44403. w: number;
  44404. h: number;
  44405. };
  44406. updatable?: boolean;
  44407. }, scene?: Nullable<Scene>): Mesh;
  44408. /**
  44409. * Creates a ground mesh from a height map
  44410. * * The parameter `url` sets the URL of the height map image resource.
  44411. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44412. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44413. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44414. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44415. * * 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.
  44416. * * 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).
  44417. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44419. * @param name defines the name of the mesh
  44420. * @param url defines the url to the height map
  44421. * @param options defines the options used to create the mesh
  44422. * @param scene defines the hosting scene
  44423. * @returns the ground mesh
  44424. * @see https://doc.babylonjs.com/babylon101/height_map
  44425. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44426. */
  44427. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44428. width?: number;
  44429. height?: number;
  44430. subdivisions?: number;
  44431. minHeight?: number;
  44432. maxHeight?: number;
  44433. colorFilter?: Color3;
  44434. alphaFilter?: number;
  44435. updatable?: boolean;
  44436. onReady?: (mesh: GroundMesh) => void;
  44437. }, scene?: Nullable<Scene>): GroundMesh;
  44438. }
  44439. }
  44440. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44441. import { Vector4 } from "babylonjs/Maths/math.vector";
  44442. import { Mesh } from "babylonjs/Meshes/mesh";
  44443. /**
  44444. * Class containing static functions to help procedurally build meshes
  44445. */
  44446. export class TorusBuilder {
  44447. /**
  44448. * Creates a torus mesh
  44449. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44450. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44451. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44455. * @param name defines the name of the mesh
  44456. * @param options defines the options used to create the mesh
  44457. * @param scene defines the hosting scene
  44458. * @returns the torus mesh
  44459. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44460. */
  44461. static CreateTorus(name: string, options: {
  44462. diameter?: number;
  44463. thickness?: number;
  44464. tessellation?: number;
  44465. updatable?: boolean;
  44466. sideOrientation?: number;
  44467. frontUVs?: Vector4;
  44468. backUVs?: Vector4;
  44469. }, scene: any): Mesh;
  44470. }
  44471. }
  44472. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44473. import { Vector4 } from "babylonjs/Maths/math.vector";
  44474. import { Color4 } from "babylonjs/Maths/math.color";
  44475. import { Mesh } from "babylonjs/Meshes/mesh";
  44476. /**
  44477. * Class containing static functions to help procedurally build meshes
  44478. */
  44479. export class CylinderBuilder {
  44480. /**
  44481. * Creates a cylinder or a cone mesh
  44482. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44483. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44484. * * 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.
  44485. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44486. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44487. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44488. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44489. * * 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).
  44490. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44491. * * 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).
  44492. * * 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
  44493. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44494. * * 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
  44495. * * 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.
  44496. * * If `enclose` is false, a ring surface is one element.
  44497. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44498. * * 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
  44499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44502. * @param name defines the name of the mesh
  44503. * @param options defines the options used to create the mesh
  44504. * @param scene defines the hosting scene
  44505. * @returns the cylinder mesh
  44506. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44507. */
  44508. static CreateCylinder(name: string, options: {
  44509. height?: number;
  44510. diameterTop?: number;
  44511. diameterBottom?: number;
  44512. diameter?: number;
  44513. tessellation?: number;
  44514. subdivisions?: number;
  44515. arc?: number;
  44516. faceColors?: Color4[];
  44517. faceUV?: Vector4[];
  44518. updatable?: boolean;
  44519. hasRings?: boolean;
  44520. enclose?: boolean;
  44521. cap?: number;
  44522. sideOrientation?: number;
  44523. frontUVs?: Vector4;
  44524. backUVs?: Vector4;
  44525. }, scene: any): Mesh;
  44526. }
  44527. }
  44528. declare module "babylonjs/XR/webXRTypes" {
  44529. import { Nullable } from "babylonjs/types";
  44530. import { IDisposable } from "babylonjs/scene";
  44531. /**
  44532. * States of the webXR experience
  44533. */
  44534. export enum WebXRState {
  44535. /**
  44536. * Transitioning to being in XR mode
  44537. */
  44538. ENTERING_XR = 0,
  44539. /**
  44540. * Transitioning to non XR mode
  44541. */
  44542. EXITING_XR = 1,
  44543. /**
  44544. * In XR mode and presenting
  44545. */
  44546. IN_XR = 2,
  44547. /**
  44548. * Not entered XR mode
  44549. */
  44550. NOT_IN_XR = 3
  44551. }
  44552. /**
  44553. * Abstraction of the XR render target
  44554. */
  44555. export interface WebXRRenderTarget extends IDisposable {
  44556. /**
  44557. * xrpresent context of the canvas which can be used to display/mirror xr content
  44558. */
  44559. canvasContext: WebGLRenderingContext;
  44560. /**
  44561. * xr layer for the canvas
  44562. */
  44563. xrLayer: Nullable<XRWebGLLayer>;
  44564. /**
  44565. * Initializes the xr layer for the session
  44566. * @param xrSession xr session
  44567. * @returns a promise that will resolve once the XR Layer has been created
  44568. */
  44569. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44570. }
  44571. }
  44572. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44573. import { Nullable } from "babylonjs/types";
  44574. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44575. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44576. /**
  44577. * COnfiguration object for WebXR output canvas
  44578. */
  44579. export class WebXRManagedOutputCanvasOptions {
  44580. /**
  44581. * An optional canvas in case you wish to create it yourself and provide it here.
  44582. * If not provided, a new canvas will be created
  44583. */
  44584. canvasElement?: HTMLCanvasElement;
  44585. /**
  44586. * Options for this XR Layer output
  44587. */
  44588. canvasOptions?: XRWebGLLayerOptions;
  44589. /**
  44590. * CSS styling for a newly created canvas (if not provided)
  44591. */
  44592. newCanvasCssStyle?: string;
  44593. /**
  44594. * Get the default values of the configuration object
  44595. * @returns default values of this configuration object
  44596. */
  44597. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44598. }
  44599. /**
  44600. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44601. */
  44602. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44603. private _options;
  44604. private _canvas;
  44605. private _engine;
  44606. /**
  44607. * Rendering context of the canvas which can be used to display/mirror xr content
  44608. */
  44609. canvasContext: WebGLRenderingContext;
  44610. /**
  44611. * xr layer for the canvas
  44612. */
  44613. xrLayer: Nullable<XRWebGLLayer>;
  44614. /**
  44615. * Initializes the canvas to be added/removed upon entering/exiting xr
  44616. * @param _xrSessionManager The XR Session manager
  44617. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44618. */
  44619. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44620. /**
  44621. * Disposes of the object
  44622. */
  44623. dispose(): void;
  44624. /**
  44625. * Initializes the xr layer for the session
  44626. * @param xrSession xr session
  44627. * @returns a promise that will resolve once the XR Layer has been created
  44628. */
  44629. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44630. private _addCanvas;
  44631. private _removeCanvas;
  44632. private _setManagedOutputCanvas;
  44633. }
  44634. }
  44635. declare module "babylonjs/XR/webXRSessionManager" {
  44636. import { Observable } from "babylonjs/Misc/observable";
  44637. import { Nullable } from "babylonjs/types";
  44638. import { IDisposable, Scene } from "babylonjs/scene";
  44639. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44640. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44641. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44642. /**
  44643. * Manages an XRSession to work with Babylon's engine
  44644. * @see https://doc.babylonjs.com/how_to/webxr
  44645. */
  44646. export class WebXRSessionManager implements IDisposable {
  44647. /** The scene which the session should be created for */
  44648. scene: Scene;
  44649. private _referenceSpace;
  44650. private _rttProvider;
  44651. private _sessionEnded;
  44652. private _xrNavigator;
  44653. private baseLayer;
  44654. /**
  44655. * The base reference space from which the session started. good if you want to reset your
  44656. * reference space
  44657. */
  44658. baseReferenceSpace: XRReferenceSpace;
  44659. /**
  44660. * Current XR frame
  44661. */
  44662. currentFrame: Nullable<XRFrame>;
  44663. /** WebXR timestamp updated every frame */
  44664. currentTimestamp: number;
  44665. /**
  44666. * Used just in case of a failure to initialize an immersive session.
  44667. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44668. */
  44669. defaultHeightCompensation: number;
  44670. /**
  44671. * Fires every time a new xrFrame arrives which can be used to update the camera
  44672. */
  44673. onXRFrameObservable: Observable<XRFrame>;
  44674. /**
  44675. * Fires when the reference space changed
  44676. */
  44677. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44678. /**
  44679. * Fires when the xr session is ended either by the device or manually done
  44680. */
  44681. onXRSessionEnded: Observable<any>;
  44682. /**
  44683. * Fires when the xr session is ended either by the device or manually done
  44684. */
  44685. onXRSessionInit: Observable<XRSession>;
  44686. /**
  44687. * Underlying xr session
  44688. */
  44689. session: XRSession;
  44690. /**
  44691. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44692. * or get the offset the player is currently at.
  44693. */
  44694. viewerReferenceSpace: XRReferenceSpace;
  44695. /**
  44696. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44697. * @param scene The scene which the session should be created for
  44698. */
  44699. constructor(
  44700. /** The scene which the session should be created for */
  44701. scene: Scene);
  44702. /**
  44703. * The current reference space used in this session. This reference space can constantly change!
  44704. * It is mainly used to offset the camera's position.
  44705. */
  44706. get referenceSpace(): XRReferenceSpace;
  44707. /**
  44708. * Set a new reference space and triggers the observable
  44709. */
  44710. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44711. /**
  44712. * Disposes of the session manager
  44713. */
  44714. dispose(): void;
  44715. /**
  44716. * Stops the xrSession and restores the render loop
  44717. * @returns Promise which resolves after it exits XR
  44718. */
  44719. exitXRAsync(): Promise<void>;
  44720. /**
  44721. * Gets the correct render target texture to be rendered this frame for this eye
  44722. * @param eye the eye for which to get the render target
  44723. * @returns the render target for the specified eye
  44724. */
  44725. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44726. /**
  44727. * Creates a WebXRRenderTarget object for the XR session
  44728. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44729. * @param options optional options to provide when creating a new render target
  44730. * @returns a WebXR render target to which the session can render
  44731. */
  44732. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44733. /**
  44734. * Initializes the manager
  44735. * After initialization enterXR can be called to start an XR session
  44736. * @returns Promise which resolves after it is initialized
  44737. */
  44738. initializeAsync(): Promise<void>;
  44739. /**
  44740. * Initializes an xr session
  44741. * @param xrSessionMode mode to initialize
  44742. * @param xrSessionInit defines optional and required values to pass to the session builder
  44743. * @returns a promise which will resolve once the session has been initialized
  44744. */
  44745. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44746. /**
  44747. * Checks if a session would be supported for the creation options specified
  44748. * @param sessionMode session mode to check if supported eg. immersive-vr
  44749. * @returns A Promise that resolves to true if supported and false if not
  44750. */
  44751. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44752. /**
  44753. * Resets the reference space to the one started the session
  44754. */
  44755. resetReferenceSpace(): void;
  44756. /**
  44757. * Starts rendering to the xr layer
  44758. */
  44759. runXRRenderLoop(): void;
  44760. /**
  44761. * Sets the reference space on the xr session
  44762. * @param referenceSpaceType space to set
  44763. * @returns a promise that will resolve once the reference space has been set
  44764. */
  44765. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44766. /**
  44767. * Updates the render state of the session
  44768. * @param state state to set
  44769. * @returns a promise that resolves once the render state has been updated
  44770. */
  44771. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44772. /**
  44773. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44774. * @param sessionMode defines the session to test
  44775. * @returns a promise with boolean as final value
  44776. */
  44777. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44778. private _createRenderTargetTexture;
  44779. }
  44780. }
  44781. declare module "babylonjs/XR/webXRCamera" {
  44782. import { Scene } from "babylonjs/scene";
  44783. import { Camera } from "babylonjs/Cameras/camera";
  44784. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44785. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44786. /**
  44787. * WebXR Camera which holds the views for the xrSession
  44788. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44789. */
  44790. export class WebXRCamera extends FreeCamera {
  44791. private _xrSessionManager;
  44792. private _firstFrame;
  44793. private _referenceQuaternion;
  44794. private _referencedPosition;
  44795. private _xrInvPositionCache;
  44796. private _xrInvQuaternionCache;
  44797. /**
  44798. * Should position compensation execute on first frame.
  44799. * This is used when copying the position from a native (non XR) camera
  44800. */
  44801. compensateOnFirstFrame: boolean;
  44802. /**
  44803. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44804. * @param name the name of the camera
  44805. * @param scene the scene to add the camera to
  44806. * @param _xrSessionManager a constructed xr session manager
  44807. */
  44808. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44809. /**
  44810. * Return the user's height, unrelated to the current ground.
  44811. * This will be the y position of this camera, when ground level is 0.
  44812. */
  44813. get realWorldHeight(): number;
  44814. /** @hidden */
  44815. _updateForDualEyeDebugging(): void;
  44816. /**
  44817. * Sets this camera's transformation based on a non-vr camera
  44818. * @param otherCamera the non-vr camera to copy the transformation from
  44819. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44820. */
  44821. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44822. /**
  44823. * Gets the current instance class name ("WebXRCamera").
  44824. * @returns the class name
  44825. */
  44826. getClassName(): string;
  44827. private _updateFromXRSession;
  44828. private _updateNumberOfRigCameras;
  44829. private _updateReferenceSpace;
  44830. private _updateReferenceSpaceOffset;
  44831. }
  44832. }
  44833. declare module "babylonjs/XR/webXRFeaturesManager" {
  44834. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44835. import { IDisposable } from "babylonjs/scene";
  44836. /**
  44837. * Defining the interface required for a (webxr) feature
  44838. */
  44839. export interface IWebXRFeature extends IDisposable {
  44840. /**
  44841. * Is this feature attached
  44842. */
  44843. attached: boolean;
  44844. /**
  44845. * Should auto-attach be disabled?
  44846. */
  44847. disableAutoAttach: boolean;
  44848. /**
  44849. * Attach the feature to the session
  44850. * Will usually be called by the features manager
  44851. *
  44852. * @param force should attachment be forced (even when already attached)
  44853. * @returns true if successful.
  44854. */
  44855. attach(force?: boolean): boolean;
  44856. /**
  44857. * Detach the feature from the session
  44858. * Will usually be called by the features manager
  44859. *
  44860. * @returns true if successful.
  44861. */
  44862. detach(): boolean;
  44863. }
  44864. /**
  44865. * A list of the currently available features without referencing them
  44866. */
  44867. export class WebXRFeatureName {
  44868. /**
  44869. * The name of the anchor system feature
  44870. */
  44871. static ANCHOR_SYSTEM: string;
  44872. /**
  44873. * The name of the background remover feature
  44874. */
  44875. static BACKGROUND_REMOVER: string;
  44876. /**
  44877. * The name of the hit test feature
  44878. */
  44879. static HIT_TEST: string;
  44880. /**
  44881. * physics impostors for xr controllers feature
  44882. */
  44883. static PHYSICS_CONTROLLERS: string;
  44884. /**
  44885. * The name of the plane detection feature
  44886. */
  44887. static PLANE_DETECTION: string;
  44888. /**
  44889. * The name of the pointer selection feature
  44890. */
  44891. static POINTER_SELECTION: string;
  44892. /**
  44893. * The name of the teleportation feature
  44894. */
  44895. static TELEPORTATION: string;
  44896. }
  44897. /**
  44898. * Defining the constructor of a feature. Used to register the modules.
  44899. */
  44900. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44901. /**
  44902. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44903. * It is mainly used in AR sessions.
  44904. *
  44905. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44906. */
  44907. export class WebXRFeaturesManager implements IDisposable {
  44908. private _xrSessionManager;
  44909. private static readonly _AvailableFeatures;
  44910. private _features;
  44911. /**
  44912. * constructs a new features manages.
  44913. *
  44914. * @param _xrSessionManager an instance of WebXRSessionManager
  44915. */
  44916. constructor(_xrSessionManager: WebXRSessionManager);
  44917. /**
  44918. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44919. * Mainly used internally.
  44920. *
  44921. * @param featureName the name of the feature to register
  44922. * @param constructorFunction the function used to construct the module
  44923. * @param version the (babylon) version of the module
  44924. * @param stable is that a stable version of this module
  44925. */
  44926. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44927. /**
  44928. * Returns a constructor of a specific feature.
  44929. *
  44930. * @param featureName the name of the feature to construct
  44931. * @param version the version of the feature to load
  44932. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44933. * @param options optional options provided to the module.
  44934. * @returns a function that, when called, will return a new instance of this feature
  44935. */
  44936. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44937. /**
  44938. * Can be used to return the list of features currently registered
  44939. *
  44940. * @returns an Array of available features
  44941. */
  44942. static GetAvailableFeatures(): string[];
  44943. /**
  44944. * Gets the versions available for a specific feature
  44945. * @param featureName the name of the feature
  44946. * @returns an array with the available versions
  44947. */
  44948. static GetAvailableVersions(featureName: string): string[];
  44949. /**
  44950. * Return the latest unstable version of this feature
  44951. * @param featureName the name of the feature to search
  44952. * @returns the version number. if not found will return -1
  44953. */
  44954. static GetLatestVersionOfFeature(featureName: string): number;
  44955. /**
  44956. * Return the latest stable version of this feature
  44957. * @param featureName the name of the feature to search
  44958. * @returns the version number. if not found will return -1
  44959. */
  44960. static GetStableVersionOfFeature(featureName: string): number;
  44961. /**
  44962. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44963. * Can be used during a session to start a feature
  44964. * @param featureName the name of feature to attach
  44965. */
  44966. attachFeature(featureName: string): void;
  44967. /**
  44968. * Can be used inside a session or when the session ends to detach a specific feature
  44969. * @param featureName the name of the feature to detach
  44970. */
  44971. detachFeature(featureName: string): void;
  44972. /**
  44973. * Used to disable an already-enabled feature
  44974. * The feature will be disposed and will be recreated once enabled.
  44975. * @param featureName the feature to disable
  44976. * @returns true if disable was successful
  44977. */
  44978. disableFeature(featureName: string | {
  44979. Name: string;
  44980. }): boolean;
  44981. /**
  44982. * dispose this features manager
  44983. */
  44984. dispose(): void;
  44985. /**
  44986. * 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.
  44987. * 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.
  44988. *
  44989. * @param featureName the name of the feature to load or the class of the feature
  44990. * @param version optional version to load. if not provided the latest version will be enabled
  44991. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44992. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44993. * @returns a new constructed feature or throws an error if feature not found.
  44994. */
  44995. enableFeature(featureName: string | {
  44996. Name: string;
  44997. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44998. /**
  44999. * get the implementation of an enabled feature.
  45000. * @param featureName the name of the feature to load
  45001. * @returns the feature class, if found
  45002. */
  45003. getEnabledFeature(featureName: string): IWebXRFeature;
  45004. /**
  45005. * Get the list of enabled features
  45006. * @returns an array of enabled features
  45007. */
  45008. getEnabledFeatures(): string[];
  45009. }
  45010. }
  45011. declare module "babylonjs/XR/webXRExperienceHelper" {
  45012. import { Observable } from "babylonjs/Misc/observable";
  45013. import { IDisposable, Scene } from "babylonjs/scene";
  45014. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45015. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45016. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  45017. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  45018. /**
  45019. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45020. * @see https://doc.babylonjs.com/how_to/webxr
  45021. */
  45022. export class WebXRExperienceHelper implements IDisposable {
  45023. private scene;
  45024. private _nonVRCamera;
  45025. private _originalSceneAutoClear;
  45026. private _supported;
  45027. /**
  45028. * Camera used to render xr content
  45029. */
  45030. camera: WebXRCamera;
  45031. /** A features manager for this xr session */
  45032. featuresManager: WebXRFeaturesManager;
  45033. /**
  45034. * Observers registered here will be triggered after the camera's initial transformation is set
  45035. * This can be used to set a different ground level or an extra rotation.
  45036. *
  45037. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45038. * to the position set after this observable is done executing.
  45039. */
  45040. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45041. /**
  45042. * Fires when the state of the experience helper has changed
  45043. */
  45044. onStateChangedObservable: Observable<WebXRState>;
  45045. /** Session manager used to keep track of xr session */
  45046. sessionManager: WebXRSessionManager;
  45047. /**
  45048. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  45049. */
  45050. state: WebXRState;
  45051. /**
  45052. * Creates a WebXRExperienceHelper
  45053. * @param scene The scene the helper should be created in
  45054. */
  45055. private constructor();
  45056. /**
  45057. * Creates the experience helper
  45058. * @param scene the scene to attach the experience helper to
  45059. * @returns a promise for the experience helper
  45060. */
  45061. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  45062. /**
  45063. * Disposes of the experience helper
  45064. */
  45065. dispose(): void;
  45066. /**
  45067. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  45068. * @param sessionMode options for the XR session
  45069. * @param referenceSpaceType frame of reference of the XR session
  45070. * @param renderTarget the output canvas that will be used to enter XR mode
  45071. * @returns promise that resolves after xr mode has entered
  45072. */
  45073. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  45074. /**
  45075. * Exits XR mode and returns the scene to its original state
  45076. * @returns promise that resolves after xr mode has exited
  45077. */
  45078. exitXRAsync(): Promise<void>;
  45079. private _nonXRToXRCamera;
  45080. private _setState;
  45081. }
  45082. }
  45083. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  45084. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45085. import { Observable } from "babylonjs/Misc/observable";
  45086. import { IDisposable } from "babylonjs/scene";
  45087. /**
  45088. * X-Y values for axes in WebXR
  45089. */
  45090. export interface IWebXRMotionControllerAxesValue {
  45091. /**
  45092. * The value of the x axis
  45093. */
  45094. x: number;
  45095. /**
  45096. * The value of the y-axis
  45097. */
  45098. y: number;
  45099. }
  45100. /**
  45101. * changed / previous values for the values of this component
  45102. */
  45103. export interface IWebXRMotionControllerComponentChangesValues<T> {
  45104. /**
  45105. * current (this frame) value
  45106. */
  45107. current: T;
  45108. /**
  45109. * previous (last change) value
  45110. */
  45111. previous: T;
  45112. }
  45113. /**
  45114. * Represents changes in the component between current frame and last values recorded
  45115. */
  45116. export interface IWebXRMotionControllerComponentChanges {
  45117. /**
  45118. * will be populated with previous and current values if axes changed
  45119. */
  45120. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  45121. /**
  45122. * will be populated with previous and current values if pressed changed
  45123. */
  45124. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45125. /**
  45126. * will be populated with previous and current values if touched changed
  45127. */
  45128. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  45129. /**
  45130. * will be populated with previous and current values if value changed
  45131. */
  45132. value?: IWebXRMotionControllerComponentChangesValues<number>;
  45133. }
  45134. /**
  45135. * This class represents a single component (for example button or thumbstick) of a motion controller
  45136. */
  45137. export class WebXRControllerComponent implements IDisposable {
  45138. /**
  45139. * the id of this component
  45140. */
  45141. id: string;
  45142. /**
  45143. * the type of the component
  45144. */
  45145. type: MotionControllerComponentType;
  45146. private _buttonIndex;
  45147. private _axesIndices;
  45148. private _axes;
  45149. private _changes;
  45150. private _currentValue;
  45151. private _hasChanges;
  45152. private _pressed;
  45153. private _touched;
  45154. /**
  45155. * button component type
  45156. */
  45157. static BUTTON_TYPE: MotionControllerComponentType;
  45158. /**
  45159. * squeeze component type
  45160. */
  45161. static SQUEEZE_TYPE: MotionControllerComponentType;
  45162. /**
  45163. * Thumbstick component type
  45164. */
  45165. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45166. /**
  45167. * Touchpad component type
  45168. */
  45169. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45170. /**
  45171. * trigger component type
  45172. */
  45173. static TRIGGER_TYPE: MotionControllerComponentType;
  45174. /**
  45175. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45176. * the axes data changes
  45177. */
  45178. onAxisValueChangedObservable: Observable<{
  45179. x: number;
  45180. y: number;
  45181. }>;
  45182. /**
  45183. * Observers registered here will be triggered when the state of a button changes
  45184. * State change is either pressed / touched / value
  45185. */
  45186. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45187. /**
  45188. * Creates a new component for a motion controller.
  45189. * It is created by the motion controller itself
  45190. *
  45191. * @param id the id of this component
  45192. * @param type the type of the component
  45193. * @param _buttonIndex index in the buttons array of the gamepad
  45194. * @param _axesIndices indices of the values in the axes array of the gamepad
  45195. */
  45196. constructor(
  45197. /**
  45198. * the id of this component
  45199. */
  45200. id: string,
  45201. /**
  45202. * the type of the component
  45203. */
  45204. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45205. /**
  45206. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45207. */
  45208. get axes(): IWebXRMotionControllerAxesValue;
  45209. /**
  45210. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45211. */
  45212. get changes(): IWebXRMotionControllerComponentChanges;
  45213. /**
  45214. * Return whether or not the component changed the last frame
  45215. */
  45216. get hasChanges(): boolean;
  45217. /**
  45218. * is the button currently pressed
  45219. */
  45220. get pressed(): boolean;
  45221. /**
  45222. * is the button currently touched
  45223. */
  45224. get touched(): boolean;
  45225. /**
  45226. * Get the current value of this component
  45227. */
  45228. get value(): number;
  45229. /**
  45230. * Dispose this component
  45231. */
  45232. dispose(): void;
  45233. /**
  45234. * Are there axes correlating to this component
  45235. * @return true is axes data is available
  45236. */
  45237. isAxes(): boolean;
  45238. /**
  45239. * Is this component a button (hence - pressable)
  45240. * @returns true if can be pressed
  45241. */
  45242. isButton(): boolean;
  45243. /**
  45244. * update this component using the gamepad object it is in. Called on every frame
  45245. * @param nativeController the native gamepad controller object
  45246. */
  45247. update(nativeController: IMinimalMotionControllerObject): void;
  45248. }
  45249. }
  45250. declare module "babylonjs/Loading/sceneLoader" {
  45251. import { Observable } from "babylonjs/Misc/observable";
  45252. import { Nullable } from "babylonjs/types";
  45253. import { Scene } from "babylonjs/scene";
  45254. import { Engine } from "babylonjs/Engines/engine";
  45255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45256. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45257. import { AssetContainer } from "babylonjs/assetContainer";
  45258. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45259. import { Skeleton } from "babylonjs/Bones/skeleton";
  45260. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45261. import { WebRequest } from "babylonjs/Misc/webRequest";
  45262. /**
  45263. * Class used to represent data loading progression
  45264. */
  45265. export class SceneLoaderProgressEvent {
  45266. /** defines if data length to load can be evaluated */
  45267. readonly lengthComputable: boolean;
  45268. /** defines the loaded data length */
  45269. readonly loaded: number;
  45270. /** defines the data length to load */
  45271. readonly total: number;
  45272. /**
  45273. * Create a new progress event
  45274. * @param lengthComputable defines if data length to load can be evaluated
  45275. * @param loaded defines the loaded data length
  45276. * @param total defines the data length to load
  45277. */
  45278. constructor(
  45279. /** defines if data length to load can be evaluated */
  45280. lengthComputable: boolean,
  45281. /** defines the loaded data length */
  45282. loaded: number,
  45283. /** defines the data length to load */
  45284. total: number);
  45285. /**
  45286. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45287. * @param event defines the source event
  45288. * @returns a new SceneLoaderProgressEvent
  45289. */
  45290. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45291. }
  45292. /**
  45293. * Interface used by SceneLoader plugins to define supported file extensions
  45294. */
  45295. export interface ISceneLoaderPluginExtensions {
  45296. /**
  45297. * Defines the list of supported extensions
  45298. */
  45299. [extension: string]: {
  45300. isBinary: boolean;
  45301. };
  45302. }
  45303. /**
  45304. * Interface used by SceneLoader plugin factory
  45305. */
  45306. export interface ISceneLoaderPluginFactory {
  45307. /**
  45308. * Defines the name of the factory
  45309. */
  45310. name: string;
  45311. /**
  45312. * Function called to create a new plugin
  45313. * @return the new plugin
  45314. */
  45315. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45316. /**
  45317. * The callback that returns true if the data can be directly loaded.
  45318. * @param data string containing the file data
  45319. * @returns if the data can be loaded directly
  45320. */
  45321. canDirectLoad?(data: string): boolean;
  45322. }
  45323. /**
  45324. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45325. */
  45326. export interface ISceneLoaderPluginBase {
  45327. /**
  45328. * The friendly name of this plugin.
  45329. */
  45330. name: string;
  45331. /**
  45332. * The file extensions supported by this plugin.
  45333. */
  45334. extensions: string | ISceneLoaderPluginExtensions;
  45335. /**
  45336. * The callback called when loading from a url.
  45337. * @param scene scene loading this url
  45338. * @param url url to load
  45339. * @param onSuccess callback called when the file successfully loads
  45340. * @param onProgress callback called while file is loading (if the server supports this mode)
  45341. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45342. * @param onError callback called when the file fails to load
  45343. * @returns a file request object
  45344. */
  45345. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45346. /**
  45347. * The callback called when loading from a file object.
  45348. * @param scene scene loading this file
  45349. * @param file defines the file to load
  45350. * @param onSuccess defines the callback to call when data is loaded
  45351. * @param onProgress defines the callback to call during loading process
  45352. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45353. * @param onError defines the callback to call when an error occurs
  45354. * @returns a file request object
  45355. */
  45356. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45357. /**
  45358. * The callback that returns true if the data can be directly loaded.
  45359. * @param data string containing the file data
  45360. * @returns if the data can be loaded directly
  45361. */
  45362. canDirectLoad?(data: string): boolean;
  45363. /**
  45364. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45365. * @param scene scene loading this data
  45366. * @param data string containing the data
  45367. * @returns data to pass to the plugin
  45368. */
  45369. directLoad?(scene: Scene, data: string): any;
  45370. /**
  45371. * The callback that allows custom handling of the root url based on the response url.
  45372. * @param rootUrl the original root url
  45373. * @param responseURL the response url if available
  45374. * @returns the new root url
  45375. */
  45376. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45377. }
  45378. /**
  45379. * Interface used to define a SceneLoader plugin
  45380. */
  45381. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45382. /**
  45383. * Import meshes into a scene.
  45384. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45385. * @param scene The scene to import into
  45386. * @param data The data to import
  45387. * @param rootUrl The root url for scene and resources
  45388. * @param meshes The meshes array to import into
  45389. * @param particleSystems The particle systems array to import into
  45390. * @param skeletons The skeletons array to import into
  45391. * @param onError The callback when import fails
  45392. * @returns True if successful or false otherwise
  45393. */
  45394. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45395. /**
  45396. * Load into a scene.
  45397. * @param scene The scene to load into
  45398. * @param data The data to import
  45399. * @param rootUrl The root url for scene and resources
  45400. * @param onError The callback when import fails
  45401. * @returns True if successful or false otherwise
  45402. */
  45403. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45404. /**
  45405. * Load into an asset container.
  45406. * @param scene The scene to load into
  45407. * @param data The data to import
  45408. * @param rootUrl The root url for scene and resources
  45409. * @param onError The callback when import fails
  45410. * @returns The loaded asset container
  45411. */
  45412. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45413. }
  45414. /**
  45415. * Interface used to define an async SceneLoader plugin
  45416. */
  45417. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45418. /**
  45419. * Import meshes into a scene.
  45420. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45421. * @param scene The scene to import into
  45422. * @param data The data to import
  45423. * @param rootUrl The root url for scene and resources
  45424. * @param onProgress The callback when the load progresses
  45425. * @param fileName Defines the name of the file to load
  45426. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45427. */
  45428. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45429. meshes: AbstractMesh[];
  45430. particleSystems: IParticleSystem[];
  45431. skeletons: Skeleton[];
  45432. animationGroups: AnimationGroup[];
  45433. }>;
  45434. /**
  45435. * Load into a scene.
  45436. * @param scene The scene to load into
  45437. * @param data The data to import
  45438. * @param rootUrl The root url for scene and resources
  45439. * @param onProgress The callback when the load progresses
  45440. * @param fileName Defines the name of the file to load
  45441. * @returns Nothing
  45442. */
  45443. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45444. /**
  45445. * Load into an asset container.
  45446. * @param scene The scene to load into
  45447. * @param data The data to import
  45448. * @param rootUrl The root url for scene and resources
  45449. * @param onProgress The callback when the load progresses
  45450. * @param fileName Defines the name of the file to load
  45451. * @returns The loaded asset container
  45452. */
  45453. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45454. }
  45455. /**
  45456. * Mode that determines how to handle old animation groups before loading new ones.
  45457. */
  45458. export enum SceneLoaderAnimationGroupLoadingMode {
  45459. /**
  45460. * Reset all old animations to initial state then dispose them.
  45461. */
  45462. Clean = 0,
  45463. /**
  45464. * Stop all old animations.
  45465. */
  45466. Stop = 1,
  45467. /**
  45468. * Restart old animations from first frame.
  45469. */
  45470. Sync = 2,
  45471. /**
  45472. * Old animations remains untouched.
  45473. */
  45474. NoSync = 3
  45475. }
  45476. /**
  45477. * Class used to load scene from various file formats using registered plugins
  45478. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45479. */
  45480. export class SceneLoader {
  45481. /**
  45482. * No logging while loading
  45483. */
  45484. static readonly NO_LOGGING: number;
  45485. /**
  45486. * Minimal logging while loading
  45487. */
  45488. static readonly MINIMAL_LOGGING: number;
  45489. /**
  45490. * Summary logging while loading
  45491. */
  45492. static readonly SUMMARY_LOGGING: number;
  45493. /**
  45494. * Detailled logging while loading
  45495. */
  45496. static readonly DETAILED_LOGGING: number;
  45497. /**
  45498. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45499. */
  45500. static get ForceFullSceneLoadingForIncremental(): boolean;
  45501. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45502. /**
  45503. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45504. */
  45505. static get ShowLoadingScreen(): boolean;
  45506. static set ShowLoadingScreen(value: boolean);
  45507. /**
  45508. * Defines the current logging level (while loading the scene)
  45509. * @ignorenaming
  45510. */
  45511. static get loggingLevel(): number;
  45512. static set loggingLevel(value: number);
  45513. /**
  45514. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45515. */
  45516. static get CleanBoneMatrixWeights(): boolean;
  45517. static set CleanBoneMatrixWeights(value: boolean);
  45518. /**
  45519. * Event raised when a plugin is used to load a scene
  45520. */
  45521. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45522. private static _registeredPlugins;
  45523. private static _getDefaultPlugin;
  45524. private static _getPluginForExtension;
  45525. private static _getPluginForDirectLoad;
  45526. private static _getPluginForFilename;
  45527. private static _getDirectLoad;
  45528. private static _loadData;
  45529. private static _getFileInfo;
  45530. /**
  45531. * Gets a plugin that can load the given extension
  45532. * @param extension defines the extension to load
  45533. * @returns a plugin or null if none works
  45534. */
  45535. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45536. /**
  45537. * Gets a boolean indicating that the given extension can be loaded
  45538. * @param extension defines the extension to load
  45539. * @returns true if the extension is supported
  45540. */
  45541. static IsPluginForExtensionAvailable(extension: string): boolean;
  45542. /**
  45543. * Adds a new plugin to the list of registered plugins
  45544. * @param plugin defines the plugin to add
  45545. */
  45546. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45547. /**
  45548. * Import meshes into a scene
  45549. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45550. * @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)
  45551. * @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)
  45552. * @param scene the instance of BABYLON.Scene to append to
  45553. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45554. * @param onProgress a callback with a progress event for each file being loaded
  45555. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45556. * @param pluginExtension the extension used to determine the plugin
  45557. * @returns The loaded plugin
  45558. */
  45559. 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>;
  45560. /**
  45561. * Import meshes into a scene
  45562. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45563. * @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)
  45564. * @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)
  45565. * @param scene the instance of BABYLON.Scene to append to
  45566. * @param onProgress a callback with a progress event for each file being loaded
  45567. * @param pluginExtension the extension used to determine the plugin
  45568. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45569. */
  45570. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45571. meshes: AbstractMesh[];
  45572. particleSystems: IParticleSystem[];
  45573. skeletons: Skeleton[];
  45574. animationGroups: AnimationGroup[];
  45575. }>;
  45576. /**
  45577. * Load a scene
  45578. * @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)
  45579. * @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)
  45580. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45581. * @param onSuccess a callback with the scene when import succeeds
  45582. * @param onProgress a callback with a progress event for each file being loaded
  45583. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45584. * @param pluginExtension the extension used to determine the plugin
  45585. * @returns The loaded plugin
  45586. */
  45587. 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>;
  45588. /**
  45589. * Load a scene
  45590. * @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)
  45591. * @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)
  45592. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45593. * @param onProgress a callback with a progress event for each file being loaded
  45594. * @param pluginExtension the extension used to determine the plugin
  45595. * @returns The loaded scene
  45596. */
  45597. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45598. /**
  45599. * Append a scene
  45600. * @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)
  45601. * @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)
  45602. * @param scene is the instance of BABYLON.Scene to append to
  45603. * @param onSuccess a callback with the scene when import succeeds
  45604. * @param onProgress a callback with a progress event for each file being loaded
  45605. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45606. * @param pluginExtension the extension used to determine the plugin
  45607. * @returns The loaded plugin
  45608. */
  45609. 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>;
  45610. /**
  45611. * Append a scene
  45612. * @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)
  45613. * @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)
  45614. * @param scene is the instance of BABYLON.Scene to append to
  45615. * @param onProgress a callback with a progress event for each file being loaded
  45616. * @param pluginExtension the extension used to determine the plugin
  45617. * @returns The given scene
  45618. */
  45619. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45620. /**
  45621. * Load a scene into an asset container
  45622. * @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)
  45623. * @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)
  45624. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45625. * @param onSuccess a callback with the scene when import succeeds
  45626. * @param onProgress a callback with a progress event for each file being loaded
  45627. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45628. * @param pluginExtension the extension used to determine the plugin
  45629. * @returns The loaded plugin
  45630. */
  45631. 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>;
  45632. /**
  45633. * Load a scene into an asset container
  45634. * @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)
  45635. * @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)
  45636. * @param scene is the instance of Scene to append to
  45637. * @param onProgress a callback with a progress event for each file being loaded
  45638. * @param pluginExtension the extension used to determine the plugin
  45639. * @returns The loaded asset container
  45640. */
  45641. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45642. /**
  45643. * Import animations from a file into a scene
  45644. * @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)
  45645. * @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)
  45646. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45647. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45648. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45649. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45650. * @param onSuccess a callback with the scene when import succeeds
  45651. * @param onProgress a callback with a progress event for each file being loaded
  45652. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45653. */
  45654. 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;
  45655. /**
  45656. * Import animations from a file into a scene
  45657. * @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)
  45658. * @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)
  45659. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45660. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45661. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45662. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45663. * @param onSuccess a callback with the scene when import succeeds
  45664. * @param onProgress a callback with a progress event for each file being loaded
  45665. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45666. * @returns the updated scene with imported animations
  45667. */
  45668. 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>;
  45669. }
  45670. }
  45671. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45672. import { IDisposable, Scene } from "babylonjs/scene";
  45673. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45674. import { Observable } from "babylonjs/Misc/observable";
  45675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45676. import { Nullable } from "babylonjs/types";
  45677. /**
  45678. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45679. */
  45680. export type MotionControllerHandedness = "none" | "left" | "right";
  45681. /**
  45682. * The type of components available in motion controllers.
  45683. * This is not the name of the component.
  45684. */
  45685. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45686. /**
  45687. * The state of a controller component
  45688. */
  45689. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45690. /**
  45691. * The schema of motion controller layout.
  45692. * No object will be initialized using this interface
  45693. * This is used just to define the profile.
  45694. */
  45695. export interface IMotionControllerLayout {
  45696. /**
  45697. * Path to load the assets. Usually relative to the base path
  45698. */
  45699. assetPath: string;
  45700. /**
  45701. * Available components (unsorted)
  45702. */
  45703. components: {
  45704. /**
  45705. * A map of component Ids
  45706. */
  45707. [componentId: string]: {
  45708. /**
  45709. * The type of input the component outputs
  45710. */
  45711. type: MotionControllerComponentType;
  45712. /**
  45713. * The indices of this component in the gamepad object
  45714. */
  45715. gamepadIndices: {
  45716. /**
  45717. * Index of button
  45718. */
  45719. button?: number;
  45720. /**
  45721. * If available, index of x-axis
  45722. */
  45723. xAxis?: number;
  45724. /**
  45725. * If available, index of y-axis
  45726. */
  45727. yAxis?: number;
  45728. };
  45729. /**
  45730. * The mesh's root node name
  45731. */
  45732. rootNodeName: string;
  45733. /**
  45734. * Animation definitions for this model
  45735. */
  45736. visualResponses: {
  45737. [stateKey: string]: {
  45738. /**
  45739. * What property will be animated
  45740. */
  45741. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45742. /**
  45743. * What states influence this visual response
  45744. */
  45745. states: MotionControllerComponentStateType[];
  45746. /**
  45747. * Type of animation - movement or visibility
  45748. */
  45749. valueNodeProperty: "transform" | "visibility";
  45750. /**
  45751. * Base node name to move. Its position will be calculated according to the min and max nodes
  45752. */
  45753. valueNodeName?: string;
  45754. /**
  45755. * Minimum movement node
  45756. */
  45757. minNodeName?: string;
  45758. /**
  45759. * Max movement node
  45760. */
  45761. maxNodeName?: string;
  45762. };
  45763. };
  45764. /**
  45765. * If touch enabled, what is the name of node to display user feedback
  45766. */
  45767. touchPointNodeName?: string;
  45768. };
  45769. };
  45770. /**
  45771. * Is it xr standard mapping or not
  45772. */
  45773. gamepadMapping: "" | "xr-standard";
  45774. /**
  45775. * Base root node of this entire model
  45776. */
  45777. rootNodeName: string;
  45778. /**
  45779. * Defines the main button component id
  45780. */
  45781. selectComponentId: string;
  45782. }
  45783. /**
  45784. * A definition for the layout map in the input profile
  45785. */
  45786. export interface IMotionControllerLayoutMap {
  45787. /**
  45788. * Layouts with handedness type as a key
  45789. */
  45790. [handedness: string]: IMotionControllerLayout;
  45791. }
  45792. /**
  45793. * The XR Input profile schema
  45794. * Profiles can be found here:
  45795. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45796. */
  45797. export interface IMotionControllerProfile {
  45798. /**
  45799. * fallback profiles for this profileId
  45800. */
  45801. fallbackProfileIds: string[];
  45802. /**
  45803. * The layout map, with handedness as key
  45804. */
  45805. layouts: IMotionControllerLayoutMap;
  45806. /**
  45807. * The id of this profile
  45808. * correlates to the profile(s) in the xrInput.profiles array
  45809. */
  45810. profileId: string;
  45811. }
  45812. /**
  45813. * A helper-interface for the 3 meshes needed for controller button animation
  45814. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45815. */
  45816. export interface IMotionControllerButtonMeshMap {
  45817. /**
  45818. * the mesh that defines the pressed value mesh position.
  45819. * This is used to find the max-position of this button
  45820. */
  45821. pressedMesh: AbstractMesh;
  45822. /**
  45823. * the mesh that defines the unpressed value mesh position.
  45824. * This is used to find the min (or initial) position of this button
  45825. */
  45826. unpressedMesh: AbstractMesh;
  45827. /**
  45828. * The mesh that will be changed when value changes
  45829. */
  45830. valueMesh: AbstractMesh;
  45831. }
  45832. /**
  45833. * A helper-interface for the 3 meshes needed for controller axis animation.
  45834. * This will be expanded when touchpad animations are fully supported
  45835. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45836. */
  45837. export interface IMotionControllerMeshMap {
  45838. /**
  45839. * the mesh that defines the maximum value mesh position.
  45840. */
  45841. maxMesh?: AbstractMesh;
  45842. /**
  45843. * the mesh that defines the minimum value mesh position.
  45844. */
  45845. minMesh?: AbstractMesh;
  45846. /**
  45847. * The mesh that will be changed when axis value changes
  45848. */
  45849. valueMesh: AbstractMesh;
  45850. }
  45851. /**
  45852. * The elements needed for change-detection of the gamepad objects in motion controllers
  45853. */
  45854. export interface IMinimalMotionControllerObject {
  45855. /**
  45856. * Available axes of this controller
  45857. */
  45858. axes: number[];
  45859. /**
  45860. * An array of available buttons
  45861. */
  45862. buttons: Array<{
  45863. /**
  45864. * Value of the button/trigger
  45865. */
  45866. value: number;
  45867. /**
  45868. * If the button/trigger is currently touched
  45869. */
  45870. touched: boolean;
  45871. /**
  45872. * If the button/trigger is currently pressed
  45873. */
  45874. pressed: boolean;
  45875. }>;
  45876. /**
  45877. * EXPERIMENTAL haptic support.
  45878. */
  45879. hapticActuators?: Array<{
  45880. pulse: (value: number, duration: number) => Promise<boolean>;
  45881. }>;
  45882. }
  45883. /**
  45884. * An Abstract Motion controller
  45885. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45886. * Each component has an observable to check for changes in value and state
  45887. */
  45888. export abstract class WebXRAbstractMotionController implements IDisposable {
  45889. protected scene: Scene;
  45890. protected layout: IMotionControllerLayout;
  45891. /**
  45892. * The gamepad object correlating to this controller
  45893. */
  45894. gamepadObject: IMinimalMotionControllerObject;
  45895. /**
  45896. * handedness (left/right/none) of this controller
  45897. */
  45898. handedness: MotionControllerHandedness;
  45899. private _initComponent;
  45900. private _modelReady;
  45901. /**
  45902. * A map of components (WebXRControllerComponent) in this motion controller
  45903. * Components have a ComponentType and can also have both button and axis definitions
  45904. */
  45905. readonly components: {
  45906. [id: string]: WebXRControllerComponent;
  45907. };
  45908. /**
  45909. * Disable the model's animation. Can be set at any time.
  45910. */
  45911. disableAnimation: boolean;
  45912. /**
  45913. * Observers registered here will be triggered when the model of this controller is done loading
  45914. */
  45915. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45916. /**
  45917. * The profile id of this motion controller
  45918. */
  45919. abstract profileId: string;
  45920. /**
  45921. * The root mesh of the model. It is null if the model was not yet initialized
  45922. */
  45923. rootMesh: Nullable<AbstractMesh>;
  45924. /**
  45925. * constructs a new abstract motion controller
  45926. * @param scene the scene to which the model of the controller will be added
  45927. * @param layout The profile layout to load
  45928. * @param gamepadObject The gamepad object correlating to this controller
  45929. * @param handedness handedness (left/right/none) of this controller
  45930. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45931. */
  45932. constructor(scene: Scene, layout: IMotionControllerLayout,
  45933. /**
  45934. * The gamepad object correlating to this controller
  45935. */
  45936. gamepadObject: IMinimalMotionControllerObject,
  45937. /**
  45938. * handedness (left/right/none) of this controller
  45939. */
  45940. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  45941. /**
  45942. * Dispose this controller, the model mesh and all its components
  45943. */
  45944. dispose(): void;
  45945. /**
  45946. * Returns all components of specific type
  45947. * @param type the type to search for
  45948. * @return an array of components with this type
  45949. */
  45950. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45951. /**
  45952. * get a component based an its component id as defined in layout.components
  45953. * @param id the id of the component
  45954. * @returns the component correlates to the id or undefined if not found
  45955. */
  45956. getComponent(id: string): WebXRControllerComponent;
  45957. /**
  45958. * Get the list of components available in this motion controller
  45959. * @returns an array of strings correlating to available components
  45960. */
  45961. getComponentIds(): string[];
  45962. /**
  45963. * Get the first component of specific type
  45964. * @param type type of component to find
  45965. * @return a controller component or null if not found
  45966. */
  45967. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45968. /**
  45969. * Get the main (Select) component of this controller as defined in the layout
  45970. * @returns the main component of this controller
  45971. */
  45972. getMainComponent(): WebXRControllerComponent;
  45973. /**
  45974. * Loads the model correlating to this controller
  45975. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45976. * @returns A promise fulfilled with the result of the model loading
  45977. */
  45978. loadModel(): Promise<boolean>;
  45979. /**
  45980. * Update this model using the current XRFrame
  45981. * @param xrFrame the current xr frame to use and update the model
  45982. */
  45983. updateFromXRFrame(xrFrame: XRFrame): void;
  45984. /**
  45985. * Backwards compatibility due to a deeply-integrated typo
  45986. */
  45987. get handness(): XREye;
  45988. /**
  45989. * Pulse (vibrate) this controller
  45990. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  45991. * Consecutive calls to this function will cancel the last pulse call
  45992. *
  45993. * @param value the strength of the pulse in 0.0...1.0 range
  45994. * @param duration Duration of the pulse in milliseconds
  45995. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  45996. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  45997. */
  45998. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  45999. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46000. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46001. /**
  46002. * Moves the axis on the controller mesh based on its current state
  46003. * @param axis the index of the axis
  46004. * @param axisValue the value of the axis which determines the meshes new position
  46005. * @hidden
  46006. */
  46007. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46008. /**
  46009. * Update the model itself with the current frame data
  46010. * @param xrFrame the frame to use for updating the model mesh
  46011. */
  46012. protected updateModel(xrFrame: XRFrame): void;
  46013. /**
  46014. * Get the filename and path for this controller's model
  46015. * @returns a map of filename and path
  46016. */
  46017. protected abstract _getFilenameAndPath(): {
  46018. filename: string;
  46019. path: string;
  46020. };
  46021. /**
  46022. * This function is called before the mesh is loaded. It checks for loading constraints.
  46023. * For example, this function can check if the GLB loader is available
  46024. * If this function returns false, the generic controller will be loaded instead
  46025. * @returns Is the client ready to load the mesh
  46026. */
  46027. protected abstract _getModelLoadingConstraints(): boolean;
  46028. /**
  46029. * This function will be called after the model was successfully loaded and can be used
  46030. * for mesh transformations before it is available for the user
  46031. * @param meshes the loaded meshes
  46032. */
  46033. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46034. /**
  46035. * Set the root mesh for this controller. Important for the WebXR controller class
  46036. * @param meshes the loaded meshes
  46037. */
  46038. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46039. /**
  46040. * A function executed each frame that updates the mesh (if needed)
  46041. * @param xrFrame the current xrFrame
  46042. */
  46043. protected abstract _updateModel(xrFrame: XRFrame): void;
  46044. private _getGenericFilenameAndPath;
  46045. private _getGenericParentMesh;
  46046. }
  46047. }
  46048. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  46049. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46051. import { Scene } from "babylonjs/scene";
  46052. /**
  46053. * A generic trigger-only motion controller for WebXR
  46054. */
  46055. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46056. /**
  46057. * Static version of the profile id of this controller
  46058. */
  46059. static ProfileId: string;
  46060. profileId: string;
  46061. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46062. protected _getFilenameAndPath(): {
  46063. filename: string;
  46064. path: string;
  46065. };
  46066. protected _getModelLoadingConstraints(): boolean;
  46067. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  46068. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46069. protected _updateModel(): void;
  46070. }
  46071. }
  46072. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46073. import { Vector4 } from "babylonjs/Maths/math.vector";
  46074. import { Mesh } from "babylonjs/Meshes/mesh";
  46075. import { Scene } from "babylonjs/scene";
  46076. import { Nullable } from "babylonjs/types";
  46077. /**
  46078. * Class containing static functions to help procedurally build meshes
  46079. */
  46080. export class SphereBuilder {
  46081. /**
  46082. * Creates a sphere mesh
  46083. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46084. * * 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`)
  46085. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46086. * * 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
  46087. * * 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)
  46088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46091. * @param name defines the name of the mesh
  46092. * @param options defines the options used to create the mesh
  46093. * @param scene defines the hosting scene
  46094. * @returns the sphere mesh
  46095. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46096. */
  46097. static CreateSphere(name: string, options: {
  46098. segments?: number;
  46099. diameter?: number;
  46100. diameterX?: number;
  46101. diameterY?: number;
  46102. diameterZ?: number;
  46103. arc?: number;
  46104. slice?: number;
  46105. sideOrientation?: number;
  46106. frontUVs?: Vector4;
  46107. backUVs?: Vector4;
  46108. updatable?: boolean;
  46109. }, scene?: Nullable<Scene>): Mesh;
  46110. }
  46111. }
  46112. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  46113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46114. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46115. import { Scene } from "babylonjs/scene";
  46116. /**
  46117. * A profiled motion controller has its profile loaded from an online repository.
  46118. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  46119. */
  46120. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  46121. private _repositoryUrl;
  46122. private _buttonMeshMapping;
  46123. private _touchDots;
  46124. /**
  46125. * The profile ID of this controller. Will be populated when the controller initializes.
  46126. */
  46127. profileId: string;
  46128. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  46129. dispose(): void;
  46130. protected _getFilenameAndPath(): {
  46131. filename: string;
  46132. path: string;
  46133. };
  46134. protected _getModelLoadingConstraints(): boolean;
  46135. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46136. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46137. protected _updateModel(_xrFrame: XRFrame): void;
  46138. }
  46139. }
  46140. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  46141. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46142. import { Scene } from "babylonjs/scene";
  46143. /**
  46144. * A construction function type to create a new controller based on an xrInput object
  46145. */
  46146. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  46147. /**
  46148. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  46149. *
  46150. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  46151. * it should be replaced with auto-loaded controllers.
  46152. *
  46153. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  46154. */
  46155. export class WebXRMotionControllerManager {
  46156. private static _AvailableControllers;
  46157. private static _Fallbacks;
  46158. private static _ProfileLoadingPromises;
  46159. private static _ProfilesList;
  46160. /**
  46161. * The base URL of the online controller repository. Can be changed at any time.
  46162. */
  46163. static BaseRepositoryUrl: string;
  46164. /**
  46165. * Which repository gets priority - local or online
  46166. */
  46167. static PrioritizeOnlineRepository: boolean;
  46168. /**
  46169. * Use the online repository, or use only locally-defined controllers
  46170. */
  46171. static UseOnlineRepository: boolean;
  46172. /**
  46173. * Clear the cache used for profile loading and reload when requested again
  46174. */
  46175. static ClearProfilesCache(): void;
  46176. /**
  46177. * Register the default fallbacks.
  46178. * This function is called automatically when this file is imported.
  46179. */
  46180. static DefaultFallbacks(): void;
  46181. /**
  46182. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46183. * @param profileId the profile to which a fallback needs to be found
  46184. * @return an array with corresponding fallback profiles
  46185. */
  46186. static FindFallbackWithProfileId(profileId: string): string[];
  46187. /**
  46188. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46189. * The order of search:
  46190. *
  46191. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46192. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46193. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46194. * 4) return the generic trigger controller if none were found
  46195. *
  46196. * @param xrInput the xrInput to which a new controller is initialized
  46197. * @param scene the scene to which the model will be added
  46198. * @param forceProfile force a certain profile for this controller
  46199. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46200. */
  46201. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46202. /**
  46203. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46204. *
  46205. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46206. *
  46207. * @param type the profile type to register
  46208. * @param constructFunction the function to be called when loading this profile
  46209. */
  46210. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46211. /**
  46212. * Register a fallback to a specific profile.
  46213. * @param profileId the profileId that will receive the fallbacks
  46214. * @param fallbacks A list of fallback profiles
  46215. */
  46216. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46217. /**
  46218. * Will update the list of profiles available in the repository
  46219. * @return a promise that resolves to a map of profiles available online
  46220. */
  46221. static UpdateProfilesList(): Promise<{
  46222. [profile: string]: string;
  46223. }>;
  46224. private static _LoadProfileFromRepository;
  46225. private static _LoadProfilesFromAvailableControllers;
  46226. }
  46227. }
  46228. declare module "babylonjs/XR/webXRInputSource" {
  46229. import { Observable } from "babylonjs/Misc/observable";
  46230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46231. import { Ray } from "babylonjs/Culling/ray";
  46232. import { Scene } from "babylonjs/scene";
  46233. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46234. /**
  46235. * Configuration options for the WebXR controller creation
  46236. */
  46237. export interface IWebXRControllerOptions {
  46238. /**
  46239. * Should the controller mesh be animated when a user interacts with it
  46240. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46241. */
  46242. disableMotionControllerAnimation?: boolean;
  46243. /**
  46244. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46245. */
  46246. doNotLoadControllerMesh?: boolean;
  46247. /**
  46248. * Force a specific controller type for this controller.
  46249. * This can be used when creating your own profile or when testing different controllers
  46250. */
  46251. forceControllerProfile?: string;
  46252. /**
  46253. * Defines a rendering group ID for meshes that will be loaded.
  46254. * This is for the default controllers only.
  46255. */
  46256. renderingGroupId?: number;
  46257. }
  46258. /**
  46259. * Represents an XR controller
  46260. */
  46261. export class WebXRInputSource {
  46262. private _scene;
  46263. /** The underlying input source for the controller */
  46264. inputSource: XRInputSource;
  46265. private _options;
  46266. private _tmpQuaternion;
  46267. private _tmpVector;
  46268. private _uniqueId;
  46269. /**
  46270. * 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
  46271. */
  46272. grip?: AbstractMesh;
  46273. /**
  46274. * If available, this is the gamepad object related to this controller.
  46275. * Using this object it is possible to get click events and trackpad changes of the
  46276. * webxr controller that is currently being used.
  46277. */
  46278. motionController?: WebXRAbstractMotionController;
  46279. /**
  46280. * Event that fires when the controller is removed/disposed.
  46281. * The object provided as event data is this controller, after associated assets were disposed.
  46282. * uniqueId is still available.
  46283. */
  46284. onDisposeObservable: Observable<WebXRInputSource>;
  46285. /**
  46286. * Will be triggered when the mesh associated with the motion controller is done loading.
  46287. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46288. * A shortened version of controller -> motion controller -> on mesh loaded.
  46289. */
  46290. onMeshLoadedObservable: Observable<AbstractMesh>;
  46291. /**
  46292. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46293. */
  46294. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46295. /**
  46296. * Pointer which can be used to select objects or attach a visible laser to
  46297. */
  46298. pointer: AbstractMesh;
  46299. /**
  46300. * Creates the controller
  46301. * @see https://doc.babylonjs.com/how_to/webxr
  46302. * @param _scene the scene which the controller should be associated to
  46303. * @param inputSource the underlying input source for the controller
  46304. * @param _options options for this controller creation
  46305. */
  46306. constructor(_scene: Scene,
  46307. /** The underlying input source for the controller */
  46308. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46309. /**
  46310. * Get this controllers unique id
  46311. */
  46312. get uniqueId(): string;
  46313. /**
  46314. * Disposes of the object
  46315. */
  46316. dispose(): void;
  46317. /**
  46318. * Gets a world space ray coming from the pointer or grip
  46319. * @param result the resulting ray
  46320. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46321. */
  46322. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46323. /**
  46324. * Updates the controller pose based on the given XRFrame
  46325. * @param xrFrame xr frame to update the pose with
  46326. * @param referenceSpace reference space to use
  46327. */
  46328. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46329. }
  46330. }
  46331. declare module "babylonjs/XR/webXRInput" {
  46332. import { Observable } from "babylonjs/Misc/observable";
  46333. import { IDisposable } from "babylonjs/scene";
  46334. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  46335. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46336. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46337. /**
  46338. * The schema for initialization options of the XR Input class
  46339. */
  46340. export interface IWebXRInputOptions {
  46341. /**
  46342. * If set to true no model will be automatically loaded
  46343. */
  46344. doNotLoadControllerMeshes?: boolean;
  46345. /**
  46346. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46347. * If not found, the xr input profile data will be used.
  46348. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46349. */
  46350. forceInputProfile?: string;
  46351. /**
  46352. * Do not send a request to the controller repository to load the profile.
  46353. *
  46354. * Instead, use the controllers available in babylon itself.
  46355. */
  46356. disableOnlineControllerRepository?: boolean;
  46357. /**
  46358. * A custom URL for the controllers repository
  46359. */
  46360. customControllersRepositoryURL?: string;
  46361. /**
  46362. * Should the controller model's components not move according to the user input
  46363. */
  46364. disableControllerAnimation?: boolean;
  46365. /**
  46366. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  46367. */
  46368. controllerOptions?: IWebXRControllerOptions;
  46369. }
  46370. /**
  46371. * XR input used to track XR inputs such as controllers/rays
  46372. */
  46373. export class WebXRInput implements IDisposable {
  46374. /**
  46375. * the xr session manager for this session
  46376. */
  46377. xrSessionManager: WebXRSessionManager;
  46378. /**
  46379. * the WebXR camera for this session. Mainly used for teleportation
  46380. */
  46381. xrCamera: WebXRCamera;
  46382. private readonly options;
  46383. /**
  46384. * XR controllers being tracked
  46385. */
  46386. controllers: Array<WebXRInputSource>;
  46387. private _frameObserver;
  46388. private _sessionEndedObserver;
  46389. private _sessionInitObserver;
  46390. /**
  46391. * Event when a controller has been connected/added
  46392. */
  46393. onControllerAddedObservable: Observable<WebXRInputSource>;
  46394. /**
  46395. * Event when a controller has been removed/disconnected
  46396. */
  46397. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46398. /**
  46399. * Initializes the WebXRInput
  46400. * @param xrSessionManager the xr session manager for this session
  46401. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46402. * @param options = initialization options for this xr input
  46403. */
  46404. constructor(
  46405. /**
  46406. * the xr session manager for this session
  46407. */
  46408. xrSessionManager: WebXRSessionManager,
  46409. /**
  46410. * the WebXR camera for this session. Mainly used for teleportation
  46411. */
  46412. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46413. private _onInputSourcesChange;
  46414. private _addAndRemoveControllers;
  46415. /**
  46416. * Disposes of the object
  46417. */
  46418. dispose(): void;
  46419. }
  46420. }
  46421. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46422. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46423. import { Observable, EventState } from "babylonjs/Misc/observable";
  46424. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46425. /**
  46426. * This is the base class for all WebXR features.
  46427. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46428. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46429. */
  46430. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46431. protected _xrSessionManager: WebXRSessionManager;
  46432. private _attached;
  46433. private _removeOnDetach;
  46434. /**
  46435. * Should auto-attach be disabled?
  46436. */
  46437. disableAutoAttach: boolean;
  46438. /**
  46439. * Construct a new (abstract) WebXR feature
  46440. * @param _xrSessionManager the xr session manager for this feature
  46441. */
  46442. constructor(_xrSessionManager: WebXRSessionManager);
  46443. /**
  46444. * Is this feature attached
  46445. */
  46446. get attached(): boolean;
  46447. /**
  46448. * attach this feature
  46449. *
  46450. * @param force should attachment be forced (even when already attached)
  46451. * @returns true if successful, false is failed or already attached
  46452. */
  46453. attach(force?: boolean): boolean;
  46454. /**
  46455. * detach this feature.
  46456. *
  46457. * @returns true if successful, false if failed or already detached
  46458. */
  46459. detach(): boolean;
  46460. /**
  46461. * Dispose this feature and all of the resources attached
  46462. */
  46463. dispose(): void;
  46464. /**
  46465. * This is used to register callbacks that will automatically be removed when detach is called.
  46466. * @param observable the observable to which the observer will be attached
  46467. * @param callback the callback to register
  46468. */
  46469. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46470. /**
  46471. * Code in this function will be executed on each xrFrame received from the browser.
  46472. * This function will not execute after the feature is detached.
  46473. * @param _xrFrame the current frame
  46474. */
  46475. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46476. }
  46477. }
  46478. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46479. import { IDisposable, Scene } from "babylonjs/scene";
  46480. import { Nullable } from "babylonjs/types";
  46481. import { Observable } from "babylonjs/Misc/observable";
  46482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46483. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46484. import { Camera } from "babylonjs/Cameras/camera";
  46485. /**
  46486. * Renders a layer on top of an existing scene
  46487. */
  46488. export class UtilityLayerRenderer implements IDisposable {
  46489. /** the original scene that will be rendered on top of */
  46490. originalScene: Scene;
  46491. private _pointerCaptures;
  46492. private _lastPointerEvents;
  46493. private static _DefaultUtilityLayer;
  46494. private static _DefaultKeepDepthUtilityLayer;
  46495. private _sharedGizmoLight;
  46496. private _renderCamera;
  46497. /**
  46498. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46499. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46500. * @returns the camera that is used when rendering the utility layer
  46501. */
  46502. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46503. /**
  46504. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46505. * @param cam the camera that should be used when rendering the utility layer
  46506. */
  46507. setRenderCamera(cam: Nullable<Camera>): void;
  46508. /**
  46509. * @hidden
  46510. * Light which used by gizmos to get light shading
  46511. */
  46512. _getSharedGizmoLight(): HemisphericLight;
  46513. /**
  46514. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46515. */
  46516. pickUtilitySceneFirst: boolean;
  46517. /**
  46518. * 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)
  46519. */
  46520. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46521. /**
  46522. * 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)
  46523. */
  46524. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46525. /**
  46526. * The scene that is rendered on top of the original scene
  46527. */
  46528. utilityLayerScene: Scene;
  46529. /**
  46530. * If the utility layer should automatically be rendered on top of existing scene
  46531. */
  46532. shouldRender: boolean;
  46533. /**
  46534. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46535. */
  46536. onlyCheckPointerDownEvents: boolean;
  46537. /**
  46538. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46539. */
  46540. processAllEvents: boolean;
  46541. /**
  46542. * Observable raised when the pointer move from the utility layer scene to the main scene
  46543. */
  46544. onPointerOutObservable: Observable<number>;
  46545. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46546. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46547. private _afterRenderObserver;
  46548. private _sceneDisposeObserver;
  46549. private _originalPointerObserver;
  46550. /**
  46551. * Instantiates a UtilityLayerRenderer
  46552. * @param originalScene the original scene that will be rendered on top of
  46553. * @param handleEvents boolean indicating if the utility layer should handle events
  46554. */
  46555. constructor(
  46556. /** the original scene that will be rendered on top of */
  46557. originalScene: Scene, handleEvents?: boolean);
  46558. private _notifyObservers;
  46559. /**
  46560. * Renders the utility layers scene on top of the original scene
  46561. */
  46562. render(): void;
  46563. /**
  46564. * Disposes of the renderer
  46565. */
  46566. dispose(): void;
  46567. private _updateCamera;
  46568. }
  46569. }
  46570. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46571. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46573. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46574. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46575. import { Scene } from "babylonjs/scene";
  46576. import { Nullable } from "babylonjs/types";
  46577. import { Color3 } from "babylonjs/Maths/math.color";
  46578. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46579. /**
  46580. * Options interface for the pointer selection module
  46581. */
  46582. export interface IWebXRControllerPointerSelectionOptions {
  46583. /**
  46584. * if provided, this scene will be used to render meshes.
  46585. */
  46586. customUtilityLayerScene?: Scene;
  46587. /**
  46588. * 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)
  46589. * If not disabled, the last picked point will be used to execute a pointer up event
  46590. * If disabled, pointer up event will be triggered right after the pointer down event.
  46591. * Used in screen and gaze target ray mode only
  46592. */
  46593. disablePointerUpOnTouchOut: boolean;
  46594. /**
  46595. * For gaze mode (time to select instead of press)
  46596. */
  46597. forceGazeMode: boolean;
  46598. /**
  46599. * 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
  46600. * to start a new countdown to the pointer down event.
  46601. * Defaults to 1.
  46602. */
  46603. gazeModePointerMovedFactor?: number;
  46604. /**
  46605. * Different button type to use instead of the main component
  46606. */
  46607. overrideButtonId?: string;
  46608. /**
  46609. * use this rendering group id for the meshes (optional)
  46610. */
  46611. renderingGroupId?: number;
  46612. /**
  46613. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46614. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46615. * 3000 means 3 seconds between pointing at something and selecting it
  46616. */
  46617. timeToSelect?: number;
  46618. /**
  46619. * Should meshes created here be added to a utility layer or the main scene
  46620. */
  46621. useUtilityLayer?: boolean;
  46622. /**
  46623. * the xr input to use with this pointer selection
  46624. */
  46625. xrInput: WebXRInput;
  46626. }
  46627. /**
  46628. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46629. */
  46630. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46631. private readonly _options;
  46632. private static _idCounter;
  46633. private _attachController;
  46634. private _controllers;
  46635. private _scene;
  46636. private _tmpVectorForPickCompare;
  46637. /**
  46638. * The module's name
  46639. */
  46640. static readonly Name: string;
  46641. /**
  46642. * The (Babylon) version of this module.
  46643. * This is an integer representing the implementation version.
  46644. * This number does not correspond to the WebXR specs version
  46645. */
  46646. static readonly Version: number;
  46647. /**
  46648. * Disable lighting on the laser pointer (so it will always be visible)
  46649. */
  46650. disablePointerLighting: boolean;
  46651. /**
  46652. * Disable lighting on the selection mesh (so it will always be visible)
  46653. */
  46654. disableSelectionMeshLighting: boolean;
  46655. /**
  46656. * Should the laser pointer be displayed
  46657. */
  46658. displayLaserPointer: boolean;
  46659. /**
  46660. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46661. */
  46662. displaySelectionMesh: boolean;
  46663. /**
  46664. * This color will be set to the laser pointer when selection is triggered
  46665. */
  46666. laserPointerPickedColor: Color3;
  46667. /**
  46668. * Default color of the laser pointer
  46669. */
  46670. lasterPointerDefaultColor: Color3;
  46671. /**
  46672. * default color of the selection ring
  46673. */
  46674. selectionMeshDefaultColor: Color3;
  46675. /**
  46676. * This color will be applied to the selection ring when selection is triggered
  46677. */
  46678. selectionMeshPickedColor: Color3;
  46679. /**
  46680. * Optional filter to be used for ray selection. This predicate shares behavior with
  46681. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46682. */
  46683. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46684. /**
  46685. * constructs a new background remover module
  46686. * @param _xrSessionManager the session manager for this module
  46687. * @param _options read-only options to be used in this module
  46688. */
  46689. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46690. /**
  46691. * attach this feature
  46692. * Will usually be called by the features manager
  46693. *
  46694. * @returns true if successful.
  46695. */
  46696. attach(): boolean;
  46697. /**
  46698. * detach this feature.
  46699. * Will usually be called by the features manager
  46700. *
  46701. * @returns true if successful.
  46702. */
  46703. detach(): boolean;
  46704. /**
  46705. * Will get the mesh under a specific pointer.
  46706. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46707. * @param controllerId the controllerId to check
  46708. * @returns The mesh under pointer or null if no mesh is under the pointer
  46709. */
  46710. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46711. /**
  46712. * Get the xr controller that correlates to the pointer id in the pointer event
  46713. *
  46714. * @param id the pointer id to search for
  46715. * @returns the controller that correlates to this id or null if not found
  46716. */
  46717. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46718. protected _onXRFrame(_xrFrame: XRFrame): void;
  46719. private _attachGazeMode;
  46720. private _attachScreenRayMode;
  46721. private _attachTrackedPointerRayMode;
  46722. private _convertNormalToDirectionOfRay;
  46723. private _detachController;
  46724. private _generateNewMeshPair;
  46725. private _pickingMoved;
  46726. private _updatePointerDistance;
  46727. }
  46728. }
  46729. declare module "babylonjs/XR/webXREnterExitUI" {
  46730. import { Nullable } from "babylonjs/types";
  46731. import { Observable } from "babylonjs/Misc/observable";
  46732. import { IDisposable, Scene } from "babylonjs/scene";
  46733. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46734. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46735. /**
  46736. * Button which can be used to enter a different mode of XR
  46737. */
  46738. export class WebXREnterExitUIButton {
  46739. /** button element */
  46740. element: HTMLElement;
  46741. /** XR initialization options for the button */
  46742. sessionMode: XRSessionMode;
  46743. /** Reference space type */
  46744. referenceSpaceType: XRReferenceSpaceType;
  46745. /**
  46746. * Creates a WebXREnterExitUIButton
  46747. * @param element button element
  46748. * @param sessionMode XR initialization session mode
  46749. * @param referenceSpaceType the type of reference space to be used
  46750. */
  46751. constructor(
  46752. /** button element */
  46753. element: HTMLElement,
  46754. /** XR initialization options for the button */
  46755. sessionMode: XRSessionMode,
  46756. /** Reference space type */
  46757. referenceSpaceType: XRReferenceSpaceType);
  46758. /**
  46759. * Extendable function which can be used to update the button's visuals when the state changes
  46760. * @param activeButton the current active button in the UI
  46761. */
  46762. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46763. }
  46764. /**
  46765. * Options to create the webXR UI
  46766. */
  46767. export class WebXREnterExitUIOptions {
  46768. /**
  46769. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46770. */
  46771. customButtons?: Array<WebXREnterExitUIButton>;
  46772. /**
  46773. * A reference space type to use when creating the default button.
  46774. * Default is local-floor
  46775. */
  46776. referenceSpaceType?: XRReferenceSpaceType;
  46777. /**
  46778. * Context to enter xr with
  46779. */
  46780. renderTarget?: Nullable<WebXRRenderTarget>;
  46781. /**
  46782. * A session mode to use when creating the default button.
  46783. * Default is immersive-vr
  46784. */
  46785. sessionMode?: XRSessionMode;
  46786. }
  46787. /**
  46788. * UI to allow the user to enter/exit XR mode
  46789. */
  46790. export class WebXREnterExitUI implements IDisposable {
  46791. private scene;
  46792. /** version of the options passed to this UI */
  46793. options: WebXREnterExitUIOptions;
  46794. private _activeButton;
  46795. private _buttons;
  46796. private _overlay;
  46797. /**
  46798. * Fired every time the active button is changed.
  46799. *
  46800. * When xr is entered via a button that launches xr that button will be the callback parameter
  46801. *
  46802. * When exiting xr the callback parameter will be null)
  46803. */
  46804. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46805. /**
  46806. *
  46807. * @param scene babylon scene object to use
  46808. * @param options (read-only) version of the options passed to this UI
  46809. */
  46810. private constructor();
  46811. /**
  46812. * Creates UI to allow the user to enter/exit XR mode
  46813. * @param scene the scene to add the ui to
  46814. * @param helper the xr experience helper to enter/exit xr with
  46815. * @param options options to configure the UI
  46816. * @returns the created ui
  46817. */
  46818. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46819. /**
  46820. * Disposes of the XR UI component
  46821. */
  46822. dispose(): void;
  46823. private _updateButtons;
  46824. }
  46825. }
  46826. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46827. import { Vector3 } from "babylonjs/Maths/math.vector";
  46828. import { Color4 } from "babylonjs/Maths/math.color";
  46829. import { Nullable } from "babylonjs/types";
  46830. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46831. import { Scene } from "babylonjs/scene";
  46832. /**
  46833. * Class containing static functions to help procedurally build meshes
  46834. */
  46835. export class LinesBuilder {
  46836. /**
  46837. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46838. * * 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
  46839. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46840. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46841. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46842. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46843. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46844. * * 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
  46845. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46848. * @param name defines the name of the new line system
  46849. * @param options defines the options used to create the line system
  46850. * @param scene defines the hosting scene
  46851. * @returns a new line system mesh
  46852. */
  46853. static CreateLineSystem(name: string, options: {
  46854. lines: Vector3[][];
  46855. updatable?: boolean;
  46856. instance?: Nullable<LinesMesh>;
  46857. colors?: Nullable<Color4[][]>;
  46858. useVertexAlpha?: boolean;
  46859. }, scene: Nullable<Scene>): LinesMesh;
  46860. /**
  46861. * Creates a line mesh
  46862. * 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
  46863. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46864. * * The parameter `points` is an array successive Vector3
  46865. * * 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
  46866. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46867. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46868. * * When updating an instance, remember that only point positions can change, not the number of points
  46869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46871. * @param name defines the name of the new line system
  46872. * @param options defines the options used to create the line system
  46873. * @param scene defines the hosting scene
  46874. * @returns a new line mesh
  46875. */
  46876. static CreateLines(name: string, options: {
  46877. points: Vector3[];
  46878. updatable?: boolean;
  46879. instance?: Nullable<LinesMesh>;
  46880. colors?: Color4[];
  46881. useVertexAlpha?: boolean;
  46882. }, scene?: Nullable<Scene>): LinesMesh;
  46883. /**
  46884. * Creates a dashed line mesh
  46885. * * 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
  46886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46887. * * The parameter `points` is an array successive Vector3
  46888. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46889. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46890. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46891. * * 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
  46892. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46893. * * When updating an instance, remember that only point positions can change, not the number of points
  46894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46895. * @param name defines the name of the mesh
  46896. * @param options defines the options used to create the mesh
  46897. * @param scene defines the hosting scene
  46898. * @returns the dashed line mesh
  46899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46900. */
  46901. static CreateDashedLines(name: string, options: {
  46902. points: Vector3[];
  46903. dashSize?: number;
  46904. gapSize?: number;
  46905. dashNb?: number;
  46906. updatable?: boolean;
  46907. instance?: LinesMesh;
  46908. useVertexAlpha?: boolean;
  46909. }, scene?: Nullable<Scene>): LinesMesh;
  46910. }
  46911. }
  46912. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46913. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46914. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46915. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46917. import { Vector3 } from "babylonjs/Maths/math.vector";
  46918. import { Material } from "babylonjs/Materials/material";
  46919. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46920. import { Scene } from "babylonjs/scene";
  46921. /**
  46922. * The options container for the teleportation module
  46923. */
  46924. export interface IWebXRTeleportationOptions {
  46925. /**
  46926. * if provided, this scene will be used to render meshes.
  46927. */
  46928. customUtilityLayerScene?: Scene;
  46929. /**
  46930. * Values to configure the default target mesh
  46931. */
  46932. defaultTargetMeshOptions?: {
  46933. /**
  46934. * Fill color of the teleportation area
  46935. */
  46936. teleportationFillColor?: string;
  46937. /**
  46938. * Border color for the teleportation area
  46939. */
  46940. teleportationBorderColor?: string;
  46941. /**
  46942. * Disable the mesh's animation sequence
  46943. */
  46944. disableAnimation?: boolean;
  46945. /**
  46946. * Disable lighting on the material or the ring and arrow
  46947. */
  46948. disableLighting?: boolean;
  46949. /**
  46950. * Override the default material of the torus and arrow
  46951. */
  46952. torusArrowMaterial?: Material;
  46953. };
  46954. /**
  46955. * A list of meshes to use as floor meshes.
  46956. * Meshes can be added and removed after initializing the feature using the
  46957. * addFloorMesh and removeFloorMesh functions
  46958. * If empty, rotation will still work
  46959. */
  46960. floorMeshes?: AbstractMesh[];
  46961. /**
  46962. * use this rendering group id for the meshes (optional)
  46963. */
  46964. renderingGroupId?: number;
  46965. /**
  46966. * Should teleportation move only to snap points
  46967. */
  46968. snapPointsOnly?: boolean;
  46969. /**
  46970. * An array of points to which the teleportation will snap to.
  46971. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46972. */
  46973. snapPositions?: Vector3[];
  46974. /**
  46975. * How close should the teleportation ray be in order to snap to position.
  46976. * Default to 0.8 units (meters)
  46977. */
  46978. snapToPositionRadius?: number;
  46979. /**
  46980. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46981. * If you want to support rotation, make sure your mesh has a direction indicator.
  46982. *
  46983. * When left untouched, the default mesh will be initialized.
  46984. */
  46985. teleportationTargetMesh?: AbstractMesh;
  46986. /**
  46987. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46988. */
  46989. timeToTeleport?: number;
  46990. /**
  46991. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46992. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46993. */
  46994. useMainComponentOnly?: boolean;
  46995. /**
  46996. * Should meshes created here be added to a utility layer or the main scene
  46997. */
  46998. useUtilityLayer?: boolean;
  46999. /**
  47000. * Babylon XR Input class for controller
  47001. */
  47002. xrInput: WebXRInput;
  47003. }
  47004. /**
  47005. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47006. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47007. * the input of the attached controllers.
  47008. */
  47009. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47010. private _options;
  47011. private _controllers;
  47012. private _currentTeleportationControllerId;
  47013. private _floorMeshes;
  47014. private _quadraticBezierCurve;
  47015. private _selectionFeature;
  47016. private _snapToPositions;
  47017. private _snappedToPoint;
  47018. private _teleportationRingMaterial?;
  47019. private _tmpRay;
  47020. private _tmpVector;
  47021. /**
  47022. * The module's name
  47023. */
  47024. static readonly Name: string;
  47025. /**
  47026. * The (Babylon) version of this module.
  47027. * This is an integer representing the implementation version.
  47028. * This number does not correspond to the webxr specs version
  47029. */
  47030. static readonly Version: number;
  47031. /**
  47032. * Is movement backwards enabled
  47033. */
  47034. backwardsMovementEnabled: boolean;
  47035. /**
  47036. * Distance to travel when moving backwards
  47037. */
  47038. backwardsTeleportationDistance: number;
  47039. /**
  47040. * The distance from the user to the inspection point in the direction of the controller
  47041. * A higher number will allow the user to move further
  47042. * defaults to 5 (meters, in xr units)
  47043. */
  47044. parabolicCheckRadius: number;
  47045. /**
  47046. * Should the module support parabolic ray on top of direct ray
  47047. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47048. * Very helpful when moving between floors / different heights
  47049. */
  47050. parabolicRayEnabled: boolean;
  47051. /**
  47052. * How much rotation should be applied when rotating right and left
  47053. */
  47054. rotationAngle: number;
  47055. /**
  47056. * Is rotation enabled when moving forward?
  47057. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47058. */
  47059. rotationEnabled: boolean;
  47060. /**
  47061. * constructs a new anchor system
  47062. * @param _xrSessionManager an instance of WebXRSessionManager
  47063. * @param _options configuration object for this feature
  47064. */
  47065. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47066. /**
  47067. * Get the snapPointsOnly flag
  47068. */
  47069. get snapPointsOnly(): boolean;
  47070. /**
  47071. * Sets the snapPointsOnly flag
  47072. * @param snapToPoints should teleportation be exclusively to snap points
  47073. */
  47074. set snapPointsOnly(snapToPoints: boolean);
  47075. /**
  47076. * Add a new mesh to the floor meshes array
  47077. * @param mesh the mesh to use as floor mesh
  47078. */
  47079. addFloorMesh(mesh: AbstractMesh): void;
  47080. /**
  47081. * Add a new snap-to point to fix teleportation to this position
  47082. * @param newSnapPoint The new Snap-To point
  47083. */
  47084. addSnapPoint(newSnapPoint: Vector3): void;
  47085. attach(): boolean;
  47086. detach(): boolean;
  47087. dispose(): void;
  47088. /**
  47089. * Remove a mesh from the floor meshes array
  47090. * @param mesh the mesh to remove
  47091. */
  47092. removeFloorMesh(mesh: AbstractMesh): void;
  47093. /**
  47094. * Remove a mesh from the floor meshes array using its name
  47095. * @param name the mesh name to remove
  47096. */
  47097. removeFloorMeshByName(name: string): void;
  47098. /**
  47099. * 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
  47100. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47101. * @returns was the point found and removed or not
  47102. */
  47103. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47104. /**
  47105. * This function sets a selection feature that will be disabled when
  47106. * the forward ray is shown and will be reattached when hidden.
  47107. * This is used to remove the selection rays when moving.
  47108. * @param selectionFeature the feature to disable when forward movement is enabled
  47109. */
  47110. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47111. protected _onXRFrame(_xrFrame: XRFrame): void;
  47112. private _attachController;
  47113. private _createDefaultTargetMesh;
  47114. private _detachController;
  47115. private _findClosestSnapPointWithRadius;
  47116. private _setTargetMeshPosition;
  47117. private _setTargetMeshVisibility;
  47118. private _showParabolicPath;
  47119. private _teleportForward;
  47120. }
  47121. }
  47122. declare module "babylonjs/XR/webXRDefaultExperience" {
  47123. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  47124. import { Scene } from "babylonjs/scene";
  47125. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  47126. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  47127. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47128. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  47129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47130. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47131. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  47132. /**
  47133. * Options for the default xr helper
  47134. */
  47135. export class WebXRDefaultExperienceOptions {
  47136. /**
  47137. * Enable or disable default UI to enter XR
  47138. */
  47139. disableDefaultUI?: boolean;
  47140. /**
  47141. * Should teleportation not initialize. defaults to false.
  47142. */
  47143. disableTeleportation?: boolean;
  47144. /**
  47145. * Floor meshes that will be used for teleport
  47146. */
  47147. floorMeshes?: Array<AbstractMesh>;
  47148. /**
  47149. * If set to true, the first frame will not be used to reset position
  47150. * The first frame is mainly used when copying transformation from the old camera
  47151. * Mainly used in AR
  47152. */
  47153. ignoreNativeCameraTransformation?: boolean;
  47154. /**
  47155. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  47156. */
  47157. inputOptions?: IWebXRInputOptions;
  47158. /**
  47159. * optional configuration for the output canvas
  47160. */
  47161. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  47162. /**
  47163. * optional UI options. This can be used among other to change session mode and reference space type
  47164. */
  47165. uiOptions?: WebXREnterExitUIOptions;
  47166. /**
  47167. * When loading teleportation and pointer select, use stable versions instead of latest.
  47168. */
  47169. useStablePlugins?: boolean;
  47170. /**
  47171. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  47172. */
  47173. renderingGroupId?: number;
  47174. }
  47175. /**
  47176. * Default experience which provides a similar setup to the previous webVRExperience
  47177. */
  47178. export class WebXRDefaultExperience {
  47179. /**
  47180. * Base experience
  47181. */
  47182. baseExperience: WebXRExperienceHelper;
  47183. /**
  47184. * Enables ui for entering/exiting xr
  47185. */
  47186. enterExitUI: WebXREnterExitUI;
  47187. /**
  47188. * Input experience extension
  47189. */
  47190. input: WebXRInput;
  47191. /**
  47192. * Enables laser pointer and selection
  47193. */
  47194. pointerSelection: WebXRControllerPointerSelection;
  47195. /**
  47196. * Default target xr should render to
  47197. */
  47198. renderTarget: WebXRRenderTarget;
  47199. /**
  47200. * Enables teleportation
  47201. */
  47202. teleportation: WebXRMotionControllerTeleportation;
  47203. private constructor();
  47204. /**
  47205. * Creates the default xr experience
  47206. * @param scene scene
  47207. * @param options options for basic configuration
  47208. * @returns resulting WebXRDefaultExperience
  47209. */
  47210. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47211. /**
  47212. * DIsposes of the experience helper
  47213. */
  47214. dispose(): void;
  47215. }
  47216. }
  47217. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47218. import { Observable } from "babylonjs/Misc/observable";
  47219. import { Nullable } from "babylonjs/types";
  47220. import { Camera } from "babylonjs/Cameras/camera";
  47221. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47222. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47223. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47224. import { Scene } from "babylonjs/scene";
  47225. import { Vector3 } from "babylonjs/Maths/math.vector";
  47226. import { Color3 } from "babylonjs/Maths/math.color";
  47227. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47229. import { Mesh } from "babylonjs/Meshes/mesh";
  47230. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47231. import { EasingFunction } from "babylonjs/Animations/easing";
  47232. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47233. import "babylonjs/Meshes/Builders/groundBuilder";
  47234. import "babylonjs/Meshes/Builders/torusBuilder";
  47235. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47236. import "babylonjs/Gamepads/gamepadSceneComponent";
  47237. import "babylonjs/Animations/animatable";
  47238. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47239. /**
  47240. * Options to modify the vr teleportation behavior.
  47241. */
  47242. export interface VRTeleportationOptions {
  47243. /**
  47244. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47245. */
  47246. floorMeshName?: string;
  47247. /**
  47248. * A list of meshes to be used as the teleportation floor. (default: empty)
  47249. */
  47250. floorMeshes?: Mesh[];
  47251. /**
  47252. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47253. */
  47254. teleportationMode?: number;
  47255. /**
  47256. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47257. */
  47258. teleportationTime?: number;
  47259. /**
  47260. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47261. */
  47262. teleportationSpeed?: number;
  47263. /**
  47264. * The easing function used in the animation or null for Linear. (default CircleEase)
  47265. */
  47266. easingFunction?: EasingFunction;
  47267. }
  47268. /**
  47269. * Options to modify the vr experience helper's behavior.
  47270. */
  47271. export interface VRExperienceHelperOptions extends WebVROptions {
  47272. /**
  47273. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47274. */
  47275. createDeviceOrientationCamera?: boolean;
  47276. /**
  47277. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47278. */
  47279. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47280. /**
  47281. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47282. */
  47283. laserToggle?: boolean;
  47284. /**
  47285. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47286. */
  47287. floorMeshes?: Mesh[];
  47288. /**
  47289. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47290. */
  47291. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47292. /**
  47293. * Defines if WebXR should be used instead of WebVR (if available)
  47294. */
  47295. useXR?: boolean;
  47296. }
  47297. /**
  47298. * Event containing information after VR has been entered
  47299. */
  47300. export class OnAfterEnteringVRObservableEvent {
  47301. /**
  47302. * If entering vr was successful
  47303. */
  47304. success: boolean;
  47305. }
  47306. /**
  47307. * Helps to quickly add VR support to an existing scene.
  47308. * See http://doc.babylonjs.com/how_to/webvr_helper
  47309. */
  47310. export class VRExperienceHelper {
  47311. /** Options to modify the vr experience helper's behavior. */
  47312. webVROptions: VRExperienceHelperOptions;
  47313. private _scene;
  47314. private _position;
  47315. private _btnVR;
  47316. private _btnVRDisplayed;
  47317. private _webVRsupported;
  47318. private _webVRready;
  47319. private _webVRrequesting;
  47320. private _webVRpresenting;
  47321. private _hasEnteredVR;
  47322. private _fullscreenVRpresenting;
  47323. private _inputElement;
  47324. private _webVRCamera;
  47325. private _vrDeviceOrientationCamera;
  47326. private _deviceOrientationCamera;
  47327. private _existingCamera;
  47328. private _onKeyDown;
  47329. private _onVrDisplayPresentChange;
  47330. private _onVRDisplayChanged;
  47331. private _onVRRequestPresentStart;
  47332. private _onVRRequestPresentComplete;
  47333. /**
  47334. * 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)
  47335. */
  47336. enableGazeEvenWhenNoPointerLock: boolean;
  47337. /**
  47338. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47339. */
  47340. exitVROnDoubleTap: boolean;
  47341. /**
  47342. * Observable raised right before entering VR.
  47343. */
  47344. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47345. /**
  47346. * Observable raised when entering VR has completed.
  47347. */
  47348. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47349. /**
  47350. * Observable raised when exiting VR.
  47351. */
  47352. onExitingVRObservable: Observable<VRExperienceHelper>;
  47353. /**
  47354. * Observable raised when controller mesh is loaded.
  47355. */
  47356. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47357. /** Return this.onEnteringVRObservable
  47358. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47359. */
  47360. get onEnteringVR(): Observable<VRExperienceHelper>;
  47361. /** Return this.onExitingVRObservable
  47362. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47363. */
  47364. get onExitingVR(): Observable<VRExperienceHelper>;
  47365. /** Return this.onControllerMeshLoadedObservable
  47366. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47367. */
  47368. get onControllerMeshLoaded(): Observable<WebVRController>;
  47369. private _rayLength;
  47370. private _useCustomVRButton;
  47371. private _teleportationRequested;
  47372. private _teleportActive;
  47373. private _floorMeshName;
  47374. private _floorMeshesCollection;
  47375. private _teleportationMode;
  47376. private _teleportationTime;
  47377. private _teleportationSpeed;
  47378. private _teleportationEasing;
  47379. private _rotationAllowed;
  47380. private _teleportBackwardsVector;
  47381. private _teleportationTarget;
  47382. private _isDefaultTeleportationTarget;
  47383. private _postProcessMove;
  47384. private _teleportationFillColor;
  47385. private _teleportationBorderColor;
  47386. private _rotationAngle;
  47387. private _haloCenter;
  47388. private _cameraGazer;
  47389. private _padSensibilityUp;
  47390. private _padSensibilityDown;
  47391. private _leftController;
  47392. private _rightController;
  47393. private _gazeColor;
  47394. private _laserColor;
  47395. private _pickedLaserColor;
  47396. private _pickedGazeColor;
  47397. /**
  47398. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47399. */
  47400. onNewMeshSelected: Observable<AbstractMesh>;
  47401. /**
  47402. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47403. * This observable will provide the mesh and the controller used to select the mesh
  47404. */
  47405. onMeshSelectedWithController: Observable<{
  47406. mesh: AbstractMesh;
  47407. controller: WebVRController;
  47408. }>;
  47409. /**
  47410. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47411. */
  47412. onNewMeshPicked: Observable<PickingInfo>;
  47413. private _circleEase;
  47414. /**
  47415. * Observable raised before camera teleportation
  47416. */
  47417. onBeforeCameraTeleport: Observable<Vector3>;
  47418. /**
  47419. * Observable raised after camera teleportation
  47420. */
  47421. onAfterCameraTeleport: Observable<Vector3>;
  47422. /**
  47423. * Observable raised when current selected mesh gets unselected
  47424. */
  47425. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47426. private _raySelectionPredicate;
  47427. /**
  47428. * To be optionaly changed by user to define custom ray selection
  47429. */
  47430. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47431. /**
  47432. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47433. */
  47434. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47435. /**
  47436. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47437. */
  47438. teleportationEnabled: boolean;
  47439. private _defaultHeight;
  47440. private _teleportationInitialized;
  47441. private _interactionsEnabled;
  47442. private _interactionsRequested;
  47443. private _displayGaze;
  47444. private _displayLaserPointer;
  47445. /**
  47446. * The mesh used to display where the user is going to teleport.
  47447. */
  47448. get teleportationTarget(): Mesh;
  47449. /**
  47450. * Sets the mesh to be used to display where the user is going to teleport.
  47451. */
  47452. set teleportationTarget(value: Mesh);
  47453. /**
  47454. * 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
  47455. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47456. * See http://doc.babylonjs.com/resources/baking_transformations
  47457. */
  47458. get gazeTrackerMesh(): Mesh;
  47459. set gazeTrackerMesh(value: Mesh);
  47460. /**
  47461. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47462. */
  47463. updateGazeTrackerScale: boolean;
  47464. /**
  47465. * If the gaze trackers color should be updated when selecting meshes
  47466. */
  47467. updateGazeTrackerColor: boolean;
  47468. /**
  47469. * If the controller laser color should be updated when selecting meshes
  47470. */
  47471. updateControllerLaserColor: boolean;
  47472. /**
  47473. * The gaze tracking mesh corresponding to the left controller
  47474. */
  47475. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47476. /**
  47477. * The gaze tracking mesh corresponding to the right controller
  47478. */
  47479. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47480. /**
  47481. * If the ray of the gaze should be displayed.
  47482. */
  47483. get displayGaze(): boolean;
  47484. /**
  47485. * Sets if the ray of the gaze should be displayed.
  47486. */
  47487. set displayGaze(value: boolean);
  47488. /**
  47489. * If the ray of the LaserPointer should be displayed.
  47490. */
  47491. get displayLaserPointer(): boolean;
  47492. /**
  47493. * Sets if the ray of the LaserPointer should be displayed.
  47494. */
  47495. set displayLaserPointer(value: boolean);
  47496. /**
  47497. * The deviceOrientationCamera used as the camera when not in VR.
  47498. */
  47499. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47500. /**
  47501. * Based on the current WebVR support, returns the current VR camera used.
  47502. */
  47503. get currentVRCamera(): Nullable<Camera>;
  47504. /**
  47505. * The webVRCamera which is used when in VR.
  47506. */
  47507. get webVRCamera(): WebVRFreeCamera;
  47508. /**
  47509. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47510. */
  47511. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47512. /**
  47513. * The html button that is used to trigger entering into VR.
  47514. */
  47515. get vrButton(): Nullable<HTMLButtonElement>;
  47516. private get _teleportationRequestInitiated();
  47517. /**
  47518. * Defines whether or not Pointer lock should be requested when switching to
  47519. * full screen.
  47520. */
  47521. requestPointerLockOnFullScreen: boolean;
  47522. /**
  47523. * If asking to force XR, this will be populated with the default xr experience
  47524. */
  47525. xr: WebXRDefaultExperience;
  47526. /**
  47527. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47528. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47529. */
  47530. xrTestDone: boolean;
  47531. /**
  47532. * Instantiates a VRExperienceHelper.
  47533. * Helps to quickly add VR support to an existing scene.
  47534. * @param scene The scene the VRExperienceHelper belongs to.
  47535. * @param webVROptions Options to modify the vr experience helper's behavior.
  47536. */
  47537. constructor(scene: Scene,
  47538. /** Options to modify the vr experience helper's behavior. */
  47539. webVROptions?: VRExperienceHelperOptions);
  47540. private completeVRInit;
  47541. private _onDefaultMeshLoaded;
  47542. private _onResize;
  47543. private _onFullscreenChange;
  47544. /**
  47545. * Gets a value indicating if we are currently in VR mode.
  47546. */
  47547. get isInVRMode(): boolean;
  47548. private onVrDisplayPresentChange;
  47549. private onVRDisplayChanged;
  47550. private moveButtonToBottomRight;
  47551. private displayVRButton;
  47552. private updateButtonVisibility;
  47553. private _cachedAngularSensibility;
  47554. /**
  47555. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47556. * Otherwise, will use the fullscreen API.
  47557. */
  47558. enterVR(): void;
  47559. /**
  47560. * Attempt to exit VR, or fullscreen.
  47561. */
  47562. exitVR(): void;
  47563. /**
  47564. * The position of the vr experience helper.
  47565. */
  47566. get position(): Vector3;
  47567. /**
  47568. * Sets the position of the vr experience helper.
  47569. */
  47570. set position(value: Vector3);
  47571. /**
  47572. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47573. */
  47574. enableInteractions(): void;
  47575. private get _noControllerIsActive();
  47576. private beforeRender;
  47577. private _isTeleportationFloor;
  47578. /**
  47579. * Adds a floor mesh to be used for teleportation.
  47580. * @param floorMesh the mesh to be used for teleportation.
  47581. */
  47582. addFloorMesh(floorMesh: Mesh): void;
  47583. /**
  47584. * Removes a floor mesh from being used for teleportation.
  47585. * @param floorMesh the mesh to be removed.
  47586. */
  47587. removeFloorMesh(floorMesh: Mesh): void;
  47588. /**
  47589. * Enables interactions and teleportation using the VR controllers and gaze.
  47590. * @param vrTeleportationOptions options to modify teleportation behavior.
  47591. */
  47592. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47593. private _onNewGamepadConnected;
  47594. private _tryEnableInteractionOnController;
  47595. private _onNewGamepadDisconnected;
  47596. private _enableInteractionOnController;
  47597. private _checkTeleportWithRay;
  47598. private _checkRotate;
  47599. private _checkTeleportBackwards;
  47600. private _enableTeleportationOnController;
  47601. private _createTeleportationCircles;
  47602. private _displayTeleportationTarget;
  47603. private _hideTeleportationTarget;
  47604. private _rotateCamera;
  47605. private _moveTeleportationSelectorTo;
  47606. private _workingVector;
  47607. private _workingQuaternion;
  47608. private _workingMatrix;
  47609. /**
  47610. * Time Constant Teleportation Mode
  47611. */
  47612. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47613. /**
  47614. * Speed Constant Teleportation Mode
  47615. */
  47616. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47617. /**
  47618. * Teleports the users feet to the desired location
  47619. * @param location The location where the user's feet should be placed
  47620. */
  47621. teleportCamera(location: Vector3): void;
  47622. private _convertNormalToDirectionOfRay;
  47623. private _castRayAndSelectObject;
  47624. private _notifySelectedMeshUnselected;
  47625. /**
  47626. * Permanently set new colors for the laser pointer
  47627. * @param color the new laser color
  47628. * @param pickedColor the new laser color when picked mesh detected
  47629. */
  47630. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47631. /**
  47632. * Set lighting enabled / disabled on the laser pointer of both controllers
  47633. * @param enabled should the lighting be enabled on the laser pointer
  47634. */
  47635. setLaserLightingState(enabled?: boolean): void;
  47636. /**
  47637. * Permanently set new colors for the gaze pointer
  47638. * @param color the new gaze color
  47639. * @param pickedColor the new gaze color when picked mesh detected
  47640. */
  47641. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47642. /**
  47643. * Sets the color of the laser ray from the vr controllers.
  47644. * @param color new color for the ray.
  47645. */
  47646. changeLaserColor(color: Color3): void;
  47647. /**
  47648. * Sets the color of the ray from the vr headsets gaze.
  47649. * @param color new color for the ray.
  47650. */
  47651. changeGazeColor(color: Color3): void;
  47652. /**
  47653. * Exits VR and disposes of the vr experience helper
  47654. */
  47655. dispose(): void;
  47656. /**
  47657. * Gets the name of the VRExperienceHelper class
  47658. * @returns "VRExperienceHelper"
  47659. */
  47660. getClassName(): string;
  47661. }
  47662. }
  47663. declare module "babylonjs/Cameras/VR/index" {
  47664. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47665. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47666. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47667. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47668. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47669. export * from "babylonjs/Cameras/VR/webVRCamera";
  47670. }
  47671. declare module "babylonjs/Cameras/RigModes/index" {
  47672. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47673. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47674. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47675. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47676. }
  47677. declare module "babylonjs/Cameras/index" {
  47678. export * from "babylonjs/Cameras/Inputs/index";
  47679. export * from "babylonjs/Cameras/cameraInputsManager";
  47680. export * from "babylonjs/Cameras/camera";
  47681. export * from "babylonjs/Cameras/targetCamera";
  47682. export * from "babylonjs/Cameras/freeCamera";
  47683. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47684. export * from "babylonjs/Cameras/touchCamera";
  47685. export * from "babylonjs/Cameras/arcRotateCamera";
  47686. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47687. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47688. export * from "babylonjs/Cameras/flyCamera";
  47689. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47690. export * from "babylonjs/Cameras/followCamera";
  47691. export * from "babylonjs/Cameras/followCameraInputsManager";
  47692. export * from "babylonjs/Cameras/gamepadCamera";
  47693. export * from "babylonjs/Cameras/Stereoscopic/index";
  47694. export * from "babylonjs/Cameras/universalCamera";
  47695. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47696. export * from "babylonjs/Cameras/VR/index";
  47697. export * from "babylonjs/Cameras/RigModes/index";
  47698. }
  47699. declare module "babylonjs/Collisions/index" {
  47700. export * from "babylonjs/Collisions/collider";
  47701. export * from "babylonjs/Collisions/collisionCoordinator";
  47702. export * from "babylonjs/Collisions/pickingInfo";
  47703. export * from "babylonjs/Collisions/intersectionInfo";
  47704. export * from "babylonjs/Collisions/meshCollisionData";
  47705. }
  47706. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47707. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47708. import { Vector3 } from "babylonjs/Maths/math.vector";
  47709. import { Ray } from "babylonjs/Culling/ray";
  47710. import { Plane } from "babylonjs/Maths/math.plane";
  47711. /**
  47712. * Contains an array of blocks representing the octree
  47713. */
  47714. export interface IOctreeContainer<T> {
  47715. /**
  47716. * Blocks within the octree
  47717. */
  47718. blocks: Array<OctreeBlock<T>>;
  47719. }
  47720. /**
  47721. * Class used to store a cell in an octree
  47722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47723. */
  47724. export class OctreeBlock<T> {
  47725. /**
  47726. * Gets the content of the current block
  47727. */
  47728. entries: T[];
  47729. /**
  47730. * Gets the list of block children
  47731. */
  47732. blocks: Array<OctreeBlock<T>>;
  47733. private _depth;
  47734. private _maxDepth;
  47735. private _capacity;
  47736. private _minPoint;
  47737. private _maxPoint;
  47738. private _boundingVectors;
  47739. private _creationFunc;
  47740. /**
  47741. * Creates a new block
  47742. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47743. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47744. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47745. * @param depth defines the current depth of this block in the octree
  47746. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47747. * @param creationFunc defines a callback to call when an element is added to the block
  47748. */
  47749. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47750. /**
  47751. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47752. */
  47753. get capacity(): number;
  47754. /**
  47755. * Gets the minimum vector (in world space) of the block's bounding box
  47756. */
  47757. get minPoint(): Vector3;
  47758. /**
  47759. * Gets the maximum vector (in world space) of the block's bounding box
  47760. */
  47761. get maxPoint(): Vector3;
  47762. /**
  47763. * Add a new element to this block
  47764. * @param entry defines the element to add
  47765. */
  47766. addEntry(entry: T): void;
  47767. /**
  47768. * Remove an element from this block
  47769. * @param entry defines the element to remove
  47770. */
  47771. removeEntry(entry: T): void;
  47772. /**
  47773. * Add an array of elements to this block
  47774. * @param entries defines the array of elements to add
  47775. */
  47776. addEntries(entries: T[]): void;
  47777. /**
  47778. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47779. * @param frustumPlanes defines the frustum planes to test
  47780. * @param selection defines the array to store current content if selection is positive
  47781. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47782. */
  47783. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47784. /**
  47785. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47786. * @param sphereCenter defines the bounding sphere center
  47787. * @param sphereRadius defines the bounding sphere radius
  47788. * @param selection defines the array to store current content if selection is positive
  47789. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47790. */
  47791. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47792. /**
  47793. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47794. * @param ray defines the ray to test with
  47795. * @param selection defines the array to store current content if selection is positive
  47796. */
  47797. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47798. /**
  47799. * Subdivide the content into child blocks (this block will then be empty)
  47800. */
  47801. createInnerBlocks(): void;
  47802. /**
  47803. * @hidden
  47804. */
  47805. 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;
  47806. }
  47807. }
  47808. declare module "babylonjs/Culling/Octrees/octree" {
  47809. import { SmartArray } from "babylonjs/Misc/smartArray";
  47810. import { Vector3 } from "babylonjs/Maths/math.vector";
  47811. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47813. import { Ray } from "babylonjs/Culling/ray";
  47814. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47815. import { Plane } from "babylonjs/Maths/math.plane";
  47816. /**
  47817. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47818. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47819. */
  47820. export class Octree<T> {
  47821. /** 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.) */
  47822. maxDepth: number;
  47823. /**
  47824. * Blocks within the octree containing objects
  47825. */
  47826. blocks: Array<OctreeBlock<T>>;
  47827. /**
  47828. * Content stored in the octree
  47829. */
  47830. dynamicContent: T[];
  47831. private _maxBlockCapacity;
  47832. private _selectionContent;
  47833. private _creationFunc;
  47834. /**
  47835. * Creates a octree
  47836. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47837. * @param creationFunc function to be used to instatiate the octree
  47838. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47839. * @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.)
  47840. */
  47841. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47842. /** 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.) */
  47843. maxDepth?: number);
  47844. /**
  47845. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47846. * @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);
  47847. * @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);
  47848. * @param entries meshes to be added to the octree blocks
  47849. */
  47850. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47851. /**
  47852. * Adds a mesh to the octree
  47853. * @param entry Mesh to add to the octree
  47854. */
  47855. addMesh(entry: T): void;
  47856. /**
  47857. * Remove an element from the octree
  47858. * @param entry defines the element to remove
  47859. */
  47860. removeMesh(entry: T): void;
  47861. /**
  47862. * Selects an array of meshes within the frustum
  47863. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47864. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47865. * @returns array of meshes within the frustum
  47866. */
  47867. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47868. /**
  47869. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47870. * @param sphereCenter defines the bounding sphere center
  47871. * @param sphereRadius defines the bounding sphere radius
  47872. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47873. * @returns an array of objects that intersect the sphere
  47874. */
  47875. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47876. /**
  47877. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47878. * @param ray defines the ray to test with
  47879. * @returns array of intersected objects
  47880. */
  47881. intersectsRay(ray: Ray): SmartArray<T>;
  47882. /**
  47883. * Adds a mesh into the octree block if it intersects the block
  47884. */
  47885. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47886. /**
  47887. * Adds a submesh into the octree block if it intersects the block
  47888. */
  47889. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47890. }
  47891. }
  47892. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47893. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47894. import { Scene } from "babylonjs/scene";
  47895. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47897. import { Ray } from "babylonjs/Culling/ray";
  47898. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47899. import { Collider } from "babylonjs/Collisions/collider";
  47900. module "babylonjs/scene" {
  47901. interface Scene {
  47902. /**
  47903. * @hidden
  47904. * Backing Filed
  47905. */
  47906. _selectionOctree: Octree<AbstractMesh>;
  47907. /**
  47908. * Gets the octree used to boost mesh selection (picking)
  47909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47910. */
  47911. selectionOctree: Octree<AbstractMesh>;
  47912. /**
  47913. * Creates or updates the octree used to boost selection (picking)
  47914. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47915. * @param maxCapacity defines the maximum capacity per leaf
  47916. * @param maxDepth defines the maximum depth of the octree
  47917. * @returns an octree of AbstractMesh
  47918. */
  47919. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47920. }
  47921. }
  47922. module "babylonjs/Meshes/abstractMesh" {
  47923. interface AbstractMesh {
  47924. /**
  47925. * @hidden
  47926. * Backing Field
  47927. */
  47928. _submeshesOctree: Octree<SubMesh>;
  47929. /**
  47930. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47931. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47932. * @param maxCapacity defines the maximum size of each block (64 by default)
  47933. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47934. * @returns the new octree
  47935. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47936. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47937. */
  47938. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47939. }
  47940. }
  47941. /**
  47942. * Defines the octree scene component responsible to manage any octrees
  47943. * in a given scene.
  47944. */
  47945. export class OctreeSceneComponent {
  47946. /**
  47947. * The component name help to identify the component in the list of scene components.
  47948. */
  47949. readonly name: string;
  47950. /**
  47951. * The scene the component belongs to.
  47952. */
  47953. scene: Scene;
  47954. /**
  47955. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47956. */
  47957. readonly checksIsEnabled: boolean;
  47958. /**
  47959. * Creates a new instance of the component for the given scene
  47960. * @param scene Defines the scene to register the component in
  47961. */
  47962. constructor(scene: Scene);
  47963. /**
  47964. * Registers the component in a given scene
  47965. */
  47966. register(): void;
  47967. /**
  47968. * Return the list of active meshes
  47969. * @returns the list of active meshes
  47970. */
  47971. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47972. /**
  47973. * Return the list of active sub meshes
  47974. * @param mesh The mesh to get the candidates sub meshes from
  47975. * @returns the list of active sub meshes
  47976. */
  47977. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47978. private _tempRay;
  47979. /**
  47980. * Return the list of sub meshes intersecting with a given local ray
  47981. * @param mesh defines the mesh to find the submesh for
  47982. * @param localRay defines the ray in local space
  47983. * @returns the list of intersecting sub meshes
  47984. */
  47985. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47986. /**
  47987. * Return the list of sub meshes colliding with a collider
  47988. * @param mesh defines the mesh to find the submesh for
  47989. * @param collider defines the collider to evaluate the collision against
  47990. * @returns the list of colliding sub meshes
  47991. */
  47992. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47993. /**
  47994. * Rebuilds the elements related to this component in case of
  47995. * context lost for instance.
  47996. */
  47997. rebuild(): void;
  47998. /**
  47999. * Disposes the component and the associated ressources.
  48000. */
  48001. dispose(): void;
  48002. }
  48003. }
  48004. declare module "babylonjs/Culling/Octrees/index" {
  48005. export * from "babylonjs/Culling/Octrees/octree";
  48006. export * from "babylonjs/Culling/Octrees/octreeBlock";
  48007. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  48008. }
  48009. declare module "babylonjs/Culling/index" {
  48010. export * from "babylonjs/Culling/boundingBox";
  48011. export * from "babylonjs/Culling/boundingInfo";
  48012. export * from "babylonjs/Culling/boundingSphere";
  48013. export * from "babylonjs/Culling/Octrees/index";
  48014. export * from "babylonjs/Culling/ray";
  48015. }
  48016. declare module "babylonjs/Gizmos/gizmo" {
  48017. import { Nullable } from "babylonjs/types";
  48018. import { IDisposable } from "babylonjs/scene";
  48019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48020. import { Mesh } from "babylonjs/Meshes/mesh";
  48021. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48022. /**
  48023. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48024. */
  48025. export class Gizmo implements IDisposable {
  48026. /** The utility layer the gizmo will be added to */
  48027. gizmoLayer: UtilityLayerRenderer;
  48028. /**
  48029. * The root mesh of the gizmo
  48030. */
  48031. _rootMesh: Mesh;
  48032. private _attachedMesh;
  48033. /**
  48034. * Ratio for the scale of the gizmo (Default: 1)
  48035. */
  48036. scaleRatio: number;
  48037. /**
  48038. * If a custom mesh has been set (Default: false)
  48039. */
  48040. protected _customMeshSet: boolean;
  48041. /**
  48042. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48043. * * When set, interactions will be enabled
  48044. */
  48045. get attachedMesh(): Nullable<AbstractMesh>;
  48046. set attachedMesh(value: Nullable<AbstractMesh>);
  48047. /**
  48048. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48049. * @param mesh The mesh to replace the default mesh of the gizmo
  48050. */
  48051. setCustomMesh(mesh: Mesh): void;
  48052. /**
  48053. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48054. */
  48055. updateGizmoRotationToMatchAttachedMesh: boolean;
  48056. /**
  48057. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48058. */
  48059. updateGizmoPositionToMatchAttachedMesh: boolean;
  48060. /**
  48061. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48062. */
  48063. updateScale: boolean;
  48064. protected _interactionsEnabled: boolean;
  48065. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48066. private _beforeRenderObserver;
  48067. private _tempVector;
  48068. /**
  48069. * Creates a gizmo
  48070. * @param gizmoLayer The utility layer the gizmo will be added to
  48071. */
  48072. constructor(
  48073. /** The utility layer the gizmo will be added to */
  48074. gizmoLayer?: UtilityLayerRenderer);
  48075. /**
  48076. * Updates the gizmo to match the attached mesh's position/rotation
  48077. */
  48078. protected _update(): void;
  48079. /**
  48080. * Disposes of the gizmo
  48081. */
  48082. dispose(): void;
  48083. }
  48084. }
  48085. declare module "babylonjs/Gizmos/planeDragGizmo" {
  48086. import { Observable } from "babylonjs/Misc/observable";
  48087. import { Nullable } from "babylonjs/types";
  48088. import { Vector3 } from "babylonjs/Maths/math.vector";
  48089. import { Color3 } from "babylonjs/Maths/math.color";
  48090. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48092. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48093. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48094. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48095. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48096. import { Scene } from "babylonjs/scene";
  48097. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48098. /**
  48099. * Single plane drag gizmo
  48100. */
  48101. export class PlaneDragGizmo extends Gizmo {
  48102. /**
  48103. * Drag behavior responsible for the gizmos dragging interactions
  48104. */
  48105. dragBehavior: PointerDragBehavior;
  48106. private _pointerObserver;
  48107. /**
  48108. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48109. */
  48110. snapDistance: number;
  48111. /**
  48112. * Event that fires each time the gizmo snaps to a new location.
  48113. * * snapDistance is the the change in distance
  48114. */
  48115. onSnapObservable: Observable<{
  48116. snapDistance: number;
  48117. }>;
  48118. private _plane;
  48119. private _coloredMaterial;
  48120. private _hoverMaterial;
  48121. private _isEnabled;
  48122. private _parent;
  48123. /** @hidden */
  48124. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48125. /** @hidden */
  48126. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48127. /**
  48128. * Creates a PlaneDragGizmo
  48129. * @param gizmoLayer The utility layer the gizmo will be added to
  48130. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48131. * @param color The color of the gizmo
  48132. */
  48133. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48134. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48135. /**
  48136. * If the gizmo is enabled
  48137. */
  48138. set isEnabled(value: boolean);
  48139. get isEnabled(): boolean;
  48140. /**
  48141. * Disposes of the gizmo
  48142. */
  48143. dispose(): void;
  48144. }
  48145. }
  48146. declare module "babylonjs/Gizmos/positionGizmo" {
  48147. import { Observable } from "babylonjs/Misc/observable";
  48148. import { Nullable } from "babylonjs/types";
  48149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48150. import { Mesh } from "babylonjs/Meshes/mesh";
  48151. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48152. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  48153. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  48154. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48155. /**
  48156. * Gizmo that enables dragging a mesh along 3 axis
  48157. */
  48158. export class PositionGizmo extends Gizmo {
  48159. /**
  48160. * Internal gizmo used for interactions on the x axis
  48161. */
  48162. xGizmo: AxisDragGizmo;
  48163. /**
  48164. * Internal gizmo used for interactions on the y axis
  48165. */
  48166. yGizmo: AxisDragGizmo;
  48167. /**
  48168. * Internal gizmo used for interactions on the z axis
  48169. */
  48170. zGizmo: AxisDragGizmo;
  48171. /**
  48172. * Internal gizmo used for interactions on the yz plane
  48173. */
  48174. xPlaneGizmo: PlaneDragGizmo;
  48175. /**
  48176. * Internal gizmo used for interactions on the xz plane
  48177. */
  48178. yPlaneGizmo: PlaneDragGizmo;
  48179. /**
  48180. * Internal gizmo used for interactions on the xy plane
  48181. */
  48182. zPlaneGizmo: PlaneDragGizmo;
  48183. /**
  48184. * private variables
  48185. */
  48186. private _meshAttached;
  48187. private _updateGizmoRotationToMatchAttachedMesh;
  48188. private _snapDistance;
  48189. private _scaleRatio;
  48190. /** Fires an event when any of it's sub gizmos are dragged */
  48191. onDragStartObservable: Observable<unknown>;
  48192. /** Fires an event when any of it's sub gizmos are released from dragging */
  48193. onDragEndObservable: Observable<unknown>;
  48194. /**
  48195. * If set to true, planar drag is enabled
  48196. */
  48197. private _planarGizmoEnabled;
  48198. get attachedMesh(): Nullable<AbstractMesh>;
  48199. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48200. /**
  48201. * Creates a PositionGizmo
  48202. * @param gizmoLayer The utility layer the gizmo will be added to
  48203. */
  48204. constructor(gizmoLayer?: UtilityLayerRenderer);
  48205. /**
  48206. * If the planar drag gizmo is enabled
  48207. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48208. */
  48209. set planarGizmoEnabled(value: boolean);
  48210. get planarGizmoEnabled(): boolean;
  48211. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48212. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48213. /**
  48214. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48215. */
  48216. set snapDistance(value: number);
  48217. get snapDistance(): number;
  48218. /**
  48219. * Ratio for the scale of the gizmo (Default: 1)
  48220. */
  48221. set scaleRatio(value: number);
  48222. get scaleRatio(): number;
  48223. /**
  48224. * Disposes of the gizmo
  48225. */
  48226. dispose(): void;
  48227. /**
  48228. * CustomMeshes are not supported by this gizmo
  48229. * @param mesh The mesh to replace the default mesh of the gizmo
  48230. */
  48231. setCustomMesh(mesh: Mesh): void;
  48232. }
  48233. }
  48234. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48235. import { Observable } from "babylonjs/Misc/observable";
  48236. import { Nullable } from "babylonjs/types";
  48237. import { Vector3 } from "babylonjs/Maths/math.vector";
  48238. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48240. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48241. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48242. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48243. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48244. import { Scene } from "babylonjs/scene";
  48245. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48246. import { Color3 } from "babylonjs/Maths/math.color";
  48247. /**
  48248. * Single axis drag gizmo
  48249. */
  48250. export class AxisDragGizmo extends Gizmo {
  48251. /**
  48252. * Drag behavior responsible for the gizmos dragging interactions
  48253. */
  48254. dragBehavior: PointerDragBehavior;
  48255. private _pointerObserver;
  48256. /**
  48257. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48258. */
  48259. snapDistance: number;
  48260. /**
  48261. * Event that fires each time the gizmo snaps to a new location.
  48262. * * snapDistance is the the change in distance
  48263. */
  48264. onSnapObservable: Observable<{
  48265. snapDistance: number;
  48266. }>;
  48267. private _isEnabled;
  48268. private _parent;
  48269. private _arrow;
  48270. private _coloredMaterial;
  48271. private _hoverMaterial;
  48272. /** @hidden */
  48273. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48274. /** @hidden */
  48275. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48276. /**
  48277. * Creates an AxisDragGizmo
  48278. * @param gizmoLayer The utility layer the gizmo will be added to
  48279. * @param dragAxis The axis which the gizmo will be able to drag on
  48280. * @param color The color of the gizmo
  48281. */
  48282. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48283. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48284. /**
  48285. * If the gizmo is enabled
  48286. */
  48287. set isEnabled(value: boolean);
  48288. get isEnabled(): boolean;
  48289. /**
  48290. * Disposes of the gizmo
  48291. */
  48292. dispose(): void;
  48293. }
  48294. }
  48295. declare module "babylonjs/Debug/axesViewer" {
  48296. import { Vector3 } from "babylonjs/Maths/math.vector";
  48297. import { Nullable } from "babylonjs/types";
  48298. import { Scene } from "babylonjs/scene";
  48299. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48300. /**
  48301. * The Axes viewer will show 3 axes in a specific point in space
  48302. */
  48303. export class AxesViewer {
  48304. private _xAxis;
  48305. private _yAxis;
  48306. private _zAxis;
  48307. private _scaleLinesFactor;
  48308. private _instanced;
  48309. /**
  48310. * Gets the hosting scene
  48311. */
  48312. scene: Scene;
  48313. /**
  48314. * Gets or sets a number used to scale line length
  48315. */
  48316. scaleLines: number;
  48317. /** Gets the node hierarchy used to render x-axis */
  48318. get xAxis(): TransformNode;
  48319. /** Gets the node hierarchy used to render y-axis */
  48320. get yAxis(): TransformNode;
  48321. /** Gets the node hierarchy used to render z-axis */
  48322. get zAxis(): TransformNode;
  48323. /**
  48324. * Creates a new AxesViewer
  48325. * @param scene defines the hosting scene
  48326. * @param scaleLines defines a number used to scale line length (1 by default)
  48327. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48328. * @param xAxis defines the node hierarchy used to render the x-axis
  48329. * @param yAxis defines the node hierarchy used to render the y-axis
  48330. * @param zAxis defines the node hierarchy used to render the z-axis
  48331. */
  48332. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48333. /**
  48334. * Force the viewer to update
  48335. * @param position defines the position of the viewer
  48336. * @param xaxis defines the x axis of the viewer
  48337. * @param yaxis defines the y axis of the viewer
  48338. * @param zaxis defines the z axis of the viewer
  48339. */
  48340. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48341. /**
  48342. * Creates an instance of this axes viewer.
  48343. * @returns a new axes viewer with instanced meshes
  48344. */
  48345. createInstance(): AxesViewer;
  48346. /** Releases resources */
  48347. dispose(): void;
  48348. private static _SetRenderingGroupId;
  48349. }
  48350. }
  48351. declare module "babylonjs/Debug/boneAxesViewer" {
  48352. import { Nullable } from "babylonjs/types";
  48353. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48354. import { Vector3 } from "babylonjs/Maths/math.vector";
  48355. import { Mesh } from "babylonjs/Meshes/mesh";
  48356. import { Bone } from "babylonjs/Bones/bone";
  48357. import { Scene } from "babylonjs/scene";
  48358. /**
  48359. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48360. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48361. */
  48362. export class BoneAxesViewer extends AxesViewer {
  48363. /**
  48364. * Gets or sets the target mesh where to display the axes viewer
  48365. */
  48366. mesh: Nullable<Mesh>;
  48367. /**
  48368. * Gets or sets the target bone where to display the axes viewer
  48369. */
  48370. bone: Nullable<Bone>;
  48371. /** Gets current position */
  48372. pos: Vector3;
  48373. /** Gets direction of X axis */
  48374. xaxis: Vector3;
  48375. /** Gets direction of Y axis */
  48376. yaxis: Vector3;
  48377. /** Gets direction of Z axis */
  48378. zaxis: Vector3;
  48379. /**
  48380. * Creates a new BoneAxesViewer
  48381. * @param scene defines the hosting scene
  48382. * @param bone defines the target bone
  48383. * @param mesh defines the target mesh
  48384. * @param scaleLines defines a scaling factor for line length (1 by default)
  48385. */
  48386. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48387. /**
  48388. * Force the viewer to update
  48389. */
  48390. update(): void;
  48391. /** Releases resources */
  48392. dispose(): void;
  48393. }
  48394. }
  48395. declare module "babylonjs/Debug/debugLayer" {
  48396. import { Scene } from "babylonjs/scene";
  48397. /**
  48398. * Interface used to define scene explorer extensibility option
  48399. */
  48400. export interface IExplorerExtensibilityOption {
  48401. /**
  48402. * Define the option label
  48403. */
  48404. label: string;
  48405. /**
  48406. * Defines the action to execute on click
  48407. */
  48408. action: (entity: any) => void;
  48409. }
  48410. /**
  48411. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48412. */
  48413. export interface IExplorerExtensibilityGroup {
  48414. /**
  48415. * Defines a predicate to test if a given type mut be extended
  48416. */
  48417. predicate: (entity: any) => boolean;
  48418. /**
  48419. * Gets the list of options added to a type
  48420. */
  48421. entries: IExplorerExtensibilityOption[];
  48422. }
  48423. /**
  48424. * Interface used to define the options to use to create the Inspector
  48425. */
  48426. export interface IInspectorOptions {
  48427. /**
  48428. * Display in overlay mode (default: false)
  48429. */
  48430. overlay?: boolean;
  48431. /**
  48432. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48433. */
  48434. globalRoot?: HTMLElement;
  48435. /**
  48436. * Display the Scene explorer
  48437. */
  48438. showExplorer?: boolean;
  48439. /**
  48440. * Display the property inspector
  48441. */
  48442. showInspector?: boolean;
  48443. /**
  48444. * Display in embed mode (both panes on the right)
  48445. */
  48446. embedMode?: boolean;
  48447. /**
  48448. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48449. */
  48450. handleResize?: boolean;
  48451. /**
  48452. * Allow the panes to popup (default: true)
  48453. */
  48454. enablePopup?: boolean;
  48455. /**
  48456. * Allow the panes to be closed by users (default: true)
  48457. */
  48458. enableClose?: boolean;
  48459. /**
  48460. * Optional list of extensibility entries
  48461. */
  48462. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48463. /**
  48464. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48465. */
  48466. inspectorURL?: string;
  48467. /**
  48468. * Optional initial tab (default to DebugLayerTab.Properties)
  48469. */
  48470. initialTab?: DebugLayerTab;
  48471. }
  48472. module "babylonjs/scene" {
  48473. interface Scene {
  48474. /**
  48475. * @hidden
  48476. * Backing field
  48477. */
  48478. _debugLayer: DebugLayer;
  48479. /**
  48480. * Gets the debug layer (aka Inspector) associated with the scene
  48481. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48482. */
  48483. debugLayer: DebugLayer;
  48484. }
  48485. }
  48486. /**
  48487. * Enum of inspector action tab
  48488. */
  48489. export enum DebugLayerTab {
  48490. /**
  48491. * Properties tag (default)
  48492. */
  48493. Properties = 0,
  48494. /**
  48495. * Debug tab
  48496. */
  48497. Debug = 1,
  48498. /**
  48499. * Statistics tab
  48500. */
  48501. Statistics = 2,
  48502. /**
  48503. * Tools tab
  48504. */
  48505. Tools = 3,
  48506. /**
  48507. * Settings tab
  48508. */
  48509. Settings = 4
  48510. }
  48511. /**
  48512. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48513. * what is happening in your scene
  48514. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48515. */
  48516. export class DebugLayer {
  48517. /**
  48518. * Define the url to get the inspector script from.
  48519. * By default it uses the babylonjs CDN.
  48520. * @ignoreNaming
  48521. */
  48522. static InspectorURL: string;
  48523. private _scene;
  48524. private BJSINSPECTOR;
  48525. private _onPropertyChangedObservable?;
  48526. /**
  48527. * Observable triggered when a property is changed through the inspector.
  48528. */
  48529. get onPropertyChangedObservable(): any;
  48530. /**
  48531. * Instantiates a new debug layer.
  48532. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48533. * what is happening in your scene
  48534. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48535. * @param scene Defines the scene to inspect
  48536. */
  48537. constructor(scene: Scene);
  48538. /** Creates the inspector window. */
  48539. private _createInspector;
  48540. /**
  48541. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48542. * @param entity defines the entity to select
  48543. * @param lineContainerTitle defines the specific block to highlight
  48544. */
  48545. select(entity: any, lineContainerTitle?: string): void;
  48546. /** Get the inspector from bundle or global */
  48547. private _getGlobalInspector;
  48548. /**
  48549. * Get if the inspector is visible or not.
  48550. * @returns true if visible otherwise, false
  48551. */
  48552. isVisible(): boolean;
  48553. /**
  48554. * Hide the inspector and close its window.
  48555. */
  48556. hide(): void;
  48557. /**
  48558. * Launch the debugLayer.
  48559. * @param config Define the configuration of the inspector
  48560. * @return a promise fulfilled when the debug layer is visible
  48561. */
  48562. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48563. }
  48564. }
  48565. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48566. import { Nullable } from "babylonjs/types";
  48567. import { Scene } from "babylonjs/scene";
  48568. import { Vector4 } from "babylonjs/Maths/math.vector";
  48569. import { Color4 } from "babylonjs/Maths/math.color";
  48570. import { Mesh } from "babylonjs/Meshes/mesh";
  48571. /**
  48572. * Class containing static functions to help procedurally build meshes
  48573. */
  48574. export class BoxBuilder {
  48575. /**
  48576. * Creates a box mesh
  48577. * * The parameter `size` sets the size (float) of each box side (default 1)
  48578. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48579. * * 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)
  48580. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48584. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48585. * @param name defines the name of the mesh
  48586. * @param options defines the options used to create the mesh
  48587. * @param scene defines the hosting scene
  48588. * @returns the box mesh
  48589. */
  48590. static CreateBox(name: string, options: {
  48591. size?: number;
  48592. width?: number;
  48593. height?: number;
  48594. depth?: number;
  48595. faceUV?: Vector4[];
  48596. faceColors?: Color4[];
  48597. sideOrientation?: number;
  48598. frontUVs?: Vector4;
  48599. backUVs?: Vector4;
  48600. wrap?: boolean;
  48601. topBaseAt?: number;
  48602. bottomBaseAt?: number;
  48603. updatable?: boolean;
  48604. }, scene?: Nullable<Scene>): Mesh;
  48605. }
  48606. }
  48607. declare module "babylonjs/Debug/physicsViewer" {
  48608. import { Nullable } from "babylonjs/types";
  48609. import { Scene } from "babylonjs/scene";
  48610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48611. import { Mesh } from "babylonjs/Meshes/mesh";
  48612. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48613. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48614. /**
  48615. * Used to show the physics impostor around the specific mesh
  48616. */
  48617. export class PhysicsViewer {
  48618. /** @hidden */
  48619. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48620. /** @hidden */
  48621. protected _meshes: Array<Nullable<AbstractMesh>>;
  48622. /** @hidden */
  48623. protected _scene: Nullable<Scene>;
  48624. /** @hidden */
  48625. protected _numMeshes: number;
  48626. /** @hidden */
  48627. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48628. private _renderFunction;
  48629. private _utilityLayer;
  48630. private _debugBoxMesh;
  48631. private _debugSphereMesh;
  48632. private _debugCylinderMesh;
  48633. private _debugMaterial;
  48634. private _debugMeshMeshes;
  48635. /**
  48636. * Creates a new PhysicsViewer
  48637. * @param scene defines the hosting scene
  48638. */
  48639. constructor(scene: Scene);
  48640. /** @hidden */
  48641. protected _updateDebugMeshes(): void;
  48642. /**
  48643. * Renders a specified physic impostor
  48644. * @param impostor defines the impostor to render
  48645. * @param targetMesh defines the mesh represented by the impostor
  48646. * @returns the new debug mesh used to render the impostor
  48647. */
  48648. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48649. /**
  48650. * Hides a specified physic impostor
  48651. * @param impostor defines the impostor to hide
  48652. */
  48653. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48654. private _getDebugMaterial;
  48655. private _getDebugBoxMesh;
  48656. private _getDebugSphereMesh;
  48657. private _getDebugCylinderMesh;
  48658. private _getDebugMeshMesh;
  48659. private _getDebugMesh;
  48660. /** Releases all resources */
  48661. dispose(): void;
  48662. }
  48663. }
  48664. declare module "babylonjs/Debug/rayHelper" {
  48665. import { Nullable } from "babylonjs/types";
  48666. import { Ray } from "babylonjs/Culling/ray";
  48667. import { Vector3 } from "babylonjs/Maths/math.vector";
  48668. import { Color3 } from "babylonjs/Maths/math.color";
  48669. import { Scene } from "babylonjs/scene";
  48670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48671. import "babylonjs/Meshes/Builders/linesBuilder";
  48672. /**
  48673. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48674. * in order to better appreciate the issue one might have.
  48675. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48676. */
  48677. export class RayHelper {
  48678. /**
  48679. * Defines the ray we are currently tryin to visualize.
  48680. */
  48681. ray: Nullable<Ray>;
  48682. private _renderPoints;
  48683. private _renderLine;
  48684. private _renderFunction;
  48685. private _scene;
  48686. private _updateToMeshFunction;
  48687. private _attachedToMesh;
  48688. private _meshSpaceDirection;
  48689. private _meshSpaceOrigin;
  48690. /**
  48691. * Helper function to create a colored helper in a scene in one line.
  48692. * @param ray Defines the ray we are currently tryin to visualize
  48693. * @param scene Defines the scene the ray is used in
  48694. * @param color Defines the color we want to see the ray in
  48695. * @returns The newly created ray helper.
  48696. */
  48697. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48698. /**
  48699. * Instantiate a new ray helper.
  48700. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48701. * in order to better appreciate the issue one might have.
  48702. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48703. * @param ray Defines the ray we are currently tryin to visualize
  48704. */
  48705. constructor(ray: Ray);
  48706. /**
  48707. * Shows the ray we are willing to debug.
  48708. * @param scene Defines the scene the ray needs to be rendered in
  48709. * @param color Defines the color the ray needs to be rendered in
  48710. */
  48711. show(scene: Scene, color?: Color3): void;
  48712. /**
  48713. * Hides the ray we are debugging.
  48714. */
  48715. hide(): void;
  48716. private _render;
  48717. /**
  48718. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48719. * @param mesh Defines the mesh we want the helper attached to
  48720. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48721. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48722. * @param length Defines the length of the ray
  48723. */
  48724. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48725. /**
  48726. * Detach the ray helper from the mesh it has previously been attached to.
  48727. */
  48728. detachFromMesh(): void;
  48729. private _updateToMesh;
  48730. /**
  48731. * Dispose the helper and release its associated resources.
  48732. */
  48733. dispose(): void;
  48734. }
  48735. }
  48736. declare module "babylonjs/Debug/skeletonViewer" {
  48737. import { Color3 } from "babylonjs/Maths/math.color";
  48738. import { Scene } from "babylonjs/scene";
  48739. import { Nullable } from "babylonjs/types";
  48740. import { Skeleton } from "babylonjs/Bones/skeleton";
  48741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48742. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48743. /**
  48744. * Class used to render a debug view of a given skeleton
  48745. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48746. */
  48747. export class SkeletonViewer {
  48748. /** defines the skeleton to render */
  48749. skeleton: Skeleton;
  48750. /** defines the mesh attached to the skeleton */
  48751. mesh: AbstractMesh;
  48752. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48753. autoUpdateBonesMatrices: boolean;
  48754. /** defines the rendering group id to use with the viewer */
  48755. renderingGroupId: number;
  48756. /** Gets or sets the color used to render the skeleton */
  48757. color: Color3;
  48758. private _scene;
  48759. private _debugLines;
  48760. private _debugMesh;
  48761. private _isEnabled;
  48762. private _renderFunction;
  48763. private _utilityLayer;
  48764. /**
  48765. * Returns the mesh used to render the bones
  48766. */
  48767. get debugMesh(): Nullable<LinesMesh>;
  48768. /**
  48769. * Creates a new SkeletonViewer
  48770. * @param skeleton defines the skeleton to render
  48771. * @param mesh defines the mesh attached to the skeleton
  48772. * @param scene defines the hosting scene
  48773. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48774. * @param renderingGroupId defines the rendering group id to use with the viewer
  48775. */
  48776. constructor(
  48777. /** defines the skeleton to render */
  48778. skeleton: Skeleton,
  48779. /** defines the mesh attached to the skeleton */
  48780. mesh: AbstractMesh, scene: Scene,
  48781. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48782. autoUpdateBonesMatrices?: boolean,
  48783. /** defines the rendering group id to use with the viewer */
  48784. renderingGroupId?: number);
  48785. /** Gets or sets a boolean indicating if the viewer is enabled */
  48786. set isEnabled(value: boolean);
  48787. get isEnabled(): boolean;
  48788. private _getBonePosition;
  48789. private _getLinesForBonesWithLength;
  48790. private _getLinesForBonesNoLength;
  48791. /** Update the viewer to sync with current skeleton state */
  48792. update(): void;
  48793. /** Release associated resources */
  48794. dispose(): void;
  48795. }
  48796. }
  48797. declare module "babylonjs/Debug/index" {
  48798. export * from "babylonjs/Debug/axesViewer";
  48799. export * from "babylonjs/Debug/boneAxesViewer";
  48800. export * from "babylonjs/Debug/debugLayer";
  48801. export * from "babylonjs/Debug/physicsViewer";
  48802. export * from "babylonjs/Debug/rayHelper";
  48803. export * from "babylonjs/Debug/skeletonViewer";
  48804. }
  48805. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  48806. import { Observable } from "babylonjs/Misc/observable";
  48807. import { Engine } from "babylonjs/Engines/engine";
  48808. import { IDisposable } from "babylonjs/scene";
  48809. import { Nullable } from "babylonjs/types";
  48810. /**
  48811. * This class will take all inputs from Keyboard, Pointer, and
  48812. * any Gamepads and provide a polling system that all devices
  48813. * will use. This class assumes that there will only be one
  48814. * pointer device and one keyboard.
  48815. */
  48816. export class DeviceInputSystem implements IDisposable {
  48817. /** POINTER_DEVICE */
  48818. static readonly POINTER_DEVICE: string;
  48819. /** KEYBOARD_DEVICE */
  48820. static readonly KEYBOARD_DEVICE: string;
  48821. /**
  48822. * Observable to be triggered when a device is connected
  48823. */
  48824. onDeviceConnectedObservable: Observable<string>;
  48825. /**
  48826. * Observable to be triggered when a device is disconnected
  48827. */
  48828. onDeviceDisconnectedObservable: Observable<string>;
  48829. private _inputs;
  48830. private _gamepads;
  48831. private _keyboardActive;
  48832. private _pointerActive;
  48833. private _elementToAttachTo;
  48834. private _keyboardDownEvent;
  48835. private _keyboardUpEvent;
  48836. private _pointerMoveEvent;
  48837. private _pointerDownEvent;
  48838. private _pointerUpEvent;
  48839. private _gamepadConnectedEvent;
  48840. private _gamepadDisconnectedEvent;
  48841. private static _MAX_KEYCODES;
  48842. private static _MAX_POINTER_INPUTS;
  48843. /**
  48844. * Default Constructor
  48845. * @param engine - engine to pull input element from
  48846. */
  48847. constructor(engine: Engine);
  48848. /**
  48849. * Checks for current device input value, given an id and input index
  48850. * @param deviceName Id of connected device
  48851. * @param inputIndex Index of device input
  48852. * @returns Current value of input
  48853. */
  48854. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  48855. /**
  48856. * Dispose of all the eventlisteners and clears the observables
  48857. */
  48858. dispose(): void;
  48859. /**
  48860. * Add device and inputs to device map
  48861. * @param deviceName Assigned name of device (may be SN)
  48862. * @param numberOfInputs Number of input entries to create for given device
  48863. */
  48864. private _registerDevice;
  48865. /**
  48866. * Given a specific device name, remove that device from the device map
  48867. * @param deviceName Name of device to be removed
  48868. */
  48869. private _unregisterDevice;
  48870. /**
  48871. * Handle all actions that come from keyboard interaction
  48872. */
  48873. private _handleKeyActions;
  48874. /**
  48875. * Handle all actions that come from pointer interaction
  48876. */
  48877. private _handlePointerActions;
  48878. /**
  48879. * Handle all actions that come from gamepad interaction
  48880. */
  48881. private _handleGamepadActions;
  48882. /**
  48883. * Update all non-event based devices with each frame
  48884. */
  48885. private _updateDevice;
  48886. }
  48887. }
  48888. declare module "babylonjs/DeviceInput/index" {
  48889. export * from "babylonjs/DeviceInput/deviceInputSystem";
  48890. }
  48891. declare module "babylonjs/Engines/nullEngine" {
  48892. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48893. import { Engine } from "babylonjs/Engines/engine";
  48894. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48895. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48897. import { Effect } from "babylonjs/Materials/effect";
  48898. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48899. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48900. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48901. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48902. /**
  48903. * Options to create the null engine
  48904. */
  48905. export class NullEngineOptions {
  48906. /**
  48907. * Render width (Default: 512)
  48908. */
  48909. renderWidth: number;
  48910. /**
  48911. * Render height (Default: 256)
  48912. */
  48913. renderHeight: number;
  48914. /**
  48915. * Texture size (Default: 512)
  48916. */
  48917. textureSize: number;
  48918. /**
  48919. * If delta time between frames should be constant
  48920. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48921. */
  48922. deterministicLockstep: boolean;
  48923. /**
  48924. * Maximum about of steps between frames (Default: 4)
  48925. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48926. */
  48927. lockstepMaxSteps: number;
  48928. }
  48929. /**
  48930. * The null engine class provides support for headless version of babylon.js.
  48931. * This can be used in server side scenario or for testing purposes
  48932. */
  48933. export class NullEngine extends Engine {
  48934. private _options;
  48935. /**
  48936. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48937. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48938. * @returns true if engine is in deterministic lock step mode
  48939. */
  48940. isDeterministicLockStep(): boolean;
  48941. /**
  48942. * Gets the max steps when engine is running in deterministic lock step
  48943. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48944. * @returns the max steps
  48945. */
  48946. getLockstepMaxSteps(): number;
  48947. /**
  48948. * Gets the current hardware scaling level.
  48949. * By default the hardware scaling level is computed from the window device ratio.
  48950. * 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.
  48951. * @returns a number indicating the current hardware scaling level
  48952. */
  48953. getHardwareScalingLevel(): number;
  48954. constructor(options?: NullEngineOptions);
  48955. /**
  48956. * Creates a vertex buffer
  48957. * @param vertices the data for the vertex buffer
  48958. * @returns the new WebGL static buffer
  48959. */
  48960. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48961. /**
  48962. * Creates a new index buffer
  48963. * @param indices defines the content of the index buffer
  48964. * @param updatable defines if the index buffer must be updatable
  48965. * @returns a new webGL buffer
  48966. */
  48967. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48968. /**
  48969. * Clear the current render buffer or the current render target (if any is set up)
  48970. * @param color defines the color to use
  48971. * @param backBuffer defines if the back buffer must be cleared
  48972. * @param depth defines if the depth buffer must be cleared
  48973. * @param stencil defines if the stencil buffer must be cleared
  48974. */
  48975. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48976. /**
  48977. * Gets the current render width
  48978. * @param useScreen defines if screen size must be used (or the current render target if any)
  48979. * @returns a number defining the current render width
  48980. */
  48981. getRenderWidth(useScreen?: boolean): number;
  48982. /**
  48983. * Gets the current render height
  48984. * @param useScreen defines if screen size must be used (or the current render target if any)
  48985. * @returns a number defining the current render height
  48986. */
  48987. getRenderHeight(useScreen?: boolean): number;
  48988. /**
  48989. * Set the WebGL's viewport
  48990. * @param viewport defines the viewport element to be used
  48991. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48992. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48993. */
  48994. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48995. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48996. /**
  48997. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48998. * @param pipelineContext defines the pipeline context to use
  48999. * @param uniformsNames defines the list of uniform names
  49000. * @returns an array of webGL uniform locations
  49001. */
  49002. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  49003. /**
  49004. * Gets the lsit of active attributes for a given webGL program
  49005. * @param pipelineContext defines the pipeline context to use
  49006. * @param attributesNames defines the list of attribute names to get
  49007. * @returns an array of indices indicating the offset of each attribute
  49008. */
  49009. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49010. /**
  49011. * Binds an effect to the webGL context
  49012. * @param effect defines the effect to bind
  49013. */
  49014. bindSamplers(effect: Effect): void;
  49015. /**
  49016. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  49017. * @param effect defines the effect to activate
  49018. */
  49019. enableEffect(effect: Effect): void;
  49020. /**
  49021. * Set various states to the webGL context
  49022. * @param culling defines backface culling state
  49023. * @param zOffset defines the value to apply to zOffset (0 by default)
  49024. * @param force defines if states must be applied even if cache is up to date
  49025. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  49026. */
  49027. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49028. /**
  49029. * Set the value of an uniform to an array of int32
  49030. * @param uniform defines the webGL uniform location where to store the value
  49031. * @param array defines the array of int32 to store
  49032. */
  49033. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49034. /**
  49035. * Set the value of an uniform to an array of int32 (stored as vec2)
  49036. * @param uniform defines the webGL uniform location where to store the value
  49037. * @param array defines the array of int32 to store
  49038. */
  49039. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49040. /**
  49041. * Set the value of an uniform to an array of int32 (stored as vec3)
  49042. * @param uniform defines the webGL uniform location where to store the value
  49043. * @param array defines the array of int32 to store
  49044. */
  49045. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49046. /**
  49047. * Set the value of an uniform to an array of int32 (stored as vec4)
  49048. * @param uniform defines the webGL uniform location where to store the value
  49049. * @param array defines the array of int32 to store
  49050. */
  49051. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49052. /**
  49053. * Set the value of an uniform to an array of float32
  49054. * @param uniform defines the webGL uniform location where to store the value
  49055. * @param array defines the array of float32 to store
  49056. */
  49057. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49058. /**
  49059. * Set the value of an uniform to an array of float32 (stored as vec2)
  49060. * @param uniform defines the webGL uniform location where to store the value
  49061. * @param array defines the array of float32 to store
  49062. */
  49063. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49064. /**
  49065. * Set the value of an uniform to an array of float32 (stored as vec3)
  49066. * @param uniform defines the webGL uniform location where to store the value
  49067. * @param array defines the array of float32 to store
  49068. */
  49069. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49070. /**
  49071. * Set the value of an uniform to an array of float32 (stored as vec4)
  49072. * @param uniform defines the webGL uniform location where to store the value
  49073. * @param array defines the array of float32 to store
  49074. */
  49075. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49076. /**
  49077. * Set the value of an uniform to an array of number
  49078. * @param uniform defines the webGL uniform location where to store the value
  49079. * @param array defines the array of number to store
  49080. */
  49081. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49082. /**
  49083. * Set the value of an uniform to an array of number (stored as vec2)
  49084. * @param uniform defines the webGL uniform location where to store the value
  49085. * @param array defines the array of number to store
  49086. */
  49087. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49088. /**
  49089. * Set the value of an uniform to an array of number (stored as vec3)
  49090. * @param uniform defines the webGL uniform location where to store the value
  49091. * @param array defines the array of number to store
  49092. */
  49093. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49094. /**
  49095. * Set the value of an uniform to an array of number (stored as vec4)
  49096. * @param uniform defines the webGL uniform location where to store the value
  49097. * @param array defines the array of number to store
  49098. */
  49099. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49100. /**
  49101. * Set the value of an uniform to an array of float32 (stored as matrices)
  49102. * @param uniform defines the webGL uniform location where to store the value
  49103. * @param matrices defines the array of float32 to store
  49104. */
  49105. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49106. /**
  49107. * Set the value of an uniform to a matrix (3x3)
  49108. * @param uniform defines the webGL uniform location where to store the value
  49109. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  49110. */
  49111. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49112. /**
  49113. * Set the value of an uniform to a matrix (2x2)
  49114. * @param uniform defines the webGL uniform location where to store the value
  49115. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  49116. */
  49117. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49118. /**
  49119. * Set the value of an uniform to a number (float)
  49120. * @param uniform defines the webGL uniform location where to store the value
  49121. * @param value defines the float number to store
  49122. */
  49123. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49124. /**
  49125. * Set the value of an uniform to a vec2
  49126. * @param uniform defines the webGL uniform location where to store the value
  49127. * @param x defines the 1st component of the value
  49128. * @param y defines the 2nd component of the value
  49129. */
  49130. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49131. /**
  49132. * Set the value of an uniform to a vec3
  49133. * @param uniform defines the webGL uniform location where to store the value
  49134. * @param x defines the 1st component of the value
  49135. * @param y defines the 2nd component of the value
  49136. * @param z defines the 3rd component of the value
  49137. */
  49138. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49139. /**
  49140. * Set the value of an uniform to a boolean
  49141. * @param uniform defines the webGL uniform location where to store the value
  49142. * @param bool defines the boolean to store
  49143. */
  49144. setBool(uniform: WebGLUniformLocation, bool: number): void;
  49145. /**
  49146. * Set the value of an uniform to a vec4
  49147. * @param uniform defines the webGL uniform location where to store the value
  49148. * @param x defines the 1st component of the value
  49149. * @param y defines the 2nd component of the value
  49150. * @param z defines the 3rd component of the value
  49151. * @param w defines the 4th component of the value
  49152. */
  49153. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49154. /**
  49155. * Sets the current alpha mode
  49156. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  49157. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49158. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49159. */
  49160. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49161. /**
  49162. * Bind webGl buffers directly to the webGL context
  49163. * @param vertexBuffers defines the vertex buffer to bind
  49164. * @param indexBuffer defines the index buffer to bind
  49165. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  49166. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  49167. * @param effect defines the effect associated with the vertex buffer
  49168. */
  49169. bindBuffers(vertexBuffers: {
  49170. [key: string]: VertexBuffer;
  49171. }, indexBuffer: DataBuffer, effect: Effect): void;
  49172. /**
  49173. * Force the entire cache to be cleared
  49174. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  49175. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  49176. */
  49177. wipeCaches(bruteForce?: boolean): void;
  49178. /**
  49179. * Send a draw order
  49180. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  49181. * @param indexStart defines the starting index
  49182. * @param indexCount defines the number of index to draw
  49183. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49184. */
  49185. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  49186. /**
  49187. * Draw a list of indexed primitives
  49188. * @param fillMode defines the primitive to use
  49189. * @param indexStart defines the starting index
  49190. * @param indexCount defines the number of index to draw
  49191. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49192. */
  49193. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49194. /**
  49195. * Draw a list of unindexed primitives
  49196. * @param fillMode defines the primitive to use
  49197. * @param verticesStart defines the index of first vertex to draw
  49198. * @param verticesCount defines the count of vertices to draw
  49199. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49200. */
  49201. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49202. /** @hidden */
  49203. _createTexture(): WebGLTexture;
  49204. /** @hidden */
  49205. _releaseTexture(texture: InternalTexture): void;
  49206. /**
  49207. * Usually called from Texture.ts.
  49208. * Passed information to create a WebGLTexture
  49209. * @param urlArg defines a value which contains one of the following:
  49210. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49211. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49212. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49213. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49214. * @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)
  49215. * @param scene needed for loading to the correct scene
  49216. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49217. * @param onLoad optional callback to be called upon successful completion
  49218. * @param onError optional callback to be called upon failure
  49219. * @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
  49220. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49221. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49222. * @param forcedExtension defines the extension to use to pick the right loader
  49223. * @param mimeType defines an optional mime type
  49224. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49225. */
  49226. 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;
  49227. /**
  49228. * Creates a new render target texture
  49229. * @param size defines the size of the texture
  49230. * @param options defines the options used to create the texture
  49231. * @returns a new render target texture stored in an InternalTexture
  49232. */
  49233. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  49234. /**
  49235. * Update the sampling mode of a given texture
  49236. * @param samplingMode defines the required sampling mode
  49237. * @param texture defines the texture to update
  49238. */
  49239. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49240. /**
  49241. * Binds the frame buffer to the specified texture.
  49242. * @param texture The texture to render to or null for the default canvas
  49243. * @param faceIndex The face of the texture to render to in case of cube texture
  49244. * @param requiredWidth The width of the target to render to
  49245. * @param requiredHeight The height of the target to render to
  49246. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  49247. * @param lodLevel defines le lod level to bind to the frame buffer
  49248. */
  49249. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49250. /**
  49251. * Unbind the current render target texture from the webGL context
  49252. * @param texture defines the render target texture to unbind
  49253. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49254. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49255. */
  49256. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49257. /**
  49258. * Creates a dynamic vertex buffer
  49259. * @param vertices the data for the dynamic vertex buffer
  49260. * @returns the new WebGL dynamic buffer
  49261. */
  49262. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  49263. /**
  49264. * Update the content of a dynamic texture
  49265. * @param texture defines the texture to update
  49266. * @param canvas defines the canvas containing the source
  49267. * @param invertY defines if data must be stored with Y axis inverted
  49268. * @param premulAlpha defines if alpha is stored as premultiplied
  49269. * @param format defines the format of the data
  49270. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  49271. */
  49272. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49273. /**
  49274. * Gets a boolean indicating if all created effects are ready
  49275. * @returns true if all effects are ready
  49276. */
  49277. areAllEffectsReady(): boolean;
  49278. /**
  49279. * @hidden
  49280. * Get the current error code of the webGL context
  49281. * @returns the error code
  49282. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49283. */
  49284. getError(): number;
  49285. /** @hidden */
  49286. _getUnpackAlignement(): number;
  49287. /** @hidden */
  49288. _unpackFlipY(value: boolean): void;
  49289. /**
  49290. * Update a dynamic index buffer
  49291. * @param indexBuffer defines the target index buffer
  49292. * @param indices defines the data to update
  49293. * @param offset defines the offset in the target index buffer where update should start
  49294. */
  49295. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49296. /**
  49297. * Updates a dynamic vertex buffer.
  49298. * @param vertexBuffer the vertex buffer to update
  49299. * @param vertices the data used to update the vertex buffer
  49300. * @param byteOffset the byte offset of the data (optional)
  49301. * @param byteLength the byte length of the data (optional)
  49302. */
  49303. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49304. /** @hidden */
  49305. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49306. /** @hidden */
  49307. _bindTexture(channel: number, texture: InternalTexture): void;
  49308. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49309. /**
  49310. * 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
  49311. */
  49312. releaseEffects(): void;
  49313. displayLoadingUI(): void;
  49314. hideLoadingUI(): void;
  49315. /** @hidden */
  49316. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49317. /** @hidden */
  49318. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49319. /** @hidden */
  49320. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49321. /** @hidden */
  49322. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49323. }
  49324. }
  49325. declare module "babylonjs/Instrumentation/timeToken" {
  49326. import { Nullable } from "babylonjs/types";
  49327. /**
  49328. * @hidden
  49329. **/
  49330. export class _TimeToken {
  49331. _startTimeQuery: Nullable<WebGLQuery>;
  49332. _endTimeQuery: Nullable<WebGLQuery>;
  49333. _timeElapsedQuery: Nullable<WebGLQuery>;
  49334. _timeElapsedQueryEnded: boolean;
  49335. }
  49336. }
  49337. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49338. import { Nullable, int } from "babylonjs/types";
  49339. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49340. /** @hidden */
  49341. export class _OcclusionDataStorage {
  49342. /** @hidden */
  49343. occlusionInternalRetryCounter: number;
  49344. /** @hidden */
  49345. isOcclusionQueryInProgress: boolean;
  49346. /** @hidden */
  49347. isOccluded: boolean;
  49348. /** @hidden */
  49349. occlusionRetryCount: number;
  49350. /** @hidden */
  49351. occlusionType: number;
  49352. /** @hidden */
  49353. occlusionQueryAlgorithmType: number;
  49354. }
  49355. module "babylonjs/Engines/engine" {
  49356. interface Engine {
  49357. /**
  49358. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49359. * @return the new query
  49360. */
  49361. createQuery(): WebGLQuery;
  49362. /**
  49363. * Delete and release a webGL query
  49364. * @param query defines the query to delete
  49365. * @return the current engine
  49366. */
  49367. deleteQuery(query: WebGLQuery): Engine;
  49368. /**
  49369. * Check if a given query has resolved and got its value
  49370. * @param query defines the query to check
  49371. * @returns true if the query got its value
  49372. */
  49373. isQueryResultAvailable(query: WebGLQuery): boolean;
  49374. /**
  49375. * Gets the value of a given query
  49376. * @param query defines the query to check
  49377. * @returns the value of the query
  49378. */
  49379. getQueryResult(query: WebGLQuery): number;
  49380. /**
  49381. * Initiates an occlusion query
  49382. * @param algorithmType defines the algorithm to use
  49383. * @param query defines the query to use
  49384. * @returns the current engine
  49385. * @see http://doc.babylonjs.com/features/occlusionquery
  49386. */
  49387. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49388. /**
  49389. * Ends an occlusion query
  49390. * @see http://doc.babylonjs.com/features/occlusionquery
  49391. * @param algorithmType defines the algorithm to use
  49392. * @returns the current engine
  49393. */
  49394. endOcclusionQuery(algorithmType: number): Engine;
  49395. /**
  49396. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49397. * Please note that only one query can be issued at a time
  49398. * @returns a time token used to track the time span
  49399. */
  49400. startTimeQuery(): Nullable<_TimeToken>;
  49401. /**
  49402. * Ends a time query
  49403. * @param token defines the token used to measure the time span
  49404. * @returns the time spent (in ns)
  49405. */
  49406. endTimeQuery(token: _TimeToken): int;
  49407. /** @hidden */
  49408. _currentNonTimestampToken: Nullable<_TimeToken>;
  49409. /** @hidden */
  49410. _createTimeQuery(): WebGLQuery;
  49411. /** @hidden */
  49412. _deleteTimeQuery(query: WebGLQuery): void;
  49413. /** @hidden */
  49414. _getGlAlgorithmType(algorithmType: number): number;
  49415. /** @hidden */
  49416. _getTimeQueryResult(query: WebGLQuery): any;
  49417. /** @hidden */
  49418. _getTimeQueryAvailability(query: WebGLQuery): any;
  49419. }
  49420. }
  49421. module "babylonjs/Meshes/abstractMesh" {
  49422. interface AbstractMesh {
  49423. /**
  49424. * Backing filed
  49425. * @hidden
  49426. */
  49427. __occlusionDataStorage: _OcclusionDataStorage;
  49428. /**
  49429. * Access property
  49430. * @hidden
  49431. */
  49432. _occlusionDataStorage: _OcclusionDataStorage;
  49433. /**
  49434. * 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.
  49435. * The default value is -1 which means don't break the query and wait till the result
  49436. * @see http://doc.babylonjs.com/features/occlusionquery
  49437. */
  49438. occlusionRetryCount: number;
  49439. /**
  49440. * 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:
  49441. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49442. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49443. * * 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.
  49444. * @see http://doc.babylonjs.com/features/occlusionquery
  49445. */
  49446. occlusionType: number;
  49447. /**
  49448. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49449. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49450. * * 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.
  49451. * @see http://doc.babylonjs.com/features/occlusionquery
  49452. */
  49453. occlusionQueryAlgorithmType: number;
  49454. /**
  49455. * 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
  49456. * @see http://doc.babylonjs.com/features/occlusionquery
  49457. */
  49458. isOccluded: boolean;
  49459. /**
  49460. * Flag to check the progress status of the query
  49461. * @see http://doc.babylonjs.com/features/occlusionquery
  49462. */
  49463. isOcclusionQueryInProgress: boolean;
  49464. }
  49465. }
  49466. }
  49467. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49468. import { Nullable } from "babylonjs/types";
  49469. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49470. /** @hidden */
  49471. export var _forceTransformFeedbackToBundle: boolean;
  49472. module "babylonjs/Engines/engine" {
  49473. interface Engine {
  49474. /**
  49475. * Creates a webGL transform feedback object
  49476. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49477. * @returns the webGL transform feedback object
  49478. */
  49479. createTransformFeedback(): WebGLTransformFeedback;
  49480. /**
  49481. * Delete a webGL transform feedback object
  49482. * @param value defines the webGL transform feedback object to delete
  49483. */
  49484. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49485. /**
  49486. * Bind a webGL transform feedback object to the webgl context
  49487. * @param value defines the webGL transform feedback object to bind
  49488. */
  49489. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49490. /**
  49491. * Begins a transform feedback operation
  49492. * @param usePoints defines if points or triangles must be used
  49493. */
  49494. beginTransformFeedback(usePoints: boolean): void;
  49495. /**
  49496. * Ends a transform feedback operation
  49497. */
  49498. endTransformFeedback(): void;
  49499. /**
  49500. * Specify the varyings to use with transform feedback
  49501. * @param program defines the associated webGL program
  49502. * @param value defines the list of strings representing the varying names
  49503. */
  49504. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49505. /**
  49506. * Bind a webGL buffer for a transform feedback operation
  49507. * @param value defines the webGL buffer to bind
  49508. */
  49509. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49510. }
  49511. }
  49512. }
  49513. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49514. import { Scene } from "babylonjs/scene";
  49515. import { Engine } from "babylonjs/Engines/engine";
  49516. import { Texture } from "babylonjs/Materials/Textures/texture";
  49517. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49518. import "babylonjs/Engines/Extensions/engine.multiRender";
  49519. /**
  49520. * Creation options of the multi render target texture.
  49521. */
  49522. export interface IMultiRenderTargetOptions {
  49523. /**
  49524. * Define if the texture needs to create mip maps after render.
  49525. */
  49526. generateMipMaps?: boolean;
  49527. /**
  49528. * Define the types of all the draw buffers we want to create
  49529. */
  49530. types?: number[];
  49531. /**
  49532. * Define the sampling modes of all the draw buffers we want to create
  49533. */
  49534. samplingModes?: number[];
  49535. /**
  49536. * Define if a depth buffer is required
  49537. */
  49538. generateDepthBuffer?: boolean;
  49539. /**
  49540. * Define if a stencil buffer is required
  49541. */
  49542. generateStencilBuffer?: boolean;
  49543. /**
  49544. * Define if a depth texture is required instead of a depth buffer
  49545. */
  49546. generateDepthTexture?: boolean;
  49547. /**
  49548. * Define the number of desired draw buffers
  49549. */
  49550. textureCount?: number;
  49551. /**
  49552. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49553. */
  49554. doNotChangeAspectRatio?: boolean;
  49555. /**
  49556. * Define the default type of the buffers we are creating
  49557. */
  49558. defaultType?: number;
  49559. }
  49560. /**
  49561. * A multi render target, like a render target provides the ability to render to a texture.
  49562. * Unlike the render target, it can render to several draw buffers in one draw.
  49563. * This is specially interesting in deferred rendering or for any effects requiring more than
  49564. * just one color from a single pass.
  49565. */
  49566. export class MultiRenderTarget extends RenderTargetTexture {
  49567. private _internalTextures;
  49568. private _textures;
  49569. private _multiRenderTargetOptions;
  49570. /**
  49571. * Get if draw buffers are currently supported by the used hardware and browser.
  49572. */
  49573. get isSupported(): boolean;
  49574. /**
  49575. * Get the list of textures generated by the multi render target.
  49576. */
  49577. get textures(): Texture[];
  49578. /**
  49579. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49580. */
  49581. get depthTexture(): Texture;
  49582. /**
  49583. * Set the wrapping mode on U of all the textures we are rendering to.
  49584. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49585. */
  49586. set wrapU(wrap: number);
  49587. /**
  49588. * Set the wrapping mode on V of all the textures we are rendering to.
  49589. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49590. */
  49591. set wrapV(wrap: number);
  49592. /**
  49593. * Instantiate a new multi render target texture.
  49594. * A multi render target, like a render target provides the ability to render to a texture.
  49595. * Unlike the render target, it can render to several draw buffers in one draw.
  49596. * This is specially interesting in deferred rendering or for any effects requiring more than
  49597. * just one color from a single pass.
  49598. * @param name Define the name of the texture
  49599. * @param size Define the size of the buffers to render to
  49600. * @param count Define the number of target we are rendering into
  49601. * @param scene Define the scene the texture belongs to
  49602. * @param options Define the options used to create the multi render target
  49603. */
  49604. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49605. /** @hidden */
  49606. _rebuild(): void;
  49607. private _createInternalTextures;
  49608. private _createTextures;
  49609. /**
  49610. * Define the number of samples used if MSAA is enabled.
  49611. */
  49612. get samples(): number;
  49613. set samples(value: number);
  49614. /**
  49615. * Resize all the textures in the multi render target.
  49616. * Be carrefull as it will recreate all the data in the new texture.
  49617. * @param size Define the new size
  49618. */
  49619. resize(size: any): void;
  49620. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49621. /**
  49622. * Dispose the render targets and their associated resources
  49623. */
  49624. dispose(): void;
  49625. /**
  49626. * Release all the underlying texture used as draw buffers.
  49627. */
  49628. releaseInternalTextures(): void;
  49629. }
  49630. }
  49631. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49633. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49634. import { Nullable } from "babylonjs/types";
  49635. module "babylonjs/Engines/thinEngine" {
  49636. interface ThinEngine {
  49637. /**
  49638. * Unbind a list of render target textures from the webGL context
  49639. * This is used only when drawBuffer extension or webGL2 are active
  49640. * @param textures defines the render target textures to unbind
  49641. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49642. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49643. */
  49644. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49645. /**
  49646. * Create a multi render target texture
  49647. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49648. * @param size defines the size of the texture
  49649. * @param options defines the creation options
  49650. * @returns the cube texture as an InternalTexture
  49651. */
  49652. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49653. /**
  49654. * Update the sample count for a given multiple render target texture
  49655. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49656. * @param textures defines the textures to update
  49657. * @param samples defines the sample count to set
  49658. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49659. */
  49660. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49661. }
  49662. }
  49663. }
  49664. declare module "babylonjs/Engines/Extensions/engine.views" {
  49665. import { Camera } from "babylonjs/Cameras/camera";
  49666. import { Nullable } from "babylonjs/types";
  49667. /**
  49668. * Class used to define an additional view for the engine
  49669. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49670. */
  49671. export class EngineView {
  49672. /** Defines the canvas where to render the view */
  49673. target: HTMLCanvasElement;
  49674. /** Defines an optional camera used to render the view (will use active camera else) */
  49675. camera?: Camera;
  49676. }
  49677. module "babylonjs/Engines/engine" {
  49678. interface Engine {
  49679. /**
  49680. * Gets or sets the HTML element to use for attaching events
  49681. */
  49682. inputElement: Nullable<HTMLElement>;
  49683. /**
  49684. * Gets the current engine view
  49685. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49686. */
  49687. activeView: Nullable<EngineView>;
  49688. /** Gets or sets the list of views */
  49689. views: EngineView[];
  49690. /**
  49691. * Register a new child canvas
  49692. * @param canvas defines the canvas to register
  49693. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49694. * @returns the associated view
  49695. */
  49696. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49697. /**
  49698. * Remove a registered child canvas
  49699. * @param canvas defines the canvas to remove
  49700. * @returns the current engine
  49701. */
  49702. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49703. }
  49704. }
  49705. }
  49706. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49707. import { Nullable } from "babylonjs/types";
  49708. module "babylonjs/Engines/engine" {
  49709. interface Engine {
  49710. /** @hidden */
  49711. _excludedCompressedTextures: string[];
  49712. /** @hidden */
  49713. _textureFormatInUse: string;
  49714. /**
  49715. * Gets the list of texture formats supported
  49716. */
  49717. readonly texturesSupported: Array<string>;
  49718. /**
  49719. * Gets the texture format in use
  49720. */
  49721. readonly textureFormatInUse: Nullable<string>;
  49722. /**
  49723. * Set the compressed texture extensions or file names to skip.
  49724. *
  49725. * @param skippedFiles defines the list of those texture files you want to skip
  49726. * Example: [".dds", ".env", "myfile.png"]
  49727. */
  49728. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49729. /**
  49730. * Set the compressed texture format to use, based on the formats you have, and the formats
  49731. * supported by the hardware / browser.
  49732. *
  49733. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49734. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49735. * to API arguments needed to compressed textures. This puts the burden on the container
  49736. * generator to house the arcane code for determining these for current & future formats.
  49737. *
  49738. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49739. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49740. *
  49741. * Note: The result of this call is not taken into account when a texture is base64.
  49742. *
  49743. * @param formatsAvailable defines the list of those format families you have created
  49744. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49745. *
  49746. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49747. * @returns The extension selected.
  49748. */
  49749. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49750. }
  49751. }
  49752. }
  49753. declare module "babylonjs/Engines/Extensions/index" {
  49754. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49755. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49756. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49757. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49758. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49759. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49760. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49761. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49762. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49763. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49764. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49765. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49766. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49767. export * from "babylonjs/Engines/Extensions/engine.views";
  49768. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49769. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49770. }
  49771. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49772. import { Nullable } from "babylonjs/types";
  49773. /**
  49774. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49775. */
  49776. export interface CubeMapInfo {
  49777. /**
  49778. * The pixel array for the front face.
  49779. * This is stored in format, left to right, up to down format.
  49780. */
  49781. front: Nullable<ArrayBufferView>;
  49782. /**
  49783. * The pixel array for the back face.
  49784. * This is stored in format, left to right, up to down format.
  49785. */
  49786. back: Nullable<ArrayBufferView>;
  49787. /**
  49788. * The pixel array for the left face.
  49789. * This is stored in format, left to right, up to down format.
  49790. */
  49791. left: Nullable<ArrayBufferView>;
  49792. /**
  49793. * The pixel array for the right face.
  49794. * This is stored in format, left to right, up to down format.
  49795. */
  49796. right: Nullable<ArrayBufferView>;
  49797. /**
  49798. * The pixel array for the up face.
  49799. * This is stored in format, left to right, up to down format.
  49800. */
  49801. up: Nullable<ArrayBufferView>;
  49802. /**
  49803. * The pixel array for the down face.
  49804. * This is stored in format, left to right, up to down format.
  49805. */
  49806. down: Nullable<ArrayBufferView>;
  49807. /**
  49808. * The size of the cubemap stored.
  49809. *
  49810. * Each faces will be size * size pixels.
  49811. */
  49812. size: number;
  49813. /**
  49814. * The format of the texture.
  49815. *
  49816. * RGBA, RGB.
  49817. */
  49818. format: number;
  49819. /**
  49820. * The type of the texture data.
  49821. *
  49822. * UNSIGNED_INT, FLOAT.
  49823. */
  49824. type: number;
  49825. /**
  49826. * Specifies whether the texture is in gamma space.
  49827. */
  49828. gammaSpace: boolean;
  49829. }
  49830. /**
  49831. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49832. */
  49833. export class PanoramaToCubeMapTools {
  49834. private static FACE_FRONT;
  49835. private static FACE_BACK;
  49836. private static FACE_RIGHT;
  49837. private static FACE_LEFT;
  49838. private static FACE_DOWN;
  49839. private static FACE_UP;
  49840. /**
  49841. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49842. *
  49843. * @param float32Array The source data.
  49844. * @param inputWidth The width of the input panorama.
  49845. * @param inputHeight The height of the input panorama.
  49846. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49847. * @return The cubemap data
  49848. */
  49849. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49850. private static CreateCubemapTexture;
  49851. private static CalcProjectionSpherical;
  49852. }
  49853. }
  49854. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49855. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49857. import { Nullable } from "babylonjs/types";
  49858. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49859. /**
  49860. * Helper class dealing with the extraction of spherical polynomial dataArray
  49861. * from a cube map.
  49862. */
  49863. export class CubeMapToSphericalPolynomialTools {
  49864. private static FileFaces;
  49865. /**
  49866. * Converts a texture to the according Spherical Polynomial data.
  49867. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49868. *
  49869. * @param texture The texture to extract the information from.
  49870. * @return The Spherical Polynomial data.
  49871. */
  49872. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49873. /**
  49874. * Converts a cubemap to the according Spherical Polynomial data.
  49875. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49876. *
  49877. * @param cubeInfo The Cube map to extract the information from.
  49878. * @return The Spherical Polynomial data.
  49879. */
  49880. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49881. }
  49882. }
  49883. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49884. import { Nullable } from "babylonjs/types";
  49885. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49886. module "babylonjs/Materials/Textures/baseTexture" {
  49887. interface BaseTexture {
  49888. /**
  49889. * Get the polynomial representation of the texture data.
  49890. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49891. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49892. */
  49893. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49894. }
  49895. }
  49896. }
  49897. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49898. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49899. /** @hidden */
  49900. export var rgbdEncodePixelShader: {
  49901. name: string;
  49902. shader: string;
  49903. };
  49904. }
  49905. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49906. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49907. /** @hidden */
  49908. export var rgbdDecodePixelShader: {
  49909. name: string;
  49910. shader: string;
  49911. };
  49912. }
  49913. declare module "babylonjs/Misc/environmentTextureTools" {
  49914. import { Nullable } from "babylonjs/types";
  49915. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49916. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49917. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49918. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49919. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49920. import "babylonjs/Shaders/rgbdEncode.fragment";
  49921. import "babylonjs/Shaders/rgbdDecode.fragment";
  49922. /**
  49923. * Raw texture data and descriptor sufficient for WebGL texture upload
  49924. */
  49925. export interface EnvironmentTextureInfo {
  49926. /**
  49927. * Version of the environment map
  49928. */
  49929. version: number;
  49930. /**
  49931. * Width of image
  49932. */
  49933. width: number;
  49934. /**
  49935. * Irradiance information stored in the file.
  49936. */
  49937. irradiance: any;
  49938. /**
  49939. * Specular information stored in the file.
  49940. */
  49941. specular: any;
  49942. }
  49943. /**
  49944. * Defines One Image in the file. It requires only the position in the file
  49945. * as well as the length.
  49946. */
  49947. interface BufferImageData {
  49948. /**
  49949. * Length of the image data.
  49950. */
  49951. length: number;
  49952. /**
  49953. * Position of the data from the null terminator delimiting the end of the JSON.
  49954. */
  49955. position: number;
  49956. }
  49957. /**
  49958. * Defines the specular data enclosed in the file.
  49959. * This corresponds to the version 1 of the data.
  49960. */
  49961. export interface EnvironmentTextureSpecularInfoV1 {
  49962. /**
  49963. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49964. */
  49965. specularDataPosition?: number;
  49966. /**
  49967. * This contains all the images data needed to reconstruct the cubemap.
  49968. */
  49969. mipmaps: Array<BufferImageData>;
  49970. /**
  49971. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49972. */
  49973. lodGenerationScale: number;
  49974. }
  49975. /**
  49976. * Sets of helpers addressing the serialization and deserialization of environment texture
  49977. * stored in a BabylonJS env file.
  49978. * Those files are usually stored as .env files.
  49979. */
  49980. export class EnvironmentTextureTools {
  49981. /**
  49982. * Magic number identifying the env file.
  49983. */
  49984. private static _MagicBytes;
  49985. /**
  49986. * Gets the environment info from an env file.
  49987. * @param data The array buffer containing the .env bytes.
  49988. * @returns the environment file info (the json header) if successfully parsed.
  49989. */
  49990. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49991. /**
  49992. * Creates an environment texture from a loaded cube texture.
  49993. * @param texture defines the cube texture to convert in env file
  49994. * @return a promise containing the environment data if succesfull.
  49995. */
  49996. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49997. /**
  49998. * Creates a JSON representation of the spherical data.
  49999. * @param texture defines the texture containing the polynomials
  50000. * @return the JSON representation of the spherical info
  50001. */
  50002. private static _CreateEnvTextureIrradiance;
  50003. /**
  50004. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50005. * @param data the image data
  50006. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50007. * @return the views described by info providing access to the underlying buffer
  50008. */
  50009. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50010. /**
  50011. * Uploads the texture info contained in the env file to the GPU.
  50012. * @param texture defines the internal texture to upload to
  50013. * @param data defines the data to load
  50014. * @param info defines the texture info retrieved through the GetEnvInfo method
  50015. * @returns a promise
  50016. */
  50017. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50018. private static _OnImageReadyAsync;
  50019. /**
  50020. * Uploads the levels of image data to the GPU.
  50021. * @param texture defines the internal texture to upload to
  50022. * @param imageData defines the array buffer views of image data [mipmap][face]
  50023. * @returns a promise
  50024. */
  50025. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50026. /**
  50027. * Uploads spherical polynomials information to the texture.
  50028. * @param texture defines the texture we are trying to upload the information to
  50029. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50030. */
  50031. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50032. /** @hidden */
  50033. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50034. }
  50035. }
  50036. declare module "babylonjs/Maths/math.vertexFormat" {
  50037. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50038. /**
  50039. * Contains position and normal vectors for a vertex
  50040. */
  50041. export class PositionNormalVertex {
  50042. /** the position of the vertex (defaut: 0,0,0) */
  50043. position: Vector3;
  50044. /** the normal of the vertex (defaut: 0,1,0) */
  50045. normal: Vector3;
  50046. /**
  50047. * Creates a PositionNormalVertex
  50048. * @param position the position of the vertex (defaut: 0,0,0)
  50049. * @param normal the normal of the vertex (defaut: 0,1,0)
  50050. */
  50051. constructor(
  50052. /** the position of the vertex (defaut: 0,0,0) */
  50053. position?: Vector3,
  50054. /** the normal of the vertex (defaut: 0,1,0) */
  50055. normal?: Vector3);
  50056. /**
  50057. * Clones the PositionNormalVertex
  50058. * @returns the cloned PositionNormalVertex
  50059. */
  50060. clone(): PositionNormalVertex;
  50061. }
  50062. /**
  50063. * Contains position, normal and uv vectors for a vertex
  50064. */
  50065. export class PositionNormalTextureVertex {
  50066. /** the position of the vertex (defaut: 0,0,0) */
  50067. position: Vector3;
  50068. /** the normal of the vertex (defaut: 0,1,0) */
  50069. normal: Vector3;
  50070. /** the uv of the vertex (default: 0,0) */
  50071. uv: Vector2;
  50072. /**
  50073. * Creates a PositionNormalTextureVertex
  50074. * @param position the position of the vertex (defaut: 0,0,0)
  50075. * @param normal the normal of the vertex (defaut: 0,1,0)
  50076. * @param uv the uv of the vertex (default: 0,0)
  50077. */
  50078. constructor(
  50079. /** the position of the vertex (defaut: 0,0,0) */
  50080. position?: Vector3,
  50081. /** the normal of the vertex (defaut: 0,1,0) */
  50082. normal?: Vector3,
  50083. /** the uv of the vertex (default: 0,0) */
  50084. uv?: Vector2);
  50085. /**
  50086. * Clones the PositionNormalTextureVertex
  50087. * @returns the cloned PositionNormalTextureVertex
  50088. */
  50089. clone(): PositionNormalTextureVertex;
  50090. }
  50091. }
  50092. declare module "babylonjs/Maths/math" {
  50093. export * from "babylonjs/Maths/math.axis";
  50094. export * from "babylonjs/Maths/math.color";
  50095. export * from "babylonjs/Maths/math.constants";
  50096. export * from "babylonjs/Maths/math.frustum";
  50097. export * from "babylonjs/Maths/math.path";
  50098. export * from "babylonjs/Maths/math.plane";
  50099. export * from "babylonjs/Maths/math.size";
  50100. export * from "babylonjs/Maths/math.vector";
  50101. export * from "babylonjs/Maths/math.vertexFormat";
  50102. export * from "babylonjs/Maths/math.viewport";
  50103. }
  50104. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  50105. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50106. /** @hidden */
  50107. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50108. private _genericAttributeLocation;
  50109. private _varyingLocationCount;
  50110. private _varyingLocationMap;
  50111. private _replacements;
  50112. private _textureCount;
  50113. private _uniforms;
  50114. lineProcessor(line: string): string;
  50115. attributeProcessor(attribute: string): string;
  50116. varyingProcessor(varying: string, isFragment: boolean): string;
  50117. uniformProcessor(uniform: string): string;
  50118. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50119. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50120. }
  50121. }
  50122. declare module "babylonjs/Engines/nativeEngine" {
  50123. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  50124. import { Engine } from "babylonjs/Engines/engine";
  50125. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  50126. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50128. import { Effect } from "babylonjs/Materials/effect";
  50129. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  50130. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  50131. import { IColor4Like } from "babylonjs/Maths/math.like";
  50132. import { Scene } from "babylonjs/scene";
  50133. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  50134. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  50135. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  50136. /**
  50137. * Container for accessors for natively-stored mesh data buffers.
  50138. */
  50139. class NativeDataBuffer extends DataBuffer {
  50140. /**
  50141. * Accessor value used to identify/retrieve a natively-stored index buffer.
  50142. */
  50143. nativeIndexBuffer?: any;
  50144. /**
  50145. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  50146. */
  50147. nativeVertexBuffer?: any;
  50148. }
  50149. /** @hidden */
  50150. class NativeTexture extends InternalTexture {
  50151. getInternalTexture(): InternalTexture;
  50152. getViewCount(): number;
  50153. }
  50154. /** @hidden */
  50155. export class NativeEngine extends Engine {
  50156. private readonly _native;
  50157. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  50158. private readonly INVALID_HANDLE;
  50159. getHardwareScalingLevel(): number;
  50160. constructor();
  50161. dispose(): void;
  50162. /**
  50163. * Can be used to override the current requestAnimationFrame requester.
  50164. * @hidden
  50165. */
  50166. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  50167. /**
  50168. * Override default engine behavior.
  50169. * @param color
  50170. * @param backBuffer
  50171. * @param depth
  50172. * @param stencil
  50173. */
  50174. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  50175. /**
  50176. * Gets host document
  50177. * @returns the host document object
  50178. */
  50179. getHostDocument(): Nullable<Document>;
  50180. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50181. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  50182. createVertexBuffer(data: DataArray): NativeDataBuffer;
  50183. recordVertexArrayObject(vertexBuffers: {
  50184. [key: string]: VertexBuffer;
  50185. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  50186. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50187. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  50188. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50189. /**
  50190. * Draw a list of indexed primitives
  50191. * @param fillMode defines the primitive to use
  50192. * @param indexStart defines the starting index
  50193. * @param indexCount defines the number of index to draw
  50194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50195. */
  50196. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50197. /**
  50198. * Draw a list of unindexed primitives
  50199. * @param fillMode defines the primitive to use
  50200. * @param verticesStart defines the index of first vertex to draw
  50201. * @param verticesCount defines the count of vertices to draw
  50202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50203. */
  50204. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50205. createPipelineContext(): IPipelineContext;
  50206. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  50207. /** @hidden */
  50208. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  50209. /** @hidden */
  50210. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  50211. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50212. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  50213. protected _setProgram(program: WebGLProgram): void;
  50214. _releaseEffect(effect: Effect): void;
  50215. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  50216. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  50217. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  50218. bindSamplers(effect: Effect): void;
  50219. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  50220. getRenderWidth(useScreen?: boolean): number;
  50221. getRenderHeight(useScreen?: boolean): number;
  50222. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  50223. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50224. /**
  50225. * Set the z offset to apply to current rendering
  50226. * @param value defines the offset to apply
  50227. */
  50228. setZOffset(value: number): void;
  50229. /**
  50230. * Gets the current value of the zOffset
  50231. * @returns the current zOffset state
  50232. */
  50233. getZOffset(): number;
  50234. /**
  50235. * Enable or disable depth buffering
  50236. * @param enable defines the state to set
  50237. */
  50238. setDepthBuffer(enable: boolean): void;
  50239. /**
  50240. * Gets a boolean indicating if depth writing is enabled
  50241. * @returns the current depth writing state
  50242. */
  50243. getDepthWrite(): boolean;
  50244. /**
  50245. * Enable or disable depth writing
  50246. * @param enable defines the state to set
  50247. */
  50248. setDepthWrite(enable: boolean): void;
  50249. /**
  50250. * Enable or disable color writing
  50251. * @param enable defines the state to set
  50252. */
  50253. setColorWrite(enable: boolean): void;
  50254. /**
  50255. * Gets a boolean indicating if color writing is enabled
  50256. * @returns the current color writing state
  50257. */
  50258. getColorWrite(): boolean;
  50259. /**
  50260. * Sets alpha constants used by some alpha blending modes
  50261. * @param r defines the red component
  50262. * @param g defines the green component
  50263. * @param b defines the blue component
  50264. * @param a defines the alpha component
  50265. */
  50266. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  50267. /**
  50268. * Sets the current alpha mode
  50269. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  50270. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50271. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50272. */
  50273. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50274. /**
  50275. * Gets the current alpha mode
  50276. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50277. * @returns the current alpha mode
  50278. */
  50279. getAlphaMode(): number;
  50280. setInt(uniform: WebGLUniformLocation, int: number): void;
  50281. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50282. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50283. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50284. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50285. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50286. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50287. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50288. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50289. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50290. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50291. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50292. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50293. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50294. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50295. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50296. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50297. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50298. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50299. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50300. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50301. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50302. wipeCaches(bruteForce?: boolean): void;
  50303. _createTexture(): WebGLTexture;
  50304. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50305. /**
  50306. * Usually called from Texture.ts.
  50307. * Passed information to create a WebGLTexture
  50308. * @param url defines a value which contains one of the following:
  50309. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50310. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50311. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50312. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50313. * @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)
  50314. * @param scene needed for loading to the correct scene
  50315. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50316. * @param onLoad optional callback to be called upon successful completion
  50317. * @param onError optional callback to be called upon failure
  50318. * @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
  50319. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50320. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50321. * @param forcedExtension defines the extension to use to pick the right loader
  50322. * @param mimeType defines an optional mime type
  50323. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50324. */
  50325. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  50326. /**
  50327. * Creates a cube texture
  50328. * @param rootUrl defines the url where the files to load is located
  50329. * @param scene defines the current scene
  50330. * @param files defines the list of files to load (1 per face)
  50331. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50332. * @param onLoad defines an optional callback raised when the texture is loaded
  50333. * @param onError defines an optional callback raised if there is an issue to load the texture
  50334. * @param format defines the format of the data
  50335. * @param forcedExtension defines the extension to use to pick the right loader
  50336. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50337. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50338. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50339. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50340. * @returns the cube texture as an InternalTexture
  50341. */
  50342. 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;
  50343. private _getSamplingFilter;
  50344. private static _GetNativeTextureFormat;
  50345. createRenderTargetTexture(size: number | {
  50346. width: number;
  50347. height: number;
  50348. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50349. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50350. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50351. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50352. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50353. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50354. /**
  50355. * Updates a dynamic vertex buffer.
  50356. * @param vertexBuffer the vertex buffer to update
  50357. * @param data the data used to update the vertex buffer
  50358. * @param byteOffset the byte offset of the data (optional)
  50359. * @param byteLength the byte length of the data (optional)
  50360. */
  50361. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50362. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50363. private _updateAnisotropicLevel;
  50364. private _getAddressMode;
  50365. /** @hidden */
  50366. _bindTexture(channel: number, texture: InternalTexture): void;
  50367. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50368. releaseEffects(): void;
  50369. /** @hidden */
  50370. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50371. /** @hidden */
  50372. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50373. /** @hidden */
  50374. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50375. /** @hidden */
  50376. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50377. }
  50378. }
  50379. declare module "babylonjs/Engines/index" {
  50380. export * from "babylonjs/Engines/constants";
  50381. export * from "babylonjs/Engines/engineCapabilities";
  50382. export * from "babylonjs/Engines/instancingAttributeInfo";
  50383. export * from "babylonjs/Engines/thinEngine";
  50384. export * from "babylonjs/Engines/engine";
  50385. export * from "babylonjs/Engines/engineStore";
  50386. export * from "babylonjs/Engines/nullEngine";
  50387. export * from "babylonjs/Engines/Extensions/index";
  50388. export * from "babylonjs/Engines/IPipelineContext";
  50389. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50390. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50391. export * from "babylonjs/Engines/nativeEngine";
  50392. }
  50393. declare module "babylonjs/Events/clipboardEvents" {
  50394. /**
  50395. * Gather the list of clipboard event types as constants.
  50396. */
  50397. export class ClipboardEventTypes {
  50398. /**
  50399. * The clipboard event is fired when a copy command is active (pressed).
  50400. */
  50401. static readonly COPY: number;
  50402. /**
  50403. * The clipboard event is fired when a cut command is active (pressed).
  50404. */
  50405. static readonly CUT: number;
  50406. /**
  50407. * The clipboard event is fired when a paste command is active (pressed).
  50408. */
  50409. static readonly PASTE: number;
  50410. }
  50411. /**
  50412. * This class is used to store clipboard related info for the onClipboardObservable event.
  50413. */
  50414. export class ClipboardInfo {
  50415. /**
  50416. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50417. */
  50418. type: number;
  50419. /**
  50420. * Defines the related dom event
  50421. */
  50422. event: ClipboardEvent;
  50423. /**
  50424. *Creates an instance of ClipboardInfo.
  50425. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50426. * @param event Defines the related dom event
  50427. */
  50428. constructor(
  50429. /**
  50430. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50431. */
  50432. type: number,
  50433. /**
  50434. * Defines the related dom event
  50435. */
  50436. event: ClipboardEvent);
  50437. /**
  50438. * Get the clipboard event's type from the keycode.
  50439. * @param keyCode Defines the keyCode for the current keyboard event.
  50440. * @return {number}
  50441. */
  50442. static GetTypeFromCharacter(keyCode: number): number;
  50443. }
  50444. }
  50445. declare module "babylonjs/Events/index" {
  50446. export * from "babylonjs/Events/keyboardEvents";
  50447. export * from "babylonjs/Events/pointerEvents";
  50448. export * from "babylonjs/Events/clipboardEvents";
  50449. }
  50450. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50451. import { Scene } from "babylonjs/scene";
  50452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50453. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50454. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50455. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50456. /**
  50457. * Google Daydream controller
  50458. */
  50459. export class DaydreamController extends WebVRController {
  50460. /**
  50461. * Base Url for the controller model.
  50462. */
  50463. static MODEL_BASE_URL: string;
  50464. /**
  50465. * File name for the controller model.
  50466. */
  50467. static MODEL_FILENAME: string;
  50468. /**
  50469. * Gamepad Id prefix used to identify Daydream Controller.
  50470. */
  50471. static readonly GAMEPAD_ID_PREFIX: string;
  50472. /**
  50473. * Creates a new DaydreamController from a gamepad
  50474. * @param vrGamepad the gamepad that the controller should be created from
  50475. */
  50476. constructor(vrGamepad: any);
  50477. /**
  50478. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50479. * @param scene scene in which to add meshes
  50480. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50481. */
  50482. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50483. /**
  50484. * Called once for each button that changed state since the last frame
  50485. * @param buttonIdx Which button index changed
  50486. * @param state New state of the button
  50487. * @param changes Which properties on the state changed since last frame
  50488. */
  50489. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50490. }
  50491. }
  50492. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50493. import { Scene } from "babylonjs/scene";
  50494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50495. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50496. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50497. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50498. /**
  50499. * Gear VR Controller
  50500. */
  50501. export class GearVRController extends WebVRController {
  50502. /**
  50503. * Base Url for the controller model.
  50504. */
  50505. static MODEL_BASE_URL: string;
  50506. /**
  50507. * File name for the controller model.
  50508. */
  50509. static MODEL_FILENAME: string;
  50510. /**
  50511. * Gamepad Id prefix used to identify this controller.
  50512. */
  50513. static readonly GAMEPAD_ID_PREFIX: string;
  50514. private readonly _buttonIndexToObservableNameMap;
  50515. /**
  50516. * Creates a new GearVRController from a gamepad
  50517. * @param vrGamepad the gamepad that the controller should be created from
  50518. */
  50519. constructor(vrGamepad: any);
  50520. /**
  50521. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50522. * @param scene scene in which to add meshes
  50523. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50524. */
  50525. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50526. /**
  50527. * Called once for each button that changed state since the last frame
  50528. * @param buttonIdx Which button index changed
  50529. * @param state New state of the button
  50530. * @param changes Which properties on the state changed since last frame
  50531. */
  50532. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50533. }
  50534. }
  50535. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50536. import { Scene } from "babylonjs/scene";
  50537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50538. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50539. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50540. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50541. /**
  50542. * Generic Controller
  50543. */
  50544. export class GenericController extends WebVRController {
  50545. /**
  50546. * Base Url for the controller model.
  50547. */
  50548. static readonly MODEL_BASE_URL: string;
  50549. /**
  50550. * File name for the controller model.
  50551. */
  50552. static readonly MODEL_FILENAME: string;
  50553. /**
  50554. * Creates a new GenericController from a gamepad
  50555. * @param vrGamepad the gamepad that the controller should be created from
  50556. */
  50557. constructor(vrGamepad: any);
  50558. /**
  50559. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50560. * @param scene scene in which to add meshes
  50561. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50562. */
  50563. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50564. /**
  50565. * Called once for each button that changed state since the last frame
  50566. * @param buttonIdx Which button index changed
  50567. * @param state New state of the button
  50568. * @param changes Which properties on the state changed since last frame
  50569. */
  50570. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50571. }
  50572. }
  50573. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50574. import { Observable } from "babylonjs/Misc/observable";
  50575. import { Scene } from "babylonjs/scene";
  50576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50577. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50578. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50579. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50580. /**
  50581. * Oculus Touch Controller
  50582. */
  50583. export class OculusTouchController extends WebVRController {
  50584. /**
  50585. * Base Url for the controller model.
  50586. */
  50587. static MODEL_BASE_URL: string;
  50588. /**
  50589. * File name for the left controller model.
  50590. */
  50591. static MODEL_LEFT_FILENAME: string;
  50592. /**
  50593. * File name for the right controller model.
  50594. */
  50595. static MODEL_RIGHT_FILENAME: string;
  50596. /**
  50597. * Base Url for the Quest controller model.
  50598. */
  50599. static QUEST_MODEL_BASE_URL: string;
  50600. /**
  50601. * @hidden
  50602. * If the controllers are running on a device that needs the updated Quest controller models
  50603. */
  50604. static _IsQuest: boolean;
  50605. /**
  50606. * Fired when the secondary trigger on this controller is modified
  50607. */
  50608. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50609. /**
  50610. * Fired when the thumb rest on this controller is modified
  50611. */
  50612. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50613. /**
  50614. * Creates a new OculusTouchController from a gamepad
  50615. * @param vrGamepad the gamepad that the controller should be created from
  50616. */
  50617. constructor(vrGamepad: any);
  50618. /**
  50619. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50620. * @param scene scene in which to add meshes
  50621. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50622. */
  50623. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50624. /**
  50625. * Fired when the A button on this controller is modified
  50626. */
  50627. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50628. /**
  50629. * Fired when the B button on this controller is modified
  50630. */
  50631. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50632. /**
  50633. * Fired when the X button on this controller is modified
  50634. */
  50635. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50636. /**
  50637. * Fired when the Y button on this controller is modified
  50638. */
  50639. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50640. /**
  50641. * Called once for each button that changed state since the last frame
  50642. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50643. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50644. * 2) secondary trigger (same)
  50645. * 3) A (right) X (left), touch, pressed = value
  50646. * 4) B / Y
  50647. * 5) thumb rest
  50648. * @param buttonIdx Which button index changed
  50649. * @param state New state of the button
  50650. * @param changes Which properties on the state changed since last frame
  50651. */
  50652. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50653. }
  50654. }
  50655. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50656. import { Scene } from "babylonjs/scene";
  50657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50658. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50659. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50660. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50661. import { Observable } from "babylonjs/Misc/observable";
  50662. /**
  50663. * Vive Controller
  50664. */
  50665. export class ViveController extends WebVRController {
  50666. /**
  50667. * Base Url for the controller model.
  50668. */
  50669. static MODEL_BASE_URL: string;
  50670. /**
  50671. * File name for the controller model.
  50672. */
  50673. static MODEL_FILENAME: string;
  50674. /**
  50675. * Creates a new ViveController from a gamepad
  50676. * @param vrGamepad the gamepad that the controller should be created from
  50677. */
  50678. constructor(vrGamepad: any);
  50679. /**
  50680. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50681. * @param scene scene in which to add meshes
  50682. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50683. */
  50684. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50685. /**
  50686. * Fired when the left button on this controller is modified
  50687. */
  50688. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50689. /**
  50690. * Fired when the right button on this controller is modified
  50691. */
  50692. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50693. /**
  50694. * Fired when the menu button on this controller is modified
  50695. */
  50696. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50697. /**
  50698. * Called once for each button that changed state since the last frame
  50699. * Vive mapping:
  50700. * 0: touchpad
  50701. * 1: trigger
  50702. * 2: left AND right buttons
  50703. * 3: menu button
  50704. * @param buttonIdx Which button index changed
  50705. * @param state New state of the button
  50706. * @param changes Which properties on the state changed since last frame
  50707. */
  50708. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50709. }
  50710. }
  50711. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50712. import { Observable } from "babylonjs/Misc/observable";
  50713. import { Scene } from "babylonjs/scene";
  50714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50715. import { Ray } from "babylonjs/Culling/ray";
  50716. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50717. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50718. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50719. /**
  50720. * Defines the WindowsMotionController object that the state of the windows motion controller
  50721. */
  50722. export class WindowsMotionController extends WebVRController {
  50723. /**
  50724. * The base url used to load the left and right controller models
  50725. */
  50726. static MODEL_BASE_URL: string;
  50727. /**
  50728. * The name of the left controller model file
  50729. */
  50730. static MODEL_LEFT_FILENAME: string;
  50731. /**
  50732. * The name of the right controller model file
  50733. */
  50734. static MODEL_RIGHT_FILENAME: string;
  50735. /**
  50736. * The controller name prefix for this controller type
  50737. */
  50738. static readonly GAMEPAD_ID_PREFIX: string;
  50739. /**
  50740. * The controller id pattern for this controller type
  50741. */
  50742. private static readonly GAMEPAD_ID_PATTERN;
  50743. private _loadedMeshInfo;
  50744. protected readonly _mapping: {
  50745. buttons: string[];
  50746. buttonMeshNames: {
  50747. trigger: string;
  50748. menu: string;
  50749. grip: string;
  50750. thumbstick: string;
  50751. trackpad: string;
  50752. };
  50753. buttonObservableNames: {
  50754. trigger: string;
  50755. menu: string;
  50756. grip: string;
  50757. thumbstick: string;
  50758. trackpad: string;
  50759. };
  50760. axisMeshNames: string[];
  50761. pointingPoseMeshName: string;
  50762. };
  50763. /**
  50764. * Fired when the trackpad on this controller is clicked
  50765. */
  50766. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50767. /**
  50768. * Fired when the trackpad on this controller is modified
  50769. */
  50770. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50771. /**
  50772. * The current x and y values of this controller's trackpad
  50773. */
  50774. trackpad: StickValues;
  50775. /**
  50776. * Creates a new WindowsMotionController from a gamepad
  50777. * @param vrGamepad the gamepad that the controller should be created from
  50778. */
  50779. constructor(vrGamepad: any);
  50780. /**
  50781. * Fired when the trigger on this controller is modified
  50782. */
  50783. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50784. /**
  50785. * Fired when the menu button on this controller is modified
  50786. */
  50787. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50788. /**
  50789. * Fired when the grip button on this controller is modified
  50790. */
  50791. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50792. /**
  50793. * Fired when the thumbstick button on this controller is modified
  50794. */
  50795. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50796. /**
  50797. * Fired when the touchpad button on this controller is modified
  50798. */
  50799. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50800. /**
  50801. * Fired when the touchpad values on this controller are modified
  50802. */
  50803. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50804. protected _updateTrackpad(): void;
  50805. /**
  50806. * Called once per frame by the engine.
  50807. */
  50808. update(): void;
  50809. /**
  50810. * Called once for each button that changed state since the last frame
  50811. * @param buttonIdx Which button index changed
  50812. * @param state New state of the button
  50813. * @param changes Which properties on the state changed since last frame
  50814. */
  50815. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50816. /**
  50817. * Moves the buttons on the controller mesh based on their current state
  50818. * @param buttonName the name of the button to move
  50819. * @param buttonValue the value of the button which determines the buttons new position
  50820. */
  50821. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50822. /**
  50823. * Moves the axis on the controller mesh based on its current state
  50824. * @param axis the index of the axis
  50825. * @param axisValue the value of the axis which determines the meshes new position
  50826. * @hidden
  50827. */
  50828. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50829. /**
  50830. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50831. * @param scene scene in which to add meshes
  50832. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50833. */
  50834. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50835. /**
  50836. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50837. * can be transformed by button presses and axes values, based on this._mapping.
  50838. *
  50839. * @param scene scene in which the meshes exist
  50840. * @param meshes list of meshes that make up the controller model to process
  50841. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50842. */
  50843. private processModel;
  50844. private createMeshInfo;
  50845. /**
  50846. * Gets the ray of the controller in the direction the controller is pointing
  50847. * @param length the length the resulting ray should be
  50848. * @returns a ray in the direction the controller is pointing
  50849. */
  50850. getForwardRay(length?: number): Ray;
  50851. /**
  50852. * Disposes of the controller
  50853. */
  50854. dispose(): void;
  50855. }
  50856. /**
  50857. * This class represents a new windows motion controller in XR.
  50858. */
  50859. export class XRWindowsMotionController extends WindowsMotionController {
  50860. /**
  50861. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50862. */
  50863. protected readonly _mapping: {
  50864. buttons: string[];
  50865. buttonMeshNames: {
  50866. trigger: string;
  50867. menu: string;
  50868. grip: string;
  50869. thumbstick: string;
  50870. trackpad: string;
  50871. };
  50872. buttonObservableNames: {
  50873. trigger: string;
  50874. menu: string;
  50875. grip: string;
  50876. thumbstick: string;
  50877. trackpad: string;
  50878. };
  50879. axisMeshNames: string[];
  50880. pointingPoseMeshName: string;
  50881. };
  50882. /**
  50883. * Construct a new XR-Based windows motion controller
  50884. *
  50885. * @param gamepadInfo the gamepad object from the browser
  50886. */
  50887. constructor(gamepadInfo: any);
  50888. /**
  50889. * holds the thumbstick values (X,Y)
  50890. */
  50891. thumbstickValues: StickValues;
  50892. /**
  50893. * Fired when the thumbstick on this controller is clicked
  50894. */
  50895. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50896. /**
  50897. * Fired when the thumbstick on this controller is modified
  50898. */
  50899. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50900. /**
  50901. * Fired when the touchpad button on this controller is modified
  50902. */
  50903. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50904. /**
  50905. * Fired when the touchpad values on this controller are modified
  50906. */
  50907. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50908. /**
  50909. * Fired when the thumbstick button on this controller is modified
  50910. * here to prevent breaking changes
  50911. */
  50912. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50913. /**
  50914. * updating the thumbstick(!) and not the trackpad.
  50915. * This is named this way due to the difference between WebVR and XR and to avoid
  50916. * changing the parent class.
  50917. */
  50918. protected _updateTrackpad(): void;
  50919. /**
  50920. * Disposes the class with joy
  50921. */
  50922. dispose(): void;
  50923. }
  50924. }
  50925. declare module "babylonjs/Gamepads/Controllers/index" {
  50926. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50927. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50928. export * from "babylonjs/Gamepads/Controllers/genericController";
  50929. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50930. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50931. export * from "babylonjs/Gamepads/Controllers/viveController";
  50932. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50933. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50934. }
  50935. declare module "babylonjs/Gamepads/index" {
  50936. export * from "babylonjs/Gamepads/Controllers/index";
  50937. export * from "babylonjs/Gamepads/gamepad";
  50938. export * from "babylonjs/Gamepads/gamepadManager";
  50939. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50940. export * from "babylonjs/Gamepads/xboxGamepad";
  50941. export * from "babylonjs/Gamepads/dualShockGamepad";
  50942. }
  50943. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50944. import { Scene } from "babylonjs/scene";
  50945. import { Vector4 } from "babylonjs/Maths/math.vector";
  50946. import { Color4 } from "babylonjs/Maths/math.color";
  50947. import { Mesh } from "babylonjs/Meshes/mesh";
  50948. import { Nullable } from "babylonjs/types";
  50949. /**
  50950. * Class containing static functions to help procedurally build meshes
  50951. */
  50952. export class PolyhedronBuilder {
  50953. /**
  50954. * Creates a polyhedron mesh
  50955. * * 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
  50956. * * The parameter `size` (positive float, default 1) sets the polygon size
  50957. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50958. * * 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`
  50959. * * 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
  50960. * * 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)`)
  50961. * * 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
  50962. * * 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
  50963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50966. * @param name defines the name of the mesh
  50967. * @param options defines the options used to create the mesh
  50968. * @param scene defines the hosting scene
  50969. * @returns the polyhedron mesh
  50970. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50971. */
  50972. static CreatePolyhedron(name: string, options: {
  50973. type?: number;
  50974. size?: number;
  50975. sizeX?: number;
  50976. sizeY?: number;
  50977. sizeZ?: number;
  50978. custom?: any;
  50979. faceUV?: Vector4[];
  50980. faceColors?: Color4[];
  50981. flat?: boolean;
  50982. updatable?: boolean;
  50983. sideOrientation?: number;
  50984. frontUVs?: Vector4;
  50985. backUVs?: Vector4;
  50986. }, scene?: Nullable<Scene>): Mesh;
  50987. }
  50988. }
  50989. declare module "babylonjs/Gizmos/scaleGizmo" {
  50990. import { Observable } from "babylonjs/Misc/observable";
  50991. import { Nullable } from "babylonjs/types";
  50992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50993. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50994. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50995. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50996. /**
  50997. * Gizmo that enables scaling a mesh along 3 axis
  50998. */
  50999. export class ScaleGizmo extends Gizmo {
  51000. /**
  51001. * Internal gizmo used for interactions on the x axis
  51002. */
  51003. xGizmo: AxisScaleGizmo;
  51004. /**
  51005. * Internal gizmo used for interactions on the y axis
  51006. */
  51007. yGizmo: AxisScaleGizmo;
  51008. /**
  51009. * Internal gizmo used for interactions on the z axis
  51010. */
  51011. zGizmo: AxisScaleGizmo;
  51012. /**
  51013. * Internal gizmo used to scale all axis equally
  51014. */
  51015. uniformScaleGizmo: AxisScaleGizmo;
  51016. private _meshAttached;
  51017. private _updateGizmoRotationToMatchAttachedMesh;
  51018. private _snapDistance;
  51019. private _scaleRatio;
  51020. private _uniformScalingMesh;
  51021. private _octahedron;
  51022. private _sensitivity;
  51023. /** Fires an event when any of it's sub gizmos are dragged */
  51024. onDragStartObservable: Observable<unknown>;
  51025. /** Fires an event when any of it's sub gizmos are released from dragging */
  51026. onDragEndObservable: Observable<unknown>;
  51027. get attachedMesh(): Nullable<AbstractMesh>;
  51028. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51029. /**
  51030. * Creates a ScaleGizmo
  51031. * @param gizmoLayer The utility layer the gizmo will be added to
  51032. */
  51033. constructor(gizmoLayer?: UtilityLayerRenderer);
  51034. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51035. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51036. /**
  51037. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51038. */
  51039. set snapDistance(value: number);
  51040. get snapDistance(): number;
  51041. /**
  51042. * Ratio for the scale of the gizmo (Default: 1)
  51043. */
  51044. set scaleRatio(value: number);
  51045. get scaleRatio(): number;
  51046. /**
  51047. * Sensitivity factor for dragging (Default: 1)
  51048. */
  51049. set sensitivity(value: number);
  51050. get sensitivity(): number;
  51051. /**
  51052. * Disposes of the gizmo
  51053. */
  51054. dispose(): void;
  51055. }
  51056. }
  51057. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  51058. import { Observable } from "babylonjs/Misc/observable";
  51059. import { Nullable } from "babylonjs/types";
  51060. import { Vector3 } from "babylonjs/Maths/math.vector";
  51061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51062. import { Mesh } from "babylonjs/Meshes/mesh";
  51063. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51064. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51065. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51066. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51067. import { Color3 } from "babylonjs/Maths/math.color";
  51068. /**
  51069. * Single axis scale gizmo
  51070. */
  51071. export class AxisScaleGizmo extends Gizmo {
  51072. /**
  51073. * Drag behavior responsible for the gizmos dragging interactions
  51074. */
  51075. dragBehavior: PointerDragBehavior;
  51076. private _pointerObserver;
  51077. /**
  51078. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51079. */
  51080. snapDistance: number;
  51081. /**
  51082. * Event that fires each time the gizmo snaps to a new location.
  51083. * * snapDistance is the the change in distance
  51084. */
  51085. onSnapObservable: Observable<{
  51086. snapDistance: number;
  51087. }>;
  51088. /**
  51089. * If the scaling operation should be done on all axis (default: false)
  51090. */
  51091. uniformScaling: boolean;
  51092. /**
  51093. * Custom sensitivity value for the drag strength
  51094. */
  51095. sensitivity: number;
  51096. private _isEnabled;
  51097. private _parent;
  51098. private _arrow;
  51099. private _coloredMaterial;
  51100. private _hoverMaterial;
  51101. /**
  51102. * Creates an AxisScaleGizmo
  51103. * @param gizmoLayer The utility layer the gizmo will be added to
  51104. * @param dragAxis The axis which the gizmo will be able to scale on
  51105. * @param color The color of the gizmo
  51106. */
  51107. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51108. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51109. /**
  51110. * If the gizmo is enabled
  51111. */
  51112. set isEnabled(value: boolean);
  51113. get isEnabled(): boolean;
  51114. /**
  51115. * Disposes of the gizmo
  51116. */
  51117. dispose(): void;
  51118. /**
  51119. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51120. * @param mesh The mesh to replace the default mesh of the gizmo
  51121. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51122. */
  51123. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51124. }
  51125. }
  51126. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  51127. import { Observable } from "babylonjs/Misc/observable";
  51128. import { Nullable } from "babylonjs/types";
  51129. import { Vector3 } from "babylonjs/Maths/math.vector";
  51130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51131. import { Mesh } from "babylonjs/Meshes/mesh";
  51132. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51133. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51134. import { Color3 } from "babylonjs/Maths/math.color";
  51135. import "babylonjs/Meshes/Builders/boxBuilder";
  51136. /**
  51137. * Bounding box gizmo
  51138. */
  51139. export class BoundingBoxGizmo extends Gizmo {
  51140. private _lineBoundingBox;
  51141. private _rotateSpheresParent;
  51142. private _scaleBoxesParent;
  51143. private _boundingDimensions;
  51144. private _renderObserver;
  51145. private _pointerObserver;
  51146. private _scaleDragSpeed;
  51147. private _tmpQuaternion;
  51148. private _tmpVector;
  51149. private _tmpRotationMatrix;
  51150. /**
  51151. * 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)
  51152. */
  51153. ignoreChildren: boolean;
  51154. /**
  51155. * 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)
  51156. */
  51157. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51158. /**
  51159. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51160. */
  51161. rotationSphereSize: number;
  51162. /**
  51163. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51164. */
  51165. scaleBoxSize: number;
  51166. /**
  51167. * 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)
  51168. */
  51169. fixedDragMeshScreenSize: boolean;
  51170. /**
  51171. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51172. */
  51173. fixedDragMeshScreenSizeDistanceFactor: number;
  51174. /**
  51175. * Fired when a rotation sphere or scale box is dragged
  51176. */
  51177. onDragStartObservable: Observable<{}>;
  51178. /**
  51179. * Fired when a scale box is dragged
  51180. */
  51181. onScaleBoxDragObservable: Observable<{}>;
  51182. /**
  51183. * Fired when a scale box drag is ended
  51184. */
  51185. onScaleBoxDragEndObservable: Observable<{}>;
  51186. /**
  51187. * Fired when a rotation sphere is dragged
  51188. */
  51189. onRotationSphereDragObservable: Observable<{}>;
  51190. /**
  51191. * Fired when a rotation sphere drag is ended
  51192. */
  51193. onRotationSphereDragEndObservable: Observable<{}>;
  51194. /**
  51195. * 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)
  51196. */
  51197. scalePivot: Nullable<Vector3>;
  51198. /**
  51199. * Mesh used as a pivot to rotate the attached mesh
  51200. */
  51201. private _anchorMesh;
  51202. private _existingMeshScale;
  51203. private _dragMesh;
  51204. private pointerDragBehavior;
  51205. private coloredMaterial;
  51206. private hoverColoredMaterial;
  51207. /**
  51208. * Sets the color of the bounding box gizmo
  51209. * @param color the color to set
  51210. */
  51211. setColor(color: Color3): void;
  51212. /**
  51213. * Creates an BoundingBoxGizmo
  51214. * @param gizmoLayer The utility layer the gizmo will be added to
  51215. * @param color The color of the gizmo
  51216. */
  51217. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51218. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51219. private _selectNode;
  51220. /**
  51221. * Updates the bounding box information for the Gizmo
  51222. */
  51223. updateBoundingBox(): void;
  51224. private _updateRotationSpheres;
  51225. private _updateScaleBoxes;
  51226. /**
  51227. * Enables rotation on the specified axis and disables rotation on the others
  51228. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51229. */
  51230. setEnabledRotationAxis(axis: string): void;
  51231. /**
  51232. * Enables/disables scaling
  51233. * @param enable if scaling should be enabled
  51234. * @param homogeneousScaling defines if scaling should only be homogeneous
  51235. */
  51236. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51237. private _updateDummy;
  51238. /**
  51239. * Enables a pointer drag behavior on the bounding box of the gizmo
  51240. */
  51241. enableDragBehavior(): void;
  51242. /**
  51243. * Disposes of the gizmo
  51244. */
  51245. dispose(): void;
  51246. /**
  51247. * 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)
  51248. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  51249. * @returns the bounding box mesh with the passed in mesh as a child
  51250. */
  51251. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  51252. /**
  51253. * CustomMeshes are not supported by this gizmo
  51254. * @param mesh The mesh to replace the default mesh of the gizmo
  51255. */
  51256. setCustomMesh(mesh: Mesh): void;
  51257. }
  51258. }
  51259. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  51260. import { Observable } from "babylonjs/Misc/observable";
  51261. import { Nullable } from "babylonjs/types";
  51262. import { Vector3 } from "babylonjs/Maths/math.vector";
  51263. import { Color3 } from "babylonjs/Maths/math.color";
  51264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51265. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51266. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51267. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51268. import "babylonjs/Meshes/Builders/linesBuilder";
  51269. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51270. /**
  51271. * Single plane rotation gizmo
  51272. */
  51273. export class PlaneRotationGizmo extends Gizmo {
  51274. /**
  51275. * Drag behavior responsible for the gizmos dragging interactions
  51276. */
  51277. dragBehavior: PointerDragBehavior;
  51278. private _pointerObserver;
  51279. /**
  51280. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51281. */
  51282. snapDistance: number;
  51283. /**
  51284. * Event that fires each time the gizmo snaps to a new location.
  51285. * * snapDistance is the the change in distance
  51286. */
  51287. onSnapObservable: Observable<{
  51288. snapDistance: number;
  51289. }>;
  51290. private _isEnabled;
  51291. private _parent;
  51292. /**
  51293. * Creates a PlaneRotationGizmo
  51294. * @param gizmoLayer The utility layer the gizmo will be added to
  51295. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51296. * @param color The color of the gizmo
  51297. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51298. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51299. */
  51300. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51301. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51302. /**
  51303. * If the gizmo is enabled
  51304. */
  51305. set isEnabled(value: boolean);
  51306. get isEnabled(): boolean;
  51307. /**
  51308. * Disposes of the gizmo
  51309. */
  51310. dispose(): void;
  51311. }
  51312. }
  51313. declare module "babylonjs/Gizmos/rotationGizmo" {
  51314. import { Observable } from "babylonjs/Misc/observable";
  51315. import { Nullable } from "babylonjs/types";
  51316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51317. import { Mesh } from "babylonjs/Meshes/mesh";
  51318. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51319. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51320. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51321. /**
  51322. * Gizmo that enables rotating a mesh along 3 axis
  51323. */
  51324. export class RotationGizmo extends Gizmo {
  51325. /**
  51326. * Internal gizmo used for interactions on the x axis
  51327. */
  51328. xGizmo: PlaneRotationGizmo;
  51329. /**
  51330. * Internal gizmo used for interactions on the y axis
  51331. */
  51332. yGizmo: PlaneRotationGizmo;
  51333. /**
  51334. * Internal gizmo used for interactions on the z axis
  51335. */
  51336. zGizmo: PlaneRotationGizmo;
  51337. /** Fires an event when any of it's sub gizmos are dragged */
  51338. onDragStartObservable: Observable<unknown>;
  51339. /** Fires an event when any of it's sub gizmos are released from dragging */
  51340. onDragEndObservable: Observable<unknown>;
  51341. private _meshAttached;
  51342. get attachedMesh(): Nullable<AbstractMesh>;
  51343. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51344. /**
  51345. * Creates a RotationGizmo
  51346. * @param gizmoLayer The utility layer the gizmo will be added to
  51347. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51348. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51349. */
  51350. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51351. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51352. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51353. /**
  51354. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51355. */
  51356. set snapDistance(value: number);
  51357. get snapDistance(): number;
  51358. /**
  51359. * Ratio for the scale of the gizmo (Default: 1)
  51360. */
  51361. set scaleRatio(value: number);
  51362. get scaleRatio(): number;
  51363. /**
  51364. * Disposes of the gizmo
  51365. */
  51366. dispose(): void;
  51367. /**
  51368. * CustomMeshes are not supported by this gizmo
  51369. * @param mesh The mesh to replace the default mesh of the gizmo
  51370. */
  51371. setCustomMesh(mesh: Mesh): void;
  51372. }
  51373. }
  51374. declare module "babylonjs/Gizmos/gizmoManager" {
  51375. import { Observable } from "babylonjs/Misc/observable";
  51376. import { Nullable } from "babylonjs/types";
  51377. import { Scene, IDisposable } from "babylonjs/scene";
  51378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51379. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51380. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51381. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51382. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51383. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51384. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51385. /**
  51386. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51387. */
  51388. export class GizmoManager implements IDisposable {
  51389. private scene;
  51390. /**
  51391. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51392. */
  51393. gizmos: {
  51394. positionGizmo: Nullable<PositionGizmo>;
  51395. rotationGizmo: Nullable<RotationGizmo>;
  51396. scaleGizmo: Nullable<ScaleGizmo>;
  51397. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51398. };
  51399. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51400. clearGizmoOnEmptyPointerEvent: boolean;
  51401. /** Fires an event when the manager is attached to a mesh */
  51402. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51403. private _gizmosEnabled;
  51404. private _pointerObserver;
  51405. private _attachedMesh;
  51406. private _boundingBoxColor;
  51407. private _defaultUtilityLayer;
  51408. private _defaultKeepDepthUtilityLayer;
  51409. /**
  51410. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51411. */
  51412. boundingBoxDragBehavior: SixDofDragBehavior;
  51413. /**
  51414. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51415. */
  51416. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51417. /**
  51418. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51419. */
  51420. usePointerToAttachGizmos: boolean;
  51421. /**
  51422. * Utility layer that the bounding box gizmo belongs to
  51423. */
  51424. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51425. /**
  51426. * Utility layer that all gizmos besides bounding box belong to
  51427. */
  51428. get utilityLayer(): UtilityLayerRenderer;
  51429. /**
  51430. * Instatiates a gizmo manager
  51431. * @param scene the scene to overlay the gizmos on top of
  51432. */
  51433. constructor(scene: Scene);
  51434. /**
  51435. * Attaches a set of gizmos to the specified mesh
  51436. * @param mesh The mesh the gizmo's should be attached to
  51437. */
  51438. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51439. /**
  51440. * If the position gizmo is enabled
  51441. */
  51442. set positionGizmoEnabled(value: boolean);
  51443. get positionGizmoEnabled(): boolean;
  51444. /**
  51445. * If the rotation gizmo is enabled
  51446. */
  51447. set rotationGizmoEnabled(value: boolean);
  51448. get rotationGizmoEnabled(): boolean;
  51449. /**
  51450. * If the scale gizmo is enabled
  51451. */
  51452. set scaleGizmoEnabled(value: boolean);
  51453. get scaleGizmoEnabled(): boolean;
  51454. /**
  51455. * If the boundingBox gizmo is enabled
  51456. */
  51457. set boundingBoxGizmoEnabled(value: boolean);
  51458. get boundingBoxGizmoEnabled(): boolean;
  51459. /**
  51460. * Disposes of the gizmo manager
  51461. */
  51462. dispose(): void;
  51463. }
  51464. }
  51465. declare module "babylonjs/Lights/directionalLight" {
  51466. import { Camera } from "babylonjs/Cameras/camera";
  51467. import { Scene } from "babylonjs/scene";
  51468. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51470. import { Light } from "babylonjs/Lights/light";
  51471. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51472. import { Effect } from "babylonjs/Materials/effect";
  51473. /**
  51474. * A directional light is defined by a direction (what a surprise!).
  51475. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51476. * 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.
  51477. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51478. */
  51479. export class DirectionalLight extends ShadowLight {
  51480. private _shadowFrustumSize;
  51481. /**
  51482. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51483. */
  51484. get shadowFrustumSize(): number;
  51485. /**
  51486. * Specifies a fix frustum size for the shadow generation.
  51487. */
  51488. set shadowFrustumSize(value: number);
  51489. private _shadowOrthoScale;
  51490. /**
  51491. * Gets the shadow projection scale against the optimal computed one.
  51492. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51493. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51494. */
  51495. get shadowOrthoScale(): number;
  51496. /**
  51497. * Sets the shadow projection scale against the optimal computed one.
  51498. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51499. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51500. */
  51501. set shadowOrthoScale(value: number);
  51502. /**
  51503. * Automatically compute the projection matrix to best fit (including all the casters)
  51504. * on each frame.
  51505. */
  51506. autoUpdateExtends: boolean;
  51507. /**
  51508. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51509. * on each frame. autoUpdateExtends must be set to true for this to work
  51510. */
  51511. autoCalcShadowZBounds: boolean;
  51512. private _orthoLeft;
  51513. private _orthoRight;
  51514. private _orthoTop;
  51515. private _orthoBottom;
  51516. /**
  51517. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51518. * The directional light is emitted from everywhere in the given direction.
  51519. * It can cast shadows.
  51520. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51521. * @param name The friendly name of the light
  51522. * @param direction The direction of the light
  51523. * @param scene The scene the light belongs to
  51524. */
  51525. constructor(name: string, direction: Vector3, scene: Scene);
  51526. /**
  51527. * Returns the string "DirectionalLight".
  51528. * @return The class name
  51529. */
  51530. getClassName(): string;
  51531. /**
  51532. * Returns the integer 1.
  51533. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51534. */
  51535. getTypeID(): number;
  51536. /**
  51537. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51538. * Returns the DirectionalLight Shadow projection matrix.
  51539. */
  51540. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51541. /**
  51542. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51543. * Returns the DirectionalLight Shadow projection matrix.
  51544. */
  51545. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51546. /**
  51547. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51548. * Returns the DirectionalLight Shadow projection matrix.
  51549. */
  51550. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51551. protected _buildUniformLayout(): void;
  51552. /**
  51553. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51554. * @param effect The effect to update
  51555. * @param lightIndex The index of the light in the effect to update
  51556. * @returns The directional light
  51557. */
  51558. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51559. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51560. /**
  51561. * Gets the minZ used for shadow according to both the scene and the light.
  51562. *
  51563. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51564. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51565. * @param activeCamera The camera we are returning the min for
  51566. * @returns the depth min z
  51567. */
  51568. getDepthMinZ(activeCamera: Camera): number;
  51569. /**
  51570. * Gets the maxZ used for shadow according to both the scene and the light.
  51571. *
  51572. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51573. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51574. * @param activeCamera The camera we are returning the max for
  51575. * @returns the depth max z
  51576. */
  51577. getDepthMaxZ(activeCamera: Camera): number;
  51578. /**
  51579. * Prepares the list of defines specific to the light type.
  51580. * @param defines the list of defines
  51581. * @param lightIndex defines the index of the light for the effect
  51582. */
  51583. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51584. }
  51585. }
  51586. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51587. import { Mesh } from "babylonjs/Meshes/mesh";
  51588. /**
  51589. * Class containing static functions to help procedurally build meshes
  51590. */
  51591. export class HemisphereBuilder {
  51592. /**
  51593. * Creates a hemisphere mesh
  51594. * @param name defines the name of the mesh
  51595. * @param options defines the options used to create the mesh
  51596. * @param scene defines the hosting scene
  51597. * @returns the hemisphere mesh
  51598. */
  51599. static CreateHemisphere(name: string, options: {
  51600. segments?: number;
  51601. diameter?: number;
  51602. sideOrientation?: number;
  51603. }, scene: any): Mesh;
  51604. }
  51605. }
  51606. declare module "babylonjs/Lights/spotLight" {
  51607. import { Nullable } from "babylonjs/types";
  51608. import { Scene } from "babylonjs/scene";
  51609. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51611. import { Effect } from "babylonjs/Materials/effect";
  51612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51613. import { Light } from "babylonjs/Lights/light";
  51614. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51615. /**
  51616. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51617. * These values define a cone of light starting from the position, emitting toward the direction.
  51618. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51619. * and the exponent defines the speed of the decay of the light with distance (reach).
  51620. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51621. */
  51622. export class SpotLight extends ShadowLight {
  51623. private _angle;
  51624. private _innerAngle;
  51625. private _cosHalfAngle;
  51626. private _lightAngleScale;
  51627. private _lightAngleOffset;
  51628. /**
  51629. * Gets the cone angle of the spot light in Radians.
  51630. */
  51631. get angle(): number;
  51632. /**
  51633. * Sets the cone angle of the spot light in Radians.
  51634. */
  51635. set angle(value: number);
  51636. /**
  51637. * Only used in gltf falloff mode, this defines the angle where
  51638. * the directional falloff will start before cutting at angle which could be seen
  51639. * as outer angle.
  51640. */
  51641. get innerAngle(): number;
  51642. /**
  51643. * Only used in gltf falloff mode, this defines the angle where
  51644. * the directional falloff will start before cutting at angle which could be seen
  51645. * as outer angle.
  51646. */
  51647. set innerAngle(value: number);
  51648. private _shadowAngleScale;
  51649. /**
  51650. * Allows scaling the angle of the light for shadow generation only.
  51651. */
  51652. get shadowAngleScale(): number;
  51653. /**
  51654. * Allows scaling the angle of the light for shadow generation only.
  51655. */
  51656. set shadowAngleScale(value: number);
  51657. /**
  51658. * The light decay speed with the distance from the emission spot.
  51659. */
  51660. exponent: number;
  51661. private _projectionTextureMatrix;
  51662. /**
  51663. * Allows reading the projecton texture
  51664. */
  51665. get projectionTextureMatrix(): Matrix;
  51666. protected _projectionTextureLightNear: number;
  51667. /**
  51668. * Gets the near clip of the Spotlight for texture projection.
  51669. */
  51670. get projectionTextureLightNear(): number;
  51671. /**
  51672. * Sets the near clip of the Spotlight for texture projection.
  51673. */
  51674. set projectionTextureLightNear(value: number);
  51675. protected _projectionTextureLightFar: number;
  51676. /**
  51677. * Gets the far clip of the Spotlight for texture projection.
  51678. */
  51679. get projectionTextureLightFar(): number;
  51680. /**
  51681. * Sets the far clip of the Spotlight for texture projection.
  51682. */
  51683. set projectionTextureLightFar(value: number);
  51684. protected _projectionTextureUpDirection: Vector3;
  51685. /**
  51686. * Gets the Up vector of the Spotlight for texture projection.
  51687. */
  51688. get projectionTextureUpDirection(): Vector3;
  51689. /**
  51690. * Sets the Up vector of the Spotlight for texture projection.
  51691. */
  51692. set projectionTextureUpDirection(value: Vector3);
  51693. private _projectionTexture;
  51694. /**
  51695. * Gets the projection texture of the light.
  51696. */
  51697. get projectionTexture(): Nullable<BaseTexture>;
  51698. /**
  51699. * Sets the projection texture of the light.
  51700. */
  51701. set projectionTexture(value: Nullable<BaseTexture>);
  51702. private _projectionTextureViewLightDirty;
  51703. private _projectionTextureProjectionLightDirty;
  51704. private _projectionTextureDirty;
  51705. private _projectionTextureViewTargetVector;
  51706. private _projectionTextureViewLightMatrix;
  51707. private _projectionTextureProjectionLightMatrix;
  51708. private _projectionTextureScalingMatrix;
  51709. /**
  51710. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51711. * It can cast shadows.
  51712. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51713. * @param name The light friendly name
  51714. * @param position The position of the spot light in the scene
  51715. * @param direction The direction of the light in the scene
  51716. * @param angle The cone angle of the light in Radians
  51717. * @param exponent The light decay speed with the distance from the emission spot
  51718. * @param scene The scene the lights belongs to
  51719. */
  51720. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51721. /**
  51722. * Returns the string "SpotLight".
  51723. * @returns the class name
  51724. */
  51725. getClassName(): string;
  51726. /**
  51727. * Returns the integer 2.
  51728. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51729. */
  51730. getTypeID(): number;
  51731. /**
  51732. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51733. */
  51734. protected _setDirection(value: Vector3): void;
  51735. /**
  51736. * Overrides the position setter to recompute the projection texture view light Matrix.
  51737. */
  51738. protected _setPosition(value: Vector3): void;
  51739. /**
  51740. * 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.
  51741. * Returns the SpotLight.
  51742. */
  51743. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51744. protected _computeProjectionTextureViewLightMatrix(): void;
  51745. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51746. /**
  51747. * Main function for light texture projection matrix computing.
  51748. */
  51749. protected _computeProjectionTextureMatrix(): void;
  51750. protected _buildUniformLayout(): void;
  51751. private _computeAngleValues;
  51752. /**
  51753. * Sets the passed Effect "effect" with the Light textures.
  51754. * @param effect The effect to update
  51755. * @param lightIndex The index of the light in the effect to update
  51756. * @returns The light
  51757. */
  51758. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51759. /**
  51760. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51761. * @param effect The effect to update
  51762. * @param lightIndex The index of the light in the effect to update
  51763. * @returns The spot light
  51764. */
  51765. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51766. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51767. /**
  51768. * Disposes the light and the associated resources.
  51769. */
  51770. dispose(): void;
  51771. /**
  51772. * Prepares the list of defines specific to the light type.
  51773. * @param defines the list of defines
  51774. * @param lightIndex defines the index of the light for the effect
  51775. */
  51776. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51777. }
  51778. }
  51779. declare module "babylonjs/Gizmos/lightGizmo" {
  51780. import { Nullable } from "babylonjs/types";
  51781. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51782. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51783. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51784. import { Light } from "babylonjs/Lights/light";
  51785. /**
  51786. * Gizmo that enables viewing a light
  51787. */
  51788. export class LightGizmo extends Gizmo {
  51789. private _lightMesh;
  51790. private _material;
  51791. private _cachedPosition;
  51792. private _cachedForward;
  51793. private _attachedMeshParent;
  51794. /**
  51795. * Creates a LightGizmo
  51796. * @param gizmoLayer The utility layer the gizmo will be added to
  51797. */
  51798. constructor(gizmoLayer?: UtilityLayerRenderer);
  51799. private _light;
  51800. /**
  51801. * The light that the gizmo is attached to
  51802. */
  51803. set light(light: Nullable<Light>);
  51804. get light(): Nullable<Light>;
  51805. /**
  51806. * Gets the material used to render the light gizmo
  51807. */
  51808. get material(): StandardMaterial;
  51809. /**
  51810. * @hidden
  51811. * Updates the gizmo to match the attached mesh's position/rotation
  51812. */
  51813. protected _update(): void;
  51814. private static _Scale;
  51815. /**
  51816. * Creates the lines for a light mesh
  51817. */
  51818. private static _CreateLightLines;
  51819. /**
  51820. * Disposes of the light gizmo
  51821. */
  51822. dispose(): void;
  51823. private static _CreateHemisphericLightMesh;
  51824. private static _CreatePointLightMesh;
  51825. private static _CreateSpotLightMesh;
  51826. private static _CreateDirectionalLightMesh;
  51827. }
  51828. }
  51829. declare module "babylonjs/Gizmos/index" {
  51830. export * from "babylonjs/Gizmos/axisDragGizmo";
  51831. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51832. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51833. export * from "babylonjs/Gizmos/gizmo";
  51834. export * from "babylonjs/Gizmos/gizmoManager";
  51835. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51836. export * from "babylonjs/Gizmos/positionGizmo";
  51837. export * from "babylonjs/Gizmos/rotationGizmo";
  51838. export * from "babylonjs/Gizmos/scaleGizmo";
  51839. export * from "babylonjs/Gizmos/lightGizmo";
  51840. export * from "babylonjs/Gizmos/planeDragGizmo";
  51841. }
  51842. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51843. /** @hidden */
  51844. export var backgroundFragmentDeclaration: {
  51845. name: string;
  51846. shader: string;
  51847. };
  51848. }
  51849. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51850. /** @hidden */
  51851. export var backgroundUboDeclaration: {
  51852. name: string;
  51853. shader: string;
  51854. };
  51855. }
  51856. declare module "babylonjs/Shaders/background.fragment" {
  51857. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51858. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51859. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51860. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51861. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51862. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51863. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51864. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51865. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51866. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51867. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51868. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51869. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51870. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51871. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51872. /** @hidden */
  51873. export var backgroundPixelShader: {
  51874. name: string;
  51875. shader: string;
  51876. };
  51877. }
  51878. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51879. /** @hidden */
  51880. export var backgroundVertexDeclaration: {
  51881. name: string;
  51882. shader: string;
  51883. };
  51884. }
  51885. declare module "babylonjs/Shaders/background.vertex" {
  51886. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51887. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51889. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51890. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51891. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51892. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51893. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51894. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51895. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51896. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51897. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51898. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51899. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51900. /** @hidden */
  51901. export var backgroundVertexShader: {
  51902. name: string;
  51903. shader: string;
  51904. };
  51905. }
  51906. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51907. import { Nullable, int, float } from "babylonjs/types";
  51908. import { Scene } from "babylonjs/scene";
  51909. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51910. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51912. import { Mesh } from "babylonjs/Meshes/mesh";
  51913. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51914. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51915. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51917. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51918. import { Color3 } from "babylonjs/Maths/math.color";
  51919. import "babylonjs/Shaders/background.fragment";
  51920. import "babylonjs/Shaders/background.vertex";
  51921. /**
  51922. * Background material used to create an efficient environement around your scene.
  51923. */
  51924. export class BackgroundMaterial extends PushMaterial {
  51925. /**
  51926. * Standard reflectance value at parallel view angle.
  51927. */
  51928. static StandardReflectance0: number;
  51929. /**
  51930. * Standard reflectance value at grazing angle.
  51931. */
  51932. static StandardReflectance90: number;
  51933. protected _primaryColor: Color3;
  51934. /**
  51935. * Key light Color (multiply against the environement texture)
  51936. */
  51937. primaryColor: Color3;
  51938. protected __perceptualColor: Nullable<Color3>;
  51939. /**
  51940. * Experimental Internal Use Only.
  51941. *
  51942. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51943. * This acts as a helper to set the primary color to a more "human friendly" value.
  51944. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51945. * output color as close as possible from the chosen value.
  51946. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51947. * part of lighting setup.)
  51948. */
  51949. get _perceptualColor(): Nullable<Color3>;
  51950. set _perceptualColor(value: Nullable<Color3>);
  51951. protected _primaryColorShadowLevel: float;
  51952. /**
  51953. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51954. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51955. */
  51956. get primaryColorShadowLevel(): float;
  51957. set primaryColorShadowLevel(value: float);
  51958. protected _primaryColorHighlightLevel: float;
  51959. /**
  51960. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51961. * The primary color is used at the level chosen to define what the white area would look.
  51962. */
  51963. get primaryColorHighlightLevel(): float;
  51964. set primaryColorHighlightLevel(value: float);
  51965. protected _reflectionTexture: Nullable<BaseTexture>;
  51966. /**
  51967. * Reflection Texture used in the material.
  51968. * Should be author in a specific way for the best result (refer to the documentation).
  51969. */
  51970. reflectionTexture: Nullable<BaseTexture>;
  51971. protected _reflectionBlur: float;
  51972. /**
  51973. * Reflection Texture level of blur.
  51974. *
  51975. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51976. * texture twice.
  51977. */
  51978. reflectionBlur: float;
  51979. protected _diffuseTexture: Nullable<BaseTexture>;
  51980. /**
  51981. * Diffuse Texture used in the material.
  51982. * Should be author in a specific way for the best result (refer to the documentation).
  51983. */
  51984. diffuseTexture: Nullable<BaseTexture>;
  51985. protected _shadowLights: Nullable<IShadowLight[]>;
  51986. /**
  51987. * Specify the list of lights casting shadow on the material.
  51988. * All scene shadow lights will be included if null.
  51989. */
  51990. shadowLights: Nullable<IShadowLight[]>;
  51991. protected _shadowLevel: float;
  51992. /**
  51993. * Helps adjusting the shadow to a softer level if required.
  51994. * 0 means black shadows and 1 means no shadows.
  51995. */
  51996. shadowLevel: float;
  51997. protected _sceneCenter: Vector3;
  51998. /**
  51999. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52000. * It is usually zero but might be interesting to modify according to your setup.
  52001. */
  52002. sceneCenter: Vector3;
  52003. protected _opacityFresnel: boolean;
  52004. /**
  52005. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52006. * This helps ensuring a nice transition when the camera goes under the ground.
  52007. */
  52008. opacityFresnel: boolean;
  52009. protected _reflectionFresnel: boolean;
  52010. /**
  52011. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52012. * This helps adding a mirror texture on the ground.
  52013. */
  52014. reflectionFresnel: boolean;
  52015. protected _reflectionFalloffDistance: number;
  52016. /**
  52017. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52018. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52019. */
  52020. reflectionFalloffDistance: number;
  52021. protected _reflectionAmount: number;
  52022. /**
  52023. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52024. */
  52025. reflectionAmount: number;
  52026. protected _reflectionReflectance0: number;
  52027. /**
  52028. * This specifies the weight of the reflection at grazing angle.
  52029. */
  52030. reflectionReflectance0: number;
  52031. protected _reflectionReflectance90: number;
  52032. /**
  52033. * This specifies the weight of the reflection at a perpendicular point of view.
  52034. */
  52035. reflectionReflectance90: number;
  52036. /**
  52037. * Sets the reflection reflectance fresnel values according to the default standard
  52038. * empirically know to work well :-)
  52039. */
  52040. set reflectionStandardFresnelWeight(value: number);
  52041. protected _useRGBColor: boolean;
  52042. /**
  52043. * Helps to directly use the maps channels instead of their level.
  52044. */
  52045. useRGBColor: boolean;
  52046. protected _enableNoise: boolean;
  52047. /**
  52048. * This helps reducing the banding effect that could occur on the background.
  52049. */
  52050. enableNoise: boolean;
  52051. /**
  52052. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52053. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52054. * Recommended to be keep at 1.0 except for special cases.
  52055. */
  52056. get fovMultiplier(): number;
  52057. set fovMultiplier(value: number);
  52058. private _fovMultiplier;
  52059. /**
  52060. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52061. */
  52062. useEquirectangularFOV: boolean;
  52063. private _maxSimultaneousLights;
  52064. /**
  52065. * Number of Simultaneous lights allowed on the material.
  52066. */
  52067. maxSimultaneousLights: int;
  52068. /**
  52069. * Default configuration related to image processing available in the Background Material.
  52070. */
  52071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52072. /**
  52073. * Keep track of the image processing observer to allow dispose and replace.
  52074. */
  52075. private _imageProcessingObserver;
  52076. /**
  52077. * Attaches a new image processing configuration to the PBR Material.
  52078. * @param configuration (if null the scene configuration will be use)
  52079. */
  52080. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52081. /**
  52082. * Gets the image processing configuration used either in this material.
  52083. */
  52084. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52085. /**
  52086. * Sets the Default image processing configuration used either in the this material.
  52087. *
  52088. * If sets to null, the scene one is in use.
  52089. */
  52090. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52091. /**
  52092. * Gets wether the color curves effect is enabled.
  52093. */
  52094. get cameraColorCurvesEnabled(): boolean;
  52095. /**
  52096. * Sets wether the color curves effect is enabled.
  52097. */
  52098. set cameraColorCurvesEnabled(value: boolean);
  52099. /**
  52100. * Gets wether the color grading effect is enabled.
  52101. */
  52102. get cameraColorGradingEnabled(): boolean;
  52103. /**
  52104. * Gets wether the color grading effect is enabled.
  52105. */
  52106. set cameraColorGradingEnabled(value: boolean);
  52107. /**
  52108. * Gets wether tonemapping is enabled or not.
  52109. */
  52110. get cameraToneMappingEnabled(): boolean;
  52111. /**
  52112. * Sets wether tonemapping is enabled or not
  52113. */
  52114. set cameraToneMappingEnabled(value: boolean);
  52115. /**
  52116. * The camera exposure used on this material.
  52117. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52118. * This corresponds to a photographic exposure.
  52119. */
  52120. get cameraExposure(): float;
  52121. /**
  52122. * The camera exposure used on this material.
  52123. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52124. * This corresponds to a photographic exposure.
  52125. */
  52126. set cameraExposure(value: float);
  52127. /**
  52128. * Gets The camera contrast used on this material.
  52129. */
  52130. get cameraContrast(): float;
  52131. /**
  52132. * Sets The camera contrast used on this material.
  52133. */
  52134. set cameraContrast(value: float);
  52135. /**
  52136. * Gets the Color Grading 2D Lookup Texture.
  52137. */
  52138. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52139. /**
  52140. * Sets the Color Grading 2D Lookup Texture.
  52141. */
  52142. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52143. /**
  52144. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52145. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52146. * 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;
  52147. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52148. */
  52149. get cameraColorCurves(): Nullable<ColorCurves>;
  52150. /**
  52151. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52152. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52153. * 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;
  52154. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52155. */
  52156. set cameraColorCurves(value: Nullable<ColorCurves>);
  52157. /**
  52158. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52159. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52160. */
  52161. switchToBGR: boolean;
  52162. private _renderTargets;
  52163. private _reflectionControls;
  52164. private _white;
  52165. private _primaryShadowColor;
  52166. private _primaryHighlightColor;
  52167. /**
  52168. * Instantiates a Background Material in the given scene
  52169. * @param name The friendly name of the material
  52170. * @param scene The scene to add the material to
  52171. */
  52172. constructor(name: string, scene: Scene);
  52173. /**
  52174. * Gets a boolean indicating that current material needs to register RTT
  52175. */
  52176. get hasRenderTargetTextures(): boolean;
  52177. /**
  52178. * The entire material has been created in order to prevent overdraw.
  52179. * @returns false
  52180. */
  52181. needAlphaTesting(): boolean;
  52182. /**
  52183. * The entire material has been created in order to prevent overdraw.
  52184. * @returns true if blending is enable
  52185. */
  52186. needAlphaBlending(): boolean;
  52187. /**
  52188. * Checks wether the material is ready to be rendered for a given mesh.
  52189. * @param mesh The mesh to render
  52190. * @param subMesh The submesh to check against
  52191. * @param useInstances Specify wether or not the material is used with instances
  52192. * @returns true if all the dependencies are ready (Textures, Effects...)
  52193. */
  52194. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52195. /**
  52196. * Compute the primary color according to the chosen perceptual color.
  52197. */
  52198. private _computePrimaryColorFromPerceptualColor;
  52199. /**
  52200. * Compute the highlights and shadow colors according to their chosen levels.
  52201. */
  52202. private _computePrimaryColors;
  52203. /**
  52204. * Build the uniform buffer used in the material.
  52205. */
  52206. buildUniformLayout(): void;
  52207. /**
  52208. * Unbind the material.
  52209. */
  52210. unbind(): void;
  52211. /**
  52212. * Bind only the world matrix to the material.
  52213. * @param world The world matrix to bind.
  52214. */
  52215. bindOnlyWorldMatrix(world: Matrix): void;
  52216. /**
  52217. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52218. * @param world The world matrix to bind.
  52219. * @param subMesh The submesh to bind for.
  52220. */
  52221. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52222. /**
  52223. * Checks to see if a texture is used in the material.
  52224. * @param texture - Base texture to use.
  52225. * @returns - Boolean specifying if a texture is used in the material.
  52226. */
  52227. hasTexture(texture: BaseTexture): boolean;
  52228. /**
  52229. * Dispose the material.
  52230. * @param forceDisposeEffect Force disposal of the associated effect.
  52231. * @param forceDisposeTextures Force disposal of the associated textures.
  52232. */
  52233. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52234. /**
  52235. * Clones the material.
  52236. * @param name The cloned name.
  52237. * @returns The cloned material.
  52238. */
  52239. clone(name: string): BackgroundMaterial;
  52240. /**
  52241. * Serializes the current material to its JSON representation.
  52242. * @returns The JSON representation.
  52243. */
  52244. serialize(): any;
  52245. /**
  52246. * Gets the class name of the material
  52247. * @returns "BackgroundMaterial"
  52248. */
  52249. getClassName(): string;
  52250. /**
  52251. * Parse a JSON input to create back a background material.
  52252. * @param source The JSON data to parse
  52253. * @param scene The scene to create the parsed material in
  52254. * @param rootUrl The root url of the assets the material depends upon
  52255. * @returns the instantiated BackgroundMaterial.
  52256. */
  52257. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52258. }
  52259. }
  52260. declare module "babylonjs/Helpers/environmentHelper" {
  52261. import { Observable } from "babylonjs/Misc/observable";
  52262. import { Nullable } from "babylonjs/types";
  52263. import { Scene } from "babylonjs/scene";
  52264. import { Vector3 } from "babylonjs/Maths/math.vector";
  52265. import { Color3 } from "babylonjs/Maths/math.color";
  52266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52267. import { Mesh } from "babylonjs/Meshes/mesh";
  52268. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52269. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  52270. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52271. import "babylonjs/Meshes/Builders/planeBuilder";
  52272. import "babylonjs/Meshes/Builders/boxBuilder";
  52273. /**
  52274. * Represents the different options available during the creation of
  52275. * a Environment helper.
  52276. *
  52277. * This can control the default ground, skybox and image processing setup of your scene.
  52278. */
  52279. export interface IEnvironmentHelperOptions {
  52280. /**
  52281. * Specifies whether or not to create a ground.
  52282. * True by default.
  52283. */
  52284. createGround: boolean;
  52285. /**
  52286. * Specifies the ground size.
  52287. * 15 by default.
  52288. */
  52289. groundSize: number;
  52290. /**
  52291. * The texture used on the ground for the main color.
  52292. * Comes from the BabylonJS CDN by default.
  52293. *
  52294. * Remarks: Can be either a texture or a url.
  52295. */
  52296. groundTexture: string | BaseTexture;
  52297. /**
  52298. * The color mixed in the ground texture by default.
  52299. * BabylonJS clearColor by default.
  52300. */
  52301. groundColor: Color3;
  52302. /**
  52303. * Specifies the ground opacity.
  52304. * 1 by default.
  52305. */
  52306. groundOpacity: number;
  52307. /**
  52308. * Enables the ground to receive shadows.
  52309. * True by default.
  52310. */
  52311. enableGroundShadow: boolean;
  52312. /**
  52313. * Helps preventing the shadow to be fully black on the ground.
  52314. * 0.5 by default.
  52315. */
  52316. groundShadowLevel: number;
  52317. /**
  52318. * Creates a mirror texture attach to the ground.
  52319. * false by default.
  52320. */
  52321. enableGroundMirror: boolean;
  52322. /**
  52323. * Specifies the ground mirror size ratio.
  52324. * 0.3 by default as the default kernel is 64.
  52325. */
  52326. groundMirrorSizeRatio: number;
  52327. /**
  52328. * Specifies the ground mirror blur kernel size.
  52329. * 64 by default.
  52330. */
  52331. groundMirrorBlurKernel: number;
  52332. /**
  52333. * Specifies the ground mirror visibility amount.
  52334. * 1 by default
  52335. */
  52336. groundMirrorAmount: number;
  52337. /**
  52338. * Specifies the ground mirror reflectance weight.
  52339. * This uses the standard weight of the background material to setup the fresnel effect
  52340. * of the mirror.
  52341. * 1 by default.
  52342. */
  52343. groundMirrorFresnelWeight: number;
  52344. /**
  52345. * Specifies the ground mirror Falloff distance.
  52346. * This can helps reducing the size of the reflection.
  52347. * 0 by Default.
  52348. */
  52349. groundMirrorFallOffDistance: number;
  52350. /**
  52351. * Specifies the ground mirror texture type.
  52352. * Unsigned Int by Default.
  52353. */
  52354. groundMirrorTextureType: number;
  52355. /**
  52356. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52357. * the shown objects.
  52358. */
  52359. groundYBias: number;
  52360. /**
  52361. * Specifies whether or not to create a skybox.
  52362. * True by default.
  52363. */
  52364. createSkybox: boolean;
  52365. /**
  52366. * Specifies the skybox size.
  52367. * 20 by default.
  52368. */
  52369. skyboxSize: number;
  52370. /**
  52371. * The texture used on the skybox for the main color.
  52372. * Comes from the BabylonJS CDN by default.
  52373. *
  52374. * Remarks: Can be either a texture or a url.
  52375. */
  52376. skyboxTexture: string | BaseTexture;
  52377. /**
  52378. * The color mixed in the skybox texture by default.
  52379. * BabylonJS clearColor by default.
  52380. */
  52381. skyboxColor: Color3;
  52382. /**
  52383. * The background rotation around the Y axis of the scene.
  52384. * This helps aligning the key lights of your scene with the background.
  52385. * 0 by default.
  52386. */
  52387. backgroundYRotation: number;
  52388. /**
  52389. * Compute automatically the size of the elements to best fit with the scene.
  52390. */
  52391. sizeAuto: boolean;
  52392. /**
  52393. * Default position of the rootMesh if autoSize is not true.
  52394. */
  52395. rootPosition: Vector3;
  52396. /**
  52397. * Sets up the image processing in the scene.
  52398. * true by default.
  52399. */
  52400. setupImageProcessing: boolean;
  52401. /**
  52402. * The texture used as your environment texture in the scene.
  52403. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52404. *
  52405. * Remarks: Can be either a texture or a url.
  52406. */
  52407. environmentTexture: string | BaseTexture;
  52408. /**
  52409. * The value of the exposure to apply to the scene.
  52410. * 0.6 by default if setupImageProcessing is true.
  52411. */
  52412. cameraExposure: number;
  52413. /**
  52414. * The value of the contrast to apply to the scene.
  52415. * 1.6 by default if setupImageProcessing is true.
  52416. */
  52417. cameraContrast: number;
  52418. /**
  52419. * Specifies whether or not tonemapping should be enabled in the scene.
  52420. * true by default if setupImageProcessing is true.
  52421. */
  52422. toneMappingEnabled: boolean;
  52423. }
  52424. /**
  52425. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52426. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52427. * It also helps with the default setup of your imageProcessing configuration.
  52428. */
  52429. export class EnvironmentHelper {
  52430. /**
  52431. * Default ground texture URL.
  52432. */
  52433. private static _groundTextureCDNUrl;
  52434. /**
  52435. * Default skybox texture URL.
  52436. */
  52437. private static _skyboxTextureCDNUrl;
  52438. /**
  52439. * Default environment texture URL.
  52440. */
  52441. private static _environmentTextureCDNUrl;
  52442. /**
  52443. * Creates the default options for the helper.
  52444. */
  52445. private static _getDefaultOptions;
  52446. private _rootMesh;
  52447. /**
  52448. * Gets the root mesh created by the helper.
  52449. */
  52450. get rootMesh(): Mesh;
  52451. private _skybox;
  52452. /**
  52453. * Gets the skybox created by the helper.
  52454. */
  52455. get skybox(): Nullable<Mesh>;
  52456. private _skyboxTexture;
  52457. /**
  52458. * Gets the skybox texture created by the helper.
  52459. */
  52460. get skyboxTexture(): Nullable<BaseTexture>;
  52461. private _skyboxMaterial;
  52462. /**
  52463. * Gets the skybox material created by the helper.
  52464. */
  52465. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52466. private _ground;
  52467. /**
  52468. * Gets the ground mesh created by the helper.
  52469. */
  52470. get ground(): Nullable<Mesh>;
  52471. private _groundTexture;
  52472. /**
  52473. * Gets the ground texture created by the helper.
  52474. */
  52475. get groundTexture(): Nullable<BaseTexture>;
  52476. private _groundMirror;
  52477. /**
  52478. * Gets the ground mirror created by the helper.
  52479. */
  52480. get groundMirror(): Nullable<MirrorTexture>;
  52481. /**
  52482. * Gets the ground mirror render list to helps pushing the meshes
  52483. * you wish in the ground reflection.
  52484. */
  52485. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52486. private _groundMaterial;
  52487. /**
  52488. * Gets the ground material created by the helper.
  52489. */
  52490. get groundMaterial(): Nullable<BackgroundMaterial>;
  52491. /**
  52492. * Stores the creation options.
  52493. */
  52494. private readonly _scene;
  52495. private _options;
  52496. /**
  52497. * This observable will be notified with any error during the creation of the environment,
  52498. * mainly texture creation errors.
  52499. */
  52500. onErrorObservable: Observable<{
  52501. message?: string;
  52502. exception?: any;
  52503. }>;
  52504. /**
  52505. * constructor
  52506. * @param options Defines the options we want to customize the helper
  52507. * @param scene The scene to add the material to
  52508. */
  52509. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52510. /**
  52511. * Updates the background according to the new options
  52512. * @param options
  52513. */
  52514. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52515. /**
  52516. * Sets the primary color of all the available elements.
  52517. * @param color the main color to affect to the ground and the background
  52518. */
  52519. setMainColor(color: Color3): void;
  52520. /**
  52521. * Setup the image processing according to the specified options.
  52522. */
  52523. private _setupImageProcessing;
  52524. /**
  52525. * Setup the environment texture according to the specified options.
  52526. */
  52527. private _setupEnvironmentTexture;
  52528. /**
  52529. * Setup the background according to the specified options.
  52530. */
  52531. private _setupBackground;
  52532. /**
  52533. * Get the scene sizes according to the setup.
  52534. */
  52535. private _getSceneSize;
  52536. /**
  52537. * Setup the ground according to the specified options.
  52538. */
  52539. private _setupGround;
  52540. /**
  52541. * Setup the ground material according to the specified options.
  52542. */
  52543. private _setupGroundMaterial;
  52544. /**
  52545. * Setup the ground diffuse texture according to the specified options.
  52546. */
  52547. private _setupGroundDiffuseTexture;
  52548. /**
  52549. * Setup the ground mirror texture according to the specified options.
  52550. */
  52551. private _setupGroundMirrorTexture;
  52552. /**
  52553. * Setup the ground to receive the mirror texture.
  52554. */
  52555. private _setupMirrorInGroundMaterial;
  52556. /**
  52557. * Setup the skybox according to the specified options.
  52558. */
  52559. private _setupSkybox;
  52560. /**
  52561. * Setup the skybox material according to the specified options.
  52562. */
  52563. private _setupSkyboxMaterial;
  52564. /**
  52565. * Setup the skybox reflection texture according to the specified options.
  52566. */
  52567. private _setupSkyboxReflectionTexture;
  52568. private _errorHandler;
  52569. /**
  52570. * Dispose all the elements created by the Helper.
  52571. */
  52572. dispose(): void;
  52573. }
  52574. }
  52575. declare module "babylonjs/Helpers/photoDome" {
  52576. import { Observable } from "babylonjs/Misc/observable";
  52577. import { Nullable } from "babylonjs/types";
  52578. import { Scene } from "babylonjs/scene";
  52579. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52580. import { Mesh } from "babylonjs/Meshes/mesh";
  52581. import { Texture } from "babylonjs/Materials/Textures/texture";
  52582. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52583. import "babylonjs/Meshes/Builders/sphereBuilder";
  52584. /**
  52585. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52586. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52587. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52588. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52589. */
  52590. export class PhotoDome extends TransformNode {
  52591. /**
  52592. * Define the image as a Monoscopic panoramic 360 image.
  52593. */
  52594. static readonly MODE_MONOSCOPIC: number;
  52595. /**
  52596. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52597. */
  52598. static readonly MODE_TOPBOTTOM: number;
  52599. /**
  52600. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52601. */
  52602. static readonly MODE_SIDEBYSIDE: number;
  52603. private _useDirectMapping;
  52604. /**
  52605. * The texture being displayed on the sphere
  52606. */
  52607. protected _photoTexture: Texture;
  52608. /**
  52609. * Gets or sets the texture being displayed on the sphere
  52610. */
  52611. get photoTexture(): Texture;
  52612. set photoTexture(value: Texture);
  52613. /**
  52614. * Observable raised when an error occured while loading the 360 image
  52615. */
  52616. onLoadErrorObservable: Observable<string>;
  52617. /**
  52618. * The skybox material
  52619. */
  52620. protected _material: BackgroundMaterial;
  52621. /**
  52622. * The surface used for the skybox
  52623. */
  52624. protected _mesh: Mesh;
  52625. /**
  52626. * Gets the mesh used for the skybox.
  52627. */
  52628. get mesh(): Mesh;
  52629. /**
  52630. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52631. * Also see the options.resolution property.
  52632. */
  52633. get fovMultiplier(): number;
  52634. set fovMultiplier(value: number);
  52635. private _imageMode;
  52636. /**
  52637. * Gets or set the current video mode for the video. It can be:
  52638. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52639. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52640. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52641. */
  52642. get imageMode(): number;
  52643. set imageMode(value: number);
  52644. /**
  52645. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52646. * @param name Element's name, child elements will append suffixes for their own names.
  52647. * @param urlsOfPhoto defines the url of the photo to display
  52648. * @param options defines an object containing optional or exposed sub element properties
  52649. * @param onError defines a callback called when an error occured while loading the texture
  52650. */
  52651. constructor(name: string, urlOfPhoto: string, options: {
  52652. resolution?: number;
  52653. size?: number;
  52654. useDirectMapping?: boolean;
  52655. faceForward?: boolean;
  52656. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52657. private _onBeforeCameraRenderObserver;
  52658. private _changeImageMode;
  52659. /**
  52660. * Releases resources associated with this node.
  52661. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52662. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52663. */
  52664. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52665. }
  52666. }
  52667. declare module "babylonjs/Misc/rgbdTextureTools" {
  52668. import "babylonjs/Shaders/rgbdDecode.fragment";
  52669. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52670. import { Texture } from "babylonjs/Materials/Textures/texture";
  52671. /**
  52672. * Class used to host RGBD texture specific utilities
  52673. */
  52674. export class RGBDTextureTools {
  52675. /**
  52676. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52677. * @param texture the texture to expand.
  52678. */
  52679. static ExpandRGBDTexture(texture: Texture): void;
  52680. }
  52681. }
  52682. declare module "babylonjs/Misc/brdfTextureTools" {
  52683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52684. import { Scene } from "babylonjs/scene";
  52685. /**
  52686. * Class used to host texture specific utilities
  52687. */
  52688. export class BRDFTextureTools {
  52689. /**
  52690. * Prevents texture cache collision
  52691. */
  52692. private static _instanceNumber;
  52693. /**
  52694. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52695. * @param scene defines the hosting scene
  52696. * @returns the environment BRDF texture
  52697. */
  52698. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52699. private static _environmentBRDFBase64Texture;
  52700. }
  52701. }
  52702. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52703. import { Nullable } from "babylonjs/types";
  52704. import { Color3 } from "babylonjs/Maths/math.color";
  52705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52706. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52707. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52708. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52709. import { Engine } from "babylonjs/Engines/engine";
  52710. import { Scene } from "babylonjs/scene";
  52711. /**
  52712. * @hidden
  52713. */
  52714. export interface IMaterialClearCoatDefines {
  52715. CLEARCOAT: boolean;
  52716. CLEARCOAT_DEFAULTIOR: boolean;
  52717. CLEARCOAT_TEXTURE: boolean;
  52718. CLEARCOAT_TEXTUREDIRECTUV: number;
  52719. CLEARCOAT_BUMP: boolean;
  52720. CLEARCOAT_BUMPDIRECTUV: number;
  52721. CLEARCOAT_TINT: boolean;
  52722. CLEARCOAT_TINT_TEXTURE: boolean;
  52723. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52724. /** @hidden */
  52725. _areTexturesDirty: boolean;
  52726. }
  52727. /**
  52728. * Define the code related to the clear coat parameters of the pbr material.
  52729. */
  52730. export class PBRClearCoatConfiguration {
  52731. /**
  52732. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52733. * The default fits with a polyurethane material.
  52734. */
  52735. private static readonly _DefaultIndexOfRefraction;
  52736. private _isEnabled;
  52737. /**
  52738. * Defines if the clear coat is enabled in the material.
  52739. */
  52740. isEnabled: boolean;
  52741. /**
  52742. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52743. */
  52744. intensity: number;
  52745. /**
  52746. * Defines the clear coat layer roughness.
  52747. */
  52748. roughness: number;
  52749. private _indexOfRefraction;
  52750. /**
  52751. * Defines the index of refraction of the clear coat.
  52752. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52753. * The default fits with a polyurethane material.
  52754. * Changing the default value is more performance intensive.
  52755. */
  52756. indexOfRefraction: number;
  52757. private _texture;
  52758. /**
  52759. * Stores the clear coat values in a texture.
  52760. */
  52761. texture: Nullable<BaseTexture>;
  52762. private _bumpTexture;
  52763. /**
  52764. * Define the clear coat specific bump texture.
  52765. */
  52766. bumpTexture: Nullable<BaseTexture>;
  52767. private _isTintEnabled;
  52768. /**
  52769. * Defines if the clear coat tint is enabled in the material.
  52770. */
  52771. isTintEnabled: boolean;
  52772. /**
  52773. * Defines the clear coat tint of the material.
  52774. * This is only use if tint is enabled
  52775. */
  52776. tintColor: Color3;
  52777. /**
  52778. * Defines the distance at which the tint color should be found in the
  52779. * clear coat media.
  52780. * This is only use if tint is enabled
  52781. */
  52782. tintColorAtDistance: number;
  52783. /**
  52784. * Defines the clear coat layer thickness.
  52785. * This is only use if tint is enabled
  52786. */
  52787. tintThickness: number;
  52788. private _tintTexture;
  52789. /**
  52790. * Stores the clear tint values in a texture.
  52791. * rgb is tint
  52792. * a is a thickness factor
  52793. */
  52794. tintTexture: Nullable<BaseTexture>;
  52795. /** @hidden */
  52796. private _internalMarkAllSubMeshesAsTexturesDirty;
  52797. /** @hidden */
  52798. _markAllSubMeshesAsTexturesDirty(): void;
  52799. /**
  52800. * Instantiate a new istance of clear coat configuration.
  52801. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52802. */
  52803. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52804. /**
  52805. * Gets wehter the submesh is ready to be used or not.
  52806. * @param defines the list of "defines" to update.
  52807. * @param scene defines the scene the material belongs to.
  52808. * @param engine defines the engine the material belongs to.
  52809. * @param disableBumpMap defines wether the material disables bump or not.
  52810. * @returns - boolean indicating that the submesh is ready or not.
  52811. */
  52812. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52813. /**
  52814. * Checks to see if a texture is used in the material.
  52815. * @param defines the list of "defines" to update.
  52816. * @param scene defines the scene to the material belongs to.
  52817. */
  52818. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52819. /**
  52820. * Binds the material data.
  52821. * @param uniformBuffer defines the Uniform buffer to fill in.
  52822. * @param scene defines the scene the material belongs to.
  52823. * @param engine defines the engine the material belongs to.
  52824. * @param disableBumpMap defines wether the material disables bump or not.
  52825. * @param isFrozen defines wether the material is frozen or not.
  52826. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52827. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52828. */
  52829. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52830. /**
  52831. * Checks to see if a texture is used in the material.
  52832. * @param texture - Base texture to use.
  52833. * @returns - Boolean specifying if a texture is used in the material.
  52834. */
  52835. hasTexture(texture: BaseTexture): boolean;
  52836. /**
  52837. * Returns an array of the actively used textures.
  52838. * @param activeTextures Array of BaseTextures
  52839. */
  52840. getActiveTextures(activeTextures: BaseTexture[]): void;
  52841. /**
  52842. * Returns the animatable textures.
  52843. * @param animatables Array of animatable textures.
  52844. */
  52845. getAnimatables(animatables: IAnimatable[]): void;
  52846. /**
  52847. * Disposes the resources of the material.
  52848. * @param forceDisposeTextures - Forces the disposal of all textures.
  52849. */
  52850. dispose(forceDisposeTextures?: boolean): void;
  52851. /**
  52852. * Get the current class name of the texture useful for serialization or dynamic coding.
  52853. * @returns "PBRClearCoatConfiguration"
  52854. */
  52855. getClassName(): string;
  52856. /**
  52857. * Add fallbacks to the effect fallbacks list.
  52858. * @param defines defines the Base texture to use.
  52859. * @param fallbacks defines the current fallback list.
  52860. * @param currentRank defines the current fallback rank.
  52861. * @returns the new fallback rank.
  52862. */
  52863. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52864. /**
  52865. * Add the required uniforms to the current list.
  52866. * @param uniforms defines the current uniform list.
  52867. */
  52868. static AddUniforms(uniforms: string[]): void;
  52869. /**
  52870. * Add the required samplers to the current list.
  52871. * @param samplers defines the current sampler list.
  52872. */
  52873. static AddSamplers(samplers: string[]): void;
  52874. /**
  52875. * Add the required uniforms to the current buffer.
  52876. * @param uniformBuffer defines the current uniform buffer.
  52877. */
  52878. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52879. /**
  52880. * Makes a duplicate of the current configuration into another one.
  52881. * @param clearCoatConfiguration define the config where to copy the info
  52882. */
  52883. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52884. /**
  52885. * Serializes this clear coat configuration.
  52886. * @returns - An object with the serialized config.
  52887. */
  52888. serialize(): any;
  52889. /**
  52890. * Parses a anisotropy Configuration from a serialized object.
  52891. * @param source - Serialized object.
  52892. * @param scene Defines the scene we are parsing for
  52893. * @param rootUrl Defines the rootUrl to load from
  52894. */
  52895. parse(source: any, scene: Scene, rootUrl: string): void;
  52896. }
  52897. }
  52898. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52899. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52901. import { Vector2 } from "babylonjs/Maths/math.vector";
  52902. import { Scene } from "babylonjs/scene";
  52903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52904. import { Nullable } from "babylonjs/types";
  52905. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52906. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52907. /**
  52908. * @hidden
  52909. */
  52910. export interface IMaterialAnisotropicDefines {
  52911. ANISOTROPIC: boolean;
  52912. ANISOTROPIC_TEXTURE: boolean;
  52913. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52914. MAINUV1: boolean;
  52915. _areTexturesDirty: boolean;
  52916. _needUVs: boolean;
  52917. }
  52918. /**
  52919. * Define the code related to the anisotropic parameters of the pbr material.
  52920. */
  52921. export class PBRAnisotropicConfiguration {
  52922. private _isEnabled;
  52923. /**
  52924. * Defines if the anisotropy is enabled in the material.
  52925. */
  52926. isEnabled: boolean;
  52927. /**
  52928. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52929. */
  52930. intensity: number;
  52931. /**
  52932. * Defines if the effect is along the tangents, bitangents or in between.
  52933. * By default, the effect is "strectching" the highlights along the tangents.
  52934. */
  52935. direction: Vector2;
  52936. private _texture;
  52937. /**
  52938. * Stores the anisotropy values in a texture.
  52939. * rg is direction (like normal from -1 to 1)
  52940. * b is a intensity
  52941. */
  52942. texture: Nullable<BaseTexture>;
  52943. /** @hidden */
  52944. private _internalMarkAllSubMeshesAsTexturesDirty;
  52945. /** @hidden */
  52946. _markAllSubMeshesAsTexturesDirty(): void;
  52947. /**
  52948. * Instantiate a new istance of anisotropy configuration.
  52949. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52950. */
  52951. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52952. /**
  52953. * Specifies that the submesh is ready to be used.
  52954. * @param defines the list of "defines" to update.
  52955. * @param scene defines the scene the material belongs to.
  52956. * @returns - boolean indicating that the submesh is ready or not.
  52957. */
  52958. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52959. /**
  52960. * Checks to see if a texture is used in the material.
  52961. * @param defines the list of "defines" to update.
  52962. * @param mesh the mesh we are preparing the defines for.
  52963. * @param scene defines the scene the material belongs to.
  52964. */
  52965. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52966. /**
  52967. * Binds the material data.
  52968. * @param uniformBuffer defines the Uniform buffer to fill in.
  52969. * @param scene defines the scene the material belongs to.
  52970. * @param isFrozen defines wether the material is frozen or not.
  52971. */
  52972. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52973. /**
  52974. * Checks to see if a texture is used in the material.
  52975. * @param texture - Base texture to use.
  52976. * @returns - Boolean specifying if a texture is used in the material.
  52977. */
  52978. hasTexture(texture: BaseTexture): boolean;
  52979. /**
  52980. * Returns an array of the actively used textures.
  52981. * @param activeTextures Array of BaseTextures
  52982. */
  52983. getActiveTextures(activeTextures: BaseTexture[]): void;
  52984. /**
  52985. * Returns the animatable textures.
  52986. * @param animatables Array of animatable textures.
  52987. */
  52988. getAnimatables(animatables: IAnimatable[]): void;
  52989. /**
  52990. * Disposes the resources of the material.
  52991. * @param forceDisposeTextures - Forces the disposal of all textures.
  52992. */
  52993. dispose(forceDisposeTextures?: boolean): void;
  52994. /**
  52995. * Get the current class name of the texture useful for serialization or dynamic coding.
  52996. * @returns "PBRAnisotropicConfiguration"
  52997. */
  52998. getClassName(): string;
  52999. /**
  53000. * Add fallbacks to the effect fallbacks list.
  53001. * @param defines defines the Base texture to use.
  53002. * @param fallbacks defines the current fallback list.
  53003. * @param currentRank defines the current fallback rank.
  53004. * @returns the new fallback rank.
  53005. */
  53006. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53007. /**
  53008. * Add the required uniforms to the current list.
  53009. * @param uniforms defines the current uniform list.
  53010. */
  53011. static AddUniforms(uniforms: string[]): void;
  53012. /**
  53013. * Add the required uniforms to the current buffer.
  53014. * @param uniformBuffer defines the current uniform buffer.
  53015. */
  53016. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53017. /**
  53018. * Add the required samplers to the current list.
  53019. * @param samplers defines the current sampler list.
  53020. */
  53021. static AddSamplers(samplers: string[]): void;
  53022. /**
  53023. * Makes a duplicate of the current configuration into another one.
  53024. * @param anisotropicConfiguration define the config where to copy the info
  53025. */
  53026. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53027. /**
  53028. * Serializes this anisotropy configuration.
  53029. * @returns - An object with the serialized config.
  53030. */
  53031. serialize(): any;
  53032. /**
  53033. * Parses a anisotropy Configuration from a serialized object.
  53034. * @param source - Serialized object.
  53035. * @param scene Defines the scene we are parsing for
  53036. * @param rootUrl Defines the rootUrl to load from
  53037. */
  53038. parse(source: any, scene: Scene, rootUrl: string): void;
  53039. }
  53040. }
  53041. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  53042. import { Scene } from "babylonjs/scene";
  53043. /**
  53044. * @hidden
  53045. */
  53046. export interface IMaterialBRDFDefines {
  53047. BRDF_V_HEIGHT_CORRELATED: boolean;
  53048. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53049. SPHERICAL_HARMONICS: boolean;
  53050. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53051. /** @hidden */
  53052. _areMiscDirty: boolean;
  53053. }
  53054. /**
  53055. * Define the code related to the BRDF parameters of the pbr material.
  53056. */
  53057. export class PBRBRDFConfiguration {
  53058. /**
  53059. * Default value used for the energy conservation.
  53060. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53061. */
  53062. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53063. /**
  53064. * Default value used for the Smith Visibility Height Correlated mode.
  53065. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53066. */
  53067. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53068. /**
  53069. * Default value used for the IBL diffuse part.
  53070. * This can help switching back to the polynomials mode globally which is a tiny bit
  53071. * less GPU intensive at the drawback of a lower quality.
  53072. */
  53073. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53074. /**
  53075. * Default value used for activating energy conservation for the specular workflow.
  53076. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53077. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53078. */
  53079. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53080. private _useEnergyConservation;
  53081. /**
  53082. * Defines if the material uses energy conservation.
  53083. */
  53084. useEnergyConservation: boolean;
  53085. private _useSmithVisibilityHeightCorrelated;
  53086. /**
  53087. * LEGACY Mode set to false
  53088. * Defines if the material uses height smith correlated visibility term.
  53089. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53090. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53091. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53092. * Not relying on height correlated will also disable energy conservation.
  53093. */
  53094. useSmithVisibilityHeightCorrelated: boolean;
  53095. private _useSphericalHarmonics;
  53096. /**
  53097. * LEGACY Mode set to false
  53098. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53099. * diffuse part of the IBL.
  53100. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53101. * to the ground truth.
  53102. */
  53103. useSphericalHarmonics: boolean;
  53104. private _useSpecularGlossinessInputEnergyConservation;
  53105. /**
  53106. * Defines if the material uses energy conservation, when the specular workflow is active.
  53107. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53108. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53109. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53110. */
  53111. useSpecularGlossinessInputEnergyConservation: boolean;
  53112. /** @hidden */
  53113. private _internalMarkAllSubMeshesAsMiscDirty;
  53114. /** @hidden */
  53115. _markAllSubMeshesAsMiscDirty(): void;
  53116. /**
  53117. * Instantiate a new istance of clear coat configuration.
  53118. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53119. */
  53120. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53121. /**
  53122. * Checks to see if a texture is used in the material.
  53123. * @param defines the list of "defines" to update.
  53124. */
  53125. prepareDefines(defines: IMaterialBRDFDefines): void;
  53126. /**
  53127. * Get the current class name of the texture useful for serialization or dynamic coding.
  53128. * @returns "PBRClearCoatConfiguration"
  53129. */
  53130. getClassName(): string;
  53131. /**
  53132. * Makes a duplicate of the current configuration into another one.
  53133. * @param brdfConfiguration define the config where to copy the info
  53134. */
  53135. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53136. /**
  53137. * Serializes this BRDF configuration.
  53138. * @returns - An object with the serialized config.
  53139. */
  53140. serialize(): any;
  53141. /**
  53142. * Parses a anisotropy Configuration from a serialized object.
  53143. * @param source - Serialized object.
  53144. * @param scene Defines the scene we are parsing for
  53145. * @param rootUrl Defines the rootUrl to load from
  53146. */
  53147. parse(source: any, scene: Scene, rootUrl: string): void;
  53148. }
  53149. }
  53150. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  53151. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53152. import { Color3 } from "babylonjs/Maths/math.color";
  53153. import { Scene } from "babylonjs/scene";
  53154. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53155. import { Nullable } from "babylonjs/types";
  53156. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53157. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53158. /**
  53159. * @hidden
  53160. */
  53161. export interface IMaterialSheenDefines {
  53162. SHEEN: boolean;
  53163. SHEEN_TEXTURE: boolean;
  53164. SHEEN_TEXTUREDIRECTUV: number;
  53165. SHEEN_LINKWITHALBEDO: boolean;
  53166. SHEEN_ROUGHNESS: boolean;
  53167. SHEEN_ALBEDOSCALING: boolean;
  53168. /** @hidden */
  53169. _areTexturesDirty: boolean;
  53170. }
  53171. /**
  53172. * Define the code related to the Sheen parameters of the pbr material.
  53173. */
  53174. export class PBRSheenConfiguration {
  53175. private _isEnabled;
  53176. /**
  53177. * Defines if the material uses sheen.
  53178. */
  53179. isEnabled: boolean;
  53180. private _linkSheenWithAlbedo;
  53181. /**
  53182. * Defines if the sheen is linked to the sheen color.
  53183. */
  53184. linkSheenWithAlbedo: boolean;
  53185. /**
  53186. * Defines the sheen intensity.
  53187. */
  53188. intensity: number;
  53189. /**
  53190. * Defines the sheen color.
  53191. */
  53192. color: Color3;
  53193. private _texture;
  53194. /**
  53195. * Stores the sheen tint values in a texture.
  53196. * rgb is tint
  53197. * a is a intensity
  53198. */
  53199. texture: Nullable<BaseTexture>;
  53200. private _roughness;
  53201. /**
  53202. * Defines the sheen roughness.
  53203. * It is not taken into account if linkSheenWithAlbedo is true.
  53204. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53205. */
  53206. roughness: Nullable<number>;
  53207. private _albedoScaling;
  53208. /**
  53209. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53210. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53211. * making it easier to setup and tweak the effect
  53212. */
  53213. albedoScaling: boolean;
  53214. /** @hidden */
  53215. private _internalMarkAllSubMeshesAsTexturesDirty;
  53216. /** @hidden */
  53217. _markAllSubMeshesAsTexturesDirty(): void;
  53218. /**
  53219. * Instantiate a new istance of clear coat configuration.
  53220. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53221. */
  53222. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53223. /**
  53224. * Specifies that the submesh is ready to be used.
  53225. * @param defines the list of "defines" to update.
  53226. * @param scene defines the scene the material belongs to.
  53227. * @returns - boolean indicating that the submesh is ready or not.
  53228. */
  53229. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53230. /**
  53231. * Checks to see if a texture is used in the material.
  53232. * @param defines the list of "defines" to update.
  53233. * @param scene defines the scene the material belongs to.
  53234. */
  53235. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53236. /**
  53237. * Binds the material data.
  53238. * @param uniformBuffer defines the Uniform buffer to fill in.
  53239. * @param scene defines the scene the material belongs to.
  53240. * @param isFrozen defines wether the material is frozen or not.
  53241. */
  53242. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53243. /**
  53244. * Checks to see if a texture is used in the material.
  53245. * @param texture - Base texture to use.
  53246. * @returns - Boolean specifying if a texture is used in the material.
  53247. */
  53248. hasTexture(texture: BaseTexture): boolean;
  53249. /**
  53250. * Returns an array of the actively used textures.
  53251. * @param activeTextures Array of BaseTextures
  53252. */
  53253. getActiveTextures(activeTextures: BaseTexture[]): void;
  53254. /**
  53255. * Returns the animatable textures.
  53256. * @param animatables Array of animatable textures.
  53257. */
  53258. getAnimatables(animatables: IAnimatable[]): void;
  53259. /**
  53260. * Disposes the resources of the material.
  53261. * @param forceDisposeTextures - Forces the disposal of all textures.
  53262. */
  53263. dispose(forceDisposeTextures?: boolean): void;
  53264. /**
  53265. * Get the current class name of the texture useful for serialization or dynamic coding.
  53266. * @returns "PBRSheenConfiguration"
  53267. */
  53268. getClassName(): string;
  53269. /**
  53270. * Add fallbacks to the effect fallbacks list.
  53271. * @param defines defines the Base texture to use.
  53272. * @param fallbacks defines the current fallback list.
  53273. * @param currentRank defines the current fallback rank.
  53274. * @returns the new fallback rank.
  53275. */
  53276. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53277. /**
  53278. * Add the required uniforms to the current list.
  53279. * @param uniforms defines the current uniform list.
  53280. */
  53281. static AddUniforms(uniforms: string[]): void;
  53282. /**
  53283. * Add the required uniforms to the current buffer.
  53284. * @param uniformBuffer defines the current uniform buffer.
  53285. */
  53286. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53287. /**
  53288. * Add the required samplers to the current list.
  53289. * @param samplers defines the current sampler list.
  53290. */
  53291. static AddSamplers(samplers: string[]): void;
  53292. /**
  53293. * Makes a duplicate of the current configuration into another one.
  53294. * @param sheenConfiguration define the config where to copy the info
  53295. */
  53296. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53297. /**
  53298. * Serializes this BRDF configuration.
  53299. * @returns - An object with the serialized config.
  53300. */
  53301. serialize(): any;
  53302. /**
  53303. * Parses a anisotropy Configuration from a serialized object.
  53304. * @param source - Serialized object.
  53305. * @param scene Defines the scene we are parsing for
  53306. * @param rootUrl Defines the rootUrl to load from
  53307. */
  53308. parse(source: any, scene: Scene, rootUrl: string): void;
  53309. }
  53310. }
  53311. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53312. import { Nullable } from "babylonjs/types";
  53313. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53314. import { Color3 } from "babylonjs/Maths/math.color";
  53315. import { SmartArray } from "babylonjs/Misc/smartArray";
  53316. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53317. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53318. import { Effect } from "babylonjs/Materials/effect";
  53319. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53320. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53321. import { Engine } from "babylonjs/Engines/engine";
  53322. import { Scene } from "babylonjs/scene";
  53323. /**
  53324. * @hidden
  53325. */
  53326. export interface IMaterialSubSurfaceDefines {
  53327. SUBSURFACE: boolean;
  53328. SS_REFRACTION: boolean;
  53329. SS_TRANSLUCENCY: boolean;
  53330. SS_SCATERRING: boolean;
  53331. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53332. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53333. SS_REFRACTIONMAP_3D: boolean;
  53334. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53335. SS_LODINREFRACTIONALPHA: boolean;
  53336. SS_GAMMAREFRACTION: boolean;
  53337. SS_RGBDREFRACTION: boolean;
  53338. SS_LINEARSPECULARREFRACTION: boolean;
  53339. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53340. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53341. /** @hidden */
  53342. _areTexturesDirty: boolean;
  53343. }
  53344. /**
  53345. * Define the code related to the sub surface parameters of the pbr material.
  53346. */
  53347. export class PBRSubSurfaceConfiguration {
  53348. private _isRefractionEnabled;
  53349. /**
  53350. * Defines if the refraction is enabled in the material.
  53351. */
  53352. isRefractionEnabled: boolean;
  53353. private _isTranslucencyEnabled;
  53354. /**
  53355. * Defines if the translucency is enabled in the material.
  53356. */
  53357. isTranslucencyEnabled: boolean;
  53358. private _isScatteringEnabled;
  53359. /**
  53360. * Defines the refraction intensity of the material.
  53361. * The refraction when enabled replaces the Diffuse part of the material.
  53362. * The intensity helps transitionning between diffuse and refraction.
  53363. */
  53364. refractionIntensity: number;
  53365. /**
  53366. * Defines the translucency intensity of the material.
  53367. * When translucency has been enabled, this defines how much of the "translucency"
  53368. * is addded to the diffuse part of the material.
  53369. */
  53370. translucencyIntensity: number;
  53371. /**
  53372. * Defines the scattering intensity of the material.
  53373. * When scattering has been enabled, this defines how much of the "scattered light"
  53374. * is addded to the diffuse part of the material.
  53375. */
  53376. scatteringIntensity: number;
  53377. private _thicknessTexture;
  53378. /**
  53379. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53380. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53381. * 0 would mean minimumThickness
  53382. * 1 would mean maximumThickness
  53383. * The other channels might be use as a mask to vary the different effects intensity.
  53384. */
  53385. thicknessTexture: Nullable<BaseTexture>;
  53386. private _refractionTexture;
  53387. /**
  53388. * Defines the texture to use for refraction.
  53389. */
  53390. refractionTexture: Nullable<BaseTexture>;
  53391. private _indexOfRefraction;
  53392. /**
  53393. * Defines the index of refraction used in the material.
  53394. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53395. */
  53396. indexOfRefraction: number;
  53397. private _invertRefractionY;
  53398. /**
  53399. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53400. */
  53401. invertRefractionY: boolean;
  53402. private _linkRefractionWithTransparency;
  53403. /**
  53404. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53405. * Materials half opaque for instance using refraction could benefit from this control.
  53406. */
  53407. linkRefractionWithTransparency: boolean;
  53408. /**
  53409. * Defines the minimum thickness stored in the thickness map.
  53410. * If no thickness map is defined, this value will be used to simulate thickness.
  53411. */
  53412. minimumThickness: number;
  53413. /**
  53414. * Defines the maximum thickness stored in the thickness map.
  53415. */
  53416. maximumThickness: number;
  53417. /**
  53418. * Defines the volume tint of the material.
  53419. * This is used for both translucency and scattering.
  53420. */
  53421. tintColor: Color3;
  53422. /**
  53423. * Defines the distance at which the tint color should be found in the media.
  53424. * This is used for refraction only.
  53425. */
  53426. tintColorAtDistance: number;
  53427. /**
  53428. * Defines how far each channel transmit through the media.
  53429. * It is defined as a color to simplify it selection.
  53430. */
  53431. diffusionDistance: Color3;
  53432. private _useMaskFromThicknessTexture;
  53433. /**
  53434. * Stores the intensity of the different subsurface effects in the thickness texture.
  53435. * * the green channel is the translucency intensity.
  53436. * * the blue channel is the scattering intensity.
  53437. * * the alpha channel is the refraction intensity.
  53438. */
  53439. useMaskFromThicknessTexture: boolean;
  53440. /** @hidden */
  53441. private _internalMarkAllSubMeshesAsTexturesDirty;
  53442. /** @hidden */
  53443. _markAllSubMeshesAsTexturesDirty(): void;
  53444. /**
  53445. * Instantiate a new istance of sub surface configuration.
  53446. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53447. */
  53448. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53449. /**
  53450. * Gets wehter the submesh is ready to be used or not.
  53451. * @param defines the list of "defines" to update.
  53452. * @param scene defines the scene the material belongs to.
  53453. * @returns - boolean indicating that the submesh is ready or not.
  53454. */
  53455. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53456. /**
  53457. * Checks to see if a texture is used in the material.
  53458. * @param defines the list of "defines" to update.
  53459. * @param scene defines the scene to the material belongs to.
  53460. */
  53461. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53462. /**
  53463. * Binds the material data.
  53464. * @param uniformBuffer defines the Uniform buffer to fill in.
  53465. * @param scene defines the scene the material belongs to.
  53466. * @param engine defines the engine the material belongs to.
  53467. * @param isFrozen defines wether the material is frozen or not.
  53468. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53469. */
  53470. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53471. /**
  53472. * Unbinds the material from the mesh.
  53473. * @param activeEffect defines the effect that should be unbound from.
  53474. * @returns true if unbound, otherwise false
  53475. */
  53476. unbind(activeEffect: Effect): boolean;
  53477. /**
  53478. * Returns the texture used for refraction or null if none is used.
  53479. * @param scene defines the scene the material belongs to.
  53480. * @returns - Refraction texture if present. If no refraction texture and refraction
  53481. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53482. */
  53483. private _getRefractionTexture;
  53484. /**
  53485. * Returns true if alpha blending should be disabled.
  53486. */
  53487. get disableAlphaBlending(): boolean;
  53488. /**
  53489. * Fills the list of render target textures.
  53490. * @param renderTargets the list of render targets to update
  53491. */
  53492. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53493. /**
  53494. * Checks to see if a texture is used in the material.
  53495. * @param texture - Base texture to use.
  53496. * @returns - Boolean specifying if a texture is used in the material.
  53497. */
  53498. hasTexture(texture: BaseTexture): boolean;
  53499. /**
  53500. * Gets a boolean indicating that current material needs to register RTT
  53501. * @returns true if this uses a render target otherwise false.
  53502. */
  53503. hasRenderTargetTextures(): boolean;
  53504. /**
  53505. * Returns an array of the actively used textures.
  53506. * @param activeTextures Array of BaseTextures
  53507. */
  53508. getActiveTextures(activeTextures: BaseTexture[]): void;
  53509. /**
  53510. * Returns the animatable textures.
  53511. * @param animatables Array of animatable textures.
  53512. */
  53513. getAnimatables(animatables: IAnimatable[]): void;
  53514. /**
  53515. * Disposes the resources of the material.
  53516. * @param forceDisposeTextures - Forces the disposal of all textures.
  53517. */
  53518. dispose(forceDisposeTextures?: boolean): void;
  53519. /**
  53520. * Get the current class name of the texture useful for serialization or dynamic coding.
  53521. * @returns "PBRSubSurfaceConfiguration"
  53522. */
  53523. getClassName(): string;
  53524. /**
  53525. * Add fallbacks to the effect fallbacks list.
  53526. * @param defines defines the Base texture to use.
  53527. * @param fallbacks defines the current fallback list.
  53528. * @param currentRank defines the current fallback rank.
  53529. * @returns the new fallback rank.
  53530. */
  53531. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53532. /**
  53533. * Add the required uniforms to the current list.
  53534. * @param uniforms defines the current uniform list.
  53535. */
  53536. static AddUniforms(uniforms: string[]): void;
  53537. /**
  53538. * Add the required samplers to the current list.
  53539. * @param samplers defines the current sampler list.
  53540. */
  53541. static AddSamplers(samplers: string[]): void;
  53542. /**
  53543. * Add the required uniforms to the current buffer.
  53544. * @param uniformBuffer defines the current uniform buffer.
  53545. */
  53546. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53547. /**
  53548. * Makes a duplicate of the current configuration into another one.
  53549. * @param configuration define the config where to copy the info
  53550. */
  53551. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53552. /**
  53553. * Serializes this Sub Surface configuration.
  53554. * @returns - An object with the serialized config.
  53555. */
  53556. serialize(): any;
  53557. /**
  53558. * Parses a anisotropy Configuration from a serialized object.
  53559. * @param source - Serialized object.
  53560. * @param scene Defines the scene we are parsing for
  53561. * @param rootUrl Defines the rootUrl to load from
  53562. */
  53563. parse(source: any, scene: Scene, rootUrl: string): void;
  53564. }
  53565. }
  53566. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53567. /** @hidden */
  53568. export var pbrFragmentDeclaration: {
  53569. name: string;
  53570. shader: string;
  53571. };
  53572. }
  53573. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53574. /** @hidden */
  53575. export var pbrUboDeclaration: {
  53576. name: string;
  53577. shader: string;
  53578. };
  53579. }
  53580. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53581. /** @hidden */
  53582. export var pbrFragmentExtraDeclaration: {
  53583. name: string;
  53584. shader: string;
  53585. };
  53586. }
  53587. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53588. /** @hidden */
  53589. export var pbrFragmentSamplersDeclaration: {
  53590. name: string;
  53591. shader: string;
  53592. };
  53593. }
  53594. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53595. /** @hidden */
  53596. export var pbrHelperFunctions: {
  53597. name: string;
  53598. shader: string;
  53599. };
  53600. }
  53601. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53602. /** @hidden */
  53603. export var harmonicsFunctions: {
  53604. name: string;
  53605. shader: string;
  53606. };
  53607. }
  53608. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53609. /** @hidden */
  53610. export var pbrDirectLightingSetupFunctions: {
  53611. name: string;
  53612. shader: string;
  53613. };
  53614. }
  53615. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53616. /** @hidden */
  53617. export var pbrDirectLightingFalloffFunctions: {
  53618. name: string;
  53619. shader: string;
  53620. };
  53621. }
  53622. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53623. /** @hidden */
  53624. export var pbrBRDFFunctions: {
  53625. name: string;
  53626. shader: string;
  53627. };
  53628. }
  53629. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53630. /** @hidden */
  53631. export var pbrDirectLightingFunctions: {
  53632. name: string;
  53633. shader: string;
  53634. };
  53635. }
  53636. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53637. /** @hidden */
  53638. export var pbrIBLFunctions: {
  53639. name: string;
  53640. shader: string;
  53641. };
  53642. }
  53643. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53644. /** @hidden */
  53645. export var pbrBlockAlbedoOpacity: {
  53646. name: string;
  53647. shader: string;
  53648. };
  53649. }
  53650. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53651. /** @hidden */
  53652. export var pbrBlockReflectivity: {
  53653. name: string;
  53654. shader: string;
  53655. };
  53656. }
  53657. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53658. /** @hidden */
  53659. export var pbrBlockAmbientOcclusion: {
  53660. name: string;
  53661. shader: string;
  53662. };
  53663. }
  53664. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53665. /** @hidden */
  53666. export var pbrBlockAlphaFresnel: {
  53667. name: string;
  53668. shader: string;
  53669. };
  53670. }
  53671. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53672. /** @hidden */
  53673. export var pbrBlockAnisotropic: {
  53674. name: string;
  53675. shader: string;
  53676. };
  53677. }
  53678. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53679. /** @hidden */
  53680. export var pbrBlockReflection: {
  53681. name: string;
  53682. shader: string;
  53683. };
  53684. }
  53685. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53686. /** @hidden */
  53687. export var pbrBlockSheen: {
  53688. name: string;
  53689. shader: string;
  53690. };
  53691. }
  53692. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53693. /** @hidden */
  53694. export var pbrBlockClearcoat: {
  53695. name: string;
  53696. shader: string;
  53697. };
  53698. }
  53699. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53700. /** @hidden */
  53701. export var pbrBlockSubSurface: {
  53702. name: string;
  53703. shader: string;
  53704. };
  53705. }
  53706. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53707. /** @hidden */
  53708. export var pbrBlockNormalGeometric: {
  53709. name: string;
  53710. shader: string;
  53711. };
  53712. }
  53713. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53714. /** @hidden */
  53715. export var pbrBlockNormalFinal: {
  53716. name: string;
  53717. shader: string;
  53718. };
  53719. }
  53720. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53721. /** @hidden */
  53722. export var pbrBlockGeometryInfo: {
  53723. name: string;
  53724. shader: string;
  53725. };
  53726. }
  53727. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53728. /** @hidden */
  53729. export var pbrBlockReflectance0: {
  53730. name: string;
  53731. shader: string;
  53732. };
  53733. }
  53734. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53735. /** @hidden */
  53736. export var pbrBlockReflectance: {
  53737. name: string;
  53738. shader: string;
  53739. };
  53740. }
  53741. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53742. /** @hidden */
  53743. export var pbrBlockDirectLighting: {
  53744. name: string;
  53745. shader: string;
  53746. };
  53747. }
  53748. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53749. /** @hidden */
  53750. export var pbrBlockFinalLitComponents: {
  53751. name: string;
  53752. shader: string;
  53753. };
  53754. }
  53755. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53756. /** @hidden */
  53757. export var pbrBlockFinalUnlitComponents: {
  53758. name: string;
  53759. shader: string;
  53760. };
  53761. }
  53762. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53763. /** @hidden */
  53764. export var pbrBlockFinalColorComposition: {
  53765. name: string;
  53766. shader: string;
  53767. };
  53768. }
  53769. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53770. /** @hidden */
  53771. export var pbrBlockImageProcessing: {
  53772. name: string;
  53773. shader: string;
  53774. };
  53775. }
  53776. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53777. /** @hidden */
  53778. export var pbrDebug: {
  53779. name: string;
  53780. shader: string;
  53781. };
  53782. }
  53783. declare module "babylonjs/Shaders/pbr.fragment" {
  53784. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53785. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53786. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53787. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53788. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53789. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53790. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53791. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53792. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53793. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53794. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53795. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53796. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53797. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53798. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53799. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53800. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53801. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53802. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53803. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53804. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  53805. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53806. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53807. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53808. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53809. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53810. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53811. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53812. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53813. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53814. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53815. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53816. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53817. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53818. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53819. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53820. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53821. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53822. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53823. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53824. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53825. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53826. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53827. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53828. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53829. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53830. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53831. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53832. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53833. /** @hidden */
  53834. export var pbrPixelShader: {
  53835. name: string;
  53836. shader: string;
  53837. };
  53838. }
  53839. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53840. /** @hidden */
  53841. export var pbrVertexDeclaration: {
  53842. name: string;
  53843. shader: string;
  53844. };
  53845. }
  53846. declare module "babylonjs/Shaders/pbr.vertex" {
  53847. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53848. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53849. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53850. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53851. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53852. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53853. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53854. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53855. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53856. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53857. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53858. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53860. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53861. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53862. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53863. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53864. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53865. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53866. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53867. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53868. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53869. /** @hidden */
  53870. export var pbrVertexShader: {
  53871. name: string;
  53872. shader: string;
  53873. };
  53874. }
  53875. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53876. import { Nullable } from "babylonjs/types";
  53877. import { Scene } from "babylonjs/scene";
  53878. import { Matrix } from "babylonjs/Maths/math.vector";
  53879. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53881. import { Mesh } from "babylonjs/Meshes/mesh";
  53882. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53883. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53884. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53885. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53886. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53887. import { Color3 } from "babylonjs/Maths/math.color";
  53888. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53889. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53890. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53891. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53893. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53894. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53895. import "babylonjs/Shaders/pbr.fragment";
  53896. import "babylonjs/Shaders/pbr.vertex";
  53897. /**
  53898. * Manages the defines for the PBR Material.
  53899. * @hidden
  53900. */
  53901. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53902. PBR: boolean;
  53903. MAINUV1: boolean;
  53904. MAINUV2: boolean;
  53905. UV1: boolean;
  53906. UV2: boolean;
  53907. ALBEDO: boolean;
  53908. GAMMAALBEDO: boolean;
  53909. ALBEDODIRECTUV: number;
  53910. VERTEXCOLOR: boolean;
  53911. AMBIENT: boolean;
  53912. AMBIENTDIRECTUV: number;
  53913. AMBIENTINGRAYSCALE: boolean;
  53914. OPACITY: boolean;
  53915. VERTEXALPHA: boolean;
  53916. OPACITYDIRECTUV: number;
  53917. OPACITYRGB: boolean;
  53918. ALPHATEST: boolean;
  53919. DEPTHPREPASS: boolean;
  53920. ALPHABLEND: boolean;
  53921. ALPHAFROMALBEDO: boolean;
  53922. ALPHATESTVALUE: string;
  53923. SPECULAROVERALPHA: boolean;
  53924. RADIANCEOVERALPHA: boolean;
  53925. ALPHAFRESNEL: boolean;
  53926. LINEARALPHAFRESNEL: boolean;
  53927. PREMULTIPLYALPHA: boolean;
  53928. EMISSIVE: boolean;
  53929. EMISSIVEDIRECTUV: number;
  53930. REFLECTIVITY: boolean;
  53931. REFLECTIVITYDIRECTUV: number;
  53932. SPECULARTERM: boolean;
  53933. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53934. MICROSURFACEAUTOMATIC: boolean;
  53935. LODBASEDMICROSFURACE: boolean;
  53936. MICROSURFACEMAP: boolean;
  53937. MICROSURFACEMAPDIRECTUV: number;
  53938. METALLICWORKFLOW: boolean;
  53939. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53940. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53941. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53942. AOSTOREINMETALMAPRED: boolean;
  53943. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53944. ENVIRONMENTBRDF: boolean;
  53945. ENVIRONMENTBRDF_RGBD: boolean;
  53946. NORMAL: boolean;
  53947. TANGENT: boolean;
  53948. BUMP: boolean;
  53949. BUMPDIRECTUV: number;
  53950. OBJECTSPACE_NORMALMAP: boolean;
  53951. PARALLAX: boolean;
  53952. PARALLAXOCCLUSION: boolean;
  53953. NORMALXYSCALE: boolean;
  53954. LIGHTMAP: boolean;
  53955. LIGHTMAPDIRECTUV: number;
  53956. USELIGHTMAPASSHADOWMAP: boolean;
  53957. GAMMALIGHTMAP: boolean;
  53958. RGBDLIGHTMAP: boolean;
  53959. REFLECTION: boolean;
  53960. REFLECTIONMAP_3D: boolean;
  53961. REFLECTIONMAP_SPHERICAL: boolean;
  53962. REFLECTIONMAP_PLANAR: boolean;
  53963. REFLECTIONMAP_CUBIC: boolean;
  53964. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53965. REFLECTIONMAP_PROJECTION: boolean;
  53966. REFLECTIONMAP_SKYBOX: boolean;
  53967. REFLECTIONMAP_EXPLICIT: boolean;
  53968. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53969. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53970. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53971. INVERTCUBICMAP: boolean;
  53972. USESPHERICALFROMREFLECTIONMAP: boolean;
  53973. USEIRRADIANCEMAP: boolean;
  53974. SPHERICAL_HARMONICS: boolean;
  53975. USESPHERICALINVERTEX: boolean;
  53976. REFLECTIONMAP_OPPOSITEZ: boolean;
  53977. LODINREFLECTIONALPHA: boolean;
  53978. GAMMAREFLECTION: boolean;
  53979. RGBDREFLECTION: boolean;
  53980. LINEARSPECULARREFLECTION: boolean;
  53981. RADIANCEOCCLUSION: boolean;
  53982. HORIZONOCCLUSION: boolean;
  53983. INSTANCES: boolean;
  53984. NUM_BONE_INFLUENCERS: number;
  53985. BonesPerMesh: number;
  53986. BONETEXTURE: boolean;
  53987. NONUNIFORMSCALING: boolean;
  53988. MORPHTARGETS: boolean;
  53989. MORPHTARGETS_NORMAL: boolean;
  53990. MORPHTARGETS_TANGENT: boolean;
  53991. MORPHTARGETS_UV: boolean;
  53992. NUM_MORPH_INFLUENCERS: number;
  53993. IMAGEPROCESSING: boolean;
  53994. VIGNETTE: boolean;
  53995. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53996. VIGNETTEBLENDMODEOPAQUE: boolean;
  53997. TONEMAPPING: boolean;
  53998. TONEMAPPING_ACES: boolean;
  53999. CONTRAST: boolean;
  54000. COLORCURVES: boolean;
  54001. COLORGRADING: boolean;
  54002. COLORGRADING3D: boolean;
  54003. SAMPLER3DGREENDEPTH: boolean;
  54004. SAMPLER3DBGRMAP: boolean;
  54005. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54006. EXPOSURE: boolean;
  54007. MULTIVIEW: boolean;
  54008. USEPHYSICALLIGHTFALLOFF: boolean;
  54009. USEGLTFLIGHTFALLOFF: boolean;
  54010. TWOSIDEDLIGHTING: boolean;
  54011. SHADOWFLOAT: boolean;
  54012. CLIPPLANE: boolean;
  54013. CLIPPLANE2: boolean;
  54014. CLIPPLANE3: boolean;
  54015. CLIPPLANE4: boolean;
  54016. CLIPPLANE5: boolean;
  54017. CLIPPLANE6: boolean;
  54018. POINTSIZE: boolean;
  54019. FOG: boolean;
  54020. LOGARITHMICDEPTH: boolean;
  54021. FORCENORMALFORWARD: boolean;
  54022. SPECULARAA: boolean;
  54023. CLEARCOAT: boolean;
  54024. CLEARCOAT_DEFAULTIOR: boolean;
  54025. CLEARCOAT_TEXTURE: boolean;
  54026. CLEARCOAT_TEXTUREDIRECTUV: number;
  54027. CLEARCOAT_BUMP: boolean;
  54028. CLEARCOAT_BUMPDIRECTUV: number;
  54029. CLEARCOAT_TINT: boolean;
  54030. CLEARCOAT_TINT_TEXTURE: boolean;
  54031. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54032. ANISOTROPIC: boolean;
  54033. ANISOTROPIC_TEXTURE: boolean;
  54034. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54035. BRDF_V_HEIGHT_CORRELATED: boolean;
  54036. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54037. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54038. SHEEN: boolean;
  54039. SHEEN_TEXTURE: boolean;
  54040. SHEEN_TEXTUREDIRECTUV: number;
  54041. SHEEN_LINKWITHALBEDO: boolean;
  54042. SHEEN_ROUGHNESS: boolean;
  54043. SHEEN_ALBEDOSCALING: boolean;
  54044. SUBSURFACE: boolean;
  54045. SS_REFRACTION: boolean;
  54046. SS_TRANSLUCENCY: boolean;
  54047. SS_SCATERRING: boolean;
  54048. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54049. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54050. SS_REFRACTIONMAP_3D: boolean;
  54051. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54052. SS_LODINREFRACTIONALPHA: boolean;
  54053. SS_GAMMAREFRACTION: boolean;
  54054. SS_RGBDREFRACTION: boolean;
  54055. SS_LINEARSPECULARREFRACTION: boolean;
  54056. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54057. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54058. UNLIT: boolean;
  54059. DEBUGMODE: number;
  54060. /**
  54061. * Initializes the PBR Material defines.
  54062. */
  54063. constructor();
  54064. /**
  54065. * Resets the PBR Material defines.
  54066. */
  54067. reset(): void;
  54068. }
  54069. /**
  54070. * The Physically based material base class of BJS.
  54071. *
  54072. * This offers the main features of a standard PBR material.
  54073. * For more information, please refer to the documentation :
  54074. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54075. */
  54076. export abstract class PBRBaseMaterial extends PushMaterial {
  54077. /**
  54078. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54079. */
  54080. static readonly PBRMATERIAL_OPAQUE: number;
  54081. /**
  54082. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54083. */
  54084. static readonly PBRMATERIAL_ALPHATEST: number;
  54085. /**
  54086. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54087. */
  54088. static readonly PBRMATERIAL_ALPHABLEND: number;
  54089. /**
  54090. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54091. * They are also discarded below the alpha cutoff threshold to improve performances.
  54092. */
  54093. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54094. /**
  54095. * Defines the default value of how much AO map is occluding the analytical lights
  54096. * (point spot...).
  54097. */
  54098. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54099. /**
  54100. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54101. */
  54102. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54103. /**
  54104. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54105. * to enhance interoperability with other engines.
  54106. */
  54107. static readonly LIGHTFALLOFF_GLTF: number;
  54108. /**
  54109. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54110. * to enhance interoperability with other materials.
  54111. */
  54112. static readonly LIGHTFALLOFF_STANDARD: number;
  54113. /**
  54114. * Intensity of the direct lights e.g. the four lights available in your scene.
  54115. * This impacts both the direct diffuse and specular highlights.
  54116. */
  54117. protected _directIntensity: number;
  54118. /**
  54119. * Intensity of the emissive part of the material.
  54120. * This helps controlling the emissive effect without modifying the emissive color.
  54121. */
  54122. protected _emissiveIntensity: number;
  54123. /**
  54124. * Intensity of the environment e.g. how much the environment will light the object
  54125. * either through harmonics for rough material or through the refelction for shiny ones.
  54126. */
  54127. protected _environmentIntensity: number;
  54128. /**
  54129. * This is a special control allowing the reduction of the specular highlights coming from the
  54130. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54131. */
  54132. protected _specularIntensity: number;
  54133. /**
  54134. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54135. */
  54136. private _lightingInfos;
  54137. /**
  54138. * Debug Control allowing disabling the bump map on this material.
  54139. */
  54140. protected _disableBumpMap: boolean;
  54141. /**
  54142. * AKA Diffuse Texture in standard nomenclature.
  54143. */
  54144. protected _albedoTexture: Nullable<BaseTexture>;
  54145. /**
  54146. * AKA Occlusion Texture in other nomenclature.
  54147. */
  54148. protected _ambientTexture: Nullable<BaseTexture>;
  54149. /**
  54150. * AKA Occlusion Texture Intensity in other nomenclature.
  54151. */
  54152. protected _ambientTextureStrength: number;
  54153. /**
  54154. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54155. * 1 means it completely occludes it
  54156. * 0 mean it has no impact
  54157. */
  54158. protected _ambientTextureImpactOnAnalyticalLights: number;
  54159. /**
  54160. * Stores the alpha values in a texture.
  54161. */
  54162. protected _opacityTexture: Nullable<BaseTexture>;
  54163. /**
  54164. * Stores the reflection values in a texture.
  54165. */
  54166. protected _reflectionTexture: Nullable<BaseTexture>;
  54167. /**
  54168. * Stores the emissive values in a texture.
  54169. */
  54170. protected _emissiveTexture: Nullable<BaseTexture>;
  54171. /**
  54172. * AKA Specular texture in other nomenclature.
  54173. */
  54174. protected _reflectivityTexture: Nullable<BaseTexture>;
  54175. /**
  54176. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54177. */
  54178. protected _metallicTexture: Nullable<BaseTexture>;
  54179. /**
  54180. * Specifies the metallic scalar of the metallic/roughness workflow.
  54181. * Can also be used to scale the metalness values of the metallic texture.
  54182. */
  54183. protected _metallic: Nullable<number>;
  54184. /**
  54185. * Specifies the roughness scalar of the metallic/roughness workflow.
  54186. * Can also be used to scale the roughness values of the metallic texture.
  54187. */
  54188. protected _roughness: Nullable<number>;
  54189. /**
  54190. * Specifies the an F0 factor to help configuring the material F0.
  54191. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54192. * to 0.5 the previously hard coded value stays the same.
  54193. * Can also be used to scale the F0 values of the metallic texture.
  54194. */
  54195. protected _metallicF0Factor: number;
  54196. /**
  54197. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54198. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54199. * your expectation as it multiplies with the texture data.
  54200. */
  54201. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  54202. /**
  54203. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54204. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54205. */
  54206. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54207. /**
  54208. * Stores surface normal data used to displace a mesh in a texture.
  54209. */
  54210. protected _bumpTexture: Nullable<BaseTexture>;
  54211. /**
  54212. * Stores the pre-calculated light information of a mesh in a texture.
  54213. */
  54214. protected _lightmapTexture: Nullable<BaseTexture>;
  54215. /**
  54216. * The color of a material in ambient lighting.
  54217. */
  54218. protected _ambientColor: Color3;
  54219. /**
  54220. * AKA Diffuse Color in other nomenclature.
  54221. */
  54222. protected _albedoColor: Color3;
  54223. /**
  54224. * AKA Specular Color in other nomenclature.
  54225. */
  54226. protected _reflectivityColor: Color3;
  54227. /**
  54228. * The color applied when light is reflected from a material.
  54229. */
  54230. protected _reflectionColor: Color3;
  54231. /**
  54232. * The color applied when light is emitted from a material.
  54233. */
  54234. protected _emissiveColor: Color3;
  54235. /**
  54236. * AKA Glossiness in other nomenclature.
  54237. */
  54238. protected _microSurface: number;
  54239. /**
  54240. * Specifies that the material will use the light map as a show map.
  54241. */
  54242. protected _useLightmapAsShadowmap: boolean;
  54243. /**
  54244. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54245. * makes the reflect vector face the model (under horizon).
  54246. */
  54247. protected _useHorizonOcclusion: boolean;
  54248. /**
  54249. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54250. * too much the area relying on ambient texture to define their ambient occlusion.
  54251. */
  54252. protected _useRadianceOcclusion: boolean;
  54253. /**
  54254. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54255. */
  54256. protected _useAlphaFromAlbedoTexture: boolean;
  54257. /**
  54258. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54259. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54260. */
  54261. protected _useSpecularOverAlpha: boolean;
  54262. /**
  54263. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54264. */
  54265. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54266. /**
  54267. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54268. */
  54269. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54270. /**
  54271. * Specifies if the metallic texture contains the roughness information in its green channel.
  54272. */
  54273. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54274. /**
  54275. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54276. */
  54277. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54278. /**
  54279. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54280. */
  54281. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54282. /**
  54283. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54284. */
  54285. protected _useAmbientInGrayScale: boolean;
  54286. /**
  54287. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54288. * The material will try to infer what glossiness each pixel should be.
  54289. */
  54290. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54291. /**
  54292. * Defines the falloff type used in this material.
  54293. * It by default is Physical.
  54294. */
  54295. protected _lightFalloff: number;
  54296. /**
  54297. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54298. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54299. */
  54300. protected _useRadianceOverAlpha: boolean;
  54301. /**
  54302. * Allows using an object space normal map (instead of tangent space).
  54303. */
  54304. protected _useObjectSpaceNormalMap: boolean;
  54305. /**
  54306. * Allows using the bump map in parallax mode.
  54307. */
  54308. protected _useParallax: boolean;
  54309. /**
  54310. * Allows using the bump map in parallax occlusion mode.
  54311. */
  54312. protected _useParallaxOcclusion: boolean;
  54313. /**
  54314. * Controls the scale bias of the parallax mode.
  54315. */
  54316. protected _parallaxScaleBias: number;
  54317. /**
  54318. * If sets to true, disables all the lights affecting the material.
  54319. */
  54320. protected _disableLighting: boolean;
  54321. /**
  54322. * Number of Simultaneous lights allowed on the material.
  54323. */
  54324. protected _maxSimultaneousLights: number;
  54325. /**
  54326. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54327. */
  54328. protected _invertNormalMapX: boolean;
  54329. /**
  54330. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54331. */
  54332. protected _invertNormalMapY: boolean;
  54333. /**
  54334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54335. */
  54336. protected _twoSidedLighting: boolean;
  54337. /**
  54338. * Defines the alpha limits in alpha test mode.
  54339. */
  54340. protected _alphaCutOff: number;
  54341. /**
  54342. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54343. */
  54344. protected _forceAlphaTest: boolean;
  54345. /**
  54346. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54347. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54348. */
  54349. protected _useAlphaFresnel: boolean;
  54350. /**
  54351. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54352. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54353. */
  54354. protected _useLinearAlphaFresnel: boolean;
  54355. /**
  54356. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54357. * from cos thetav and roughness:
  54358. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54359. */
  54360. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54361. /**
  54362. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54363. */
  54364. protected _forceIrradianceInFragment: boolean;
  54365. /**
  54366. * Force normal to face away from face.
  54367. */
  54368. protected _forceNormalForward: boolean;
  54369. /**
  54370. * Enables specular anti aliasing in the PBR shader.
  54371. * It will both interacts on the Geometry for analytical and IBL lighting.
  54372. * It also prefilter the roughness map based on the bump values.
  54373. */
  54374. protected _enableSpecularAntiAliasing: boolean;
  54375. /**
  54376. * Default configuration related to image processing available in the PBR Material.
  54377. */
  54378. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54379. /**
  54380. * Keep track of the image processing observer to allow dispose and replace.
  54381. */
  54382. private _imageProcessingObserver;
  54383. /**
  54384. * Attaches a new image processing configuration to the PBR Material.
  54385. * @param configuration
  54386. */
  54387. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54388. /**
  54389. * Stores the available render targets.
  54390. */
  54391. private _renderTargets;
  54392. /**
  54393. * Sets the global ambient color for the material used in lighting calculations.
  54394. */
  54395. private _globalAmbientColor;
  54396. /**
  54397. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54398. */
  54399. private _useLogarithmicDepth;
  54400. /**
  54401. * If set to true, no lighting calculations will be applied.
  54402. */
  54403. private _unlit;
  54404. private _debugMode;
  54405. /**
  54406. * @hidden
  54407. * This is reserved for the inspector.
  54408. * Defines the material debug mode.
  54409. * It helps seeing only some components of the material while troubleshooting.
  54410. */
  54411. debugMode: number;
  54412. /**
  54413. * @hidden
  54414. * This is reserved for the inspector.
  54415. * Specify from where on screen the debug mode should start.
  54416. * The value goes from -1 (full screen) to 1 (not visible)
  54417. * It helps with side by side comparison against the final render
  54418. * This defaults to -1
  54419. */
  54420. private debugLimit;
  54421. /**
  54422. * @hidden
  54423. * This is reserved for the inspector.
  54424. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54425. * You can use the factor to better multiply the final value.
  54426. */
  54427. private debugFactor;
  54428. /**
  54429. * Defines the clear coat layer parameters for the material.
  54430. */
  54431. readonly clearCoat: PBRClearCoatConfiguration;
  54432. /**
  54433. * Defines the anisotropic parameters for the material.
  54434. */
  54435. readonly anisotropy: PBRAnisotropicConfiguration;
  54436. /**
  54437. * Defines the BRDF parameters for the material.
  54438. */
  54439. readonly brdf: PBRBRDFConfiguration;
  54440. /**
  54441. * Defines the Sheen parameters for the material.
  54442. */
  54443. readonly sheen: PBRSheenConfiguration;
  54444. /**
  54445. * Defines the SubSurface parameters for the material.
  54446. */
  54447. readonly subSurface: PBRSubSurfaceConfiguration;
  54448. protected _rebuildInParallel: boolean;
  54449. /**
  54450. * Instantiates a new PBRMaterial instance.
  54451. *
  54452. * @param name The material name
  54453. * @param scene The scene the material will be use in.
  54454. */
  54455. constructor(name: string, scene: Scene);
  54456. /**
  54457. * Gets a boolean indicating that current material needs to register RTT
  54458. */
  54459. get hasRenderTargetTextures(): boolean;
  54460. /**
  54461. * Gets the name of the material class.
  54462. */
  54463. getClassName(): string;
  54464. /**
  54465. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54466. */
  54467. get useLogarithmicDepth(): boolean;
  54468. /**
  54469. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54470. */
  54471. set useLogarithmicDepth(value: boolean);
  54472. /**
  54473. * Returns true if alpha blending should be disabled.
  54474. */
  54475. protected get _disableAlphaBlending(): boolean;
  54476. /**
  54477. * Specifies whether or not this material should be rendered in alpha blend mode.
  54478. */
  54479. needAlphaBlending(): boolean;
  54480. /**
  54481. * Specifies whether or not this material should be rendered in alpha test mode.
  54482. */
  54483. needAlphaTesting(): boolean;
  54484. /**
  54485. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54486. */
  54487. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54488. /**
  54489. * Gets the texture used for the alpha test.
  54490. */
  54491. getAlphaTestTexture(): Nullable<BaseTexture>;
  54492. /**
  54493. * Specifies that the submesh is ready to be used.
  54494. * @param mesh - BJS mesh.
  54495. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54496. * @param useInstances - Specifies that instances should be used.
  54497. * @returns - boolean indicating that the submesh is ready or not.
  54498. */
  54499. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54500. /**
  54501. * Specifies if the material uses metallic roughness workflow.
  54502. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54503. */
  54504. isMetallicWorkflow(): boolean;
  54505. private _prepareEffect;
  54506. private _prepareDefines;
  54507. /**
  54508. * Force shader compilation
  54509. */
  54510. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54511. /**
  54512. * Initializes the uniform buffer layout for the shader.
  54513. */
  54514. buildUniformLayout(): void;
  54515. /**
  54516. * Unbinds the material from the mesh
  54517. */
  54518. unbind(): void;
  54519. /**
  54520. * Binds the submesh data.
  54521. * @param world - The world matrix.
  54522. * @param mesh - The BJS mesh.
  54523. * @param subMesh - A submesh of the BJS mesh.
  54524. */
  54525. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54526. /**
  54527. * Returns the animatable textures.
  54528. * @returns - Array of animatable textures.
  54529. */
  54530. getAnimatables(): IAnimatable[];
  54531. /**
  54532. * Returns the texture used for reflections.
  54533. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54534. */
  54535. private _getReflectionTexture;
  54536. /**
  54537. * Returns an array of the actively used textures.
  54538. * @returns - Array of BaseTextures
  54539. */
  54540. getActiveTextures(): BaseTexture[];
  54541. /**
  54542. * Checks to see if a texture is used in the material.
  54543. * @param texture - Base texture to use.
  54544. * @returns - Boolean specifying if a texture is used in the material.
  54545. */
  54546. hasTexture(texture: BaseTexture): boolean;
  54547. /**
  54548. * Disposes the resources of the material.
  54549. * @param forceDisposeEffect - Forces the disposal of effects.
  54550. * @param forceDisposeTextures - Forces the disposal of all textures.
  54551. */
  54552. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54553. }
  54554. }
  54555. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54556. import { Nullable } from "babylonjs/types";
  54557. import { Scene } from "babylonjs/scene";
  54558. import { Color3 } from "babylonjs/Maths/math.color";
  54559. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54560. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54562. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54563. /**
  54564. * The Physically based material of BJS.
  54565. *
  54566. * This offers the main features of a standard PBR material.
  54567. * For more information, please refer to the documentation :
  54568. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54569. */
  54570. export class PBRMaterial extends PBRBaseMaterial {
  54571. /**
  54572. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54573. */
  54574. static readonly PBRMATERIAL_OPAQUE: number;
  54575. /**
  54576. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54577. */
  54578. static readonly PBRMATERIAL_ALPHATEST: number;
  54579. /**
  54580. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54581. */
  54582. static readonly PBRMATERIAL_ALPHABLEND: number;
  54583. /**
  54584. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54585. * They are also discarded below the alpha cutoff threshold to improve performances.
  54586. */
  54587. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54588. /**
  54589. * Defines the default value of how much AO map is occluding the analytical lights
  54590. * (point spot...).
  54591. */
  54592. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54593. /**
  54594. * Intensity of the direct lights e.g. the four lights available in your scene.
  54595. * This impacts both the direct diffuse and specular highlights.
  54596. */
  54597. directIntensity: number;
  54598. /**
  54599. * Intensity of the emissive part of the material.
  54600. * This helps controlling the emissive effect without modifying the emissive color.
  54601. */
  54602. emissiveIntensity: number;
  54603. /**
  54604. * Intensity of the environment e.g. how much the environment will light the object
  54605. * either through harmonics for rough material or through the refelction for shiny ones.
  54606. */
  54607. environmentIntensity: number;
  54608. /**
  54609. * This is a special control allowing the reduction of the specular highlights coming from the
  54610. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54611. */
  54612. specularIntensity: number;
  54613. /**
  54614. * Debug Control allowing disabling the bump map on this material.
  54615. */
  54616. disableBumpMap: boolean;
  54617. /**
  54618. * AKA Diffuse Texture in standard nomenclature.
  54619. */
  54620. albedoTexture: BaseTexture;
  54621. /**
  54622. * AKA Occlusion Texture in other nomenclature.
  54623. */
  54624. ambientTexture: BaseTexture;
  54625. /**
  54626. * AKA Occlusion Texture Intensity in other nomenclature.
  54627. */
  54628. ambientTextureStrength: number;
  54629. /**
  54630. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54631. * 1 means it completely occludes it
  54632. * 0 mean it has no impact
  54633. */
  54634. ambientTextureImpactOnAnalyticalLights: number;
  54635. /**
  54636. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54637. */
  54638. opacityTexture: BaseTexture;
  54639. /**
  54640. * Stores the reflection values in a texture.
  54641. */
  54642. reflectionTexture: Nullable<BaseTexture>;
  54643. /**
  54644. * Stores the emissive values in a texture.
  54645. */
  54646. emissiveTexture: BaseTexture;
  54647. /**
  54648. * AKA Specular texture in other nomenclature.
  54649. */
  54650. reflectivityTexture: BaseTexture;
  54651. /**
  54652. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54653. */
  54654. metallicTexture: BaseTexture;
  54655. /**
  54656. * Specifies the metallic scalar of the metallic/roughness workflow.
  54657. * Can also be used to scale the metalness values of the metallic texture.
  54658. */
  54659. metallic: Nullable<number>;
  54660. /**
  54661. * Specifies the roughness scalar of the metallic/roughness workflow.
  54662. * Can also be used to scale the roughness values of the metallic texture.
  54663. */
  54664. roughness: Nullable<number>;
  54665. /**
  54666. * Specifies the an F0 factor to help configuring the material F0.
  54667. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54668. * to 0.5 the previously hard coded value stays the same.
  54669. * Can also be used to scale the F0 values of the metallic texture.
  54670. */
  54671. metallicF0Factor: number;
  54672. /**
  54673. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54674. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54675. * your expectation as it multiplies with the texture data.
  54676. */
  54677. useMetallicF0FactorFromMetallicTexture: boolean;
  54678. /**
  54679. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54680. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54681. */
  54682. microSurfaceTexture: BaseTexture;
  54683. /**
  54684. * Stores surface normal data used to displace a mesh in a texture.
  54685. */
  54686. bumpTexture: BaseTexture;
  54687. /**
  54688. * Stores the pre-calculated light information of a mesh in a texture.
  54689. */
  54690. lightmapTexture: BaseTexture;
  54691. /**
  54692. * Stores the refracted light information in a texture.
  54693. */
  54694. get refractionTexture(): Nullable<BaseTexture>;
  54695. set refractionTexture(value: Nullable<BaseTexture>);
  54696. /**
  54697. * The color of a material in ambient lighting.
  54698. */
  54699. ambientColor: Color3;
  54700. /**
  54701. * AKA Diffuse Color in other nomenclature.
  54702. */
  54703. albedoColor: Color3;
  54704. /**
  54705. * AKA Specular Color in other nomenclature.
  54706. */
  54707. reflectivityColor: Color3;
  54708. /**
  54709. * The color reflected from the material.
  54710. */
  54711. reflectionColor: Color3;
  54712. /**
  54713. * The color emitted from the material.
  54714. */
  54715. emissiveColor: Color3;
  54716. /**
  54717. * AKA Glossiness in other nomenclature.
  54718. */
  54719. microSurface: number;
  54720. /**
  54721. * source material index of refraction (IOR)' / 'destination material IOR.
  54722. */
  54723. get indexOfRefraction(): number;
  54724. set indexOfRefraction(value: number);
  54725. /**
  54726. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54727. */
  54728. get invertRefractionY(): boolean;
  54729. set invertRefractionY(value: boolean);
  54730. /**
  54731. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54732. * Materials half opaque for instance using refraction could benefit from this control.
  54733. */
  54734. get linkRefractionWithTransparency(): boolean;
  54735. set linkRefractionWithTransparency(value: boolean);
  54736. /**
  54737. * If true, the light map contains occlusion information instead of lighting info.
  54738. */
  54739. useLightmapAsShadowmap: boolean;
  54740. /**
  54741. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54742. */
  54743. useAlphaFromAlbedoTexture: boolean;
  54744. /**
  54745. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54746. */
  54747. forceAlphaTest: boolean;
  54748. /**
  54749. * Defines the alpha limits in alpha test mode.
  54750. */
  54751. alphaCutOff: number;
  54752. /**
  54753. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54754. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54755. */
  54756. useSpecularOverAlpha: boolean;
  54757. /**
  54758. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54759. */
  54760. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54761. /**
  54762. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54763. */
  54764. useRoughnessFromMetallicTextureAlpha: boolean;
  54765. /**
  54766. * Specifies if the metallic texture contains the roughness information in its green channel.
  54767. */
  54768. useRoughnessFromMetallicTextureGreen: boolean;
  54769. /**
  54770. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54771. */
  54772. useMetallnessFromMetallicTextureBlue: boolean;
  54773. /**
  54774. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54775. */
  54776. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54777. /**
  54778. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54779. */
  54780. useAmbientInGrayScale: boolean;
  54781. /**
  54782. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54783. * The material will try to infer what glossiness each pixel should be.
  54784. */
  54785. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54786. /**
  54787. * BJS is using an harcoded light falloff based on a manually sets up range.
  54788. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54789. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54790. */
  54791. get usePhysicalLightFalloff(): boolean;
  54792. /**
  54793. * BJS is using an harcoded light falloff based on a manually sets up range.
  54794. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54795. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54796. */
  54797. set usePhysicalLightFalloff(value: boolean);
  54798. /**
  54799. * In order to support the falloff compatibility with gltf, a special mode has been added
  54800. * to reproduce the gltf light falloff.
  54801. */
  54802. get useGLTFLightFalloff(): boolean;
  54803. /**
  54804. * In order to support the falloff compatibility with gltf, a special mode has been added
  54805. * to reproduce the gltf light falloff.
  54806. */
  54807. set useGLTFLightFalloff(value: boolean);
  54808. /**
  54809. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54810. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54811. */
  54812. useRadianceOverAlpha: boolean;
  54813. /**
  54814. * Allows using an object space normal map (instead of tangent space).
  54815. */
  54816. useObjectSpaceNormalMap: boolean;
  54817. /**
  54818. * Allows using the bump map in parallax mode.
  54819. */
  54820. useParallax: boolean;
  54821. /**
  54822. * Allows using the bump map in parallax occlusion mode.
  54823. */
  54824. useParallaxOcclusion: boolean;
  54825. /**
  54826. * Controls the scale bias of the parallax mode.
  54827. */
  54828. parallaxScaleBias: number;
  54829. /**
  54830. * If sets to true, disables all the lights affecting the material.
  54831. */
  54832. disableLighting: boolean;
  54833. /**
  54834. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54835. */
  54836. forceIrradianceInFragment: boolean;
  54837. /**
  54838. * Number of Simultaneous lights allowed on the material.
  54839. */
  54840. maxSimultaneousLights: number;
  54841. /**
  54842. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54843. */
  54844. invertNormalMapX: boolean;
  54845. /**
  54846. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54847. */
  54848. invertNormalMapY: boolean;
  54849. /**
  54850. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54851. */
  54852. twoSidedLighting: boolean;
  54853. /**
  54854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54855. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54856. */
  54857. useAlphaFresnel: boolean;
  54858. /**
  54859. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54860. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54861. */
  54862. useLinearAlphaFresnel: boolean;
  54863. /**
  54864. * Let user defines the brdf lookup texture used for IBL.
  54865. * A default 8bit version is embedded but you could point at :
  54866. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54867. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54868. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54869. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54870. */
  54871. environmentBRDFTexture: Nullable<BaseTexture>;
  54872. /**
  54873. * Force normal to face away from face.
  54874. */
  54875. forceNormalForward: boolean;
  54876. /**
  54877. * Enables specular anti aliasing in the PBR shader.
  54878. * It will both interacts on the Geometry for analytical and IBL lighting.
  54879. * It also prefilter the roughness map based on the bump values.
  54880. */
  54881. enableSpecularAntiAliasing: boolean;
  54882. /**
  54883. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54884. * makes the reflect vector face the model (under horizon).
  54885. */
  54886. useHorizonOcclusion: boolean;
  54887. /**
  54888. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54889. * too much the area relying on ambient texture to define their ambient occlusion.
  54890. */
  54891. useRadianceOcclusion: boolean;
  54892. /**
  54893. * If set to true, no lighting calculations will be applied.
  54894. */
  54895. unlit: boolean;
  54896. /**
  54897. * Gets the image processing configuration used either in this material.
  54898. */
  54899. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54900. /**
  54901. * Sets the Default image processing configuration used either in the this material.
  54902. *
  54903. * If sets to null, the scene one is in use.
  54904. */
  54905. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54906. /**
  54907. * Gets wether the color curves effect is enabled.
  54908. */
  54909. get cameraColorCurvesEnabled(): boolean;
  54910. /**
  54911. * Sets wether the color curves effect is enabled.
  54912. */
  54913. set cameraColorCurvesEnabled(value: boolean);
  54914. /**
  54915. * Gets wether the color grading effect is enabled.
  54916. */
  54917. get cameraColorGradingEnabled(): boolean;
  54918. /**
  54919. * Gets wether the color grading effect is enabled.
  54920. */
  54921. set cameraColorGradingEnabled(value: boolean);
  54922. /**
  54923. * Gets wether tonemapping is enabled or not.
  54924. */
  54925. get cameraToneMappingEnabled(): boolean;
  54926. /**
  54927. * Sets wether tonemapping is enabled or not
  54928. */
  54929. set cameraToneMappingEnabled(value: boolean);
  54930. /**
  54931. * The camera exposure used on this material.
  54932. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54933. * This corresponds to a photographic exposure.
  54934. */
  54935. get cameraExposure(): number;
  54936. /**
  54937. * The camera exposure used on this material.
  54938. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54939. * This corresponds to a photographic exposure.
  54940. */
  54941. set cameraExposure(value: number);
  54942. /**
  54943. * Gets The camera contrast used on this material.
  54944. */
  54945. get cameraContrast(): number;
  54946. /**
  54947. * Sets The camera contrast used on this material.
  54948. */
  54949. set cameraContrast(value: number);
  54950. /**
  54951. * Gets the Color Grading 2D Lookup Texture.
  54952. */
  54953. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54954. /**
  54955. * Sets the Color Grading 2D Lookup Texture.
  54956. */
  54957. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54958. /**
  54959. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54960. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54961. * 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;
  54962. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54963. */
  54964. get cameraColorCurves(): Nullable<ColorCurves>;
  54965. /**
  54966. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54967. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54968. * 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;
  54969. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54970. */
  54971. set cameraColorCurves(value: Nullable<ColorCurves>);
  54972. /**
  54973. * Instantiates a new PBRMaterial instance.
  54974. *
  54975. * @param name The material name
  54976. * @param scene The scene the material will be use in.
  54977. */
  54978. constructor(name: string, scene: Scene);
  54979. /**
  54980. * Returns the name of this material class.
  54981. */
  54982. getClassName(): string;
  54983. /**
  54984. * Makes a duplicate of the current material.
  54985. * @param name - name to use for the new material.
  54986. */
  54987. clone(name: string): PBRMaterial;
  54988. /**
  54989. * Serializes this PBR Material.
  54990. * @returns - An object with the serialized material.
  54991. */
  54992. serialize(): any;
  54993. /**
  54994. * Parses a PBR Material from a serialized object.
  54995. * @param source - Serialized object.
  54996. * @param scene - BJS scene instance.
  54997. * @param rootUrl - url for the scene object
  54998. * @returns - PBRMaterial
  54999. */
  55000. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55001. }
  55002. }
  55003. declare module "babylonjs/Misc/dds" {
  55004. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55006. import { Nullable } from "babylonjs/types";
  55007. import { Scene } from "babylonjs/scene";
  55008. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  55009. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55010. /**
  55011. * Direct draw surface info
  55012. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55013. */
  55014. export interface DDSInfo {
  55015. /**
  55016. * Width of the texture
  55017. */
  55018. width: number;
  55019. /**
  55020. * Width of the texture
  55021. */
  55022. height: number;
  55023. /**
  55024. * Number of Mipmaps for the texture
  55025. * @see https://en.wikipedia.org/wiki/Mipmap
  55026. */
  55027. mipmapCount: number;
  55028. /**
  55029. * If the textures format is a known fourCC format
  55030. * @see https://www.fourcc.org/
  55031. */
  55032. isFourCC: boolean;
  55033. /**
  55034. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55035. */
  55036. isRGB: boolean;
  55037. /**
  55038. * If the texture is a lumincance format
  55039. */
  55040. isLuminance: boolean;
  55041. /**
  55042. * If this is a cube texture
  55043. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55044. */
  55045. isCube: boolean;
  55046. /**
  55047. * If the texture is a compressed format eg. FOURCC_DXT1
  55048. */
  55049. isCompressed: boolean;
  55050. /**
  55051. * The dxgiFormat of the texture
  55052. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55053. */
  55054. dxgiFormat: number;
  55055. /**
  55056. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55057. */
  55058. textureType: number;
  55059. /**
  55060. * Sphericle polynomial created for the dds texture
  55061. */
  55062. sphericalPolynomial?: SphericalPolynomial;
  55063. }
  55064. /**
  55065. * Class used to provide DDS decompression tools
  55066. */
  55067. export class DDSTools {
  55068. /**
  55069. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55070. */
  55071. static StoreLODInAlphaChannel: boolean;
  55072. /**
  55073. * Gets DDS information from an array buffer
  55074. * @param data defines the array buffer view to read data from
  55075. * @returns the DDS information
  55076. */
  55077. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55078. private static _FloatView;
  55079. private static _Int32View;
  55080. private static _ToHalfFloat;
  55081. private static _FromHalfFloat;
  55082. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55083. private static _GetHalfFloatRGBAArrayBuffer;
  55084. private static _GetFloatRGBAArrayBuffer;
  55085. private static _GetFloatAsUIntRGBAArrayBuffer;
  55086. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55087. private static _GetRGBAArrayBuffer;
  55088. private static _ExtractLongWordOrder;
  55089. private static _GetRGBArrayBuffer;
  55090. private static _GetLuminanceArrayBuffer;
  55091. /**
  55092. * Uploads DDS Levels to a Babylon Texture
  55093. * @hidden
  55094. */
  55095. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55096. }
  55097. module "babylonjs/Engines/thinEngine" {
  55098. interface ThinEngine {
  55099. /**
  55100. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55101. * @param rootUrl defines the url where the file to load is located
  55102. * @param scene defines the current scene
  55103. * @param lodScale defines scale to apply to the mip map selection
  55104. * @param lodOffset defines offset to apply to the mip map selection
  55105. * @param onLoad defines an optional callback raised when the texture is loaded
  55106. * @param onError defines an optional callback raised if there is an issue to load the texture
  55107. * @param format defines the format of the data
  55108. * @param forcedExtension defines the extension to use to pick the right loader
  55109. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55110. * @returns the cube texture as an InternalTexture
  55111. */
  55112. 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;
  55113. }
  55114. }
  55115. }
  55116. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  55117. import { Nullable } from "babylonjs/types";
  55118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55119. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55120. /**
  55121. * Implementation of the DDS Texture Loader.
  55122. * @hidden
  55123. */
  55124. export class _DDSTextureLoader implements IInternalTextureLoader {
  55125. /**
  55126. * Defines wether the loader supports cascade loading the different faces.
  55127. */
  55128. readonly supportCascades: boolean;
  55129. /**
  55130. * This returns if the loader support the current file information.
  55131. * @param extension defines the file extension of the file being loaded
  55132. * @returns true if the loader can load the specified file
  55133. */
  55134. canLoad(extension: string): boolean;
  55135. /**
  55136. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55137. * @param data contains the texture data
  55138. * @param texture defines the BabylonJS internal texture
  55139. * @param createPolynomials will be true if polynomials have been requested
  55140. * @param onLoad defines the callback to trigger once the texture is ready
  55141. * @param onError defines the callback to trigger in case of error
  55142. */
  55143. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55144. /**
  55145. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55146. * @param data contains the texture data
  55147. * @param texture defines the BabylonJS internal texture
  55148. * @param callback defines the method to call once ready to upload
  55149. */
  55150. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55151. }
  55152. }
  55153. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  55154. import { Nullable } from "babylonjs/types";
  55155. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55156. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55157. /**
  55158. * Implementation of the ENV Texture Loader.
  55159. * @hidden
  55160. */
  55161. export class _ENVTextureLoader implements IInternalTextureLoader {
  55162. /**
  55163. * Defines wether the loader supports cascade loading the different faces.
  55164. */
  55165. readonly supportCascades: boolean;
  55166. /**
  55167. * This returns if the loader support the current file information.
  55168. * @param extension defines the file extension of the file being loaded
  55169. * @returns true if the loader can load the specified file
  55170. */
  55171. canLoad(extension: string): boolean;
  55172. /**
  55173. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55174. * @param data contains the texture data
  55175. * @param texture defines the BabylonJS internal texture
  55176. * @param createPolynomials will be true if polynomials have been requested
  55177. * @param onLoad defines the callback to trigger once the texture is ready
  55178. * @param onError defines the callback to trigger in case of error
  55179. */
  55180. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55181. /**
  55182. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55183. * @param data contains the texture data
  55184. * @param texture defines the BabylonJS internal texture
  55185. * @param callback defines the method to call once ready to upload
  55186. */
  55187. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55188. }
  55189. }
  55190. declare module "babylonjs/Misc/khronosTextureContainer" {
  55191. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55192. /**
  55193. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55194. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55195. */
  55196. export class KhronosTextureContainer {
  55197. /** contents of the KTX container file */
  55198. data: ArrayBufferView;
  55199. private static HEADER_LEN;
  55200. private static COMPRESSED_2D;
  55201. private static COMPRESSED_3D;
  55202. private static TEX_2D;
  55203. private static TEX_3D;
  55204. /**
  55205. * Gets the openGL type
  55206. */
  55207. glType: number;
  55208. /**
  55209. * Gets the openGL type size
  55210. */
  55211. glTypeSize: number;
  55212. /**
  55213. * Gets the openGL format
  55214. */
  55215. glFormat: number;
  55216. /**
  55217. * Gets the openGL internal format
  55218. */
  55219. glInternalFormat: number;
  55220. /**
  55221. * Gets the base internal format
  55222. */
  55223. glBaseInternalFormat: number;
  55224. /**
  55225. * Gets image width in pixel
  55226. */
  55227. pixelWidth: number;
  55228. /**
  55229. * Gets image height in pixel
  55230. */
  55231. pixelHeight: number;
  55232. /**
  55233. * Gets image depth in pixels
  55234. */
  55235. pixelDepth: number;
  55236. /**
  55237. * Gets the number of array elements
  55238. */
  55239. numberOfArrayElements: number;
  55240. /**
  55241. * Gets the number of faces
  55242. */
  55243. numberOfFaces: number;
  55244. /**
  55245. * Gets the number of mipmap levels
  55246. */
  55247. numberOfMipmapLevels: number;
  55248. /**
  55249. * Gets the bytes of key value data
  55250. */
  55251. bytesOfKeyValueData: number;
  55252. /**
  55253. * Gets the load type
  55254. */
  55255. loadType: number;
  55256. /**
  55257. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55258. */
  55259. isInvalid: boolean;
  55260. /**
  55261. * Creates a new KhronosTextureContainer
  55262. * @param data contents of the KTX container file
  55263. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55264. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55265. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55266. */
  55267. constructor(
  55268. /** contents of the KTX container file */
  55269. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55270. /**
  55271. * Uploads KTX content to a Babylon Texture.
  55272. * It is assumed that the texture has already been created & is currently bound
  55273. * @hidden
  55274. */
  55275. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55276. private _upload2DCompressedLevels;
  55277. /**
  55278. * Checks if the given data starts with a KTX file identifier.
  55279. * @param data the data to check
  55280. * @returns true if the data is a KTX file or false otherwise
  55281. */
  55282. static IsValid(data: ArrayBufferView): boolean;
  55283. }
  55284. }
  55285. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55286. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55287. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55288. /**
  55289. * Class for loading KTX2 files
  55290. * !!! Experimental Extension Subject to Changes !!!
  55291. * @hidden
  55292. */
  55293. export class KhronosTextureContainer2 {
  55294. private static _ModulePromise;
  55295. private static _TranscodeFormat;
  55296. constructor(engine: ThinEngine);
  55297. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55298. private _determineTranscodeFormat;
  55299. /**
  55300. * Checks if the given data starts with a KTX2 file identifier.
  55301. * @param data the data to check
  55302. * @returns true if the data is a KTX2 file or false otherwise
  55303. */
  55304. static IsValid(data: ArrayBufferView): boolean;
  55305. }
  55306. }
  55307. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55308. import { Nullable } from "babylonjs/types";
  55309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55310. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55311. /**
  55312. * Implementation of the KTX Texture Loader.
  55313. * @hidden
  55314. */
  55315. export class _KTXTextureLoader implements IInternalTextureLoader {
  55316. /**
  55317. * Defines wether the loader supports cascade loading the different faces.
  55318. */
  55319. readonly supportCascades: boolean;
  55320. /**
  55321. * This returns if the loader support the current file information.
  55322. * @param extension defines the file extension of the file being loaded
  55323. * @returns true if the loader can load the specified file
  55324. */
  55325. canLoad(extension: string): boolean;
  55326. /**
  55327. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55328. * @param data contains the texture data
  55329. * @param texture defines the BabylonJS internal texture
  55330. * @param createPolynomials will be true if polynomials have been requested
  55331. * @param onLoad defines the callback to trigger once the texture is ready
  55332. * @param onError defines the callback to trigger in case of error
  55333. */
  55334. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55335. /**
  55336. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55337. * @param data contains the texture data
  55338. * @param texture defines the BabylonJS internal texture
  55339. * @param callback defines the method to call once ready to upload
  55340. */
  55341. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55342. }
  55343. }
  55344. declare module "babylonjs/Helpers/sceneHelpers" {
  55345. import { Nullable } from "babylonjs/types";
  55346. import { Mesh } from "babylonjs/Meshes/mesh";
  55347. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55348. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55349. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55350. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55351. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55352. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55353. import "babylonjs/Meshes/Builders/boxBuilder";
  55354. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55355. /** @hidden */
  55356. export var _forceSceneHelpersToBundle: boolean;
  55357. module "babylonjs/scene" {
  55358. interface Scene {
  55359. /**
  55360. * Creates a default light for the scene.
  55361. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55362. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55363. */
  55364. createDefaultLight(replace?: boolean): void;
  55365. /**
  55366. * Creates a default camera for the scene.
  55367. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55368. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55369. * @param replace has default false, when true replaces the active camera in the scene
  55370. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55371. */
  55372. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55373. /**
  55374. * Creates a default camera and a default light.
  55375. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55376. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55377. * @param replace has the default false, when true replaces the active camera/light in the scene
  55378. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55379. */
  55380. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55381. /**
  55382. * Creates a new sky box
  55383. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55384. * @param environmentTexture defines the texture to use as environment texture
  55385. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55386. * @param scale defines the overall scale of the skybox
  55387. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55388. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55389. * @returns a new mesh holding the sky box
  55390. */
  55391. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55392. /**
  55393. * Creates a new environment
  55394. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55395. * @param options defines the options you can use to configure the environment
  55396. * @returns the new EnvironmentHelper
  55397. */
  55398. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55399. /**
  55400. * Creates a new VREXperienceHelper
  55401. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55402. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55403. * @returns a new VREXperienceHelper
  55404. */
  55405. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55406. /**
  55407. * Creates a new WebXRDefaultExperience
  55408. * @see http://doc.babylonjs.com/how_to/webxr
  55409. * @param options experience options
  55410. * @returns a promise for a new WebXRDefaultExperience
  55411. */
  55412. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55413. }
  55414. }
  55415. }
  55416. declare module "babylonjs/Helpers/videoDome" {
  55417. import { Scene } from "babylonjs/scene";
  55418. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55419. import { Mesh } from "babylonjs/Meshes/mesh";
  55420. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55421. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55422. import "babylonjs/Meshes/Builders/sphereBuilder";
  55423. /**
  55424. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55425. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55426. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55427. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55428. */
  55429. export class VideoDome extends TransformNode {
  55430. /**
  55431. * Define the video source as a Monoscopic panoramic 360 video.
  55432. */
  55433. static readonly MODE_MONOSCOPIC: number;
  55434. /**
  55435. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55436. */
  55437. static readonly MODE_TOPBOTTOM: number;
  55438. /**
  55439. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55440. */
  55441. static readonly MODE_SIDEBYSIDE: number;
  55442. private _halfDome;
  55443. private _useDirectMapping;
  55444. /**
  55445. * The video texture being displayed on the sphere
  55446. */
  55447. protected _videoTexture: VideoTexture;
  55448. /**
  55449. * Gets the video texture being displayed on the sphere
  55450. */
  55451. get videoTexture(): VideoTexture;
  55452. /**
  55453. * The skybox material
  55454. */
  55455. protected _material: BackgroundMaterial;
  55456. /**
  55457. * The surface used for the skybox
  55458. */
  55459. protected _mesh: Mesh;
  55460. /**
  55461. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55462. */
  55463. private _halfDomeMask;
  55464. /**
  55465. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55466. * Also see the options.resolution property.
  55467. */
  55468. get fovMultiplier(): number;
  55469. set fovMultiplier(value: number);
  55470. private _videoMode;
  55471. /**
  55472. * Gets or set the current video mode for the video. It can be:
  55473. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55474. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55475. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55476. */
  55477. get videoMode(): number;
  55478. set videoMode(value: number);
  55479. /**
  55480. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55481. *
  55482. */
  55483. get halfDome(): boolean;
  55484. /**
  55485. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55486. */
  55487. set halfDome(enabled: boolean);
  55488. /**
  55489. * Oberserver used in Stereoscopic VR Mode.
  55490. */
  55491. private _onBeforeCameraRenderObserver;
  55492. /**
  55493. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55494. * @param name Element's name, child elements will append suffixes for their own names.
  55495. * @param urlsOrVideo defines the url(s) or the video element to use
  55496. * @param options An object containing optional or exposed sub element properties
  55497. */
  55498. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55499. resolution?: number;
  55500. clickToPlay?: boolean;
  55501. autoPlay?: boolean;
  55502. loop?: boolean;
  55503. size?: number;
  55504. poster?: string;
  55505. faceForward?: boolean;
  55506. useDirectMapping?: boolean;
  55507. halfDomeMode?: boolean;
  55508. }, scene: Scene);
  55509. private _changeVideoMode;
  55510. /**
  55511. * Releases resources associated with this node.
  55512. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55513. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55514. */
  55515. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55516. }
  55517. }
  55518. declare module "babylonjs/Helpers/index" {
  55519. export * from "babylonjs/Helpers/environmentHelper";
  55520. export * from "babylonjs/Helpers/photoDome";
  55521. export * from "babylonjs/Helpers/sceneHelpers";
  55522. export * from "babylonjs/Helpers/videoDome";
  55523. }
  55524. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55525. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55526. import { IDisposable } from "babylonjs/scene";
  55527. import { Engine } from "babylonjs/Engines/engine";
  55528. /**
  55529. * This class can be used to get instrumentation data from a Babylon engine
  55530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55531. */
  55532. export class EngineInstrumentation implements IDisposable {
  55533. /**
  55534. * Define the instrumented engine.
  55535. */
  55536. engine: Engine;
  55537. private _captureGPUFrameTime;
  55538. private _gpuFrameTimeToken;
  55539. private _gpuFrameTime;
  55540. private _captureShaderCompilationTime;
  55541. private _shaderCompilationTime;
  55542. private _onBeginFrameObserver;
  55543. private _onEndFrameObserver;
  55544. private _onBeforeShaderCompilationObserver;
  55545. private _onAfterShaderCompilationObserver;
  55546. /**
  55547. * Gets the perf counter used for GPU frame time
  55548. */
  55549. get gpuFrameTimeCounter(): PerfCounter;
  55550. /**
  55551. * Gets the GPU frame time capture status
  55552. */
  55553. get captureGPUFrameTime(): boolean;
  55554. /**
  55555. * Enable or disable the GPU frame time capture
  55556. */
  55557. set captureGPUFrameTime(value: boolean);
  55558. /**
  55559. * Gets the perf counter used for shader compilation time
  55560. */
  55561. get shaderCompilationTimeCounter(): PerfCounter;
  55562. /**
  55563. * Gets the shader compilation time capture status
  55564. */
  55565. get captureShaderCompilationTime(): boolean;
  55566. /**
  55567. * Enable or disable the shader compilation time capture
  55568. */
  55569. set captureShaderCompilationTime(value: boolean);
  55570. /**
  55571. * Instantiates a new engine instrumentation.
  55572. * This class can be used to get instrumentation data from a Babylon engine
  55573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55574. * @param engine Defines the engine to instrument
  55575. */
  55576. constructor(
  55577. /**
  55578. * Define the instrumented engine.
  55579. */
  55580. engine: Engine);
  55581. /**
  55582. * Dispose and release associated resources.
  55583. */
  55584. dispose(): void;
  55585. }
  55586. }
  55587. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55588. import { Scene, IDisposable } from "babylonjs/scene";
  55589. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55590. /**
  55591. * This class can be used to get instrumentation data from a Babylon engine
  55592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55593. */
  55594. export class SceneInstrumentation implements IDisposable {
  55595. /**
  55596. * Defines the scene to instrument
  55597. */
  55598. scene: Scene;
  55599. private _captureActiveMeshesEvaluationTime;
  55600. private _activeMeshesEvaluationTime;
  55601. private _captureRenderTargetsRenderTime;
  55602. private _renderTargetsRenderTime;
  55603. private _captureFrameTime;
  55604. private _frameTime;
  55605. private _captureRenderTime;
  55606. private _renderTime;
  55607. private _captureInterFrameTime;
  55608. private _interFrameTime;
  55609. private _captureParticlesRenderTime;
  55610. private _particlesRenderTime;
  55611. private _captureSpritesRenderTime;
  55612. private _spritesRenderTime;
  55613. private _capturePhysicsTime;
  55614. private _physicsTime;
  55615. private _captureAnimationsTime;
  55616. private _animationsTime;
  55617. private _captureCameraRenderTime;
  55618. private _cameraRenderTime;
  55619. private _onBeforeActiveMeshesEvaluationObserver;
  55620. private _onAfterActiveMeshesEvaluationObserver;
  55621. private _onBeforeRenderTargetsRenderObserver;
  55622. private _onAfterRenderTargetsRenderObserver;
  55623. private _onAfterRenderObserver;
  55624. private _onBeforeDrawPhaseObserver;
  55625. private _onAfterDrawPhaseObserver;
  55626. private _onBeforeAnimationsObserver;
  55627. private _onBeforeParticlesRenderingObserver;
  55628. private _onAfterParticlesRenderingObserver;
  55629. private _onBeforeSpritesRenderingObserver;
  55630. private _onAfterSpritesRenderingObserver;
  55631. private _onBeforePhysicsObserver;
  55632. private _onAfterPhysicsObserver;
  55633. private _onAfterAnimationsObserver;
  55634. private _onBeforeCameraRenderObserver;
  55635. private _onAfterCameraRenderObserver;
  55636. /**
  55637. * Gets the perf counter used for active meshes evaluation time
  55638. */
  55639. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55640. /**
  55641. * Gets the active meshes evaluation time capture status
  55642. */
  55643. get captureActiveMeshesEvaluationTime(): boolean;
  55644. /**
  55645. * Enable or disable the active meshes evaluation time capture
  55646. */
  55647. set captureActiveMeshesEvaluationTime(value: boolean);
  55648. /**
  55649. * Gets the perf counter used for render targets render time
  55650. */
  55651. get renderTargetsRenderTimeCounter(): PerfCounter;
  55652. /**
  55653. * Gets the render targets render time capture status
  55654. */
  55655. get captureRenderTargetsRenderTime(): boolean;
  55656. /**
  55657. * Enable or disable the render targets render time capture
  55658. */
  55659. set captureRenderTargetsRenderTime(value: boolean);
  55660. /**
  55661. * Gets the perf counter used for particles render time
  55662. */
  55663. get particlesRenderTimeCounter(): PerfCounter;
  55664. /**
  55665. * Gets the particles render time capture status
  55666. */
  55667. get captureParticlesRenderTime(): boolean;
  55668. /**
  55669. * Enable or disable the particles render time capture
  55670. */
  55671. set captureParticlesRenderTime(value: boolean);
  55672. /**
  55673. * Gets the perf counter used for sprites render time
  55674. */
  55675. get spritesRenderTimeCounter(): PerfCounter;
  55676. /**
  55677. * Gets the sprites render time capture status
  55678. */
  55679. get captureSpritesRenderTime(): boolean;
  55680. /**
  55681. * Enable or disable the sprites render time capture
  55682. */
  55683. set captureSpritesRenderTime(value: boolean);
  55684. /**
  55685. * Gets the perf counter used for physics time
  55686. */
  55687. get physicsTimeCounter(): PerfCounter;
  55688. /**
  55689. * Gets the physics time capture status
  55690. */
  55691. get capturePhysicsTime(): boolean;
  55692. /**
  55693. * Enable or disable the physics time capture
  55694. */
  55695. set capturePhysicsTime(value: boolean);
  55696. /**
  55697. * Gets the perf counter used for animations time
  55698. */
  55699. get animationsTimeCounter(): PerfCounter;
  55700. /**
  55701. * Gets the animations time capture status
  55702. */
  55703. get captureAnimationsTime(): boolean;
  55704. /**
  55705. * Enable or disable the animations time capture
  55706. */
  55707. set captureAnimationsTime(value: boolean);
  55708. /**
  55709. * Gets the perf counter used for frame time capture
  55710. */
  55711. get frameTimeCounter(): PerfCounter;
  55712. /**
  55713. * Gets the frame time capture status
  55714. */
  55715. get captureFrameTime(): boolean;
  55716. /**
  55717. * Enable or disable the frame time capture
  55718. */
  55719. set captureFrameTime(value: boolean);
  55720. /**
  55721. * Gets the perf counter used for inter-frames time capture
  55722. */
  55723. get interFrameTimeCounter(): PerfCounter;
  55724. /**
  55725. * Gets the inter-frames time capture status
  55726. */
  55727. get captureInterFrameTime(): boolean;
  55728. /**
  55729. * Enable or disable the inter-frames time capture
  55730. */
  55731. set captureInterFrameTime(value: boolean);
  55732. /**
  55733. * Gets the perf counter used for render time capture
  55734. */
  55735. get renderTimeCounter(): PerfCounter;
  55736. /**
  55737. * Gets the render time capture status
  55738. */
  55739. get captureRenderTime(): boolean;
  55740. /**
  55741. * Enable or disable the render time capture
  55742. */
  55743. set captureRenderTime(value: boolean);
  55744. /**
  55745. * Gets the perf counter used for camera render time capture
  55746. */
  55747. get cameraRenderTimeCounter(): PerfCounter;
  55748. /**
  55749. * Gets the camera render time capture status
  55750. */
  55751. get captureCameraRenderTime(): boolean;
  55752. /**
  55753. * Enable or disable the camera render time capture
  55754. */
  55755. set captureCameraRenderTime(value: boolean);
  55756. /**
  55757. * Gets the perf counter used for draw calls
  55758. */
  55759. get drawCallsCounter(): PerfCounter;
  55760. /**
  55761. * Instantiates a new scene instrumentation.
  55762. * This class can be used to get instrumentation data from a Babylon engine
  55763. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55764. * @param scene Defines the scene to instrument
  55765. */
  55766. constructor(
  55767. /**
  55768. * Defines the scene to instrument
  55769. */
  55770. scene: Scene);
  55771. /**
  55772. * Dispose and release associated resources.
  55773. */
  55774. dispose(): void;
  55775. }
  55776. }
  55777. declare module "babylonjs/Instrumentation/index" {
  55778. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55779. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55780. export * from "babylonjs/Instrumentation/timeToken";
  55781. }
  55782. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55783. /** @hidden */
  55784. export var glowMapGenerationPixelShader: {
  55785. name: string;
  55786. shader: string;
  55787. };
  55788. }
  55789. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55790. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55791. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55792. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55793. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55794. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55795. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55796. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55797. /** @hidden */
  55798. export var glowMapGenerationVertexShader: {
  55799. name: string;
  55800. shader: string;
  55801. };
  55802. }
  55803. declare module "babylonjs/Layers/effectLayer" {
  55804. import { Observable } from "babylonjs/Misc/observable";
  55805. import { Nullable } from "babylonjs/types";
  55806. import { Camera } from "babylonjs/Cameras/camera";
  55807. import { Scene } from "babylonjs/scene";
  55808. import { ISize } from "babylonjs/Maths/math.size";
  55809. import { Color4 } from "babylonjs/Maths/math.color";
  55810. import { Engine } from "babylonjs/Engines/engine";
  55811. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55813. import { Mesh } from "babylonjs/Meshes/mesh";
  55814. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55816. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55817. import { Effect } from "babylonjs/Materials/effect";
  55818. import { Material } from "babylonjs/Materials/material";
  55819. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55820. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55821. /**
  55822. * Effect layer options. This helps customizing the behaviour
  55823. * of the effect layer.
  55824. */
  55825. export interface IEffectLayerOptions {
  55826. /**
  55827. * Multiplication factor apply to the canvas size to compute the render target size
  55828. * used to generated the objects (the smaller the faster).
  55829. */
  55830. mainTextureRatio: number;
  55831. /**
  55832. * Enforces a fixed size texture to ensure effect stability across devices.
  55833. */
  55834. mainTextureFixedSize?: number;
  55835. /**
  55836. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55837. */
  55838. alphaBlendingMode: number;
  55839. /**
  55840. * The camera attached to the layer.
  55841. */
  55842. camera: Nullable<Camera>;
  55843. /**
  55844. * The rendering group to draw the layer in.
  55845. */
  55846. renderingGroupId: number;
  55847. }
  55848. /**
  55849. * The effect layer Helps adding post process effect blended with the main pass.
  55850. *
  55851. * This can be for instance use to generate glow or higlight effects on the scene.
  55852. *
  55853. * The effect layer class can not be used directly and is intented to inherited from to be
  55854. * customized per effects.
  55855. */
  55856. export abstract class EffectLayer {
  55857. private _vertexBuffers;
  55858. private _indexBuffer;
  55859. private _cachedDefines;
  55860. private _effectLayerMapGenerationEffect;
  55861. private _effectLayerOptions;
  55862. private _mergeEffect;
  55863. protected _scene: Scene;
  55864. protected _engine: Engine;
  55865. protected _maxSize: number;
  55866. protected _mainTextureDesiredSize: ISize;
  55867. protected _mainTexture: RenderTargetTexture;
  55868. protected _shouldRender: boolean;
  55869. protected _postProcesses: PostProcess[];
  55870. protected _textures: BaseTexture[];
  55871. protected _emissiveTextureAndColor: {
  55872. texture: Nullable<BaseTexture>;
  55873. color: Color4;
  55874. };
  55875. /**
  55876. * The name of the layer
  55877. */
  55878. name: string;
  55879. /**
  55880. * The clear color of the texture used to generate the glow map.
  55881. */
  55882. neutralColor: Color4;
  55883. /**
  55884. * Specifies whether the highlight layer is enabled or not.
  55885. */
  55886. isEnabled: boolean;
  55887. /**
  55888. * Gets the camera attached to the layer.
  55889. */
  55890. get camera(): Nullable<Camera>;
  55891. /**
  55892. * Gets the rendering group id the layer should render in.
  55893. */
  55894. get renderingGroupId(): number;
  55895. set renderingGroupId(renderingGroupId: number);
  55896. /**
  55897. * An event triggered when the effect layer has been disposed.
  55898. */
  55899. onDisposeObservable: Observable<EffectLayer>;
  55900. /**
  55901. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55902. */
  55903. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55904. /**
  55905. * An event triggered when the generated texture is being merged in the scene.
  55906. */
  55907. onBeforeComposeObservable: Observable<EffectLayer>;
  55908. /**
  55909. * An event triggered when the mesh is rendered into the effect render target.
  55910. */
  55911. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55912. /**
  55913. * An event triggered after the mesh has been rendered into the effect render target.
  55914. */
  55915. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55916. /**
  55917. * An event triggered when the generated texture has been merged in the scene.
  55918. */
  55919. onAfterComposeObservable: Observable<EffectLayer>;
  55920. /**
  55921. * An event triggered when the efffect layer changes its size.
  55922. */
  55923. onSizeChangedObservable: Observable<EffectLayer>;
  55924. /** @hidden */
  55925. static _SceneComponentInitialization: (scene: Scene) => void;
  55926. /**
  55927. * Instantiates a new effect Layer and references it in the scene.
  55928. * @param name The name of the layer
  55929. * @param scene The scene to use the layer in
  55930. */
  55931. constructor(
  55932. /** The Friendly of the effect in the scene */
  55933. name: string, scene: Scene);
  55934. /**
  55935. * Get the effect name of the layer.
  55936. * @return The effect name
  55937. */
  55938. abstract getEffectName(): string;
  55939. /**
  55940. * Checks for the readiness of the element composing the layer.
  55941. * @param subMesh the mesh to check for
  55942. * @param useInstances specify whether or not to use instances to render the mesh
  55943. * @return true if ready otherwise, false
  55944. */
  55945. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55946. /**
  55947. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55948. * @returns true if the effect requires stencil during the main canvas render pass.
  55949. */
  55950. abstract needStencil(): boolean;
  55951. /**
  55952. * Create the merge effect. This is the shader use to blit the information back
  55953. * to the main canvas at the end of the scene rendering.
  55954. * @returns The effect containing the shader used to merge the effect on the main canvas
  55955. */
  55956. protected abstract _createMergeEffect(): Effect;
  55957. /**
  55958. * Creates the render target textures and post processes used in the effect layer.
  55959. */
  55960. protected abstract _createTextureAndPostProcesses(): void;
  55961. /**
  55962. * Implementation specific of rendering the generating effect on the main canvas.
  55963. * @param effect The effect used to render through
  55964. */
  55965. protected abstract _internalRender(effect: Effect): void;
  55966. /**
  55967. * Sets the required values for both the emissive texture and and the main color.
  55968. */
  55969. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55970. /**
  55971. * Free any resources and references associated to a mesh.
  55972. * Internal use
  55973. * @param mesh The mesh to free.
  55974. */
  55975. abstract _disposeMesh(mesh: Mesh): void;
  55976. /**
  55977. * Serializes this layer (Glow or Highlight for example)
  55978. * @returns a serialized layer object
  55979. */
  55980. abstract serialize?(): any;
  55981. /**
  55982. * Initializes the effect layer with the required options.
  55983. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55984. */
  55985. protected _init(options: Partial<IEffectLayerOptions>): void;
  55986. /**
  55987. * Generates the index buffer of the full screen quad blending to the main canvas.
  55988. */
  55989. private _generateIndexBuffer;
  55990. /**
  55991. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55992. */
  55993. private _generateVertexBuffer;
  55994. /**
  55995. * Sets the main texture desired size which is the closest power of two
  55996. * of the engine canvas size.
  55997. */
  55998. private _setMainTextureSize;
  55999. /**
  56000. * Creates the main texture for the effect layer.
  56001. */
  56002. protected _createMainTexture(): void;
  56003. /**
  56004. * Adds specific effects defines.
  56005. * @param defines The defines to add specifics to.
  56006. */
  56007. protected _addCustomEffectDefines(defines: string[]): void;
  56008. /**
  56009. * Checks for the readiness of the element composing the layer.
  56010. * @param subMesh the mesh to check for
  56011. * @param useInstances specify whether or not to use instances to render the mesh
  56012. * @param emissiveTexture the associated emissive texture used to generate the glow
  56013. * @return true if ready otherwise, false
  56014. */
  56015. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56016. /**
  56017. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56018. */
  56019. render(): void;
  56020. /**
  56021. * Determine if a given mesh will be used in the current effect.
  56022. * @param mesh mesh to test
  56023. * @returns true if the mesh will be used
  56024. */
  56025. hasMesh(mesh: AbstractMesh): boolean;
  56026. /**
  56027. * Returns true if the layer contains information to display, otherwise false.
  56028. * @returns true if the glow layer should be rendered
  56029. */
  56030. shouldRender(): boolean;
  56031. /**
  56032. * Returns true if the mesh should render, otherwise false.
  56033. * @param mesh The mesh to render
  56034. * @returns true if it should render otherwise false
  56035. */
  56036. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56037. /**
  56038. * Returns true if the mesh can be rendered, otherwise false.
  56039. * @param mesh The mesh to render
  56040. * @param material The material used on the mesh
  56041. * @returns true if it can be rendered otherwise false
  56042. */
  56043. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56044. /**
  56045. * Returns true if the mesh should render, otherwise false.
  56046. * @param mesh The mesh to render
  56047. * @returns true if it should render otherwise false
  56048. */
  56049. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56050. /**
  56051. * Renders the submesh passed in parameter to the generation map.
  56052. */
  56053. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56054. /**
  56055. * Defines whether the current material of the mesh should be use to render the effect.
  56056. * @param mesh defines the current mesh to render
  56057. */
  56058. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56059. /**
  56060. * Rebuild the required buffers.
  56061. * @hidden Internal use only.
  56062. */
  56063. _rebuild(): void;
  56064. /**
  56065. * Dispose only the render target textures and post process.
  56066. */
  56067. private _disposeTextureAndPostProcesses;
  56068. /**
  56069. * Dispose the highlight layer and free resources.
  56070. */
  56071. dispose(): void;
  56072. /**
  56073. * Gets the class name of the effect layer
  56074. * @returns the string with the class name of the effect layer
  56075. */
  56076. getClassName(): string;
  56077. /**
  56078. * Creates an effect layer from parsed effect layer data
  56079. * @param parsedEffectLayer defines effect layer data
  56080. * @param scene defines the current scene
  56081. * @param rootUrl defines the root URL containing the effect layer information
  56082. * @returns a parsed effect Layer
  56083. */
  56084. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56085. }
  56086. }
  56087. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  56088. import { Scene } from "babylonjs/scene";
  56089. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56090. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56091. import { AbstractScene } from "babylonjs/abstractScene";
  56092. module "babylonjs/abstractScene" {
  56093. interface AbstractScene {
  56094. /**
  56095. * The list of effect layers (highlights/glow) added to the scene
  56096. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56097. * @see http://doc.babylonjs.com/how_to/glow_layer
  56098. */
  56099. effectLayers: Array<EffectLayer>;
  56100. /**
  56101. * Removes the given effect layer from this scene.
  56102. * @param toRemove defines the effect layer to remove
  56103. * @returns the index of the removed effect layer
  56104. */
  56105. removeEffectLayer(toRemove: EffectLayer): number;
  56106. /**
  56107. * Adds the given effect layer to this scene
  56108. * @param newEffectLayer defines the effect layer to add
  56109. */
  56110. addEffectLayer(newEffectLayer: EffectLayer): void;
  56111. }
  56112. }
  56113. /**
  56114. * Defines the layer scene component responsible to manage any effect layers
  56115. * in a given scene.
  56116. */
  56117. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56118. /**
  56119. * The component name helpfull to identify the component in the list of scene components.
  56120. */
  56121. readonly name: string;
  56122. /**
  56123. * The scene the component belongs to.
  56124. */
  56125. scene: Scene;
  56126. private _engine;
  56127. private _renderEffects;
  56128. private _needStencil;
  56129. private _previousStencilState;
  56130. /**
  56131. * Creates a new instance of the component for the given scene
  56132. * @param scene Defines the scene to register the component in
  56133. */
  56134. constructor(scene: Scene);
  56135. /**
  56136. * Registers the component in a given scene
  56137. */
  56138. register(): void;
  56139. /**
  56140. * Rebuilds the elements related to this component in case of
  56141. * context lost for instance.
  56142. */
  56143. rebuild(): void;
  56144. /**
  56145. * Serializes the component data to the specified json object
  56146. * @param serializationObject The object to serialize to
  56147. */
  56148. serialize(serializationObject: any): void;
  56149. /**
  56150. * Adds all the elements from the container to the scene
  56151. * @param container the container holding the elements
  56152. */
  56153. addFromContainer(container: AbstractScene): void;
  56154. /**
  56155. * Removes all the elements in the container from the scene
  56156. * @param container contains the elements to remove
  56157. * @param dispose if the removed element should be disposed (default: false)
  56158. */
  56159. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56160. /**
  56161. * Disposes the component and the associated ressources.
  56162. */
  56163. dispose(): void;
  56164. private _isReadyForMesh;
  56165. private _renderMainTexture;
  56166. private _setStencil;
  56167. private _setStencilBack;
  56168. private _draw;
  56169. private _drawCamera;
  56170. private _drawRenderingGroup;
  56171. }
  56172. }
  56173. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  56174. /** @hidden */
  56175. export var glowMapMergePixelShader: {
  56176. name: string;
  56177. shader: string;
  56178. };
  56179. }
  56180. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  56181. /** @hidden */
  56182. export var glowMapMergeVertexShader: {
  56183. name: string;
  56184. shader: string;
  56185. };
  56186. }
  56187. declare module "babylonjs/Layers/glowLayer" {
  56188. import { Nullable } from "babylonjs/types";
  56189. import { Camera } from "babylonjs/Cameras/camera";
  56190. import { Scene } from "babylonjs/scene";
  56191. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56193. import { Mesh } from "babylonjs/Meshes/mesh";
  56194. import { Texture } from "babylonjs/Materials/Textures/texture";
  56195. import { Effect } from "babylonjs/Materials/effect";
  56196. import { Material } from "babylonjs/Materials/material";
  56197. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56198. import { Color4 } from "babylonjs/Maths/math.color";
  56199. import "babylonjs/Shaders/glowMapMerge.fragment";
  56200. import "babylonjs/Shaders/glowMapMerge.vertex";
  56201. import "babylonjs/Layers/effectLayerSceneComponent";
  56202. module "babylonjs/abstractScene" {
  56203. interface AbstractScene {
  56204. /**
  56205. * Return a the first highlight layer of the scene with a given name.
  56206. * @param name The name of the highlight layer to look for.
  56207. * @return The highlight layer if found otherwise null.
  56208. */
  56209. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56210. }
  56211. }
  56212. /**
  56213. * Glow layer options. This helps customizing the behaviour
  56214. * of the glow layer.
  56215. */
  56216. export interface IGlowLayerOptions {
  56217. /**
  56218. * Multiplication factor apply to the canvas size to compute the render target size
  56219. * used to generated the glowing objects (the smaller the faster).
  56220. */
  56221. mainTextureRatio: number;
  56222. /**
  56223. * Enforces a fixed size texture to ensure resize independant blur.
  56224. */
  56225. mainTextureFixedSize?: number;
  56226. /**
  56227. * How big is the kernel of the blur texture.
  56228. */
  56229. blurKernelSize: number;
  56230. /**
  56231. * The camera attached to the layer.
  56232. */
  56233. camera: Nullable<Camera>;
  56234. /**
  56235. * Enable MSAA by chosing the number of samples.
  56236. */
  56237. mainTextureSamples?: number;
  56238. /**
  56239. * The rendering group to draw the layer in.
  56240. */
  56241. renderingGroupId: number;
  56242. }
  56243. /**
  56244. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56245. *
  56246. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56247. *
  56248. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56249. */
  56250. export class GlowLayer extends EffectLayer {
  56251. /**
  56252. * Effect Name of the layer.
  56253. */
  56254. static readonly EffectName: string;
  56255. /**
  56256. * The default blur kernel size used for the glow.
  56257. */
  56258. static DefaultBlurKernelSize: number;
  56259. /**
  56260. * The default texture size ratio used for the glow.
  56261. */
  56262. static DefaultTextureRatio: number;
  56263. /**
  56264. * Sets the kernel size of the blur.
  56265. */
  56266. set blurKernelSize(value: number);
  56267. /**
  56268. * Gets the kernel size of the blur.
  56269. */
  56270. get blurKernelSize(): number;
  56271. /**
  56272. * Sets the glow intensity.
  56273. */
  56274. set intensity(value: number);
  56275. /**
  56276. * Gets the glow intensity.
  56277. */
  56278. get intensity(): number;
  56279. private _options;
  56280. private _intensity;
  56281. private _horizontalBlurPostprocess1;
  56282. private _verticalBlurPostprocess1;
  56283. private _horizontalBlurPostprocess2;
  56284. private _verticalBlurPostprocess2;
  56285. private _blurTexture1;
  56286. private _blurTexture2;
  56287. private _postProcesses1;
  56288. private _postProcesses2;
  56289. private _includedOnlyMeshes;
  56290. private _excludedMeshes;
  56291. private _meshesUsingTheirOwnMaterials;
  56292. /**
  56293. * Callback used to let the user override the color selection on a per mesh basis
  56294. */
  56295. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56296. /**
  56297. * Callback used to let the user override the texture selection on a per mesh basis
  56298. */
  56299. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56300. /**
  56301. * Instantiates a new glow Layer and references it to the scene.
  56302. * @param name The name of the layer
  56303. * @param scene The scene to use the layer in
  56304. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56305. */
  56306. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56307. /**
  56308. * Get the effect name of the layer.
  56309. * @return The effect name
  56310. */
  56311. getEffectName(): string;
  56312. /**
  56313. * Create the merge effect. This is the shader use to blit the information back
  56314. * to the main canvas at the end of the scene rendering.
  56315. */
  56316. protected _createMergeEffect(): Effect;
  56317. /**
  56318. * Creates the render target textures and post processes used in the glow layer.
  56319. */
  56320. protected _createTextureAndPostProcesses(): void;
  56321. /**
  56322. * Checks for the readiness of the element composing the layer.
  56323. * @param subMesh the mesh to check for
  56324. * @param useInstances specify wether or not to use instances to render the mesh
  56325. * @param emissiveTexture the associated emissive texture used to generate the glow
  56326. * @return true if ready otherwise, false
  56327. */
  56328. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56329. /**
  56330. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56331. */
  56332. needStencil(): boolean;
  56333. /**
  56334. * Returns true if the mesh can be rendered, otherwise false.
  56335. * @param mesh The mesh to render
  56336. * @param material The material used on the mesh
  56337. * @returns true if it can be rendered otherwise false
  56338. */
  56339. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56340. /**
  56341. * Implementation specific of rendering the generating effect on the main canvas.
  56342. * @param effect The effect used to render through
  56343. */
  56344. protected _internalRender(effect: Effect): void;
  56345. /**
  56346. * Sets the required values for both the emissive texture and and the main color.
  56347. */
  56348. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56349. /**
  56350. * Returns true if the mesh should render, otherwise false.
  56351. * @param mesh The mesh to render
  56352. * @returns true if it should render otherwise false
  56353. */
  56354. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56355. /**
  56356. * Adds specific effects defines.
  56357. * @param defines The defines to add specifics to.
  56358. */
  56359. protected _addCustomEffectDefines(defines: string[]): void;
  56360. /**
  56361. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56362. * @param mesh The mesh to exclude from the glow layer
  56363. */
  56364. addExcludedMesh(mesh: Mesh): void;
  56365. /**
  56366. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56367. * @param mesh The mesh to remove
  56368. */
  56369. removeExcludedMesh(mesh: Mesh): void;
  56370. /**
  56371. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56372. * @param mesh The mesh to include in the glow layer
  56373. */
  56374. addIncludedOnlyMesh(mesh: Mesh): void;
  56375. /**
  56376. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56377. * @param mesh The mesh to remove
  56378. */
  56379. removeIncludedOnlyMesh(mesh: Mesh): void;
  56380. /**
  56381. * Determine if a given mesh will be used in the glow layer
  56382. * @param mesh The mesh to test
  56383. * @returns true if the mesh will be highlighted by the current glow layer
  56384. */
  56385. hasMesh(mesh: AbstractMesh): boolean;
  56386. /**
  56387. * Defines whether the current material of the mesh should be use to render the effect.
  56388. * @param mesh defines the current mesh to render
  56389. */
  56390. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56391. /**
  56392. * Add a mesh to be rendered through its own material and not with emissive only.
  56393. * @param mesh The mesh for which we need to use its material
  56394. */
  56395. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56396. /**
  56397. * Remove a mesh from being rendered through its own material and not with emissive only.
  56398. * @param mesh The mesh for which we need to not use its material
  56399. */
  56400. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56401. /**
  56402. * Free any resources and references associated to a mesh.
  56403. * Internal use
  56404. * @param mesh The mesh to free.
  56405. * @hidden
  56406. */
  56407. _disposeMesh(mesh: Mesh): void;
  56408. /**
  56409. * Gets the class name of the effect layer
  56410. * @returns the string with the class name of the effect layer
  56411. */
  56412. getClassName(): string;
  56413. /**
  56414. * Serializes this glow layer
  56415. * @returns a serialized glow layer object
  56416. */
  56417. serialize(): any;
  56418. /**
  56419. * Creates a Glow Layer from parsed glow layer data
  56420. * @param parsedGlowLayer defines glow layer data
  56421. * @param scene defines the current scene
  56422. * @param rootUrl defines the root URL containing the glow layer information
  56423. * @returns a parsed Glow Layer
  56424. */
  56425. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56426. }
  56427. }
  56428. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56429. /** @hidden */
  56430. export var glowBlurPostProcessPixelShader: {
  56431. name: string;
  56432. shader: string;
  56433. };
  56434. }
  56435. declare module "babylonjs/Layers/highlightLayer" {
  56436. import { Observable } from "babylonjs/Misc/observable";
  56437. import { Nullable } from "babylonjs/types";
  56438. import { Camera } from "babylonjs/Cameras/camera";
  56439. import { Scene } from "babylonjs/scene";
  56440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56442. import { Mesh } from "babylonjs/Meshes/mesh";
  56443. import { Effect } from "babylonjs/Materials/effect";
  56444. import { Material } from "babylonjs/Materials/material";
  56445. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56446. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56447. import "babylonjs/Shaders/glowMapMerge.fragment";
  56448. import "babylonjs/Shaders/glowMapMerge.vertex";
  56449. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56450. module "babylonjs/abstractScene" {
  56451. interface AbstractScene {
  56452. /**
  56453. * Return a the first highlight layer of the scene with a given name.
  56454. * @param name The name of the highlight layer to look for.
  56455. * @return The highlight layer if found otherwise null.
  56456. */
  56457. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56458. }
  56459. }
  56460. /**
  56461. * Highlight layer options. This helps customizing the behaviour
  56462. * of the highlight layer.
  56463. */
  56464. export interface IHighlightLayerOptions {
  56465. /**
  56466. * Multiplication factor apply to the canvas size to compute the render target size
  56467. * used to generated the glowing objects (the smaller the faster).
  56468. */
  56469. mainTextureRatio: number;
  56470. /**
  56471. * Enforces a fixed size texture to ensure resize independant blur.
  56472. */
  56473. mainTextureFixedSize?: number;
  56474. /**
  56475. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56476. * of the picture to blur (the smaller the faster).
  56477. */
  56478. blurTextureSizeRatio: number;
  56479. /**
  56480. * How big in texel of the blur texture is the vertical blur.
  56481. */
  56482. blurVerticalSize: number;
  56483. /**
  56484. * How big in texel of the blur texture is the horizontal blur.
  56485. */
  56486. blurHorizontalSize: number;
  56487. /**
  56488. * Alpha blending mode used to apply the blur. Default is combine.
  56489. */
  56490. alphaBlendingMode: number;
  56491. /**
  56492. * The camera attached to the layer.
  56493. */
  56494. camera: Nullable<Camera>;
  56495. /**
  56496. * Should we display highlight as a solid stroke?
  56497. */
  56498. isStroke?: boolean;
  56499. /**
  56500. * The rendering group to draw the layer in.
  56501. */
  56502. renderingGroupId: number;
  56503. }
  56504. /**
  56505. * The highlight layer Helps adding a glow effect around a mesh.
  56506. *
  56507. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56508. * glowy meshes to your scene.
  56509. *
  56510. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56511. */
  56512. export class HighlightLayer extends EffectLayer {
  56513. name: string;
  56514. /**
  56515. * Effect Name of the highlight layer.
  56516. */
  56517. static readonly EffectName: string;
  56518. /**
  56519. * The neutral color used during the preparation of the glow effect.
  56520. * This is black by default as the blend operation is a blend operation.
  56521. */
  56522. static NeutralColor: Color4;
  56523. /**
  56524. * Stencil value used for glowing meshes.
  56525. */
  56526. static GlowingMeshStencilReference: number;
  56527. /**
  56528. * Stencil value used for the other meshes in the scene.
  56529. */
  56530. static NormalMeshStencilReference: number;
  56531. /**
  56532. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56533. */
  56534. innerGlow: boolean;
  56535. /**
  56536. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56537. */
  56538. outerGlow: boolean;
  56539. /**
  56540. * Specifies the horizontal size of the blur.
  56541. */
  56542. set blurHorizontalSize(value: number);
  56543. /**
  56544. * Specifies the vertical size of the blur.
  56545. */
  56546. set blurVerticalSize(value: number);
  56547. /**
  56548. * Gets the horizontal size of the blur.
  56549. */
  56550. get blurHorizontalSize(): number;
  56551. /**
  56552. * Gets the vertical size of the blur.
  56553. */
  56554. get blurVerticalSize(): number;
  56555. /**
  56556. * An event triggered when the highlight layer is being blurred.
  56557. */
  56558. onBeforeBlurObservable: Observable<HighlightLayer>;
  56559. /**
  56560. * An event triggered when the highlight layer has been blurred.
  56561. */
  56562. onAfterBlurObservable: Observable<HighlightLayer>;
  56563. private _instanceGlowingMeshStencilReference;
  56564. private _options;
  56565. private _downSamplePostprocess;
  56566. private _horizontalBlurPostprocess;
  56567. private _verticalBlurPostprocess;
  56568. private _blurTexture;
  56569. private _meshes;
  56570. private _excludedMeshes;
  56571. /**
  56572. * Instantiates a new highlight Layer and references it to the scene..
  56573. * @param name The name of the layer
  56574. * @param scene The scene to use the layer in
  56575. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56576. */
  56577. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56578. /**
  56579. * Get the effect name of the layer.
  56580. * @return The effect name
  56581. */
  56582. getEffectName(): string;
  56583. /**
  56584. * Create the merge effect. This is the shader use to blit the information back
  56585. * to the main canvas at the end of the scene rendering.
  56586. */
  56587. protected _createMergeEffect(): Effect;
  56588. /**
  56589. * Creates the render target textures and post processes used in the highlight layer.
  56590. */
  56591. protected _createTextureAndPostProcesses(): void;
  56592. /**
  56593. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56594. */
  56595. needStencil(): boolean;
  56596. /**
  56597. * Checks for the readiness of the element composing the layer.
  56598. * @param subMesh the mesh to check for
  56599. * @param useInstances specify wether or not to use instances to render the mesh
  56600. * @param emissiveTexture the associated emissive texture used to generate the glow
  56601. * @return true if ready otherwise, false
  56602. */
  56603. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56604. /**
  56605. * Implementation specific of rendering the generating effect on the main canvas.
  56606. * @param effect The effect used to render through
  56607. */
  56608. protected _internalRender(effect: Effect): void;
  56609. /**
  56610. * Returns true if the layer contains information to display, otherwise false.
  56611. */
  56612. shouldRender(): boolean;
  56613. /**
  56614. * Returns true if the mesh should render, otherwise false.
  56615. * @param mesh The mesh to render
  56616. * @returns true if it should render otherwise false
  56617. */
  56618. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56619. /**
  56620. * Adds specific effects defines.
  56621. * @param defines The defines to add specifics to.
  56622. */
  56623. protected _addCustomEffectDefines(defines: string[]): void;
  56624. /**
  56625. * Sets the required values for both the emissive texture and and the main color.
  56626. */
  56627. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56628. /**
  56629. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56630. * @param mesh The mesh to exclude from the highlight layer
  56631. */
  56632. addExcludedMesh(mesh: Mesh): void;
  56633. /**
  56634. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56635. * @param mesh The mesh to highlight
  56636. */
  56637. removeExcludedMesh(mesh: Mesh): void;
  56638. /**
  56639. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56640. * @param mesh mesh to test
  56641. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56642. */
  56643. hasMesh(mesh: AbstractMesh): boolean;
  56644. /**
  56645. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56646. * @param mesh The mesh to highlight
  56647. * @param color The color of the highlight
  56648. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56649. */
  56650. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56651. /**
  56652. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56653. * @param mesh The mesh to highlight
  56654. */
  56655. removeMesh(mesh: Mesh): void;
  56656. /**
  56657. * Remove all the meshes currently referenced in the highlight layer
  56658. */
  56659. removeAllMeshes(): void;
  56660. /**
  56661. * Force the stencil to the normal expected value for none glowing parts
  56662. */
  56663. private _defaultStencilReference;
  56664. /**
  56665. * Free any resources and references associated to a mesh.
  56666. * Internal use
  56667. * @param mesh The mesh to free.
  56668. * @hidden
  56669. */
  56670. _disposeMesh(mesh: Mesh): void;
  56671. /**
  56672. * Dispose the highlight layer and free resources.
  56673. */
  56674. dispose(): void;
  56675. /**
  56676. * Gets the class name of the effect layer
  56677. * @returns the string with the class name of the effect layer
  56678. */
  56679. getClassName(): string;
  56680. /**
  56681. * Serializes this Highlight layer
  56682. * @returns a serialized Highlight layer object
  56683. */
  56684. serialize(): any;
  56685. /**
  56686. * Creates a Highlight layer from parsed Highlight layer data
  56687. * @param parsedHightlightLayer defines the Highlight layer data
  56688. * @param scene defines the current scene
  56689. * @param rootUrl defines the root URL containing the Highlight layer information
  56690. * @returns a parsed Highlight layer
  56691. */
  56692. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56693. }
  56694. }
  56695. declare module "babylonjs/Layers/layerSceneComponent" {
  56696. import { Scene } from "babylonjs/scene";
  56697. import { ISceneComponent } from "babylonjs/sceneComponent";
  56698. import { Layer } from "babylonjs/Layers/layer";
  56699. import { AbstractScene } from "babylonjs/abstractScene";
  56700. module "babylonjs/abstractScene" {
  56701. interface AbstractScene {
  56702. /**
  56703. * The list of layers (background and foreground) of the scene
  56704. */
  56705. layers: Array<Layer>;
  56706. }
  56707. }
  56708. /**
  56709. * Defines the layer scene component responsible to manage any layers
  56710. * in a given scene.
  56711. */
  56712. export class LayerSceneComponent implements ISceneComponent {
  56713. /**
  56714. * The component name helpfull to identify the component in the list of scene components.
  56715. */
  56716. readonly name: string;
  56717. /**
  56718. * The scene the component belongs to.
  56719. */
  56720. scene: Scene;
  56721. private _engine;
  56722. /**
  56723. * Creates a new instance of the component for the given scene
  56724. * @param scene Defines the scene to register the component in
  56725. */
  56726. constructor(scene: Scene);
  56727. /**
  56728. * Registers the component in a given scene
  56729. */
  56730. register(): void;
  56731. /**
  56732. * Rebuilds the elements related to this component in case of
  56733. * context lost for instance.
  56734. */
  56735. rebuild(): void;
  56736. /**
  56737. * Disposes the component and the associated ressources.
  56738. */
  56739. dispose(): void;
  56740. private _draw;
  56741. private _drawCameraPredicate;
  56742. private _drawCameraBackground;
  56743. private _drawCameraForeground;
  56744. private _drawRenderTargetPredicate;
  56745. private _drawRenderTargetBackground;
  56746. private _drawRenderTargetForeground;
  56747. /**
  56748. * Adds all the elements from the container to the scene
  56749. * @param container the container holding the elements
  56750. */
  56751. addFromContainer(container: AbstractScene): void;
  56752. /**
  56753. * Removes all the elements in the container from the scene
  56754. * @param container contains the elements to remove
  56755. * @param dispose if the removed element should be disposed (default: false)
  56756. */
  56757. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56758. }
  56759. }
  56760. declare module "babylonjs/Shaders/layer.fragment" {
  56761. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56762. /** @hidden */
  56763. export var layerPixelShader: {
  56764. name: string;
  56765. shader: string;
  56766. };
  56767. }
  56768. declare module "babylonjs/Shaders/layer.vertex" {
  56769. /** @hidden */
  56770. export var layerVertexShader: {
  56771. name: string;
  56772. shader: string;
  56773. };
  56774. }
  56775. declare module "babylonjs/Layers/layer" {
  56776. import { Observable } from "babylonjs/Misc/observable";
  56777. import { Nullable } from "babylonjs/types";
  56778. import { Scene } from "babylonjs/scene";
  56779. import { Vector2 } from "babylonjs/Maths/math.vector";
  56780. import { Color4 } from "babylonjs/Maths/math.color";
  56781. import { Texture } from "babylonjs/Materials/Textures/texture";
  56782. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56783. import "babylonjs/Shaders/layer.fragment";
  56784. import "babylonjs/Shaders/layer.vertex";
  56785. /**
  56786. * This represents a full screen 2d layer.
  56787. * This can be useful to display a picture in the background of your scene for instance.
  56788. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56789. */
  56790. export class Layer {
  56791. /**
  56792. * Define the name of the layer.
  56793. */
  56794. name: string;
  56795. /**
  56796. * Define the texture the layer should display.
  56797. */
  56798. texture: Nullable<Texture>;
  56799. /**
  56800. * Is the layer in background or foreground.
  56801. */
  56802. isBackground: boolean;
  56803. /**
  56804. * Define the color of the layer (instead of texture).
  56805. */
  56806. color: Color4;
  56807. /**
  56808. * Define the scale of the layer in order to zoom in out of the texture.
  56809. */
  56810. scale: Vector2;
  56811. /**
  56812. * Define an offset for the layer in order to shift the texture.
  56813. */
  56814. offset: Vector2;
  56815. /**
  56816. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56817. */
  56818. alphaBlendingMode: number;
  56819. /**
  56820. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56821. * Alpha test will not mix with the background color in case of transparency.
  56822. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56823. */
  56824. alphaTest: boolean;
  56825. /**
  56826. * Define a mask to restrict the layer to only some of the scene cameras.
  56827. */
  56828. layerMask: number;
  56829. /**
  56830. * Define the list of render target the layer is visible into.
  56831. */
  56832. renderTargetTextures: RenderTargetTexture[];
  56833. /**
  56834. * Define if the layer is only used in renderTarget or if it also
  56835. * renders in the main frame buffer of the canvas.
  56836. */
  56837. renderOnlyInRenderTargetTextures: boolean;
  56838. private _scene;
  56839. private _vertexBuffers;
  56840. private _indexBuffer;
  56841. private _effect;
  56842. private _previousDefines;
  56843. /**
  56844. * An event triggered when the layer is disposed.
  56845. */
  56846. onDisposeObservable: Observable<Layer>;
  56847. private _onDisposeObserver;
  56848. /**
  56849. * Back compatibility with callback before the onDisposeObservable existed.
  56850. * The set callback will be triggered when the layer has been disposed.
  56851. */
  56852. set onDispose(callback: () => void);
  56853. /**
  56854. * An event triggered before rendering the scene
  56855. */
  56856. onBeforeRenderObservable: Observable<Layer>;
  56857. private _onBeforeRenderObserver;
  56858. /**
  56859. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56860. * The set callback will be triggered just before rendering the layer.
  56861. */
  56862. set onBeforeRender(callback: () => void);
  56863. /**
  56864. * An event triggered after rendering the scene
  56865. */
  56866. onAfterRenderObservable: Observable<Layer>;
  56867. private _onAfterRenderObserver;
  56868. /**
  56869. * Back compatibility with callback before the onAfterRenderObservable existed.
  56870. * The set callback will be triggered just after rendering the layer.
  56871. */
  56872. set onAfterRender(callback: () => void);
  56873. /**
  56874. * Instantiates a new layer.
  56875. * This represents a full screen 2d layer.
  56876. * This can be useful to display a picture in the background of your scene for instance.
  56877. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56878. * @param name Define the name of the layer in the scene
  56879. * @param imgUrl Define the url of the texture to display in the layer
  56880. * @param scene Define the scene the layer belongs to
  56881. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56882. * @param color Defines a color for the layer
  56883. */
  56884. constructor(
  56885. /**
  56886. * Define the name of the layer.
  56887. */
  56888. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56889. private _createIndexBuffer;
  56890. /** @hidden */
  56891. _rebuild(): void;
  56892. /**
  56893. * Renders the layer in the scene.
  56894. */
  56895. render(): void;
  56896. /**
  56897. * Disposes and releases the associated ressources.
  56898. */
  56899. dispose(): void;
  56900. }
  56901. }
  56902. declare module "babylonjs/Layers/index" {
  56903. export * from "babylonjs/Layers/effectLayer";
  56904. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56905. export * from "babylonjs/Layers/glowLayer";
  56906. export * from "babylonjs/Layers/highlightLayer";
  56907. export * from "babylonjs/Layers/layer";
  56908. export * from "babylonjs/Layers/layerSceneComponent";
  56909. }
  56910. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56911. /** @hidden */
  56912. export var lensFlarePixelShader: {
  56913. name: string;
  56914. shader: string;
  56915. };
  56916. }
  56917. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56918. /** @hidden */
  56919. export var lensFlareVertexShader: {
  56920. name: string;
  56921. shader: string;
  56922. };
  56923. }
  56924. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56925. import { Scene } from "babylonjs/scene";
  56926. import { Vector3 } from "babylonjs/Maths/math.vector";
  56927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56928. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56929. import "babylonjs/Shaders/lensFlare.fragment";
  56930. import "babylonjs/Shaders/lensFlare.vertex";
  56931. import { Viewport } from "babylonjs/Maths/math.viewport";
  56932. /**
  56933. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56934. * It is usually composed of several `lensFlare`.
  56935. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56936. */
  56937. export class LensFlareSystem {
  56938. /**
  56939. * Define the name of the lens flare system
  56940. */
  56941. name: string;
  56942. /**
  56943. * List of lens flares used in this system.
  56944. */
  56945. lensFlares: LensFlare[];
  56946. /**
  56947. * Define a limit from the border the lens flare can be visible.
  56948. */
  56949. borderLimit: number;
  56950. /**
  56951. * Define a viewport border we do not want to see the lens flare in.
  56952. */
  56953. viewportBorder: number;
  56954. /**
  56955. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56956. */
  56957. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56958. /**
  56959. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56960. */
  56961. layerMask: number;
  56962. /**
  56963. * Define the id of the lens flare system in the scene.
  56964. * (equal to name by default)
  56965. */
  56966. id: string;
  56967. private _scene;
  56968. private _emitter;
  56969. private _vertexBuffers;
  56970. private _indexBuffer;
  56971. private _effect;
  56972. private _positionX;
  56973. private _positionY;
  56974. private _isEnabled;
  56975. /** @hidden */
  56976. static _SceneComponentInitialization: (scene: Scene) => void;
  56977. /**
  56978. * Instantiates a lens flare system.
  56979. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56980. * It is usually composed of several `lensFlare`.
  56981. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56982. * @param name Define the name of the lens flare system in the scene
  56983. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56984. * @param scene Define the scene the lens flare system belongs to
  56985. */
  56986. constructor(
  56987. /**
  56988. * Define the name of the lens flare system
  56989. */
  56990. name: string, emitter: any, scene: Scene);
  56991. /**
  56992. * Define if the lens flare system is enabled.
  56993. */
  56994. get isEnabled(): boolean;
  56995. set isEnabled(value: boolean);
  56996. /**
  56997. * Get the scene the effects belongs to.
  56998. * @returns the scene holding the lens flare system
  56999. */
  57000. getScene(): Scene;
  57001. /**
  57002. * Get the emitter of the lens flare system.
  57003. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57004. * @returns the emitter of the lens flare system
  57005. */
  57006. getEmitter(): any;
  57007. /**
  57008. * Set the emitter of the lens flare system.
  57009. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57010. * @param newEmitter Define the new emitter of the system
  57011. */
  57012. setEmitter(newEmitter: any): void;
  57013. /**
  57014. * Get the lens flare system emitter position.
  57015. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57016. * @returns the position
  57017. */
  57018. getEmitterPosition(): Vector3;
  57019. /**
  57020. * @hidden
  57021. */
  57022. computeEffectivePosition(globalViewport: Viewport): boolean;
  57023. /** @hidden */
  57024. _isVisible(): boolean;
  57025. /**
  57026. * @hidden
  57027. */
  57028. render(): boolean;
  57029. /**
  57030. * Dispose and release the lens flare with its associated resources.
  57031. */
  57032. dispose(): void;
  57033. /**
  57034. * Parse a lens flare system from a JSON repressentation
  57035. * @param parsedLensFlareSystem Define the JSON to parse
  57036. * @param scene Define the scene the parsed system should be instantiated in
  57037. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57038. * @returns the parsed system
  57039. */
  57040. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57041. /**
  57042. * Serialize the current Lens Flare System into a JSON representation.
  57043. * @returns the serialized JSON
  57044. */
  57045. serialize(): any;
  57046. }
  57047. }
  57048. declare module "babylonjs/LensFlares/lensFlare" {
  57049. import { Nullable } from "babylonjs/types";
  57050. import { Color3 } from "babylonjs/Maths/math.color";
  57051. import { Texture } from "babylonjs/Materials/Textures/texture";
  57052. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57053. /**
  57054. * This represents one of the lens effect in a `lensFlareSystem`.
  57055. * It controls one of the indiviual texture used in the effect.
  57056. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57057. */
  57058. export class LensFlare {
  57059. /**
  57060. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57061. */
  57062. size: number;
  57063. /**
  57064. * 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.
  57065. */
  57066. position: number;
  57067. /**
  57068. * Define the lens color.
  57069. */
  57070. color: Color3;
  57071. /**
  57072. * Define the lens texture.
  57073. */
  57074. texture: Nullable<Texture>;
  57075. /**
  57076. * Define the alpha mode to render this particular lens.
  57077. */
  57078. alphaMode: number;
  57079. private _system;
  57080. /**
  57081. * Creates a new Lens Flare.
  57082. * This represents one of the lens effect in a `lensFlareSystem`.
  57083. * It controls one of the indiviual texture used in the effect.
  57084. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57085. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57086. * @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.
  57087. * @param color Define the lens color
  57088. * @param imgUrl Define the lens texture url
  57089. * @param system Define the `lensFlareSystem` this flare is part of
  57090. * @returns The newly created Lens Flare
  57091. */
  57092. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57093. /**
  57094. * Instantiates a new Lens Flare.
  57095. * This represents one of the lens effect in a `lensFlareSystem`.
  57096. * It controls one of the indiviual texture used in the effect.
  57097. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57098. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57099. * @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.
  57100. * @param color Define the lens color
  57101. * @param imgUrl Define the lens texture url
  57102. * @param system Define the `lensFlareSystem` this flare is part of
  57103. */
  57104. constructor(
  57105. /**
  57106. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57107. */
  57108. size: number,
  57109. /**
  57110. * 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.
  57111. */
  57112. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57113. /**
  57114. * Dispose and release the lens flare with its associated resources.
  57115. */
  57116. dispose(): void;
  57117. }
  57118. }
  57119. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  57120. import { Nullable } from "babylonjs/types";
  57121. import { Scene } from "babylonjs/scene";
  57122. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57123. import { AbstractScene } from "babylonjs/abstractScene";
  57124. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  57125. module "babylonjs/abstractScene" {
  57126. interface AbstractScene {
  57127. /**
  57128. * The list of lens flare system added to the scene
  57129. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57130. */
  57131. lensFlareSystems: Array<LensFlareSystem>;
  57132. /**
  57133. * Removes the given lens flare system from this scene.
  57134. * @param toRemove The lens flare system to remove
  57135. * @returns The index of the removed lens flare system
  57136. */
  57137. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57138. /**
  57139. * Adds the given lens flare system to this scene
  57140. * @param newLensFlareSystem The lens flare system to add
  57141. */
  57142. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57143. /**
  57144. * Gets a lens flare system using its name
  57145. * @param name defines the name to look for
  57146. * @returns the lens flare system or null if not found
  57147. */
  57148. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57149. /**
  57150. * Gets a lens flare system using its id
  57151. * @param id defines the id to look for
  57152. * @returns the lens flare system or null if not found
  57153. */
  57154. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57155. }
  57156. }
  57157. /**
  57158. * Defines the lens flare scene component responsible to manage any lens flares
  57159. * in a given scene.
  57160. */
  57161. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57162. /**
  57163. * The component name helpfull to identify the component in the list of scene components.
  57164. */
  57165. readonly name: string;
  57166. /**
  57167. * The scene the component belongs to.
  57168. */
  57169. scene: Scene;
  57170. /**
  57171. * Creates a new instance of the component for the given scene
  57172. * @param scene Defines the scene to register the component in
  57173. */
  57174. constructor(scene: Scene);
  57175. /**
  57176. * Registers the component in a given scene
  57177. */
  57178. register(): void;
  57179. /**
  57180. * Rebuilds the elements related to this component in case of
  57181. * context lost for instance.
  57182. */
  57183. rebuild(): void;
  57184. /**
  57185. * Adds all the elements from the container to the scene
  57186. * @param container the container holding the elements
  57187. */
  57188. addFromContainer(container: AbstractScene): void;
  57189. /**
  57190. * Removes all the elements in the container from the scene
  57191. * @param container contains the elements to remove
  57192. * @param dispose if the removed element should be disposed (default: false)
  57193. */
  57194. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57195. /**
  57196. * Serializes the component data to the specified json object
  57197. * @param serializationObject The object to serialize to
  57198. */
  57199. serialize(serializationObject: any): void;
  57200. /**
  57201. * Disposes the component and the associated ressources.
  57202. */
  57203. dispose(): void;
  57204. private _draw;
  57205. }
  57206. }
  57207. declare module "babylonjs/LensFlares/index" {
  57208. export * from "babylonjs/LensFlares/lensFlare";
  57209. export * from "babylonjs/LensFlares/lensFlareSystem";
  57210. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  57211. }
  57212. declare module "babylonjs/Shaders/depth.fragment" {
  57213. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  57214. /** @hidden */
  57215. export var depthPixelShader: {
  57216. name: string;
  57217. shader: string;
  57218. };
  57219. }
  57220. declare module "babylonjs/Shaders/depth.vertex" {
  57221. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57223. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57224. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57225. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57226. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57227. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57228. /** @hidden */
  57229. export var depthVertexShader: {
  57230. name: string;
  57231. shader: string;
  57232. };
  57233. }
  57234. declare module "babylonjs/Rendering/depthRenderer" {
  57235. import { Nullable } from "babylonjs/types";
  57236. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57237. import { Scene } from "babylonjs/scene";
  57238. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57239. import { Camera } from "babylonjs/Cameras/camera";
  57240. import "babylonjs/Shaders/depth.fragment";
  57241. import "babylonjs/Shaders/depth.vertex";
  57242. /**
  57243. * This represents a depth renderer in Babylon.
  57244. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57245. */
  57246. export class DepthRenderer {
  57247. private _scene;
  57248. private _depthMap;
  57249. private _effect;
  57250. private readonly _storeNonLinearDepth;
  57251. private readonly _clearColor;
  57252. /** Get if the depth renderer is using packed depth or not */
  57253. readonly isPacked: boolean;
  57254. private _cachedDefines;
  57255. private _camera;
  57256. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57257. enabled: boolean;
  57258. /**
  57259. * Specifiess that the depth renderer will only be used within
  57260. * the camera it is created for.
  57261. * This can help forcing its rendering during the camera processing.
  57262. */
  57263. useOnlyInActiveCamera: boolean;
  57264. /** @hidden */
  57265. static _SceneComponentInitialization: (scene: Scene) => void;
  57266. /**
  57267. * Instantiates a depth renderer
  57268. * @param scene The scene the renderer belongs to
  57269. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57270. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57271. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57272. */
  57273. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57274. /**
  57275. * Creates the depth rendering effect and checks if the effect is ready.
  57276. * @param subMesh The submesh to be used to render the depth map of
  57277. * @param useInstances If multiple world instances should be used
  57278. * @returns if the depth renderer is ready to render the depth map
  57279. */
  57280. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57281. /**
  57282. * Gets the texture which the depth map will be written to.
  57283. * @returns The depth map texture
  57284. */
  57285. getDepthMap(): RenderTargetTexture;
  57286. /**
  57287. * Disposes of the depth renderer.
  57288. */
  57289. dispose(): void;
  57290. }
  57291. }
  57292. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57293. /** @hidden */
  57294. export var minmaxReduxPixelShader: {
  57295. name: string;
  57296. shader: string;
  57297. };
  57298. }
  57299. declare module "babylonjs/Misc/minMaxReducer" {
  57300. import { Nullable } from "babylonjs/types";
  57301. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57302. import { Camera } from "babylonjs/Cameras/camera";
  57303. import { Observer } from "babylonjs/Misc/observable";
  57304. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57305. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57306. import { Observable } from "babylonjs/Misc/observable";
  57307. import "babylonjs/Shaders/minmaxRedux.fragment";
  57308. /**
  57309. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57310. * and maximum values from all values of the texture.
  57311. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57312. * The source values are read from the red channel of the texture.
  57313. */
  57314. export class MinMaxReducer {
  57315. /**
  57316. * Observable triggered when the computation has been performed
  57317. */
  57318. onAfterReductionPerformed: Observable<{
  57319. min: number;
  57320. max: number;
  57321. }>;
  57322. protected _camera: Camera;
  57323. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57324. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57325. protected _postProcessManager: PostProcessManager;
  57326. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57327. protected _forceFullscreenViewport: boolean;
  57328. /**
  57329. * Creates a min/max reducer
  57330. * @param camera The camera to use for the post processes
  57331. */
  57332. constructor(camera: Camera);
  57333. /**
  57334. * Gets the texture used to read the values from.
  57335. */
  57336. get sourceTexture(): Nullable<RenderTargetTexture>;
  57337. /**
  57338. * Sets the source texture to read the values from.
  57339. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57340. * because in such textures '1' value must not be taken into account to compute the maximum
  57341. * as this value is used to clear the texture.
  57342. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57343. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57344. * @param depthRedux Indicates if the texture is a depth texture or not
  57345. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57346. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57347. */
  57348. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57349. /**
  57350. * Defines the refresh rate of the computation.
  57351. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57352. */
  57353. get refreshRate(): number;
  57354. set refreshRate(value: number);
  57355. protected _activated: boolean;
  57356. /**
  57357. * Gets the activation status of the reducer
  57358. */
  57359. get activated(): boolean;
  57360. /**
  57361. * Activates the reduction computation.
  57362. * When activated, the observers registered in onAfterReductionPerformed are
  57363. * called after the compuation is performed
  57364. */
  57365. activate(): void;
  57366. /**
  57367. * Deactivates the reduction computation.
  57368. */
  57369. deactivate(): void;
  57370. /**
  57371. * Disposes the min/max reducer
  57372. * @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.
  57373. */
  57374. dispose(disposeAll?: boolean): void;
  57375. }
  57376. }
  57377. declare module "babylonjs/Misc/depthReducer" {
  57378. import { Nullable } from "babylonjs/types";
  57379. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57380. import { Camera } from "babylonjs/Cameras/camera";
  57381. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57382. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57383. /**
  57384. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57385. */
  57386. export class DepthReducer extends MinMaxReducer {
  57387. private _depthRenderer;
  57388. private _depthRendererId;
  57389. /**
  57390. * Gets the depth renderer used for the computation.
  57391. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57392. */
  57393. get depthRenderer(): Nullable<DepthRenderer>;
  57394. /**
  57395. * Creates a depth reducer
  57396. * @param camera The camera used to render the depth texture
  57397. */
  57398. constructor(camera: Camera);
  57399. /**
  57400. * Sets the depth renderer to use to generate the depth map
  57401. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57402. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57403. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57404. */
  57405. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57406. /** @hidden */
  57407. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57408. /**
  57409. * Activates the reduction computation.
  57410. * When activated, the observers registered in onAfterReductionPerformed are
  57411. * called after the compuation is performed
  57412. */
  57413. activate(): void;
  57414. /**
  57415. * Deactivates the reduction computation.
  57416. */
  57417. deactivate(): void;
  57418. /**
  57419. * Disposes the depth reducer
  57420. * @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.
  57421. */
  57422. dispose(disposeAll?: boolean): void;
  57423. }
  57424. }
  57425. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57426. import { Nullable } from "babylonjs/types";
  57427. import { Scene } from "babylonjs/scene";
  57428. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57429. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57431. import { Effect } from "babylonjs/Materials/effect";
  57432. import "babylonjs/Shaders/shadowMap.fragment";
  57433. import "babylonjs/Shaders/shadowMap.vertex";
  57434. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57435. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57436. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57437. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57438. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57439. /**
  57440. * A CSM implementation allowing casting shadows on large scenes.
  57441. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57442. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57443. */
  57444. export class CascadedShadowGenerator extends ShadowGenerator {
  57445. private static readonly frustumCornersNDCSpace;
  57446. /**
  57447. * Name of the CSM class
  57448. */
  57449. static CLASSNAME: string;
  57450. /**
  57451. * Defines the default number of cascades used by the CSM.
  57452. */
  57453. static readonly DEFAULT_CASCADES_COUNT: number;
  57454. /**
  57455. * Defines the minimum number of cascades used by the CSM.
  57456. */
  57457. static readonly MIN_CASCADES_COUNT: number;
  57458. /**
  57459. * Defines the maximum number of cascades used by the CSM.
  57460. */
  57461. static readonly MAX_CASCADES_COUNT: number;
  57462. protected _validateFilter(filter: number): number;
  57463. /**
  57464. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57465. */
  57466. penumbraDarkness: number;
  57467. private _numCascades;
  57468. /**
  57469. * Gets or set the number of cascades used by the CSM.
  57470. */
  57471. get numCascades(): number;
  57472. set numCascades(value: number);
  57473. /**
  57474. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57475. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57476. */
  57477. stabilizeCascades: boolean;
  57478. private _freezeShadowCastersBoundingInfo;
  57479. private _freezeShadowCastersBoundingInfoObservable;
  57480. /**
  57481. * Enables or disables the shadow casters bounding info computation.
  57482. * If your shadow casters don't move, you can disable this feature.
  57483. * If it is enabled, the bounding box computation is done every frame.
  57484. */
  57485. get freezeShadowCastersBoundingInfo(): boolean;
  57486. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57487. private _scbiMin;
  57488. private _scbiMax;
  57489. protected _computeShadowCastersBoundingInfo(): void;
  57490. protected _shadowCastersBoundingInfo: BoundingInfo;
  57491. /**
  57492. * Gets or sets the shadow casters bounding info.
  57493. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57494. * so that the system won't overwrite the bounds you provide
  57495. */
  57496. get shadowCastersBoundingInfo(): BoundingInfo;
  57497. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57498. protected _breaksAreDirty: boolean;
  57499. protected _minDistance: number;
  57500. protected _maxDistance: number;
  57501. /**
  57502. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57503. *
  57504. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57505. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57506. * @param min minimal distance for the breaks (default to 0.)
  57507. * @param max maximal distance for the breaks (default to 1.)
  57508. */
  57509. setMinMaxDistance(min: number, max: number): void;
  57510. /** Gets the minimal distance used in the cascade break computation */
  57511. get minDistance(): number;
  57512. /** Gets the maximal distance used in the cascade break computation */
  57513. get maxDistance(): number;
  57514. /**
  57515. * Gets the class name of that object
  57516. * @returns "CascadedShadowGenerator"
  57517. */
  57518. getClassName(): string;
  57519. private _cascadeMinExtents;
  57520. private _cascadeMaxExtents;
  57521. /**
  57522. * Gets a cascade minimum extents
  57523. * @param cascadeIndex index of the cascade
  57524. * @returns the minimum cascade extents
  57525. */
  57526. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57527. /**
  57528. * Gets a cascade maximum extents
  57529. * @param cascadeIndex index of the cascade
  57530. * @returns the maximum cascade extents
  57531. */
  57532. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57533. private _cascades;
  57534. private _currentLayer;
  57535. private _viewSpaceFrustumsZ;
  57536. private _viewMatrices;
  57537. private _projectionMatrices;
  57538. private _transformMatrices;
  57539. private _transformMatricesAsArray;
  57540. private _frustumLengths;
  57541. private _lightSizeUVCorrection;
  57542. private _depthCorrection;
  57543. private _frustumCornersWorldSpace;
  57544. private _frustumCenter;
  57545. private _shadowCameraPos;
  57546. private _shadowMaxZ;
  57547. /**
  57548. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57549. * It defaults to camera.maxZ
  57550. */
  57551. get shadowMaxZ(): number;
  57552. /**
  57553. * Sets the shadow max z distance.
  57554. */
  57555. set shadowMaxZ(value: number);
  57556. protected _debug: boolean;
  57557. /**
  57558. * Gets or sets the debug flag.
  57559. * When enabled, the cascades are materialized by different colors on the screen.
  57560. */
  57561. get debug(): boolean;
  57562. set debug(dbg: boolean);
  57563. private _depthClamp;
  57564. /**
  57565. * Gets or sets the depth clamping value.
  57566. *
  57567. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57568. * to account for the shadow casters far away.
  57569. *
  57570. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57571. */
  57572. get depthClamp(): boolean;
  57573. set depthClamp(value: boolean);
  57574. private _cascadeBlendPercentage;
  57575. /**
  57576. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57577. * It defaults to 0.1 (10% blending).
  57578. */
  57579. get cascadeBlendPercentage(): number;
  57580. set cascadeBlendPercentage(value: number);
  57581. private _lambda;
  57582. /**
  57583. * Gets or set the lambda parameter.
  57584. * This parameter is used to split the camera frustum and create the cascades.
  57585. * 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.
  57586. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57587. */
  57588. get lambda(): number;
  57589. set lambda(value: number);
  57590. /**
  57591. * Gets the view matrix corresponding to a given cascade
  57592. * @param cascadeNum cascade to retrieve the view matrix from
  57593. * @returns the cascade view matrix
  57594. */
  57595. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57596. /**
  57597. * Gets the projection matrix corresponding to a given cascade
  57598. * @param cascadeNum cascade to retrieve the projection matrix from
  57599. * @returns the cascade projection matrix
  57600. */
  57601. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57602. /**
  57603. * Gets the transformation matrix corresponding to a given cascade
  57604. * @param cascadeNum cascade to retrieve the transformation matrix from
  57605. * @returns the cascade transformation matrix
  57606. */
  57607. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57608. private _depthRenderer;
  57609. /**
  57610. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57611. *
  57612. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57613. *
  57614. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57615. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57616. * @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
  57617. */
  57618. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57619. private _depthReducer;
  57620. private _autoCalcDepthBounds;
  57621. /**
  57622. * Gets or sets the autoCalcDepthBounds property.
  57623. *
  57624. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57625. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57626. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57627. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57628. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57629. */
  57630. get autoCalcDepthBounds(): boolean;
  57631. set autoCalcDepthBounds(value: boolean);
  57632. /**
  57633. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57634. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57635. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57636. * for setting the refresh rate on the renderer yourself!
  57637. */
  57638. get autoCalcDepthBoundsRefreshRate(): number;
  57639. set autoCalcDepthBoundsRefreshRate(value: number);
  57640. /**
  57641. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57642. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57643. * you change the camera near/far planes!
  57644. */
  57645. splitFrustum(): void;
  57646. private _splitFrustum;
  57647. private _computeMatrices;
  57648. private _computeFrustumInWorldSpace;
  57649. private _computeCascadeFrustum;
  57650. /**
  57651. * Support test.
  57652. */
  57653. static get IsSupported(): boolean;
  57654. /** @hidden */
  57655. static _SceneComponentInitialization: (scene: Scene) => void;
  57656. /**
  57657. * Creates a Cascaded Shadow Generator object.
  57658. * A ShadowGenerator is the required tool to use the shadows.
  57659. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57660. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57661. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57662. * @param light The directional light object generating the shadows.
  57663. * @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.
  57664. */
  57665. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57666. protected _initializeGenerator(): void;
  57667. protected _createTargetRenderTexture(): void;
  57668. protected _initializeShadowMap(): void;
  57669. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  57670. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57671. /**
  57672. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57673. * @param defines Defines of the material we want to update
  57674. * @param lightIndex Index of the light in the enabled light list of the material
  57675. */
  57676. prepareDefines(defines: any, lightIndex: number): void;
  57677. /**
  57678. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57679. * defined in the generator but impacting the effect).
  57680. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57681. * @param effect The effect we are binfing the information for
  57682. */
  57683. bindShadowLight(lightIndex: string, effect: Effect): void;
  57684. /**
  57685. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57686. * (eq to view projection * shadow projection matrices)
  57687. * @returns The transform matrix used to create the shadow map
  57688. */
  57689. getTransformMatrix(): Matrix;
  57690. /**
  57691. * Disposes the ShadowGenerator.
  57692. * Returns nothing.
  57693. */
  57694. dispose(): void;
  57695. /**
  57696. * Serializes the shadow generator setup to a json object.
  57697. * @returns The serialized JSON object
  57698. */
  57699. serialize(): any;
  57700. /**
  57701. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57702. * @param parsedShadowGenerator The JSON object to parse
  57703. * @param scene The scene to create the shadow map for
  57704. * @returns The parsed shadow generator
  57705. */
  57706. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57707. }
  57708. }
  57709. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57710. import { Scene } from "babylonjs/scene";
  57711. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57712. import { AbstractScene } from "babylonjs/abstractScene";
  57713. /**
  57714. * Defines the shadow generator component responsible to manage any shadow generators
  57715. * in a given scene.
  57716. */
  57717. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57718. /**
  57719. * The component name helpfull to identify the component in the list of scene components.
  57720. */
  57721. readonly name: string;
  57722. /**
  57723. * The scene the component belongs to.
  57724. */
  57725. scene: Scene;
  57726. /**
  57727. * Creates a new instance of the component for the given scene
  57728. * @param scene Defines the scene to register the component in
  57729. */
  57730. constructor(scene: Scene);
  57731. /**
  57732. * Registers the component in a given scene
  57733. */
  57734. register(): void;
  57735. /**
  57736. * Rebuilds the elements related to this component in case of
  57737. * context lost for instance.
  57738. */
  57739. rebuild(): void;
  57740. /**
  57741. * Serializes the component data to the specified json object
  57742. * @param serializationObject The object to serialize to
  57743. */
  57744. serialize(serializationObject: any): void;
  57745. /**
  57746. * Adds all the elements from the container to the scene
  57747. * @param container the container holding the elements
  57748. */
  57749. addFromContainer(container: AbstractScene): void;
  57750. /**
  57751. * Removes all the elements in the container from the scene
  57752. * @param container contains the elements to remove
  57753. * @param dispose if the removed element should be disposed (default: false)
  57754. */
  57755. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57756. /**
  57757. * Rebuilds the elements related to this component in case of
  57758. * context lost for instance.
  57759. */
  57760. dispose(): void;
  57761. private _gatherRenderTargets;
  57762. }
  57763. }
  57764. declare module "babylonjs/Lights/Shadows/index" {
  57765. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57766. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57767. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57768. }
  57769. declare module "babylonjs/Lights/pointLight" {
  57770. import { Scene } from "babylonjs/scene";
  57771. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57773. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57774. import { Effect } from "babylonjs/Materials/effect";
  57775. /**
  57776. * A point light is a light defined by an unique point in world space.
  57777. * The light is emitted in every direction from this point.
  57778. * A good example of a point light is a standard light bulb.
  57779. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57780. */
  57781. export class PointLight extends ShadowLight {
  57782. private _shadowAngle;
  57783. /**
  57784. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57785. * This specifies what angle the shadow will use to be created.
  57786. *
  57787. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57788. */
  57789. get shadowAngle(): number;
  57790. /**
  57791. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57792. * This specifies what angle the shadow will use to be created.
  57793. *
  57794. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57795. */
  57796. set shadowAngle(value: number);
  57797. /**
  57798. * Gets the direction if it has been set.
  57799. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57800. */
  57801. get direction(): Vector3;
  57802. /**
  57803. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57804. */
  57805. set direction(value: Vector3);
  57806. /**
  57807. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57808. * A PointLight emits the light in every direction.
  57809. * It can cast shadows.
  57810. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57811. * ```javascript
  57812. * var pointLight = new PointLight("pl", camera.position, scene);
  57813. * ```
  57814. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57815. * @param name The light friendly name
  57816. * @param position The position of the point light in the scene
  57817. * @param scene The scene the lights belongs to
  57818. */
  57819. constructor(name: string, position: Vector3, scene: Scene);
  57820. /**
  57821. * Returns the string "PointLight"
  57822. * @returns the class name
  57823. */
  57824. getClassName(): string;
  57825. /**
  57826. * Returns the integer 0.
  57827. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57828. */
  57829. getTypeID(): number;
  57830. /**
  57831. * Specifies wether or not the shadowmap should be a cube texture.
  57832. * @returns true if the shadowmap needs to be a cube texture.
  57833. */
  57834. needCube(): boolean;
  57835. /**
  57836. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57837. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57838. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57839. */
  57840. getShadowDirection(faceIndex?: number): Vector3;
  57841. /**
  57842. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57843. * - fov = PI / 2
  57844. * - aspect ratio : 1.0
  57845. * - z-near and far equal to the active camera minZ and maxZ.
  57846. * Returns the PointLight.
  57847. */
  57848. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57849. protected _buildUniformLayout(): void;
  57850. /**
  57851. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57852. * @param effect The effect to update
  57853. * @param lightIndex The index of the light in the effect to update
  57854. * @returns The point light
  57855. */
  57856. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57857. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57858. /**
  57859. * Prepares the list of defines specific to the light type.
  57860. * @param defines the list of defines
  57861. * @param lightIndex defines the index of the light for the effect
  57862. */
  57863. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57864. }
  57865. }
  57866. declare module "babylonjs/Lights/index" {
  57867. export * from "babylonjs/Lights/light";
  57868. export * from "babylonjs/Lights/shadowLight";
  57869. export * from "babylonjs/Lights/Shadows/index";
  57870. export * from "babylonjs/Lights/directionalLight";
  57871. export * from "babylonjs/Lights/hemisphericLight";
  57872. export * from "babylonjs/Lights/pointLight";
  57873. export * from "babylonjs/Lights/spotLight";
  57874. }
  57875. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57876. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57877. /**
  57878. * Header information of HDR texture files.
  57879. */
  57880. export interface HDRInfo {
  57881. /**
  57882. * The height of the texture in pixels.
  57883. */
  57884. height: number;
  57885. /**
  57886. * The width of the texture in pixels.
  57887. */
  57888. width: number;
  57889. /**
  57890. * The index of the beginning of the data in the binary file.
  57891. */
  57892. dataPosition: number;
  57893. }
  57894. /**
  57895. * This groups tools to convert HDR texture to native colors array.
  57896. */
  57897. export class HDRTools {
  57898. private static Ldexp;
  57899. private static Rgbe2float;
  57900. private static readStringLine;
  57901. /**
  57902. * Reads header information from an RGBE texture stored in a native array.
  57903. * More information on this format are available here:
  57904. * https://en.wikipedia.org/wiki/RGBE_image_format
  57905. *
  57906. * @param uint8array The binary file stored in native array.
  57907. * @return The header information.
  57908. */
  57909. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57910. /**
  57911. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57912. * This RGBE texture needs to store the information as a panorama.
  57913. *
  57914. * More information on this format are available here:
  57915. * https://en.wikipedia.org/wiki/RGBE_image_format
  57916. *
  57917. * @param buffer The binary file stored in an array buffer.
  57918. * @param size The expected size of the extracted cubemap.
  57919. * @return The Cube Map information.
  57920. */
  57921. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57922. /**
  57923. * Returns the pixels data extracted from an RGBE texture.
  57924. * This pixels will be stored left to right up to down in the R G B order in one array.
  57925. *
  57926. * More information on this format are available here:
  57927. * https://en.wikipedia.org/wiki/RGBE_image_format
  57928. *
  57929. * @param uint8array The binary file stored in an array buffer.
  57930. * @param hdrInfo The header information of the file.
  57931. * @return The pixels data in RGB right to left up to down order.
  57932. */
  57933. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57934. private static RGBE_ReadPixels_RLE;
  57935. }
  57936. }
  57937. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57938. import { Nullable } from "babylonjs/types";
  57939. import { Scene } from "babylonjs/scene";
  57940. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57941. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57942. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57943. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57944. /**
  57945. * This represents a texture coming from an HDR input.
  57946. *
  57947. * The only supported format is currently panorama picture stored in RGBE format.
  57948. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57949. */
  57950. export class HDRCubeTexture extends BaseTexture {
  57951. private static _facesMapping;
  57952. private _generateHarmonics;
  57953. private _noMipmap;
  57954. private _textureMatrix;
  57955. private _size;
  57956. private _onLoad;
  57957. private _onError;
  57958. /**
  57959. * The texture URL.
  57960. */
  57961. url: string;
  57962. /**
  57963. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57964. */
  57965. coordinatesMode: number;
  57966. protected _isBlocking: boolean;
  57967. /**
  57968. * Sets wether or not the texture is blocking during loading.
  57969. */
  57970. set isBlocking(value: boolean);
  57971. /**
  57972. * Gets wether or not the texture is blocking during loading.
  57973. */
  57974. get isBlocking(): boolean;
  57975. protected _rotationY: number;
  57976. /**
  57977. * Sets texture matrix rotation angle around Y axis in radians.
  57978. */
  57979. set rotationY(value: number);
  57980. /**
  57981. * Gets texture matrix rotation angle around Y axis radians.
  57982. */
  57983. get rotationY(): number;
  57984. /**
  57985. * Gets or sets the center of the bounding box associated with the cube texture
  57986. * It must define where the camera used to render the texture was set
  57987. */
  57988. boundingBoxPosition: Vector3;
  57989. private _boundingBoxSize;
  57990. /**
  57991. * Gets or sets the size of the bounding box associated with the cube texture
  57992. * When defined, the cubemap will switch to local mode
  57993. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57994. * @example https://www.babylonjs-playground.com/#RNASML
  57995. */
  57996. set boundingBoxSize(value: Vector3);
  57997. get boundingBoxSize(): Vector3;
  57998. /**
  57999. * Instantiates an HDRTexture from the following parameters.
  58000. *
  58001. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58002. * @param scene The scene the texture will be used in
  58003. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58004. * @param noMipmap Forces to not generate the mipmap if true
  58005. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58006. * @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)
  58007. * @param reserved Reserved flag for internal use.
  58008. */
  58009. 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>);
  58010. /**
  58011. * Get the current class name of the texture useful for serialization or dynamic coding.
  58012. * @returns "HDRCubeTexture"
  58013. */
  58014. getClassName(): string;
  58015. /**
  58016. * Occurs when the file is raw .hdr file.
  58017. */
  58018. private loadTexture;
  58019. clone(): HDRCubeTexture;
  58020. delayLoad(): void;
  58021. /**
  58022. * Get the texture reflection matrix used to rotate/transform the reflection.
  58023. * @returns the reflection matrix
  58024. */
  58025. getReflectionTextureMatrix(): Matrix;
  58026. /**
  58027. * Set the texture reflection matrix used to rotate/transform the reflection.
  58028. * @param value Define the reflection matrix to set
  58029. */
  58030. setReflectionTextureMatrix(value: Matrix): void;
  58031. /**
  58032. * Parses a JSON representation of an HDR Texture in order to create the texture
  58033. * @param parsedTexture Define the JSON representation
  58034. * @param scene Define the scene the texture should be created in
  58035. * @param rootUrl Define the root url in case we need to load relative dependencies
  58036. * @returns the newly created texture after parsing
  58037. */
  58038. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58039. serialize(): any;
  58040. }
  58041. }
  58042. declare module "babylonjs/Physics/physicsEngine" {
  58043. import { Nullable } from "babylonjs/types";
  58044. import { Vector3 } from "babylonjs/Maths/math.vector";
  58045. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58046. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  58047. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  58048. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58049. /**
  58050. * Class used to control physics engine
  58051. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58052. */
  58053. export class PhysicsEngine implements IPhysicsEngine {
  58054. private _physicsPlugin;
  58055. /**
  58056. * Global value used to control the smallest number supported by the simulation
  58057. */
  58058. static Epsilon: number;
  58059. private _impostors;
  58060. private _joints;
  58061. private _subTimeStep;
  58062. /**
  58063. * Gets the gravity vector used by the simulation
  58064. */
  58065. gravity: Vector3;
  58066. /**
  58067. * Factory used to create the default physics plugin.
  58068. * @returns The default physics plugin
  58069. */
  58070. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58071. /**
  58072. * Creates a new Physics Engine
  58073. * @param gravity defines the gravity vector used by the simulation
  58074. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58075. */
  58076. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58077. /**
  58078. * Sets the gravity vector used by the simulation
  58079. * @param gravity defines the gravity vector to use
  58080. */
  58081. setGravity(gravity: Vector3): void;
  58082. /**
  58083. * Set the time step of the physics engine.
  58084. * Default is 1/60.
  58085. * To slow it down, enter 1/600 for example.
  58086. * To speed it up, 1/30
  58087. * @param newTimeStep defines the new timestep to apply to this world.
  58088. */
  58089. setTimeStep(newTimeStep?: number): void;
  58090. /**
  58091. * Get the time step of the physics engine.
  58092. * @returns the current time step
  58093. */
  58094. getTimeStep(): number;
  58095. /**
  58096. * Set the sub time step of the physics engine.
  58097. * Default is 0 meaning there is no sub steps
  58098. * To increase physics resolution precision, set a small value (like 1 ms)
  58099. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58100. */
  58101. setSubTimeStep(subTimeStep?: number): void;
  58102. /**
  58103. * Get the sub time step of the physics engine.
  58104. * @returns the current sub time step
  58105. */
  58106. getSubTimeStep(): number;
  58107. /**
  58108. * Release all resources
  58109. */
  58110. dispose(): void;
  58111. /**
  58112. * Gets the name of the current physics plugin
  58113. * @returns the name of the plugin
  58114. */
  58115. getPhysicsPluginName(): string;
  58116. /**
  58117. * Adding a new impostor for the impostor tracking.
  58118. * This will be done by the impostor itself.
  58119. * @param impostor the impostor to add
  58120. */
  58121. addImpostor(impostor: PhysicsImpostor): void;
  58122. /**
  58123. * Remove an impostor from the engine.
  58124. * This impostor and its mesh will not longer be updated by the physics engine.
  58125. * @param impostor the impostor to remove
  58126. */
  58127. removeImpostor(impostor: PhysicsImpostor): void;
  58128. /**
  58129. * Add a joint to the physics engine
  58130. * @param mainImpostor defines the main impostor to which the joint is added.
  58131. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58132. * @param joint defines the joint that will connect both impostors.
  58133. */
  58134. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58135. /**
  58136. * Removes a joint from the simulation
  58137. * @param mainImpostor defines the impostor used with the joint
  58138. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58139. * @param joint defines the joint to remove
  58140. */
  58141. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58142. /**
  58143. * Called by the scene. No need to call it.
  58144. * @param delta defines the timespam between frames
  58145. */
  58146. _step(delta: number): void;
  58147. /**
  58148. * Gets the current plugin used to run the simulation
  58149. * @returns current plugin
  58150. */
  58151. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58152. /**
  58153. * Gets the list of physic impostors
  58154. * @returns an array of PhysicsImpostor
  58155. */
  58156. getImpostors(): Array<PhysicsImpostor>;
  58157. /**
  58158. * Gets the impostor for a physics enabled object
  58159. * @param object defines the object impersonated by the impostor
  58160. * @returns the PhysicsImpostor or null if not found
  58161. */
  58162. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58163. /**
  58164. * Gets the impostor for a physics body object
  58165. * @param body defines physics body used by the impostor
  58166. * @returns the PhysicsImpostor or null if not found
  58167. */
  58168. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58169. /**
  58170. * Does a raycast in the physics world
  58171. * @param from when should the ray start?
  58172. * @param to when should the ray end?
  58173. * @returns PhysicsRaycastResult
  58174. */
  58175. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58176. }
  58177. }
  58178. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  58179. import { Nullable } from "babylonjs/types";
  58180. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58182. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58183. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58184. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58185. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58186. /** @hidden */
  58187. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58188. private _useDeltaForWorldStep;
  58189. world: any;
  58190. name: string;
  58191. private _physicsMaterials;
  58192. private _fixedTimeStep;
  58193. private _cannonRaycastResult;
  58194. private _raycastResult;
  58195. private _physicsBodysToRemoveAfterStep;
  58196. BJSCANNON: any;
  58197. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58198. setGravity(gravity: Vector3): void;
  58199. setTimeStep(timeStep: number): void;
  58200. getTimeStep(): number;
  58201. executeStep(delta: number): void;
  58202. private _removeMarkedPhysicsBodiesFromWorld;
  58203. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58204. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58205. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58206. private _processChildMeshes;
  58207. removePhysicsBody(impostor: PhysicsImpostor): void;
  58208. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58209. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58210. private _addMaterial;
  58211. private _checkWithEpsilon;
  58212. private _createShape;
  58213. private _createHeightmap;
  58214. private _minus90X;
  58215. private _plus90X;
  58216. private _tmpPosition;
  58217. private _tmpDeltaPosition;
  58218. private _tmpUnityRotation;
  58219. private _updatePhysicsBodyTransformation;
  58220. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58221. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58222. isSupported(): boolean;
  58223. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58224. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58225. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58226. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58227. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58228. getBodyMass(impostor: PhysicsImpostor): number;
  58229. getBodyFriction(impostor: PhysicsImpostor): number;
  58230. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58231. getBodyRestitution(impostor: PhysicsImpostor): number;
  58232. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58233. sleepBody(impostor: PhysicsImpostor): void;
  58234. wakeUpBody(impostor: PhysicsImpostor): void;
  58235. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58236. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58237. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58238. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58239. getRadius(impostor: PhysicsImpostor): number;
  58240. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58241. dispose(): void;
  58242. private _extendNamespace;
  58243. /**
  58244. * Does a raycast in the physics world
  58245. * @param from when should the ray start?
  58246. * @param to when should the ray end?
  58247. * @returns PhysicsRaycastResult
  58248. */
  58249. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58250. }
  58251. }
  58252. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  58253. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58254. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58255. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58257. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  58258. import { Nullable } from "babylonjs/types";
  58259. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58260. /** @hidden */
  58261. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58262. private _useDeltaForWorldStep;
  58263. world: any;
  58264. name: string;
  58265. BJSOIMO: any;
  58266. private _raycastResult;
  58267. private _fixedTimeStep;
  58268. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58269. setGravity(gravity: Vector3): void;
  58270. setTimeStep(timeStep: number): void;
  58271. getTimeStep(): number;
  58272. private _tmpImpostorsArray;
  58273. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58274. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58275. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58276. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58277. private _tmpPositionVector;
  58278. removePhysicsBody(impostor: PhysicsImpostor): void;
  58279. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58280. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58281. isSupported(): boolean;
  58282. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58283. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58284. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58285. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58286. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58287. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58288. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58289. getBodyMass(impostor: PhysicsImpostor): number;
  58290. getBodyFriction(impostor: PhysicsImpostor): number;
  58291. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58292. getBodyRestitution(impostor: PhysicsImpostor): number;
  58293. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58294. sleepBody(impostor: PhysicsImpostor): void;
  58295. wakeUpBody(impostor: PhysicsImpostor): void;
  58296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58297. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58298. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58299. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58300. getRadius(impostor: PhysicsImpostor): number;
  58301. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58302. dispose(): void;
  58303. /**
  58304. * Does a raycast in the physics world
  58305. * @param from when should the ray start?
  58306. * @param to when should the ray end?
  58307. * @returns PhysicsRaycastResult
  58308. */
  58309. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58310. }
  58311. }
  58312. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58313. import { Nullable } from "babylonjs/types";
  58314. import { Scene } from "babylonjs/scene";
  58315. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58316. import { Color4 } from "babylonjs/Maths/math.color";
  58317. import { Mesh } from "babylonjs/Meshes/mesh";
  58318. /**
  58319. * Class containing static functions to help procedurally build meshes
  58320. */
  58321. export class RibbonBuilder {
  58322. /**
  58323. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58324. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58325. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58326. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58327. * * 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
  58328. * * 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
  58329. * * 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
  58330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58333. * * 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
  58334. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58335. * * 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
  58336. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58338. * @param name defines the name of the mesh
  58339. * @param options defines the options used to create the mesh
  58340. * @param scene defines the hosting scene
  58341. * @returns the ribbon mesh
  58342. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58343. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58344. */
  58345. static CreateRibbon(name: string, options: {
  58346. pathArray: Vector3[][];
  58347. closeArray?: boolean;
  58348. closePath?: boolean;
  58349. offset?: number;
  58350. updatable?: boolean;
  58351. sideOrientation?: number;
  58352. frontUVs?: Vector4;
  58353. backUVs?: Vector4;
  58354. instance?: Mesh;
  58355. invertUV?: boolean;
  58356. uvs?: Vector2[];
  58357. colors?: Color4[];
  58358. }, scene?: Nullable<Scene>): Mesh;
  58359. }
  58360. }
  58361. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58362. import { Nullable } from "babylonjs/types";
  58363. import { Scene } from "babylonjs/scene";
  58364. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58365. import { Mesh } from "babylonjs/Meshes/mesh";
  58366. /**
  58367. * Class containing static functions to help procedurally build meshes
  58368. */
  58369. export class ShapeBuilder {
  58370. /**
  58371. * 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.
  58372. * * 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.
  58373. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58374. * * 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.
  58375. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58376. * * 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
  58377. * * 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
  58378. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58381. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58383. * @param name defines the name of the mesh
  58384. * @param options defines the options used to create the mesh
  58385. * @param scene defines the hosting scene
  58386. * @returns the extruded shape mesh
  58387. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58389. */
  58390. static ExtrudeShape(name: string, options: {
  58391. shape: Vector3[];
  58392. path: Vector3[];
  58393. scale?: number;
  58394. rotation?: number;
  58395. cap?: number;
  58396. updatable?: boolean;
  58397. sideOrientation?: number;
  58398. frontUVs?: Vector4;
  58399. backUVs?: Vector4;
  58400. instance?: Mesh;
  58401. invertUV?: boolean;
  58402. }, scene?: Nullable<Scene>): Mesh;
  58403. /**
  58404. * Creates an custom extruded shape mesh.
  58405. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58406. * * 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.
  58407. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58408. * * 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
  58409. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58410. * * 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
  58411. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58412. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58413. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58414. * * 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
  58415. * * 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
  58416. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58421. * @param name defines the name of the mesh
  58422. * @param options defines the options used to create the mesh
  58423. * @param scene defines the hosting scene
  58424. * @returns the custom extruded shape mesh
  58425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58426. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58428. */
  58429. static ExtrudeShapeCustom(name: string, options: {
  58430. shape: Vector3[];
  58431. path: Vector3[];
  58432. scaleFunction?: any;
  58433. rotationFunction?: any;
  58434. ribbonCloseArray?: boolean;
  58435. ribbonClosePath?: boolean;
  58436. cap?: number;
  58437. updatable?: boolean;
  58438. sideOrientation?: number;
  58439. frontUVs?: Vector4;
  58440. backUVs?: Vector4;
  58441. instance?: Mesh;
  58442. invertUV?: boolean;
  58443. }, scene?: Nullable<Scene>): Mesh;
  58444. private static _ExtrudeShapeGeneric;
  58445. }
  58446. }
  58447. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58448. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58449. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58450. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58451. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58452. import { Nullable } from "babylonjs/types";
  58453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58454. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58455. /**
  58456. * AmmoJS Physics plugin
  58457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58458. * @see https://github.com/kripken/ammo.js/
  58459. */
  58460. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58461. private _useDeltaForWorldStep;
  58462. /**
  58463. * Reference to the Ammo library
  58464. */
  58465. bjsAMMO: any;
  58466. /**
  58467. * Created ammoJS world which physics bodies are added to
  58468. */
  58469. world: any;
  58470. /**
  58471. * Name of the plugin
  58472. */
  58473. name: string;
  58474. private _timeStep;
  58475. private _fixedTimeStep;
  58476. private _maxSteps;
  58477. private _tmpQuaternion;
  58478. private _tmpAmmoTransform;
  58479. private _tmpAmmoQuaternion;
  58480. private _tmpAmmoConcreteContactResultCallback;
  58481. private _collisionConfiguration;
  58482. private _dispatcher;
  58483. private _overlappingPairCache;
  58484. private _solver;
  58485. private _softBodySolver;
  58486. private _tmpAmmoVectorA;
  58487. private _tmpAmmoVectorB;
  58488. private _tmpAmmoVectorC;
  58489. private _tmpAmmoVectorD;
  58490. private _tmpContactCallbackResult;
  58491. private _tmpAmmoVectorRCA;
  58492. private _tmpAmmoVectorRCB;
  58493. private _raycastResult;
  58494. private static readonly DISABLE_COLLISION_FLAG;
  58495. private static readonly KINEMATIC_FLAG;
  58496. private static readonly DISABLE_DEACTIVATION_FLAG;
  58497. /**
  58498. * Initializes the ammoJS plugin
  58499. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58500. * @param ammoInjection can be used to inject your own ammo reference
  58501. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58502. */
  58503. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58504. /**
  58505. * Sets the gravity of the physics world (m/(s^2))
  58506. * @param gravity Gravity to set
  58507. */
  58508. setGravity(gravity: Vector3): void;
  58509. /**
  58510. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58511. * @param timeStep timestep to use in seconds
  58512. */
  58513. setTimeStep(timeStep: number): void;
  58514. /**
  58515. * 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)
  58516. * @param fixedTimeStep fixedTimeStep to use in seconds
  58517. */
  58518. setFixedTimeStep(fixedTimeStep: number): void;
  58519. /**
  58520. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58521. * @param maxSteps the maximum number of steps by the physics engine per frame
  58522. */
  58523. setMaxSteps(maxSteps: number): void;
  58524. /**
  58525. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58526. * @returns the current timestep in seconds
  58527. */
  58528. getTimeStep(): number;
  58529. /**
  58530. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58531. */
  58532. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58533. private _isImpostorInContact;
  58534. private _isImpostorPairInContact;
  58535. private _stepSimulation;
  58536. /**
  58537. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58538. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58539. * After the step the babylon meshes are set to the position of the physics imposters
  58540. * @param delta amount of time to step forward
  58541. * @param impostors array of imposters to update before/after the step
  58542. */
  58543. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58544. /**
  58545. * Update babylon mesh to match physics world object
  58546. * @param impostor imposter to match
  58547. */
  58548. private _afterSoftStep;
  58549. /**
  58550. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58551. * @param impostor imposter to match
  58552. */
  58553. private _ropeStep;
  58554. /**
  58555. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58556. * @param impostor imposter to match
  58557. */
  58558. private _softbodyOrClothStep;
  58559. private _tmpMatrix;
  58560. /**
  58561. * Applies an impulse on the imposter
  58562. * @param impostor imposter to apply impulse to
  58563. * @param force amount of force to be applied to the imposter
  58564. * @param contactPoint the location to apply the impulse on the imposter
  58565. */
  58566. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58567. /**
  58568. * Applies a force on the imposter
  58569. * @param impostor imposter to apply force
  58570. * @param force amount of force to be applied to the imposter
  58571. * @param contactPoint the location to apply the force on the imposter
  58572. */
  58573. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58574. /**
  58575. * Creates a physics body using the plugin
  58576. * @param impostor the imposter to create the physics body on
  58577. */
  58578. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58579. /**
  58580. * Removes the physics body from the imposter and disposes of the body's memory
  58581. * @param impostor imposter to remove the physics body from
  58582. */
  58583. removePhysicsBody(impostor: PhysicsImpostor): void;
  58584. /**
  58585. * Generates a joint
  58586. * @param impostorJoint the imposter joint to create the joint with
  58587. */
  58588. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58589. /**
  58590. * Removes a joint
  58591. * @param impostorJoint the imposter joint to remove the joint from
  58592. */
  58593. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58594. private _addMeshVerts;
  58595. /**
  58596. * Initialise the soft body vertices to match its object's (mesh) vertices
  58597. * Softbody vertices (nodes) are in world space and to match this
  58598. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58599. * @param impostor to create the softbody for
  58600. */
  58601. private _softVertexData;
  58602. /**
  58603. * Create an impostor's soft body
  58604. * @param impostor to create the softbody for
  58605. */
  58606. private _createSoftbody;
  58607. /**
  58608. * Create cloth for an impostor
  58609. * @param impostor to create the softbody for
  58610. */
  58611. private _createCloth;
  58612. /**
  58613. * Create rope for an impostor
  58614. * @param impostor to create the softbody for
  58615. */
  58616. private _createRope;
  58617. /**
  58618. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58619. * @param impostor to create the custom physics shape for
  58620. */
  58621. private _createCustom;
  58622. private _addHullVerts;
  58623. private _createShape;
  58624. /**
  58625. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58626. * @param impostor imposter containing the physics body and babylon object
  58627. */
  58628. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58629. /**
  58630. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58631. * @param impostor imposter containing the physics body and babylon object
  58632. * @param newPosition new position
  58633. * @param newRotation new rotation
  58634. */
  58635. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58636. /**
  58637. * If this plugin is supported
  58638. * @returns true if its supported
  58639. */
  58640. isSupported(): boolean;
  58641. /**
  58642. * Sets the linear velocity of the physics body
  58643. * @param impostor imposter to set the velocity on
  58644. * @param velocity velocity to set
  58645. */
  58646. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58647. /**
  58648. * Sets the angular velocity of the physics body
  58649. * @param impostor imposter to set the velocity on
  58650. * @param velocity velocity to set
  58651. */
  58652. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58653. /**
  58654. * gets the linear velocity
  58655. * @param impostor imposter to get linear velocity from
  58656. * @returns linear velocity
  58657. */
  58658. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58659. /**
  58660. * gets the angular velocity
  58661. * @param impostor imposter to get angular velocity from
  58662. * @returns angular velocity
  58663. */
  58664. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58665. /**
  58666. * Sets the mass of physics body
  58667. * @param impostor imposter to set the mass on
  58668. * @param mass mass to set
  58669. */
  58670. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58671. /**
  58672. * Gets the mass of the physics body
  58673. * @param impostor imposter to get the mass from
  58674. * @returns mass
  58675. */
  58676. getBodyMass(impostor: PhysicsImpostor): number;
  58677. /**
  58678. * Gets friction of the impostor
  58679. * @param impostor impostor to get friction from
  58680. * @returns friction value
  58681. */
  58682. getBodyFriction(impostor: PhysicsImpostor): number;
  58683. /**
  58684. * Sets friction of the impostor
  58685. * @param impostor impostor to set friction on
  58686. * @param friction friction value
  58687. */
  58688. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58689. /**
  58690. * Gets restitution of the impostor
  58691. * @param impostor impostor to get restitution from
  58692. * @returns restitution value
  58693. */
  58694. getBodyRestitution(impostor: PhysicsImpostor): number;
  58695. /**
  58696. * Sets resitution of the impostor
  58697. * @param impostor impostor to set resitution on
  58698. * @param restitution resitution value
  58699. */
  58700. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58701. /**
  58702. * Gets pressure inside the impostor
  58703. * @param impostor impostor to get pressure from
  58704. * @returns pressure value
  58705. */
  58706. getBodyPressure(impostor: PhysicsImpostor): number;
  58707. /**
  58708. * Sets pressure inside a soft body impostor
  58709. * Cloth and rope must remain 0 pressure
  58710. * @param impostor impostor to set pressure on
  58711. * @param pressure pressure value
  58712. */
  58713. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58714. /**
  58715. * Gets stiffness of the impostor
  58716. * @param impostor impostor to get stiffness from
  58717. * @returns pressure value
  58718. */
  58719. getBodyStiffness(impostor: PhysicsImpostor): number;
  58720. /**
  58721. * Sets stiffness of the impostor
  58722. * @param impostor impostor to set stiffness on
  58723. * @param stiffness stiffness value from 0 to 1
  58724. */
  58725. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58726. /**
  58727. * Gets velocityIterations of the impostor
  58728. * @param impostor impostor to get velocity iterations from
  58729. * @returns velocityIterations value
  58730. */
  58731. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58732. /**
  58733. * Sets velocityIterations of the impostor
  58734. * @param impostor impostor to set velocity iterations on
  58735. * @param velocityIterations velocityIterations value
  58736. */
  58737. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58738. /**
  58739. * Gets positionIterations of the impostor
  58740. * @param impostor impostor to get position iterations from
  58741. * @returns positionIterations value
  58742. */
  58743. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58744. /**
  58745. * Sets positionIterations of the impostor
  58746. * @param impostor impostor to set position on
  58747. * @param positionIterations positionIterations value
  58748. */
  58749. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58750. /**
  58751. * Append an anchor to a cloth object
  58752. * @param impostor is the cloth impostor to add anchor to
  58753. * @param otherImpostor is the rigid impostor to anchor to
  58754. * @param width ratio across width from 0 to 1
  58755. * @param height ratio up height from 0 to 1
  58756. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58757. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58758. */
  58759. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58760. /**
  58761. * Append an hook to a rope object
  58762. * @param impostor is the rope impostor to add hook to
  58763. * @param otherImpostor is the rigid impostor to hook to
  58764. * @param length ratio along the rope from 0 to 1
  58765. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58766. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58767. */
  58768. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58769. /**
  58770. * Sleeps the physics body and stops it from being active
  58771. * @param impostor impostor to sleep
  58772. */
  58773. sleepBody(impostor: PhysicsImpostor): void;
  58774. /**
  58775. * Activates the physics body
  58776. * @param impostor impostor to activate
  58777. */
  58778. wakeUpBody(impostor: PhysicsImpostor): void;
  58779. /**
  58780. * Updates the distance parameters of the joint
  58781. * @param joint joint to update
  58782. * @param maxDistance maximum distance of the joint
  58783. * @param minDistance minimum distance of the joint
  58784. */
  58785. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58786. /**
  58787. * Sets a motor on the joint
  58788. * @param joint joint to set motor on
  58789. * @param speed speed of the motor
  58790. * @param maxForce maximum force of the motor
  58791. * @param motorIndex index of the motor
  58792. */
  58793. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58794. /**
  58795. * Sets the motors limit
  58796. * @param joint joint to set limit on
  58797. * @param upperLimit upper limit
  58798. * @param lowerLimit lower limit
  58799. */
  58800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58801. /**
  58802. * Syncs the position and rotation of a mesh with the impostor
  58803. * @param mesh mesh to sync
  58804. * @param impostor impostor to update the mesh with
  58805. */
  58806. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58807. /**
  58808. * Gets the radius of the impostor
  58809. * @param impostor impostor to get radius from
  58810. * @returns the radius
  58811. */
  58812. getRadius(impostor: PhysicsImpostor): number;
  58813. /**
  58814. * Gets the box size of the impostor
  58815. * @param impostor impostor to get box size from
  58816. * @param result the resulting box size
  58817. */
  58818. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58819. /**
  58820. * Disposes of the impostor
  58821. */
  58822. dispose(): void;
  58823. /**
  58824. * Does a raycast in the physics world
  58825. * @param from when should the ray start?
  58826. * @param to when should the ray end?
  58827. * @returns PhysicsRaycastResult
  58828. */
  58829. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58830. }
  58831. }
  58832. declare module "babylonjs/Probes/reflectionProbe" {
  58833. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58834. import { Vector3 } from "babylonjs/Maths/math.vector";
  58835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58836. import { Nullable } from "babylonjs/types";
  58837. import { Scene } from "babylonjs/scene";
  58838. module "babylonjs/abstractScene" {
  58839. interface AbstractScene {
  58840. /**
  58841. * The list of reflection probes added to the scene
  58842. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58843. */
  58844. reflectionProbes: Array<ReflectionProbe>;
  58845. /**
  58846. * Removes the given reflection probe from this scene.
  58847. * @param toRemove The reflection probe to remove
  58848. * @returns The index of the removed reflection probe
  58849. */
  58850. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58851. /**
  58852. * Adds the given reflection probe to this scene.
  58853. * @param newReflectionProbe The reflection probe to add
  58854. */
  58855. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58856. }
  58857. }
  58858. /**
  58859. * Class used to generate realtime reflection / refraction cube textures
  58860. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58861. */
  58862. export class ReflectionProbe {
  58863. /** defines the name of the probe */
  58864. name: string;
  58865. private _scene;
  58866. private _renderTargetTexture;
  58867. private _projectionMatrix;
  58868. private _viewMatrix;
  58869. private _target;
  58870. private _add;
  58871. private _attachedMesh;
  58872. private _invertYAxis;
  58873. /** Gets or sets probe position (center of the cube map) */
  58874. position: Vector3;
  58875. /**
  58876. * Creates a new reflection probe
  58877. * @param name defines the name of the probe
  58878. * @param size defines the texture resolution (for each face)
  58879. * @param scene defines the hosting scene
  58880. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58881. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58882. */
  58883. constructor(
  58884. /** defines the name of the probe */
  58885. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58886. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58887. get samples(): number;
  58888. set samples(value: number);
  58889. /** Gets or sets the refresh rate to use (on every frame by default) */
  58890. get refreshRate(): number;
  58891. set refreshRate(value: number);
  58892. /**
  58893. * Gets the hosting scene
  58894. * @returns a Scene
  58895. */
  58896. getScene(): Scene;
  58897. /** Gets the internal CubeTexture used to render to */
  58898. get cubeTexture(): RenderTargetTexture;
  58899. /** Gets the list of meshes to render */
  58900. get renderList(): Nullable<AbstractMesh[]>;
  58901. /**
  58902. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58903. * @param mesh defines the mesh to attach to
  58904. */
  58905. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58906. /**
  58907. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58908. * @param renderingGroupId The rendering group id corresponding to its index
  58909. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58910. */
  58911. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58912. /**
  58913. * Clean all associated resources
  58914. */
  58915. dispose(): void;
  58916. /**
  58917. * Converts the reflection probe information to a readable string for debug purpose.
  58918. * @param fullDetails Supports for multiple levels of logging within scene loading
  58919. * @returns the human readable reflection probe info
  58920. */
  58921. toString(fullDetails?: boolean): string;
  58922. /**
  58923. * Get the class name of the relfection probe.
  58924. * @returns "ReflectionProbe"
  58925. */
  58926. getClassName(): string;
  58927. /**
  58928. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58929. * @returns The JSON representation of the texture
  58930. */
  58931. serialize(): any;
  58932. /**
  58933. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58934. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58935. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58936. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58937. * @returns The parsed reflection probe if successful
  58938. */
  58939. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58940. }
  58941. }
  58942. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58943. /** @hidden */
  58944. export var _BabylonLoaderRegistered: boolean;
  58945. /**
  58946. * Helps setting up some configuration for the babylon file loader.
  58947. */
  58948. export class BabylonFileLoaderConfiguration {
  58949. /**
  58950. * The loader does not allow injecting custom physix engine into the plugins.
  58951. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58952. * So you could set this variable to your engine import to make it work.
  58953. */
  58954. static LoaderInjectedPhysicsEngine: any;
  58955. }
  58956. }
  58957. declare module "babylonjs/Loading/Plugins/index" {
  58958. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58959. }
  58960. declare module "babylonjs/Loading/index" {
  58961. export * from "babylonjs/Loading/loadingScreen";
  58962. export * from "babylonjs/Loading/Plugins/index";
  58963. export * from "babylonjs/Loading/sceneLoader";
  58964. export * from "babylonjs/Loading/sceneLoaderFlags";
  58965. }
  58966. declare module "babylonjs/Materials/Background/index" {
  58967. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58968. }
  58969. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58970. import { Scene } from "babylonjs/scene";
  58971. import { Color3 } from "babylonjs/Maths/math.color";
  58972. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58974. /**
  58975. * The Physically based simple base material of BJS.
  58976. *
  58977. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58978. * It is used as the base class for both the specGloss and metalRough conventions.
  58979. */
  58980. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58981. /**
  58982. * Number of Simultaneous lights allowed on the material.
  58983. */
  58984. maxSimultaneousLights: number;
  58985. /**
  58986. * If sets to true, disables all the lights affecting the material.
  58987. */
  58988. disableLighting: boolean;
  58989. /**
  58990. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58991. */
  58992. environmentTexture: BaseTexture;
  58993. /**
  58994. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58995. */
  58996. invertNormalMapX: boolean;
  58997. /**
  58998. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58999. */
  59000. invertNormalMapY: boolean;
  59001. /**
  59002. * Normal map used in the model.
  59003. */
  59004. normalTexture: BaseTexture;
  59005. /**
  59006. * Emissivie color used to self-illuminate the model.
  59007. */
  59008. emissiveColor: Color3;
  59009. /**
  59010. * Emissivie texture used to self-illuminate the model.
  59011. */
  59012. emissiveTexture: BaseTexture;
  59013. /**
  59014. * Occlusion Channel Strenght.
  59015. */
  59016. occlusionStrength: number;
  59017. /**
  59018. * Occlusion Texture of the material (adding extra occlusion effects).
  59019. */
  59020. occlusionTexture: BaseTexture;
  59021. /**
  59022. * Defines the alpha limits in alpha test mode.
  59023. */
  59024. alphaCutOff: number;
  59025. /**
  59026. * Gets the current double sided mode.
  59027. */
  59028. get doubleSided(): boolean;
  59029. /**
  59030. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59031. */
  59032. set doubleSided(value: boolean);
  59033. /**
  59034. * Stores the pre-calculated light information of a mesh in a texture.
  59035. */
  59036. lightmapTexture: BaseTexture;
  59037. /**
  59038. * If true, the light map contains occlusion information instead of lighting info.
  59039. */
  59040. useLightmapAsShadowmap: boolean;
  59041. /**
  59042. * Instantiates a new PBRMaterial instance.
  59043. *
  59044. * @param name The material name
  59045. * @param scene The scene the material will be use in.
  59046. */
  59047. constructor(name: string, scene: Scene);
  59048. getClassName(): string;
  59049. }
  59050. }
  59051. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  59052. import { Scene } from "babylonjs/scene";
  59053. import { Color3 } from "babylonjs/Maths/math.color";
  59054. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59055. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59056. /**
  59057. * The PBR material of BJS following the metal roughness convention.
  59058. *
  59059. * This fits to the PBR convention in the GLTF definition:
  59060. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59061. */
  59062. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59063. /**
  59064. * The base color has two different interpretations depending on the value of metalness.
  59065. * When the material is a metal, the base color is the specific measured reflectance value
  59066. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59067. * of the material.
  59068. */
  59069. baseColor: Color3;
  59070. /**
  59071. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59072. * well as opacity information in the alpha channel.
  59073. */
  59074. baseTexture: BaseTexture;
  59075. /**
  59076. * Specifies the metallic scalar value of the material.
  59077. * Can also be used to scale the metalness values of the metallic texture.
  59078. */
  59079. metallic: number;
  59080. /**
  59081. * Specifies the roughness scalar value of the material.
  59082. * Can also be used to scale the roughness values of the metallic texture.
  59083. */
  59084. roughness: number;
  59085. /**
  59086. * Texture containing both the metallic value in the B channel and the
  59087. * roughness value in the G channel to keep better precision.
  59088. */
  59089. metallicRoughnessTexture: BaseTexture;
  59090. /**
  59091. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59092. *
  59093. * @param name The material name
  59094. * @param scene The scene the material will be use in.
  59095. */
  59096. constructor(name: string, scene: Scene);
  59097. /**
  59098. * Return the currrent class name of the material.
  59099. */
  59100. getClassName(): string;
  59101. /**
  59102. * Makes a duplicate of the current material.
  59103. * @param name - name to use for the new material.
  59104. */
  59105. clone(name: string): PBRMetallicRoughnessMaterial;
  59106. /**
  59107. * Serialize the material to a parsable JSON object.
  59108. */
  59109. serialize(): any;
  59110. /**
  59111. * Parses a JSON object correponding to the serialize function.
  59112. */
  59113. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59114. }
  59115. }
  59116. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  59117. import { Scene } from "babylonjs/scene";
  59118. import { Color3 } from "babylonjs/Maths/math.color";
  59119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59120. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59121. /**
  59122. * The PBR material of BJS following the specular glossiness convention.
  59123. *
  59124. * This fits to the PBR convention in the GLTF definition:
  59125. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59126. */
  59127. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59128. /**
  59129. * Specifies the diffuse color of the material.
  59130. */
  59131. diffuseColor: Color3;
  59132. /**
  59133. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59134. * channel.
  59135. */
  59136. diffuseTexture: BaseTexture;
  59137. /**
  59138. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59139. */
  59140. specularColor: Color3;
  59141. /**
  59142. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59143. */
  59144. glossiness: number;
  59145. /**
  59146. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59147. */
  59148. specularGlossinessTexture: BaseTexture;
  59149. /**
  59150. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59151. *
  59152. * @param name The material name
  59153. * @param scene The scene the material will be use in.
  59154. */
  59155. constructor(name: string, scene: Scene);
  59156. /**
  59157. * Return the currrent class name of the material.
  59158. */
  59159. getClassName(): string;
  59160. /**
  59161. * Makes a duplicate of the current material.
  59162. * @param name - name to use for the new material.
  59163. */
  59164. clone(name: string): PBRSpecularGlossinessMaterial;
  59165. /**
  59166. * Serialize the material to a parsable JSON object.
  59167. */
  59168. serialize(): any;
  59169. /**
  59170. * Parses a JSON object correponding to the serialize function.
  59171. */
  59172. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59173. }
  59174. }
  59175. declare module "babylonjs/Materials/PBR/index" {
  59176. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59177. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  59178. export * from "babylonjs/Materials/PBR/pbrMaterial";
  59179. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  59180. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  59181. }
  59182. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  59183. import { Nullable } from "babylonjs/types";
  59184. import { Scene } from "babylonjs/scene";
  59185. import { Matrix } from "babylonjs/Maths/math.vector";
  59186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59187. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59188. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59189. /**
  59190. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59191. * It can help converting any input color in a desired output one. This can then be used to create effects
  59192. * from sepia, black and white to sixties or futuristic rendering...
  59193. *
  59194. * The only supported format is currently 3dl.
  59195. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59196. */
  59197. export class ColorGradingTexture extends BaseTexture {
  59198. /**
  59199. * The texture URL.
  59200. */
  59201. url: string;
  59202. /**
  59203. * Empty line regex stored for GC.
  59204. */
  59205. private static _noneEmptyLineRegex;
  59206. private _textureMatrix;
  59207. private _engine;
  59208. private _onLoad;
  59209. /**
  59210. * Instantiates a ColorGradingTexture from the following parameters.
  59211. *
  59212. * @param url The location of the color gradind data (currently only supporting 3dl)
  59213. * @param sceneOrEngine The scene or engine the texture will be used in
  59214. * @param onLoad defines a callback triggered when the texture has been loaded
  59215. */
  59216. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59217. /**
  59218. * Fires the onload event from the constructor if requested.
  59219. */
  59220. private _triggerOnLoad;
  59221. /**
  59222. * Returns the texture matrix used in most of the material.
  59223. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59224. */
  59225. getTextureMatrix(): Matrix;
  59226. /**
  59227. * Occurs when the file being loaded is a .3dl LUT file.
  59228. */
  59229. private load3dlTexture;
  59230. /**
  59231. * Starts the loading process of the texture.
  59232. */
  59233. private loadTexture;
  59234. /**
  59235. * Clones the color gradind texture.
  59236. */
  59237. clone(): ColorGradingTexture;
  59238. /**
  59239. * Called during delayed load for textures.
  59240. */
  59241. delayLoad(): void;
  59242. /**
  59243. * Parses a color grading texture serialized by Babylon.
  59244. * @param parsedTexture The texture information being parsedTexture
  59245. * @param scene The scene to load the texture in
  59246. * @param rootUrl The root url of the data assets to load
  59247. * @return A color gradind texture
  59248. */
  59249. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59250. /**
  59251. * Serializes the LUT texture to json format.
  59252. */
  59253. serialize(): any;
  59254. /**
  59255. * Returns true if the passed parameter is a scene object (can be use for typings)
  59256. * @param sceneOrEngine The object to test.
  59257. */
  59258. private static _isScene;
  59259. }
  59260. }
  59261. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  59262. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59263. import { Scene } from "babylonjs/scene";
  59264. import { Nullable } from "babylonjs/types";
  59265. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59266. /**
  59267. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59268. */
  59269. export class EquiRectangularCubeTexture extends BaseTexture {
  59270. /** The six faces of the cube. */
  59271. private static _FacesMapping;
  59272. private _noMipmap;
  59273. private _onLoad;
  59274. private _onError;
  59275. /** The size of the cubemap. */
  59276. private _size;
  59277. /** The buffer of the image. */
  59278. private _buffer;
  59279. /** The width of the input image. */
  59280. private _width;
  59281. /** The height of the input image. */
  59282. private _height;
  59283. /** The URL to the image. */
  59284. url: string;
  59285. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59286. coordinatesMode: number;
  59287. /**
  59288. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59289. * @param url The location of the image
  59290. * @param scene The scene the texture will be used in
  59291. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59292. * @param noMipmap Forces to not generate the mipmap if true
  59293. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59294. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59295. * @param onLoad — defines a callback called when texture is loaded
  59296. * @param onError — defines a callback called if there is an error
  59297. */
  59298. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59299. /**
  59300. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59301. */
  59302. private loadImage;
  59303. /**
  59304. * Convert the image buffer into a cubemap and create a CubeTexture.
  59305. */
  59306. private loadTexture;
  59307. /**
  59308. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59309. * @param buffer The ArrayBuffer that should be converted.
  59310. * @returns The buffer as Float32Array.
  59311. */
  59312. private getFloat32ArrayFromArrayBuffer;
  59313. /**
  59314. * Get the current class name of the texture useful for serialization or dynamic coding.
  59315. * @returns "EquiRectangularCubeTexture"
  59316. */
  59317. getClassName(): string;
  59318. /**
  59319. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59320. * @returns A clone of the current EquiRectangularCubeTexture.
  59321. */
  59322. clone(): EquiRectangularCubeTexture;
  59323. }
  59324. }
  59325. declare module "babylonjs/Misc/tga" {
  59326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59327. /**
  59328. * Based on jsTGALoader - Javascript loader for TGA file
  59329. * By Vincent Thibault
  59330. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59331. */
  59332. export class TGATools {
  59333. private static _TYPE_INDEXED;
  59334. private static _TYPE_RGB;
  59335. private static _TYPE_GREY;
  59336. private static _TYPE_RLE_INDEXED;
  59337. private static _TYPE_RLE_RGB;
  59338. private static _TYPE_RLE_GREY;
  59339. private static _ORIGIN_MASK;
  59340. private static _ORIGIN_SHIFT;
  59341. private static _ORIGIN_BL;
  59342. private static _ORIGIN_BR;
  59343. private static _ORIGIN_UL;
  59344. private static _ORIGIN_UR;
  59345. /**
  59346. * Gets the header of a TGA file
  59347. * @param data defines the TGA data
  59348. * @returns the header
  59349. */
  59350. static GetTGAHeader(data: Uint8Array): any;
  59351. /**
  59352. * Uploads TGA content to a Babylon Texture
  59353. * @hidden
  59354. */
  59355. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59356. /** @hidden */
  59357. 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;
  59358. /** @hidden */
  59359. 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;
  59360. /** @hidden */
  59361. 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;
  59362. /** @hidden */
  59363. 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;
  59364. /** @hidden */
  59365. 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;
  59366. /** @hidden */
  59367. 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;
  59368. }
  59369. }
  59370. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59371. import { Nullable } from "babylonjs/types";
  59372. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59373. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59374. /**
  59375. * Implementation of the TGA Texture Loader.
  59376. * @hidden
  59377. */
  59378. export class _TGATextureLoader implements IInternalTextureLoader {
  59379. /**
  59380. * Defines wether the loader supports cascade loading the different faces.
  59381. */
  59382. readonly supportCascades: boolean;
  59383. /**
  59384. * This returns if the loader support the current file information.
  59385. * @param extension defines the file extension of the file being loaded
  59386. * @returns true if the loader can load the specified file
  59387. */
  59388. canLoad(extension: string): boolean;
  59389. /**
  59390. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59391. * @param data contains the texture data
  59392. * @param texture defines the BabylonJS internal texture
  59393. * @param createPolynomials will be true if polynomials have been requested
  59394. * @param onLoad defines the callback to trigger once the texture is ready
  59395. * @param onError defines the callback to trigger in case of error
  59396. */
  59397. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59398. /**
  59399. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59400. * @param data contains the texture data
  59401. * @param texture defines the BabylonJS internal texture
  59402. * @param callback defines the method to call once ready to upload
  59403. */
  59404. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59405. }
  59406. }
  59407. declare module "babylonjs/Misc/basis" {
  59408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59409. /**
  59410. * Info about the .basis files
  59411. */
  59412. class BasisFileInfo {
  59413. /**
  59414. * If the file has alpha
  59415. */
  59416. hasAlpha: boolean;
  59417. /**
  59418. * Info about each image of the basis file
  59419. */
  59420. images: Array<{
  59421. levels: Array<{
  59422. width: number;
  59423. height: number;
  59424. transcodedPixels: ArrayBufferView;
  59425. }>;
  59426. }>;
  59427. }
  59428. /**
  59429. * Result of transcoding a basis file
  59430. */
  59431. class TranscodeResult {
  59432. /**
  59433. * Info about the .basis file
  59434. */
  59435. fileInfo: BasisFileInfo;
  59436. /**
  59437. * Format to use when loading the file
  59438. */
  59439. format: number;
  59440. }
  59441. /**
  59442. * Configuration options for the Basis transcoder
  59443. */
  59444. export class BasisTranscodeConfiguration {
  59445. /**
  59446. * Supported compression formats used to determine the supported output format of the transcoder
  59447. */
  59448. supportedCompressionFormats?: {
  59449. /**
  59450. * etc1 compression format
  59451. */
  59452. etc1?: boolean;
  59453. /**
  59454. * s3tc compression format
  59455. */
  59456. s3tc?: boolean;
  59457. /**
  59458. * pvrtc compression format
  59459. */
  59460. pvrtc?: boolean;
  59461. /**
  59462. * etc2 compression format
  59463. */
  59464. etc2?: boolean;
  59465. };
  59466. /**
  59467. * If mipmap levels should be loaded for transcoded images (Default: true)
  59468. */
  59469. loadMipmapLevels?: boolean;
  59470. /**
  59471. * Index of a single image to load (Default: all images)
  59472. */
  59473. loadSingleImage?: number;
  59474. }
  59475. /**
  59476. * Used to load .Basis files
  59477. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59478. */
  59479. export class BasisTools {
  59480. private static _IgnoreSupportedFormats;
  59481. /**
  59482. * URL to use when loading the basis transcoder
  59483. */
  59484. static JSModuleURL: string;
  59485. /**
  59486. * URL to use when loading the wasm module for the transcoder
  59487. */
  59488. static WasmModuleURL: string;
  59489. /**
  59490. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59491. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59492. * @returns internal format corresponding to the Basis format
  59493. */
  59494. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59495. private static _WorkerPromise;
  59496. private static _Worker;
  59497. private static _actionId;
  59498. private static _CreateWorkerAsync;
  59499. /**
  59500. * Transcodes a loaded image file to compressed pixel data
  59501. * @param data image data to transcode
  59502. * @param config configuration options for the transcoding
  59503. * @returns a promise resulting in the transcoded image
  59504. */
  59505. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59506. /**
  59507. * Loads a texture from the transcode result
  59508. * @param texture texture load to
  59509. * @param transcodeResult the result of transcoding the basis file to load from
  59510. */
  59511. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59512. }
  59513. }
  59514. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59515. import { Nullable } from "babylonjs/types";
  59516. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59517. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59518. /**
  59519. * Loader for .basis file format
  59520. */
  59521. export class _BasisTextureLoader implements IInternalTextureLoader {
  59522. /**
  59523. * Defines whether the loader supports cascade loading the different faces.
  59524. */
  59525. readonly supportCascades: boolean;
  59526. /**
  59527. * This returns if the loader support the current file information.
  59528. * @param extension defines the file extension of the file being loaded
  59529. * @returns true if the loader can load the specified file
  59530. */
  59531. canLoad(extension: string): boolean;
  59532. /**
  59533. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59534. * @param data contains the texture data
  59535. * @param texture defines the BabylonJS internal texture
  59536. * @param createPolynomials will be true if polynomials have been requested
  59537. * @param onLoad defines the callback to trigger once the texture is ready
  59538. * @param onError defines the callback to trigger in case of error
  59539. */
  59540. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59541. /**
  59542. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59543. * @param data contains the texture data
  59544. * @param texture defines the BabylonJS internal texture
  59545. * @param callback defines the method to call once ready to upload
  59546. */
  59547. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59548. }
  59549. }
  59550. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59551. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59552. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59553. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59554. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59555. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59556. }
  59557. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59558. import { Scene } from "babylonjs/scene";
  59559. import { Texture } from "babylonjs/Materials/Textures/texture";
  59560. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59561. /**
  59562. * 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.
  59563. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59564. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59565. */
  59566. export class CustomProceduralTexture extends ProceduralTexture {
  59567. private _animate;
  59568. private _time;
  59569. private _config;
  59570. private _texturePath;
  59571. /**
  59572. * Instantiates a new Custom Procedural Texture.
  59573. * 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.
  59574. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59575. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59576. * @param name Define the name of the texture
  59577. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59578. * @param size Define the size of the texture to create
  59579. * @param scene Define the scene the texture belongs to
  59580. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59581. * @param generateMipMaps Define if the texture should creates mip maps or not
  59582. */
  59583. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59584. private _loadJson;
  59585. /**
  59586. * Is the texture ready to be used ? (rendered at least once)
  59587. * @returns true if ready, otherwise, false.
  59588. */
  59589. isReady(): boolean;
  59590. /**
  59591. * Render the texture to its associated render target.
  59592. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59593. */
  59594. render(useCameraPostProcess?: boolean): void;
  59595. /**
  59596. * Update the list of dependant textures samplers in the shader.
  59597. */
  59598. updateTextures(): void;
  59599. /**
  59600. * Update the uniform values of the procedural texture in the shader.
  59601. */
  59602. updateShaderUniforms(): void;
  59603. /**
  59604. * Define if the texture animates or not.
  59605. */
  59606. get animate(): boolean;
  59607. set animate(value: boolean);
  59608. }
  59609. }
  59610. declare module "babylonjs/Shaders/noise.fragment" {
  59611. /** @hidden */
  59612. export var noisePixelShader: {
  59613. name: string;
  59614. shader: string;
  59615. };
  59616. }
  59617. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59618. import { Nullable } from "babylonjs/types";
  59619. import { Scene } from "babylonjs/scene";
  59620. import { Texture } from "babylonjs/Materials/Textures/texture";
  59621. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59622. import "babylonjs/Shaders/noise.fragment";
  59623. /**
  59624. * Class used to generate noise procedural textures
  59625. */
  59626. export class NoiseProceduralTexture extends ProceduralTexture {
  59627. private _time;
  59628. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59629. brightness: number;
  59630. /** Defines the number of octaves to process */
  59631. octaves: number;
  59632. /** Defines the level of persistence (0.8 by default) */
  59633. persistence: number;
  59634. /** Gets or sets animation speed factor (default is 1) */
  59635. animationSpeedFactor: number;
  59636. /**
  59637. * Creates a new NoiseProceduralTexture
  59638. * @param name defines the name fo the texture
  59639. * @param size defines the size of the texture (default is 256)
  59640. * @param scene defines the hosting scene
  59641. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59642. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59643. */
  59644. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59645. private _updateShaderUniforms;
  59646. protected _getDefines(): string;
  59647. /** Generate the current state of the procedural texture */
  59648. render(useCameraPostProcess?: boolean): void;
  59649. /**
  59650. * Serializes this noise procedural texture
  59651. * @returns a serialized noise procedural texture object
  59652. */
  59653. serialize(): any;
  59654. /**
  59655. * Clone the texture.
  59656. * @returns the cloned texture
  59657. */
  59658. clone(): NoiseProceduralTexture;
  59659. /**
  59660. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59661. * @param parsedTexture defines parsed texture data
  59662. * @param scene defines the current scene
  59663. * @param rootUrl defines the root URL containing noise procedural texture information
  59664. * @returns a parsed NoiseProceduralTexture
  59665. */
  59666. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59667. }
  59668. }
  59669. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59670. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59671. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59672. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59673. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59674. }
  59675. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59676. import { Nullable } from "babylonjs/types";
  59677. import { Scene } from "babylonjs/scene";
  59678. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59679. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59680. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59681. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59682. /**
  59683. * Raw cube texture where the raw buffers are passed in
  59684. */
  59685. export class RawCubeTexture extends CubeTexture {
  59686. /**
  59687. * Creates a cube texture where the raw buffers are passed in.
  59688. * @param scene defines the scene the texture is attached to
  59689. * @param data defines the array of data to use to create each face
  59690. * @param size defines the size of the textures
  59691. * @param format defines the format of the data
  59692. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59693. * @param generateMipMaps defines if the engine should generate the mip levels
  59694. * @param invertY defines if data must be stored with Y axis inverted
  59695. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59696. * @param compression defines the compression used (null by default)
  59697. */
  59698. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59699. /**
  59700. * Updates the raw cube texture.
  59701. * @param data defines the data to store
  59702. * @param format defines the data format
  59703. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59704. * @param invertY defines if data must be stored with Y axis inverted
  59705. * @param compression defines the compression used (null by default)
  59706. * @param level defines which level of the texture to update
  59707. */
  59708. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59709. /**
  59710. * Updates a raw cube texture with RGBD encoded data.
  59711. * @param data defines the array of data [mipmap][face] to use to create each face
  59712. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59713. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59714. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59715. * @returns a promsie that resolves when the operation is complete
  59716. */
  59717. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59718. /**
  59719. * Clones the raw cube texture.
  59720. * @return a new cube texture
  59721. */
  59722. clone(): CubeTexture;
  59723. /** @hidden */
  59724. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59725. }
  59726. }
  59727. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59728. import { Scene } from "babylonjs/scene";
  59729. import { Texture } from "babylonjs/Materials/Textures/texture";
  59730. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59731. /**
  59732. * Class used to store 3D textures containing user data
  59733. */
  59734. export class RawTexture3D extends Texture {
  59735. /** Gets or sets the texture format to use */
  59736. format: number;
  59737. private _engine;
  59738. /**
  59739. * Create a new RawTexture3D
  59740. * @param data defines the data of the texture
  59741. * @param width defines the width of the texture
  59742. * @param height defines the height of the texture
  59743. * @param depth defines the depth of the texture
  59744. * @param format defines the texture format to use
  59745. * @param scene defines the hosting scene
  59746. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59747. * @param invertY defines if texture must be stored with Y axis inverted
  59748. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59749. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59750. */
  59751. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59752. /** Gets or sets the texture format to use */
  59753. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59754. /**
  59755. * Update the texture with new data
  59756. * @param data defines the data to store in the texture
  59757. */
  59758. update(data: ArrayBufferView): void;
  59759. }
  59760. }
  59761. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59762. import { Scene } from "babylonjs/scene";
  59763. import { Texture } from "babylonjs/Materials/Textures/texture";
  59764. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59765. /**
  59766. * Class used to store 2D array textures containing user data
  59767. */
  59768. export class RawTexture2DArray extends Texture {
  59769. /** Gets or sets the texture format to use */
  59770. format: number;
  59771. private _engine;
  59772. /**
  59773. * Create a new RawTexture2DArray
  59774. * @param data defines the data of the texture
  59775. * @param width defines the width of the texture
  59776. * @param height defines the height of the texture
  59777. * @param depth defines the number of layers of the texture
  59778. * @param format defines the texture format to use
  59779. * @param scene defines the hosting scene
  59780. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59781. * @param invertY defines if texture must be stored with Y axis inverted
  59782. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59783. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59784. */
  59785. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59786. /** Gets or sets the texture format to use */
  59787. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59788. /**
  59789. * Update the texture with new data
  59790. * @param data defines the data to store in the texture
  59791. */
  59792. update(data: ArrayBufferView): void;
  59793. }
  59794. }
  59795. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59796. import { Scene } from "babylonjs/scene";
  59797. import { Plane } from "babylonjs/Maths/math.plane";
  59798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59799. /**
  59800. * Creates a refraction texture used by refraction channel of the standard material.
  59801. * It is like a mirror but to see through a material.
  59802. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59803. */
  59804. export class RefractionTexture extends RenderTargetTexture {
  59805. /**
  59806. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59807. * 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.
  59808. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59809. */
  59810. refractionPlane: Plane;
  59811. /**
  59812. * Define how deep under the surface we should see.
  59813. */
  59814. depth: number;
  59815. /**
  59816. * Creates a refraction texture used by refraction channel of the standard material.
  59817. * It is like a mirror but to see through a material.
  59818. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59819. * @param name Define the texture name
  59820. * @param size Define the size of the underlying texture
  59821. * @param scene Define the scene the refraction belongs to
  59822. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59823. */
  59824. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59825. /**
  59826. * Clone the refraction texture.
  59827. * @returns the cloned texture
  59828. */
  59829. clone(): RefractionTexture;
  59830. /**
  59831. * Serialize the texture to a JSON representation you could use in Parse later on
  59832. * @returns the serialized JSON representation
  59833. */
  59834. serialize(): any;
  59835. }
  59836. }
  59837. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59838. import { Nullable } from "babylonjs/types";
  59839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59840. import { Matrix } from "babylonjs/Maths/math.vector";
  59841. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59842. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59843. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59844. import { Scene } from "babylonjs/scene";
  59845. /**
  59846. * Defines the options related to the creation of an HtmlElementTexture
  59847. */
  59848. export interface IHtmlElementTextureOptions {
  59849. /**
  59850. * Defines wether mip maps should be created or not.
  59851. */
  59852. generateMipMaps?: boolean;
  59853. /**
  59854. * Defines the sampling mode of the texture.
  59855. */
  59856. samplingMode?: number;
  59857. /**
  59858. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59859. */
  59860. engine: Nullable<ThinEngine>;
  59861. /**
  59862. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59863. */
  59864. scene: Nullable<Scene>;
  59865. }
  59866. /**
  59867. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59868. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59869. * is automatically managed.
  59870. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59871. * in your application.
  59872. *
  59873. * As the update is not automatic, you need to call them manually.
  59874. */
  59875. export class HtmlElementTexture extends BaseTexture {
  59876. /**
  59877. * The texture URL.
  59878. */
  59879. element: HTMLVideoElement | HTMLCanvasElement;
  59880. private static readonly DefaultOptions;
  59881. private _textureMatrix;
  59882. private _engine;
  59883. private _isVideo;
  59884. private _generateMipMaps;
  59885. private _samplingMode;
  59886. /**
  59887. * Instantiates a HtmlElementTexture from the following parameters.
  59888. *
  59889. * @param name Defines the name of the texture
  59890. * @param element Defines the video or canvas the texture is filled with
  59891. * @param options Defines the other none mandatory texture creation options
  59892. */
  59893. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59894. private _createInternalTexture;
  59895. /**
  59896. * Returns the texture matrix used in most of the material.
  59897. */
  59898. getTextureMatrix(): Matrix;
  59899. /**
  59900. * Updates the content of the texture.
  59901. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59902. */
  59903. update(invertY?: Nullable<boolean>): void;
  59904. }
  59905. }
  59906. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59907. import { Vector2 } from "babylonjs/Maths/math.vector";
  59908. /**
  59909. * Defines the basic options interface of a TexturePacker Frame
  59910. */
  59911. export interface ITexturePackerFrame {
  59912. /**
  59913. * The frame ID
  59914. */
  59915. id: number;
  59916. /**
  59917. * The frames Scale
  59918. */
  59919. scale: Vector2;
  59920. /**
  59921. * The Frames offset
  59922. */
  59923. offset: Vector2;
  59924. }
  59925. /**
  59926. * This is a support class for frame Data on texture packer sets.
  59927. */
  59928. export class TexturePackerFrame implements ITexturePackerFrame {
  59929. /**
  59930. * The frame ID
  59931. */
  59932. id: number;
  59933. /**
  59934. * The frames Scale
  59935. */
  59936. scale: Vector2;
  59937. /**
  59938. * The Frames offset
  59939. */
  59940. offset: Vector2;
  59941. /**
  59942. * Initializes a texture package frame.
  59943. * @param id The numerical frame identifier
  59944. * @param scale Scalar Vector2 for UV frame
  59945. * @param offset Vector2 for the frame position in UV units.
  59946. * @returns TexturePackerFrame
  59947. */
  59948. constructor(id: number, scale: Vector2, offset: Vector2);
  59949. }
  59950. }
  59951. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59953. import { Scene } from "babylonjs/scene";
  59954. import { Nullable } from "babylonjs/types";
  59955. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59956. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59957. /**
  59958. * Defines the basic options interface of a TexturePacker
  59959. */
  59960. export interface ITexturePackerOptions {
  59961. /**
  59962. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59963. */
  59964. map?: string[];
  59965. /**
  59966. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59967. */
  59968. uvsIn?: string;
  59969. /**
  59970. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59971. */
  59972. uvsOut?: string;
  59973. /**
  59974. * number representing the layout style. Defaults to LAYOUT_STRIP
  59975. */
  59976. layout?: number;
  59977. /**
  59978. * number of columns if using custom column count layout(2). This defaults to 4.
  59979. */
  59980. colnum?: number;
  59981. /**
  59982. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59983. */
  59984. updateInputMeshes?: boolean;
  59985. /**
  59986. * boolean flag to dispose all the source textures. Defaults to true.
  59987. */
  59988. disposeSources?: boolean;
  59989. /**
  59990. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59991. */
  59992. fillBlanks?: boolean;
  59993. /**
  59994. * string value representing the context fill style color. Defaults to 'black'.
  59995. */
  59996. customFillColor?: string;
  59997. /**
  59998. * Width and Height Value of each Frame in the TexturePacker Sets
  59999. */
  60000. frameSize?: number;
  60001. /**
  60002. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60003. */
  60004. paddingRatio?: number;
  60005. /**
  60006. * Number that declares the fill method for the padding gutter.
  60007. */
  60008. paddingMode?: number;
  60009. /**
  60010. * If in SUBUV_COLOR padding mode what color to use.
  60011. */
  60012. paddingColor?: Color3 | Color4;
  60013. }
  60014. /**
  60015. * Defines the basic interface of a TexturePacker JSON File
  60016. */
  60017. export interface ITexturePackerJSON {
  60018. /**
  60019. * The frame ID
  60020. */
  60021. name: string;
  60022. /**
  60023. * The base64 channel data
  60024. */
  60025. sets: any;
  60026. /**
  60027. * The options of the Packer
  60028. */
  60029. options: ITexturePackerOptions;
  60030. /**
  60031. * The frame data of the Packer
  60032. */
  60033. frames: Array<number>;
  60034. }
  60035. /**
  60036. * This is a support class that generates a series of packed texture sets.
  60037. * @see https://doc.babylonjs.com/babylon101/materials
  60038. */
  60039. export class TexturePacker {
  60040. /** Packer Layout Constant 0 */
  60041. static readonly LAYOUT_STRIP: number;
  60042. /** Packer Layout Constant 1 */
  60043. static readonly LAYOUT_POWER2: number;
  60044. /** Packer Layout Constant 2 */
  60045. static readonly LAYOUT_COLNUM: number;
  60046. /** Packer Layout Constant 0 */
  60047. static readonly SUBUV_WRAP: number;
  60048. /** Packer Layout Constant 1 */
  60049. static readonly SUBUV_EXTEND: number;
  60050. /** Packer Layout Constant 2 */
  60051. static readonly SUBUV_COLOR: number;
  60052. /** The Name of the Texture Package */
  60053. name: string;
  60054. /** The scene scope of the TexturePacker */
  60055. scene: Scene;
  60056. /** The Meshes to target */
  60057. meshes: AbstractMesh[];
  60058. /** Arguments passed with the Constructor */
  60059. options: ITexturePackerOptions;
  60060. /** The promise that is started upon initialization */
  60061. promise: Nullable<Promise<TexturePacker | string>>;
  60062. /** The Container object for the channel sets that are generated */
  60063. sets: object;
  60064. /** The Container array for the frames that are generated */
  60065. frames: TexturePackerFrame[];
  60066. /** The expected number of textures the system is parsing. */
  60067. private _expecting;
  60068. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60069. private _paddingValue;
  60070. /**
  60071. * Initializes a texture package series from an array of meshes or a single mesh.
  60072. * @param name The name of the package
  60073. * @param meshes The target meshes to compose the package from
  60074. * @param options The arguments that texture packer should follow while building.
  60075. * @param scene The scene which the textures are scoped to.
  60076. * @returns TexturePacker
  60077. */
  60078. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60079. /**
  60080. * Starts the package process
  60081. * @param resolve The promises resolution function
  60082. * @returns TexturePacker
  60083. */
  60084. private _createFrames;
  60085. /**
  60086. * Calculates the Size of the Channel Sets
  60087. * @returns Vector2
  60088. */
  60089. private _calculateSize;
  60090. /**
  60091. * Calculates the UV data for the frames.
  60092. * @param baseSize the base frameSize
  60093. * @param padding the base frame padding
  60094. * @param dtSize size of the Dynamic Texture for that channel
  60095. * @param dtUnits is 1/dtSize
  60096. * @param update flag to update the input meshes
  60097. */
  60098. private _calculateMeshUVFrames;
  60099. /**
  60100. * Calculates the frames Offset.
  60101. * @param index of the frame
  60102. * @returns Vector2
  60103. */
  60104. private _getFrameOffset;
  60105. /**
  60106. * Updates a Mesh to the frame data
  60107. * @param mesh that is the target
  60108. * @param frameID or the frame index
  60109. */
  60110. private _updateMeshUV;
  60111. /**
  60112. * Updates a Meshes materials to use the texture packer channels
  60113. * @param m is the mesh to target
  60114. * @param force all channels on the packer to be set.
  60115. */
  60116. private _updateTextureReferences;
  60117. /**
  60118. * Public method to set a Mesh to a frame
  60119. * @param m that is the target
  60120. * @param frameID or the frame index
  60121. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60122. */
  60123. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60124. /**
  60125. * Starts the async promise to compile the texture packer.
  60126. * @returns Promise<void>
  60127. */
  60128. processAsync(): Promise<void>;
  60129. /**
  60130. * Disposes all textures associated with this packer
  60131. */
  60132. dispose(): void;
  60133. /**
  60134. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60135. * @param imageType is the image type to use.
  60136. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60137. */
  60138. download(imageType?: string, quality?: number): void;
  60139. /**
  60140. * Public method to load a texturePacker JSON file.
  60141. * @param data of the JSON file in string format.
  60142. */
  60143. updateFromJSON(data: string): void;
  60144. }
  60145. }
  60146. declare module "babylonjs/Materials/Textures/Packer/index" {
  60147. export * from "babylonjs/Materials/Textures/Packer/packer";
  60148. export * from "babylonjs/Materials/Textures/Packer/frame";
  60149. }
  60150. declare module "babylonjs/Materials/Textures/index" {
  60151. export * from "babylonjs/Materials/Textures/baseTexture";
  60152. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  60153. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  60154. export * from "babylonjs/Materials/Textures/cubeTexture";
  60155. export * from "babylonjs/Materials/Textures/dynamicTexture";
  60156. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60157. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  60158. export * from "babylonjs/Materials/Textures/internalTexture";
  60159. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  60160. export * from "babylonjs/Materials/Textures/Loaders/index";
  60161. export * from "babylonjs/Materials/Textures/mirrorTexture";
  60162. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  60163. export * from "babylonjs/Materials/Textures/Procedurals/index";
  60164. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  60165. export * from "babylonjs/Materials/Textures/rawTexture";
  60166. export * from "babylonjs/Materials/Textures/rawTexture3D";
  60167. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  60168. export * from "babylonjs/Materials/Textures/refractionTexture";
  60169. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  60170. export * from "babylonjs/Materials/Textures/texture";
  60171. export * from "babylonjs/Materials/Textures/videoTexture";
  60172. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  60173. export * from "babylonjs/Materials/Textures/Packer/index";
  60174. }
  60175. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  60176. /**
  60177. * Enum used to define the target of a block
  60178. */
  60179. export enum NodeMaterialBlockTargets {
  60180. /** Vertex shader */
  60181. Vertex = 1,
  60182. /** Fragment shader */
  60183. Fragment = 2,
  60184. /** Neutral */
  60185. Neutral = 4,
  60186. /** Vertex and Fragment */
  60187. VertexAndFragment = 3
  60188. }
  60189. }
  60190. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  60191. /**
  60192. * Defines the kind of connection point for node based material
  60193. */
  60194. export enum NodeMaterialBlockConnectionPointTypes {
  60195. /** Float */
  60196. Float = 1,
  60197. /** Int */
  60198. Int = 2,
  60199. /** Vector2 */
  60200. Vector2 = 4,
  60201. /** Vector3 */
  60202. Vector3 = 8,
  60203. /** Vector4 */
  60204. Vector4 = 16,
  60205. /** Color3 */
  60206. Color3 = 32,
  60207. /** Color4 */
  60208. Color4 = 64,
  60209. /** Matrix */
  60210. Matrix = 128,
  60211. /** Custom object */
  60212. Object = 256,
  60213. /** Detect type based on connection */
  60214. AutoDetect = 1024,
  60215. /** Output type that will be defined by input type */
  60216. BasedOnInput = 2048
  60217. }
  60218. }
  60219. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  60220. /**
  60221. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  60222. */
  60223. export enum NodeMaterialBlockConnectionPointMode {
  60224. /** Value is an uniform */
  60225. Uniform = 0,
  60226. /** Value is a mesh attribute */
  60227. Attribute = 1,
  60228. /** Value is a varying between vertex and fragment shaders */
  60229. Varying = 2,
  60230. /** Mode is undefined */
  60231. Undefined = 3
  60232. }
  60233. }
  60234. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  60235. /**
  60236. * Enum used to define system values e.g. values automatically provided by the system
  60237. */
  60238. export enum NodeMaterialSystemValues {
  60239. /** World */
  60240. World = 1,
  60241. /** View */
  60242. View = 2,
  60243. /** Projection */
  60244. Projection = 3,
  60245. /** ViewProjection */
  60246. ViewProjection = 4,
  60247. /** WorldView */
  60248. WorldView = 5,
  60249. /** WorldViewProjection */
  60250. WorldViewProjection = 6,
  60251. /** CameraPosition */
  60252. CameraPosition = 7,
  60253. /** Fog Color */
  60254. FogColor = 8,
  60255. /** Delta time */
  60256. DeltaTime = 9
  60257. }
  60258. }
  60259. declare module "babylonjs/Materials/Node/Enums/index" {
  60260. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60261. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60262. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  60263. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60264. }
  60265. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  60266. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60267. /**
  60268. * Root class for all node material optimizers
  60269. */
  60270. export class NodeMaterialOptimizer {
  60271. /**
  60272. * Function used to optimize a NodeMaterial graph
  60273. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  60274. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  60275. */
  60276. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  60277. }
  60278. }
  60279. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  60280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60283. import { Scene } from "babylonjs/scene";
  60284. /**
  60285. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  60286. */
  60287. export class TransformBlock extends NodeMaterialBlock {
  60288. /**
  60289. * Defines the value to use to complement W value to transform it to a Vector4
  60290. */
  60291. complementW: number;
  60292. /**
  60293. * Defines the value to use to complement z value to transform it to a Vector4
  60294. */
  60295. complementZ: number;
  60296. /**
  60297. * Creates a new TransformBlock
  60298. * @param name defines the block name
  60299. */
  60300. constructor(name: string);
  60301. /**
  60302. * Gets the current class name
  60303. * @returns the class name
  60304. */
  60305. getClassName(): string;
  60306. /**
  60307. * Gets the vector input
  60308. */
  60309. get vector(): NodeMaterialConnectionPoint;
  60310. /**
  60311. * Gets the output component
  60312. */
  60313. get output(): NodeMaterialConnectionPoint;
  60314. /**
  60315. * Gets the xyz output component
  60316. */
  60317. get xyz(): NodeMaterialConnectionPoint;
  60318. /**
  60319. * Gets the matrix transform input
  60320. */
  60321. get transform(): NodeMaterialConnectionPoint;
  60322. protected _buildBlock(state: NodeMaterialBuildState): this;
  60323. serialize(): any;
  60324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60325. protected _dumpPropertiesCode(): string;
  60326. }
  60327. }
  60328. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60329. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60330. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60331. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60332. /**
  60333. * Block used to output the vertex position
  60334. */
  60335. export class VertexOutputBlock extends NodeMaterialBlock {
  60336. /**
  60337. * Creates a new VertexOutputBlock
  60338. * @param name defines the block name
  60339. */
  60340. constructor(name: string);
  60341. /**
  60342. * Gets the current class name
  60343. * @returns the class name
  60344. */
  60345. getClassName(): string;
  60346. /**
  60347. * Gets the vector input component
  60348. */
  60349. get vector(): NodeMaterialConnectionPoint;
  60350. protected _buildBlock(state: NodeMaterialBuildState): this;
  60351. }
  60352. }
  60353. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60357. /**
  60358. * Block used to output the final color
  60359. */
  60360. export class FragmentOutputBlock extends NodeMaterialBlock {
  60361. /**
  60362. * Create a new FragmentOutputBlock
  60363. * @param name defines the block name
  60364. */
  60365. constructor(name: string);
  60366. /**
  60367. * Gets the current class name
  60368. * @returns the class name
  60369. */
  60370. getClassName(): string;
  60371. /**
  60372. * Gets the rgba input component
  60373. */
  60374. get rgba(): NodeMaterialConnectionPoint;
  60375. /**
  60376. * Gets the rgb input component
  60377. */
  60378. get rgb(): NodeMaterialConnectionPoint;
  60379. /**
  60380. * Gets the a input component
  60381. */
  60382. get a(): NodeMaterialConnectionPoint;
  60383. protected _buildBlock(state: NodeMaterialBuildState): this;
  60384. }
  60385. }
  60386. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  60387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60392. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60393. import { Effect } from "babylonjs/Materials/effect";
  60394. import { Mesh } from "babylonjs/Meshes/mesh";
  60395. import { Nullable } from "babylonjs/types";
  60396. import { Scene } from "babylonjs/scene";
  60397. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60398. /**
  60399. * Base block used to read a reflection texture from a sampler
  60400. */
  60401. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  60402. /** @hidden */
  60403. _define3DName: string;
  60404. /** @hidden */
  60405. _defineCubicName: string;
  60406. /** @hidden */
  60407. _defineExplicitName: string;
  60408. /** @hidden */
  60409. _defineProjectionName: string;
  60410. /** @hidden */
  60411. _defineLocalCubicName: string;
  60412. /** @hidden */
  60413. _defineSphericalName: string;
  60414. /** @hidden */
  60415. _definePlanarName: string;
  60416. /** @hidden */
  60417. _defineEquirectangularName: string;
  60418. /** @hidden */
  60419. _defineMirroredEquirectangularFixedName: string;
  60420. /** @hidden */
  60421. _defineEquirectangularFixedName: string;
  60422. /** @hidden */
  60423. _defineSkyboxName: string;
  60424. /** @hidden */
  60425. _defineOppositeZ: string;
  60426. /** @hidden */
  60427. _cubeSamplerName: string;
  60428. /** @hidden */
  60429. _2DSamplerName: string;
  60430. protected _positionUVWName: string;
  60431. protected _directionWName: string;
  60432. protected _reflectionVectorName: string;
  60433. /** @hidden */
  60434. _reflectionCoordsName: string;
  60435. /** @hidden */
  60436. _reflectionMatrixName: string;
  60437. protected _reflectionColorName: string;
  60438. /**
  60439. * Gets or sets the texture associated with the node
  60440. */
  60441. texture: Nullable<BaseTexture>;
  60442. /**
  60443. * Create a new ReflectionTextureBaseBlock
  60444. * @param name defines the block name
  60445. */
  60446. constructor(name: string);
  60447. /**
  60448. * Gets the current class name
  60449. * @returns the class name
  60450. */
  60451. getClassName(): string;
  60452. /**
  60453. * Gets the world position input component
  60454. */
  60455. abstract get position(): NodeMaterialConnectionPoint;
  60456. /**
  60457. * Gets the world position input component
  60458. */
  60459. abstract get worldPosition(): NodeMaterialConnectionPoint;
  60460. /**
  60461. * Gets the world normal input component
  60462. */
  60463. abstract get worldNormal(): NodeMaterialConnectionPoint;
  60464. /**
  60465. * Gets the world input component
  60466. */
  60467. abstract get world(): NodeMaterialConnectionPoint;
  60468. /**
  60469. * Gets the camera (or eye) position component
  60470. */
  60471. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  60472. /**
  60473. * Gets the view input component
  60474. */
  60475. abstract get view(): NodeMaterialConnectionPoint;
  60476. protected _getTexture(): Nullable<BaseTexture>;
  60477. autoConfigure(material: NodeMaterial): void;
  60478. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60479. isReady(): boolean;
  60480. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60481. /**
  60482. * Gets the code to inject in the vertex shader
  60483. * @param state current state of the node material building
  60484. * @returns the shader code
  60485. */
  60486. handleVertexSide(state: NodeMaterialBuildState): string;
  60487. /**
  60488. * Handles the inits for the fragment code path
  60489. * @param state node material build state
  60490. */
  60491. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  60492. /**
  60493. * Generates the reflection coords code for the fragment code path
  60494. * @param worldNormalVarName name of the world normal variable
  60495. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  60496. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  60497. * @returns the shader code
  60498. */
  60499. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  60500. /**
  60501. * Generates the reflection color code for the fragment code path
  60502. * @param lodVarName name of the lod variable
  60503. * @param swizzleLookupTexture swizzle to use for the final color variable
  60504. * @returns the shader code
  60505. */
  60506. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  60507. /**
  60508. * Generates the code corresponding to the connected output points
  60509. * @param state node material build state
  60510. * @param varName name of the variable to output
  60511. * @returns the shader code
  60512. */
  60513. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  60514. protected _buildBlock(state: NodeMaterialBuildState): this;
  60515. protected _dumpPropertiesCode(): string;
  60516. serialize(): any;
  60517. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60518. }
  60519. }
  60520. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  60521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60522. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60523. import { Nullable } from "babylonjs/types";
  60524. /**
  60525. * Defines a connection point to be used for points with a custom object type
  60526. */
  60527. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  60528. private _blockType;
  60529. private _blockName;
  60530. private _nameForCheking?;
  60531. /**
  60532. * Creates a new connection point
  60533. * @param name defines the connection point name
  60534. * @param ownerBlock defines the block hosting this connection point
  60535. * @param direction defines the direction of the connection point
  60536. */
  60537. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  60538. /**
  60539. * Gets a number indicating if the current point can be connected to another point
  60540. * @param connectionPoint defines the other connection point
  60541. * @returns a number defining the compatibility state
  60542. */
  60543. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60544. /**
  60545. * Creates a block suitable to be used as an input for this input point.
  60546. * If null is returned, a block based on the point type will be created.
  60547. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  60548. */
  60549. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  60550. }
  60551. }
  60552. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  60553. /**
  60554. * Enum defining the type of properties that can be edited in the property pages in the NME
  60555. */
  60556. export enum PropertyTypeForEdition {
  60557. /** property is a boolean */
  60558. Boolean = 0,
  60559. /** property is a float */
  60560. Float = 1,
  60561. /** property is a Vector2 */
  60562. Vector2 = 2,
  60563. /** property is a list of values */
  60564. List = 3
  60565. }
  60566. /**
  60567. * Interface that defines an option in a variable of type list
  60568. */
  60569. export interface IEditablePropertyListOption {
  60570. /** label of the option */
  60571. "label": string;
  60572. /** value of the option */
  60573. "value": number;
  60574. }
  60575. /**
  60576. * Interface that defines the options available for an editable property
  60577. */
  60578. export interface IEditablePropertyOption {
  60579. /** min value */
  60580. "min"?: number;
  60581. /** max value */
  60582. "max"?: number;
  60583. /** notifiers: indicates which actions to take when the property is changed */
  60584. "notifiers"?: {
  60585. /** the material should be rebuilt */
  60586. "rebuild"?: boolean;
  60587. /** the preview should be updated */
  60588. "update"?: boolean;
  60589. };
  60590. /** list of the options for a variable of type list */
  60591. "options"?: IEditablePropertyListOption[];
  60592. }
  60593. /**
  60594. * Interface that describes an editable property
  60595. */
  60596. export interface IPropertyDescriptionForEdition {
  60597. /** name of the property */
  60598. "propertyName": string;
  60599. /** display name of the property */
  60600. "displayName": string;
  60601. /** type of the property */
  60602. "type": PropertyTypeForEdition;
  60603. /** group of the property - all properties with the same group value will be displayed in a specific section */
  60604. "groupName": string;
  60605. /** options for the property */
  60606. "options": IEditablePropertyOption;
  60607. }
  60608. /**
  60609. * Decorator that flags a property in a node material block as being editable
  60610. */
  60611. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  60612. }
  60613. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  60614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60616. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60618. import { Nullable } from "babylonjs/types";
  60619. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60620. import { Mesh } from "babylonjs/Meshes/mesh";
  60621. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60622. import { Effect } from "babylonjs/Materials/effect";
  60623. import { Scene } from "babylonjs/scene";
  60624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60625. /**
  60626. * Block used to implement the refraction part of the sub surface module of the PBR material
  60627. */
  60628. export class RefractionBlock extends NodeMaterialBlock {
  60629. /** @hidden */
  60630. _define3DName: string;
  60631. /** @hidden */
  60632. _refractionMatrixName: string;
  60633. /** @hidden */
  60634. _defineLODRefractionAlpha: string;
  60635. /** @hidden */
  60636. _defineLinearSpecularRefraction: string;
  60637. /** @hidden */
  60638. _defineOppositeZ: string;
  60639. /** @hidden */
  60640. _cubeSamplerName: string;
  60641. /** @hidden */
  60642. _2DSamplerName: string;
  60643. /** @hidden */
  60644. _vRefractionMicrosurfaceInfosName: string;
  60645. /** @hidden */
  60646. _vRefractionInfosName: string;
  60647. private _scene;
  60648. /**
  60649. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  60650. * Materials half opaque for instance using refraction could benefit from this control.
  60651. */
  60652. linkRefractionWithTransparency: boolean;
  60653. /**
  60654. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  60655. */
  60656. invertRefractionY: boolean;
  60657. /**
  60658. * Gets or sets the texture associated with the node
  60659. */
  60660. texture: Nullable<BaseTexture>;
  60661. /**
  60662. * Create a new RefractionBlock
  60663. * @param name defines the block name
  60664. */
  60665. constructor(name: string);
  60666. /**
  60667. * Gets the current class name
  60668. * @returns the class name
  60669. */
  60670. getClassName(): string;
  60671. /**
  60672. * Gets the intensity input component
  60673. */
  60674. get intensity(): NodeMaterialConnectionPoint;
  60675. /**
  60676. * Gets the index of refraction input component
  60677. */
  60678. get indexOfRefraction(): NodeMaterialConnectionPoint;
  60679. /**
  60680. * Gets the tint at distance input component
  60681. */
  60682. get tintAtDistance(): NodeMaterialConnectionPoint;
  60683. /**
  60684. * Gets the view input component
  60685. */
  60686. get view(): NodeMaterialConnectionPoint;
  60687. /**
  60688. * Gets the refraction object output component
  60689. */
  60690. get refraction(): NodeMaterialConnectionPoint;
  60691. /**
  60692. * Returns true if the block has a texture
  60693. */
  60694. get hasTexture(): boolean;
  60695. protected _getTexture(): Nullable<BaseTexture>;
  60696. autoConfigure(material: NodeMaterial): void;
  60697. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60698. isReady(): boolean;
  60699. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  60700. /**
  60701. * Gets the main code of the block (fragment side)
  60702. * @param state current state of the node material building
  60703. * @returns the shader code
  60704. */
  60705. getCode(state: NodeMaterialBuildState): string;
  60706. protected _buildBlock(state: NodeMaterialBuildState): this;
  60707. protected _dumpPropertiesCode(): string;
  60708. serialize(): any;
  60709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60710. }
  60711. }
  60712. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60714. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60715. import { Scene } from "babylonjs/scene";
  60716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60717. import { Matrix } from "babylonjs/Maths/math.vector";
  60718. import { Mesh } from "babylonjs/Meshes/mesh";
  60719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60720. import { Observable } from "babylonjs/Misc/observable";
  60721. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60722. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60723. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60724. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60725. import { Nullable } from "babylonjs/types";
  60726. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60727. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60728. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  60729. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  60730. /**
  60731. * Interface used to configure the node material editor
  60732. */
  60733. export interface INodeMaterialEditorOptions {
  60734. /** Define the URl to load node editor script */
  60735. editorURL?: string;
  60736. }
  60737. /** @hidden */
  60738. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60739. NORMAL: boolean;
  60740. TANGENT: boolean;
  60741. UV1: boolean;
  60742. /** BONES */
  60743. NUM_BONE_INFLUENCERS: number;
  60744. BonesPerMesh: number;
  60745. BONETEXTURE: boolean;
  60746. /** MORPH TARGETS */
  60747. MORPHTARGETS: boolean;
  60748. MORPHTARGETS_NORMAL: boolean;
  60749. MORPHTARGETS_TANGENT: boolean;
  60750. MORPHTARGETS_UV: boolean;
  60751. NUM_MORPH_INFLUENCERS: number;
  60752. /** IMAGE PROCESSING */
  60753. IMAGEPROCESSING: boolean;
  60754. VIGNETTE: boolean;
  60755. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60756. VIGNETTEBLENDMODEOPAQUE: boolean;
  60757. TONEMAPPING: boolean;
  60758. TONEMAPPING_ACES: boolean;
  60759. CONTRAST: boolean;
  60760. EXPOSURE: boolean;
  60761. COLORCURVES: boolean;
  60762. COLORGRADING: boolean;
  60763. COLORGRADING3D: boolean;
  60764. SAMPLER3DGREENDEPTH: boolean;
  60765. SAMPLER3DBGRMAP: boolean;
  60766. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60767. /** MISC. */
  60768. BUMPDIRECTUV: number;
  60769. constructor();
  60770. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  60771. }
  60772. /**
  60773. * Class used to configure NodeMaterial
  60774. */
  60775. export interface INodeMaterialOptions {
  60776. /**
  60777. * Defines if blocks should emit comments
  60778. */
  60779. emitComments: boolean;
  60780. }
  60781. /**
  60782. * Class used to create a node based material built by assembling shader blocks
  60783. */
  60784. export class NodeMaterial extends PushMaterial {
  60785. private static _BuildIdGenerator;
  60786. private _options;
  60787. private _vertexCompilationState;
  60788. private _fragmentCompilationState;
  60789. private _sharedData;
  60790. private _buildId;
  60791. private _buildWasSuccessful;
  60792. private _cachedWorldViewMatrix;
  60793. private _cachedWorldViewProjectionMatrix;
  60794. private _optimizers;
  60795. private _animationFrame;
  60796. /** Define the Url to load node editor script */
  60797. static EditorURL: string;
  60798. /** Define the Url to load snippets */
  60799. static SnippetUrl: string;
  60800. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  60801. static IgnoreTexturesAtLoadTime: boolean;
  60802. private BJSNODEMATERIALEDITOR;
  60803. /** Get the inspector from bundle or global */
  60804. private _getGlobalNodeMaterialEditor;
  60805. /**
  60806. * Snippet ID if the material was created from the snippet server
  60807. */
  60808. snippetId: string;
  60809. /**
  60810. * Gets or sets data used by visual editor
  60811. * @see https://nme.babylonjs.com
  60812. */
  60813. editorData: any;
  60814. /**
  60815. * 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)
  60816. */
  60817. ignoreAlpha: boolean;
  60818. /**
  60819. * Defines the maximum number of lights that can be used in the material
  60820. */
  60821. maxSimultaneousLights: number;
  60822. /**
  60823. * Observable raised when the material is built
  60824. */
  60825. onBuildObservable: Observable<NodeMaterial>;
  60826. /**
  60827. * Gets or sets the root nodes of the material vertex shader
  60828. */
  60829. _vertexOutputNodes: NodeMaterialBlock[];
  60830. /**
  60831. * Gets or sets the root nodes of the material fragment (pixel) shader
  60832. */
  60833. _fragmentOutputNodes: NodeMaterialBlock[];
  60834. /** Gets or sets options to control the node material overall behavior */
  60835. get options(): INodeMaterialOptions;
  60836. set options(options: INodeMaterialOptions);
  60837. /**
  60838. * Default configuration related to image processing available in the standard Material.
  60839. */
  60840. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60841. /**
  60842. * Gets the image processing configuration used either in this material.
  60843. */
  60844. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60845. /**
  60846. * Sets the Default image processing configuration used either in the this material.
  60847. *
  60848. * If sets to null, the scene one is in use.
  60849. */
  60850. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60851. /**
  60852. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60853. */
  60854. attachedBlocks: NodeMaterialBlock[];
  60855. /**
  60856. * Create a new node based material
  60857. * @param name defines the material name
  60858. * @param scene defines the hosting scene
  60859. * @param options defines creation option
  60860. */
  60861. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60862. /**
  60863. * Gets the current class name of the material e.g. "NodeMaterial"
  60864. * @returns the class name
  60865. */
  60866. getClassName(): string;
  60867. /**
  60868. * Keep track of the image processing observer to allow dispose and replace.
  60869. */
  60870. private _imageProcessingObserver;
  60871. /**
  60872. * Attaches a new image processing configuration to the Standard Material.
  60873. * @param configuration
  60874. */
  60875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60876. /**
  60877. * Get a block by its name
  60878. * @param name defines the name of the block to retrieve
  60879. * @returns the required block or null if not found
  60880. */
  60881. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60882. /**
  60883. * Get a block by its name
  60884. * @param predicate defines the predicate used to find the good candidate
  60885. * @returns the required block or null if not found
  60886. */
  60887. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60888. /**
  60889. * Get an input block by its name
  60890. * @param predicate defines the predicate used to find the good candidate
  60891. * @returns the required input block or null if not found
  60892. */
  60893. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60894. /**
  60895. * Gets the list of input blocks attached to this material
  60896. * @returns an array of InputBlocks
  60897. */
  60898. getInputBlocks(): InputBlock[];
  60899. /**
  60900. * Adds a new optimizer to the list of optimizers
  60901. * @param optimizer defines the optimizers to add
  60902. * @returns the current material
  60903. */
  60904. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60905. /**
  60906. * Remove an optimizer from the list of optimizers
  60907. * @param optimizer defines the optimizers to remove
  60908. * @returns the current material
  60909. */
  60910. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60911. /**
  60912. * Add a new block to the list of output nodes
  60913. * @param node defines the node to add
  60914. * @returns the current material
  60915. */
  60916. addOutputNode(node: NodeMaterialBlock): this;
  60917. /**
  60918. * Remove a block from the list of root nodes
  60919. * @param node defines the node to remove
  60920. * @returns the current material
  60921. */
  60922. removeOutputNode(node: NodeMaterialBlock): this;
  60923. private _addVertexOutputNode;
  60924. private _removeVertexOutputNode;
  60925. private _addFragmentOutputNode;
  60926. private _removeFragmentOutputNode;
  60927. /**
  60928. * Specifies if the material will require alpha blending
  60929. * @returns a boolean specifying if alpha blending is needed
  60930. */
  60931. needAlphaBlending(): boolean;
  60932. /**
  60933. * Specifies if this material should be rendered in alpha test mode
  60934. * @returns a boolean specifying if an alpha test is needed.
  60935. */
  60936. needAlphaTesting(): boolean;
  60937. private _initializeBlock;
  60938. private _resetDualBlocks;
  60939. /**
  60940. * Remove a block from the current node material
  60941. * @param block defines the block to remove
  60942. */
  60943. removeBlock(block: NodeMaterialBlock): void;
  60944. /**
  60945. * Build the material and generates the inner effect
  60946. * @param verbose defines if the build should log activity
  60947. */
  60948. build(verbose?: boolean): void;
  60949. /**
  60950. * Runs an otpimization phase to try to improve the shader code
  60951. */
  60952. optimize(): void;
  60953. private _prepareDefinesForAttributes;
  60954. /**
  60955. * Get if the submesh is ready to be used and all its information available.
  60956. * Child classes can use it to update shaders
  60957. * @param mesh defines the mesh to check
  60958. * @param subMesh defines which submesh to check
  60959. * @param useInstances specifies that instances should be used
  60960. * @returns a boolean indicating that the submesh is ready or not
  60961. */
  60962. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60963. /**
  60964. * Get a string representing the shaders built by the current node graph
  60965. */
  60966. get compiledShaders(): string;
  60967. /**
  60968. * Binds the world matrix to the material
  60969. * @param world defines the world transformation matrix
  60970. */
  60971. bindOnlyWorldMatrix(world: Matrix): void;
  60972. /**
  60973. * Binds the submesh to this material by preparing the effect and shader to draw
  60974. * @param world defines the world transformation matrix
  60975. * @param mesh defines the mesh containing the submesh
  60976. * @param subMesh defines the submesh to bind the material to
  60977. */
  60978. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60979. /**
  60980. * Gets the active textures from the material
  60981. * @returns an array of textures
  60982. */
  60983. getActiveTextures(): BaseTexture[];
  60984. /**
  60985. * Gets the list of texture blocks
  60986. * @returns an array of texture blocks
  60987. */
  60988. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock)[];
  60989. /**
  60990. * Specifies if the material uses a texture
  60991. * @param texture defines the texture to check against the material
  60992. * @returns a boolean specifying if the material uses the texture
  60993. */
  60994. hasTexture(texture: BaseTexture): boolean;
  60995. /**
  60996. * Disposes the material
  60997. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60998. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60999. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  61000. */
  61001. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  61002. /** Creates the node editor window. */
  61003. private _createNodeEditor;
  61004. /**
  61005. * Launch the node material editor
  61006. * @param config Define the configuration of the editor
  61007. * @return a promise fulfilled when the node editor is visible
  61008. */
  61009. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  61010. /**
  61011. * Clear the current material
  61012. */
  61013. clear(): void;
  61014. /**
  61015. * Clear the current material and set it to a default state
  61016. */
  61017. setToDefault(): void;
  61018. /**
  61019. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  61020. * @param url defines the url to load from
  61021. * @returns a promise that will fullfil when the material is fully loaded
  61022. */
  61023. loadAsync(url: string): Promise<void>;
  61024. private _gatherBlocks;
  61025. /**
  61026. * Generate a string containing the code declaration required to create an equivalent of this material
  61027. * @returns a string
  61028. */
  61029. generateCode(): string;
  61030. /**
  61031. * Serializes this material in a JSON representation
  61032. * @returns the serialized material object
  61033. */
  61034. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  61035. private _restoreConnections;
  61036. /**
  61037. * Clear the current graph and load a new one from a serialization object
  61038. * @param source defines the JSON representation of the material
  61039. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61040. */
  61041. loadFromSerialization(source: any, rootUrl?: string): void;
  61042. /**
  61043. * Makes a duplicate of the current material.
  61044. * @param name - name to use for the new material.
  61045. */
  61046. clone(name: string): NodeMaterial;
  61047. /**
  61048. * Creates a node material from parsed material data
  61049. * @param source defines the JSON representation of the material
  61050. * @param scene defines the hosting scene
  61051. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61052. * @returns a new node material
  61053. */
  61054. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  61055. /**
  61056. * Creates a node material from a snippet saved in a remote file
  61057. * @param name defines the name of the material to create
  61058. * @param url defines the url to load from
  61059. * @param scene defines the hosting scene
  61060. * @returns a promise that will resolve to the new node material
  61061. */
  61062. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  61063. /**
  61064. * Creates a node material from a snippet saved by the node material editor
  61065. * @param snippetId defines the snippet to load
  61066. * @param scene defines the hosting scene
  61067. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61068. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  61069. * @returns a promise that will resolve to the new node material
  61070. */
  61071. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  61072. /**
  61073. * Creates a new node material set to default basic configuration
  61074. * @param name defines the name of the material
  61075. * @param scene defines the hosting scene
  61076. * @returns a new NodeMaterial
  61077. */
  61078. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  61079. }
  61080. }
  61081. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  61082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61084. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61085. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61087. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61088. import { Effect } from "babylonjs/Materials/effect";
  61089. import { Mesh } from "babylonjs/Meshes/mesh";
  61090. import { Nullable } from "babylonjs/types";
  61091. import { Texture } from "babylonjs/Materials/Textures/texture";
  61092. import { Scene } from "babylonjs/scene";
  61093. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61094. /**
  61095. * Block used to read a texture from a sampler
  61096. */
  61097. export class TextureBlock extends NodeMaterialBlock {
  61098. private _defineName;
  61099. private _linearDefineName;
  61100. private _gammaDefineName;
  61101. private _tempTextureRead;
  61102. private _samplerName;
  61103. private _transformedUVName;
  61104. private _textureTransformName;
  61105. private _textureInfoName;
  61106. private _mainUVName;
  61107. private _mainUVDefineName;
  61108. /**
  61109. * Gets or sets the texture associated with the node
  61110. */
  61111. texture: Nullable<Texture>;
  61112. /**
  61113. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  61114. */
  61115. convertToGammaSpace: boolean;
  61116. /**
  61117. * Gets or sets a boolean indicating if content needs to be converted to linear space
  61118. */
  61119. convertToLinearSpace: boolean;
  61120. /**
  61121. * Create a new TextureBlock
  61122. * @param name defines the block name
  61123. */
  61124. constructor(name: string);
  61125. /**
  61126. * Gets the current class name
  61127. * @returns the class name
  61128. */
  61129. getClassName(): string;
  61130. /**
  61131. * Gets the uv input component
  61132. */
  61133. get uv(): NodeMaterialConnectionPoint;
  61134. /**
  61135. * Gets the rgba output component
  61136. */
  61137. get rgba(): NodeMaterialConnectionPoint;
  61138. /**
  61139. * Gets the rgb output component
  61140. */
  61141. get rgb(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the r output component
  61144. */
  61145. get r(): NodeMaterialConnectionPoint;
  61146. /**
  61147. * Gets the g output component
  61148. */
  61149. get g(): NodeMaterialConnectionPoint;
  61150. /**
  61151. * Gets the b output component
  61152. */
  61153. get b(): NodeMaterialConnectionPoint;
  61154. /**
  61155. * Gets the a output component
  61156. */
  61157. get a(): NodeMaterialConnectionPoint;
  61158. get target(): NodeMaterialBlockTargets;
  61159. autoConfigure(material: NodeMaterial): void;
  61160. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61162. isReady(): boolean;
  61163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61164. private get _isMixed();
  61165. private _injectVertexCode;
  61166. private _writeTextureRead;
  61167. private _writeOutput;
  61168. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61169. protected _dumpPropertiesCode(): string;
  61170. serialize(): any;
  61171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61172. }
  61173. }
  61174. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  61175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61177. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61178. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61179. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  61180. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  61181. import { Scene } from "babylonjs/scene";
  61182. /**
  61183. * Class used to store shared data between 2 NodeMaterialBuildState
  61184. */
  61185. export class NodeMaterialBuildStateSharedData {
  61186. /**
  61187. * Gets the list of emitted varyings
  61188. */
  61189. temps: string[];
  61190. /**
  61191. * Gets the list of emitted varyings
  61192. */
  61193. varyings: string[];
  61194. /**
  61195. * Gets the varying declaration string
  61196. */
  61197. varyingDeclaration: string;
  61198. /**
  61199. * Input blocks
  61200. */
  61201. inputBlocks: InputBlock[];
  61202. /**
  61203. * Input blocks
  61204. */
  61205. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock)[];
  61206. /**
  61207. * Bindable blocks (Blocks that need to set data to the effect)
  61208. */
  61209. bindableBlocks: NodeMaterialBlock[];
  61210. /**
  61211. * List of blocks that can provide a compilation fallback
  61212. */
  61213. blocksWithFallbacks: NodeMaterialBlock[];
  61214. /**
  61215. * List of blocks that can provide a define update
  61216. */
  61217. blocksWithDefines: NodeMaterialBlock[];
  61218. /**
  61219. * List of blocks that can provide a repeatable content
  61220. */
  61221. repeatableContentBlocks: NodeMaterialBlock[];
  61222. /**
  61223. * List of blocks that can provide a dynamic list of uniforms
  61224. */
  61225. dynamicUniformBlocks: NodeMaterialBlock[];
  61226. /**
  61227. * List of blocks that can block the isReady function for the material
  61228. */
  61229. blockingBlocks: NodeMaterialBlock[];
  61230. /**
  61231. * Gets the list of animated inputs
  61232. */
  61233. animatedInputs: InputBlock[];
  61234. /**
  61235. * Build Id used to avoid multiple recompilations
  61236. */
  61237. buildId: number;
  61238. /** List of emitted variables */
  61239. variableNames: {
  61240. [key: string]: number;
  61241. };
  61242. /** List of emitted defines */
  61243. defineNames: {
  61244. [key: string]: number;
  61245. };
  61246. /** Should emit comments? */
  61247. emitComments: boolean;
  61248. /** Emit build activity */
  61249. verbose: boolean;
  61250. /** Gets or sets the hosting scene */
  61251. scene: Scene;
  61252. /**
  61253. * Gets the compilation hints emitted at compilation time
  61254. */
  61255. hints: {
  61256. needWorldViewMatrix: boolean;
  61257. needWorldViewProjectionMatrix: boolean;
  61258. needAlphaBlending: boolean;
  61259. needAlphaTesting: boolean;
  61260. };
  61261. /**
  61262. * List of compilation checks
  61263. */
  61264. checks: {
  61265. emitVertex: boolean;
  61266. emitFragment: boolean;
  61267. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  61268. };
  61269. /** Creates a new shared data */
  61270. constructor();
  61271. /**
  61272. * Emits console errors and exceptions if there is a failing check
  61273. */
  61274. emitErrors(): void;
  61275. }
  61276. }
  61277. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  61278. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61279. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61280. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  61281. /**
  61282. * Class used to store node based material build state
  61283. */
  61284. export class NodeMaterialBuildState {
  61285. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  61286. supportUniformBuffers: boolean;
  61287. /**
  61288. * Gets the list of emitted attributes
  61289. */
  61290. attributes: string[];
  61291. /**
  61292. * Gets the list of emitted uniforms
  61293. */
  61294. uniforms: string[];
  61295. /**
  61296. * Gets the list of emitted constants
  61297. */
  61298. constants: string[];
  61299. /**
  61300. * Gets the list of emitted samplers
  61301. */
  61302. samplers: string[];
  61303. /**
  61304. * Gets the list of emitted functions
  61305. */
  61306. functions: {
  61307. [key: string]: string;
  61308. };
  61309. /**
  61310. * Gets the list of emitted extensions
  61311. */
  61312. extensions: {
  61313. [key: string]: string;
  61314. };
  61315. /**
  61316. * Gets the target of the compilation state
  61317. */
  61318. target: NodeMaterialBlockTargets;
  61319. /**
  61320. * Gets the list of emitted counters
  61321. */
  61322. counters: {
  61323. [key: string]: number;
  61324. };
  61325. /**
  61326. * Shared data between multiple NodeMaterialBuildState instances
  61327. */
  61328. sharedData: NodeMaterialBuildStateSharedData;
  61329. /** @hidden */
  61330. _vertexState: NodeMaterialBuildState;
  61331. /** @hidden */
  61332. _attributeDeclaration: string;
  61333. /** @hidden */
  61334. _uniformDeclaration: string;
  61335. /** @hidden */
  61336. _constantDeclaration: string;
  61337. /** @hidden */
  61338. _samplerDeclaration: string;
  61339. /** @hidden */
  61340. _varyingTransfer: string;
  61341. /** @hidden */
  61342. _injectAtEnd: string;
  61343. private _repeatableContentAnchorIndex;
  61344. /** @hidden */
  61345. _builtCompilationString: string;
  61346. /**
  61347. * Gets the emitted compilation strings
  61348. */
  61349. compilationString: string;
  61350. /**
  61351. * Finalize the compilation strings
  61352. * @param state defines the current compilation state
  61353. */
  61354. finalize(state: NodeMaterialBuildState): void;
  61355. /** @hidden */
  61356. get _repeatableContentAnchor(): string;
  61357. /** @hidden */
  61358. _getFreeVariableName(prefix: string): string;
  61359. /** @hidden */
  61360. _getFreeDefineName(prefix: string): string;
  61361. /** @hidden */
  61362. _excludeVariableName(name: string): void;
  61363. /** @hidden */
  61364. _emit2DSampler(name: string): void;
  61365. /** @hidden */
  61366. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  61367. /** @hidden */
  61368. _emitExtension(name: string, extension: string): void;
  61369. /** @hidden */
  61370. _emitFunction(name: string, code: string, comments: string): void;
  61371. /** @hidden */
  61372. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  61373. replaceStrings?: {
  61374. search: RegExp;
  61375. replace: string;
  61376. }[];
  61377. repeatKey?: string;
  61378. }): string;
  61379. /** @hidden */
  61380. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  61381. repeatKey?: string;
  61382. removeAttributes?: boolean;
  61383. removeUniforms?: boolean;
  61384. removeVaryings?: boolean;
  61385. removeIfDef?: boolean;
  61386. replaceStrings?: {
  61387. search: RegExp;
  61388. replace: string;
  61389. }[];
  61390. }, storeKey?: string): void;
  61391. /** @hidden */
  61392. _registerTempVariable(name: string): boolean;
  61393. /** @hidden */
  61394. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  61395. /** @hidden */
  61396. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  61397. /** @hidden */
  61398. _emitFloat(value: number): string;
  61399. }
  61400. }
  61401. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  61402. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61404. import { Nullable } from "babylonjs/types";
  61405. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61406. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61407. import { Effect } from "babylonjs/Materials/effect";
  61408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61409. import { Mesh } from "babylonjs/Meshes/mesh";
  61410. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61411. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61412. import { Scene } from "babylonjs/scene";
  61413. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61414. /**
  61415. * Defines a block that can be used inside a node based material
  61416. */
  61417. export class NodeMaterialBlock {
  61418. private _buildId;
  61419. private _buildTarget;
  61420. private _target;
  61421. private _isFinalMerger;
  61422. private _isInput;
  61423. protected _isUnique: boolean;
  61424. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  61425. inputsAreExclusive: boolean;
  61426. /** @hidden */
  61427. _codeVariableName: string;
  61428. /** @hidden */
  61429. _inputs: NodeMaterialConnectionPoint[];
  61430. /** @hidden */
  61431. _outputs: NodeMaterialConnectionPoint[];
  61432. /** @hidden */
  61433. _preparationId: number;
  61434. /**
  61435. * Gets or sets the name of the block
  61436. */
  61437. name: string;
  61438. /**
  61439. * Gets or sets the unique id of the node
  61440. */
  61441. uniqueId: number;
  61442. /**
  61443. * Gets or sets the comments associated with this block
  61444. */
  61445. comments: string;
  61446. /**
  61447. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  61448. */
  61449. get isUnique(): boolean;
  61450. /**
  61451. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  61452. */
  61453. get isFinalMerger(): boolean;
  61454. /**
  61455. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  61456. */
  61457. get isInput(): boolean;
  61458. /**
  61459. * Gets or sets the build Id
  61460. */
  61461. get buildId(): number;
  61462. set buildId(value: number);
  61463. /**
  61464. * Gets or sets the target of the block
  61465. */
  61466. get target(): NodeMaterialBlockTargets;
  61467. set target(value: NodeMaterialBlockTargets);
  61468. /**
  61469. * Gets the list of input points
  61470. */
  61471. get inputs(): NodeMaterialConnectionPoint[];
  61472. /** Gets the list of output points */
  61473. get outputs(): NodeMaterialConnectionPoint[];
  61474. /**
  61475. * Find an input by its name
  61476. * @param name defines the name of the input to look for
  61477. * @returns the input or null if not found
  61478. */
  61479. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61480. /**
  61481. * Find an output by its name
  61482. * @param name defines the name of the outputto look for
  61483. * @returns the output or null if not found
  61484. */
  61485. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  61486. /**
  61487. * Creates a new NodeMaterialBlock
  61488. * @param name defines the block name
  61489. * @param target defines the target of that block (Vertex by default)
  61490. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  61491. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  61492. */
  61493. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  61494. /**
  61495. * Initialize the block and prepare the context for build
  61496. * @param state defines the state that will be used for the build
  61497. */
  61498. initialize(state: NodeMaterialBuildState): void;
  61499. /**
  61500. * Bind data to effect. Will only be called for blocks with isBindable === true
  61501. * @param effect defines the effect to bind data to
  61502. * @param nodeMaterial defines the hosting NodeMaterial
  61503. * @param mesh defines the mesh that will be rendered
  61504. * @param subMesh defines the submesh that will be rendered
  61505. */
  61506. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61507. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  61508. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  61509. protected _writeFloat(value: number): string;
  61510. /**
  61511. * Gets the current class name e.g. "NodeMaterialBlock"
  61512. * @returns the class name
  61513. */
  61514. getClassName(): string;
  61515. /**
  61516. * Register a new input. Must be called inside a block constructor
  61517. * @param name defines the connection point name
  61518. * @param type defines the connection point type
  61519. * @param isOptional defines a boolean indicating that this input can be omitted
  61520. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61521. * @param point an already created connection point. If not provided, create a new one
  61522. * @returns the current block
  61523. */
  61524. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61525. /**
  61526. * Register a new output. Must be called inside a block constructor
  61527. * @param name defines the connection point name
  61528. * @param type defines the connection point type
  61529. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61530. * @param point an already created connection point. If not provided, create a new one
  61531. * @returns the current block
  61532. */
  61533. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  61534. /**
  61535. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61536. * @param forOutput defines an optional connection point to check compatibility with
  61537. * @returns the first available input or null
  61538. */
  61539. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61540. /**
  61541. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61542. * @param forBlock defines an optional block to check compatibility with
  61543. * @returns the first available input or null
  61544. */
  61545. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61546. /**
  61547. * Gets the sibling of the given output
  61548. * @param current defines the current output
  61549. * @returns the next output in the list or null
  61550. */
  61551. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61552. /**
  61553. * Connect current block with another block
  61554. * @param other defines the block to connect with
  61555. * @param options define the various options to help pick the right connections
  61556. * @returns the current block
  61557. */
  61558. connectTo(other: NodeMaterialBlock, options?: {
  61559. input?: string;
  61560. output?: string;
  61561. outputSwizzle?: string;
  61562. }): this | undefined;
  61563. protected _buildBlock(state: NodeMaterialBuildState): void;
  61564. /**
  61565. * Add uniforms, samplers and uniform buffers at compilation time
  61566. * @param state defines the state to update
  61567. * @param nodeMaterial defines the node material requesting the update
  61568. * @param defines defines the material defines to update
  61569. * @param uniformBuffers defines the list of uniform buffer names
  61570. */
  61571. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61572. /**
  61573. * Add potential fallbacks if shader compilation fails
  61574. * @param mesh defines the mesh to be rendered
  61575. * @param fallbacks defines the current prioritized list of fallbacks
  61576. */
  61577. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61578. /**
  61579. * Initialize defines for shader compilation
  61580. * @param mesh defines the mesh to be rendered
  61581. * @param nodeMaterial defines the node material requesting the update
  61582. * @param defines defines the material defines to update
  61583. * @param useInstances specifies that instances should be used
  61584. */
  61585. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61586. /**
  61587. * Update defines for shader compilation
  61588. * @param mesh defines the mesh to be rendered
  61589. * @param nodeMaterial defines the node material requesting the update
  61590. * @param defines defines the material defines to update
  61591. * @param useInstances specifies that instances should be used
  61592. */
  61593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61594. /**
  61595. * Lets the block try to connect some inputs automatically
  61596. * @param material defines the hosting NodeMaterial
  61597. */
  61598. autoConfigure(material: NodeMaterial): void;
  61599. /**
  61600. * Function called when a block is declared as repeatable content generator
  61601. * @param vertexShaderState defines the current compilation state for the vertex shader
  61602. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61603. * @param mesh defines the mesh to be rendered
  61604. * @param defines defines the material defines to update
  61605. */
  61606. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61607. /**
  61608. * Checks if the block is ready
  61609. * @param mesh defines the mesh to be rendered
  61610. * @param nodeMaterial defines the node material requesting the update
  61611. * @param defines defines the material defines to update
  61612. * @param useInstances specifies that instances should be used
  61613. * @returns true if the block is ready
  61614. */
  61615. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61616. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61617. private _processBuild;
  61618. /**
  61619. * Compile the current node and generate the shader code
  61620. * @param state defines the current compilation state (uniforms, samplers, current string)
  61621. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61622. * @returns true if already built
  61623. */
  61624. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61625. protected _inputRename(name: string): string;
  61626. protected _outputRename(name: string): string;
  61627. protected _dumpPropertiesCode(): string;
  61628. /** @hidden */
  61629. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61630. /** @hidden */
  61631. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61632. /**
  61633. * Clone the current block to a new identical block
  61634. * @param scene defines the hosting scene
  61635. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61636. * @returns a copy of the current block
  61637. */
  61638. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61639. /**
  61640. * Serializes this block in a JSON representation
  61641. * @returns the serialized block object
  61642. */
  61643. serialize(): any;
  61644. /** @hidden */
  61645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61646. private _deserializePortDisplayNames;
  61647. /**
  61648. * Release resources
  61649. */
  61650. dispose(): void;
  61651. }
  61652. }
  61653. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61654. /**
  61655. * Enum defining the type of animations supported by InputBlock
  61656. */
  61657. export enum AnimatedInputBlockTypes {
  61658. /** No animation */
  61659. None = 0,
  61660. /** Time based animation. Will only work for floats */
  61661. Time = 1
  61662. }
  61663. }
  61664. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61666. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61667. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61668. import { Nullable } from "babylonjs/types";
  61669. import { Effect } from "babylonjs/Materials/effect";
  61670. import { Matrix } from "babylonjs/Maths/math.vector";
  61671. import { Scene } from "babylonjs/scene";
  61672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61673. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61674. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61675. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61676. import { Observable } from "babylonjs/Misc/observable";
  61677. /**
  61678. * Block used to expose an input value
  61679. */
  61680. export class InputBlock extends NodeMaterialBlock {
  61681. private _mode;
  61682. private _associatedVariableName;
  61683. private _storedValue;
  61684. private _valueCallback;
  61685. private _type;
  61686. private _animationType;
  61687. /** Gets or set a value used to limit the range of float values */
  61688. min: number;
  61689. /** Gets or set a value used to limit the range of float values */
  61690. max: number;
  61691. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61692. isBoolean: boolean;
  61693. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61694. matrixMode: number;
  61695. /** @hidden */
  61696. _systemValue: Nullable<NodeMaterialSystemValues>;
  61697. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61698. visibleInInspector: boolean;
  61699. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61700. isConstant: boolean;
  61701. /** Gets or sets the group to use to display this block in the Inspector */
  61702. groupInInspector: string;
  61703. /** Gets an observable raised when the value is changed */
  61704. onValueChangedObservable: Observable<InputBlock>;
  61705. /**
  61706. * Gets or sets the connection point type (default is float)
  61707. */
  61708. get type(): NodeMaterialBlockConnectionPointTypes;
  61709. /**
  61710. * Creates a new InputBlock
  61711. * @param name defines the block name
  61712. * @param target defines the target of that block (Vertex by default)
  61713. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61714. */
  61715. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61716. /**
  61717. * Gets the output component
  61718. */
  61719. get output(): NodeMaterialConnectionPoint;
  61720. /**
  61721. * Set the source of this connection point to a vertex attribute
  61722. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61723. * @returns the current connection point
  61724. */
  61725. setAsAttribute(attributeName?: string): InputBlock;
  61726. /**
  61727. * Set the source of this connection point to a system value
  61728. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61729. * @returns the current connection point
  61730. */
  61731. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61732. /**
  61733. * Gets or sets the value of that point.
  61734. * Please note that this value will be ignored if valueCallback is defined
  61735. */
  61736. get value(): any;
  61737. set value(value: any);
  61738. /**
  61739. * Gets or sets a callback used to get the value of that point.
  61740. * Please note that setting this value will force the connection point to ignore the value property
  61741. */
  61742. get valueCallback(): () => any;
  61743. set valueCallback(value: () => any);
  61744. /**
  61745. * Gets or sets the associated variable name in the shader
  61746. */
  61747. get associatedVariableName(): string;
  61748. set associatedVariableName(value: string);
  61749. /** Gets or sets the type of animation applied to the input */
  61750. get animationType(): AnimatedInputBlockTypes;
  61751. set animationType(value: AnimatedInputBlockTypes);
  61752. /**
  61753. * Gets a boolean indicating that this connection point not defined yet
  61754. */
  61755. get isUndefined(): boolean;
  61756. /**
  61757. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61758. * In this case the connection point name must be the name of the uniform to use.
  61759. * Can only be set on inputs
  61760. */
  61761. get isUniform(): boolean;
  61762. set isUniform(value: boolean);
  61763. /**
  61764. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61765. * In this case the connection point name must be the name of the attribute to use
  61766. * Can only be set on inputs
  61767. */
  61768. get isAttribute(): boolean;
  61769. set isAttribute(value: boolean);
  61770. /**
  61771. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61772. * Can only be set on exit points
  61773. */
  61774. get isVarying(): boolean;
  61775. set isVarying(value: boolean);
  61776. /**
  61777. * Gets a boolean indicating that the current connection point is a system value
  61778. */
  61779. get isSystemValue(): boolean;
  61780. /**
  61781. * Gets or sets the current well known value or null if not defined as a system value
  61782. */
  61783. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61784. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61785. /**
  61786. * Gets the current class name
  61787. * @returns the class name
  61788. */
  61789. getClassName(): string;
  61790. /**
  61791. * Animate the input if animationType !== None
  61792. * @param scene defines the rendering scene
  61793. */
  61794. animate(scene: Scene): void;
  61795. private _emitDefine;
  61796. initialize(state: NodeMaterialBuildState): void;
  61797. /**
  61798. * Set the input block to its default value (based on its type)
  61799. */
  61800. setDefaultValue(): void;
  61801. private _emitConstant;
  61802. private _emit;
  61803. /** @hidden */
  61804. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61805. /** @hidden */
  61806. _transmit(effect: Effect, scene: Scene): void;
  61807. protected _buildBlock(state: NodeMaterialBuildState): void;
  61808. protected _dumpPropertiesCode(): string;
  61809. dispose(): void;
  61810. serialize(): any;
  61811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61812. }
  61813. }
  61814. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61815. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61816. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61817. import { Nullable } from "babylonjs/types";
  61818. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61819. import { Observable } from "babylonjs/Misc/observable";
  61820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61821. /**
  61822. * Enum used to define the compatibility state between two connection points
  61823. */
  61824. export enum NodeMaterialConnectionPointCompatibilityStates {
  61825. /** Points are compatibles */
  61826. Compatible = 0,
  61827. /** Points are incompatible because of their types */
  61828. TypeIncompatible = 1,
  61829. /** Points are incompatible because of their targets (vertex vs fragment) */
  61830. TargetIncompatible = 2
  61831. }
  61832. /**
  61833. * Defines the direction of a connection point
  61834. */
  61835. export enum NodeMaterialConnectionPointDirection {
  61836. /** Input */
  61837. Input = 0,
  61838. /** Output */
  61839. Output = 1
  61840. }
  61841. /**
  61842. * Defines a connection point for a block
  61843. */
  61844. export class NodeMaterialConnectionPoint {
  61845. /** @hidden */
  61846. _ownerBlock: NodeMaterialBlock;
  61847. /** @hidden */
  61848. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61849. private _endpoints;
  61850. private _associatedVariableName;
  61851. private _direction;
  61852. /** @hidden */
  61853. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61854. /** @hidden */
  61855. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61856. private _type;
  61857. /** @hidden */
  61858. _enforceAssociatedVariableName: boolean;
  61859. /** Gets the direction of the point */
  61860. get direction(): NodeMaterialConnectionPointDirection;
  61861. /** Indicates that this connection point needs dual validation before being connected to another point */
  61862. needDualDirectionValidation: boolean;
  61863. /**
  61864. * Gets or sets the additional types supported by this connection point
  61865. */
  61866. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61867. /**
  61868. * Gets or sets the additional types excluded by this connection point
  61869. */
  61870. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61871. /**
  61872. * Observable triggered when this point is connected
  61873. */
  61874. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61875. /**
  61876. * Gets or sets the associated variable name in the shader
  61877. */
  61878. get associatedVariableName(): string;
  61879. set associatedVariableName(value: string);
  61880. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61881. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61882. /**
  61883. * Gets or sets the connection point type (default is float)
  61884. */
  61885. get type(): NodeMaterialBlockConnectionPointTypes;
  61886. set type(value: NodeMaterialBlockConnectionPointTypes);
  61887. /**
  61888. * Gets or sets the connection point name
  61889. */
  61890. name: string;
  61891. /**
  61892. * Gets or sets the connection point name
  61893. */
  61894. displayName: string;
  61895. /**
  61896. * Gets or sets a boolean indicating that this connection point can be omitted
  61897. */
  61898. isOptional: boolean;
  61899. /**
  61900. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61901. */
  61902. define: string;
  61903. /** @hidden */
  61904. _prioritizeVertex: boolean;
  61905. private _target;
  61906. /** Gets or sets the target of that connection point */
  61907. get target(): NodeMaterialBlockTargets;
  61908. set target(value: NodeMaterialBlockTargets);
  61909. /**
  61910. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  61911. */
  61912. get isConnected(): boolean;
  61913. /**
  61914. * Gets a boolean indicating that the current point is connected to an input block
  61915. */
  61916. get isConnectedToInputBlock(): boolean;
  61917. /**
  61918. * Gets a the connected input block (if any)
  61919. */
  61920. get connectInputBlock(): Nullable<InputBlock>;
  61921. /** Get the other side of the connection (if any) */
  61922. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61923. /** Get the block that owns this connection point */
  61924. get ownerBlock(): NodeMaterialBlock;
  61925. /** Get the block connected on the other side of this connection (if any) */
  61926. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61927. /** Get the block connected on the endpoints of this connection (if any) */
  61928. get connectedBlocks(): Array<NodeMaterialBlock>;
  61929. /** Gets the list of connected endpoints */
  61930. get endpoints(): NodeMaterialConnectionPoint[];
  61931. /** Gets a boolean indicating if that output point is connected to at least one input */
  61932. get hasEndpoints(): boolean;
  61933. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61934. get isConnectedInVertexShader(): boolean;
  61935. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61936. get isConnectedInFragmentShader(): boolean;
  61937. /**
  61938. * Creates a block suitable to be used as an input for this input point.
  61939. * If null is returned, a block based on the point type will be created.
  61940. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  61941. */
  61942. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  61943. /**
  61944. * Creates a new connection point
  61945. * @param name defines the connection point name
  61946. * @param ownerBlock defines the block hosting this connection point
  61947. * @param direction defines the direction of the connection point
  61948. */
  61949. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61950. /**
  61951. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61952. * @returns the class name
  61953. */
  61954. getClassName(): string;
  61955. /**
  61956. * Gets a boolean indicating if the current point can be connected to another point
  61957. * @param connectionPoint defines the other connection point
  61958. * @returns a boolean
  61959. */
  61960. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61961. /**
  61962. * Gets a number indicating if the current point can be connected to another point
  61963. * @param connectionPoint defines the other connection point
  61964. * @returns a number defining the compatibility state
  61965. */
  61966. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61967. /**
  61968. * Connect this point to another connection point
  61969. * @param connectionPoint defines the other connection point
  61970. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61971. * @returns the current connection point
  61972. */
  61973. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61974. /**
  61975. * Disconnect this point from one of his endpoint
  61976. * @param endpoint defines the other connection point
  61977. * @returns the current connection point
  61978. */
  61979. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Serializes this point in a JSON representation
  61982. * @param isInput defines if the connection point is an input (default is true)
  61983. * @returns the serialized point object
  61984. */
  61985. serialize(isInput?: boolean): any;
  61986. /**
  61987. * Release resources
  61988. */
  61989. dispose(): void;
  61990. }
  61991. }
  61992. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61993. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61994. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61996. import { Mesh } from "babylonjs/Meshes/mesh";
  61997. import { Effect } from "babylonjs/Materials/effect";
  61998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61999. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62000. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62001. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62002. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62003. /**
  62004. * Block used to add support for vertex skinning (bones)
  62005. */
  62006. export class BonesBlock extends NodeMaterialBlock {
  62007. /**
  62008. * Creates a new BonesBlock
  62009. * @param name defines the block name
  62010. */
  62011. constructor(name: string);
  62012. /**
  62013. * Initialize the block and prepare the context for build
  62014. * @param state defines the state that will be used for the build
  62015. */
  62016. initialize(state: NodeMaterialBuildState): void;
  62017. /**
  62018. * Gets the current class name
  62019. * @returns the class name
  62020. */
  62021. getClassName(): string;
  62022. /**
  62023. * Gets the matrix indices input component
  62024. */
  62025. get matricesIndices(): NodeMaterialConnectionPoint;
  62026. /**
  62027. * Gets the matrix weights input component
  62028. */
  62029. get matricesWeights(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the extra matrix indices input component
  62032. */
  62033. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the extra matrix weights input component
  62036. */
  62037. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the world input component
  62040. */
  62041. get world(): NodeMaterialConnectionPoint;
  62042. /**
  62043. * Gets the output component
  62044. */
  62045. get output(): NodeMaterialConnectionPoint;
  62046. autoConfigure(material: NodeMaterial): void;
  62047. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62050. protected _buildBlock(state: NodeMaterialBuildState): this;
  62051. }
  62052. }
  62053. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  62054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62058. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62059. /**
  62060. * Block used to add support for instances
  62061. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62062. */
  62063. export class InstancesBlock extends NodeMaterialBlock {
  62064. /**
  62065. * Creates a new InstancesBlock
  62066. * @param name defines the block name
  62067. */
  62068. constructor(name: string);
  62069. /**
  62070. * Gets the current class name
  62071. * @returns the class name
  62072. */
  62073. getClassName(): string;
  62074. /**
  62075. * Gets the first world row input component
  62076. */
  62077. get world0(): NodeMaterialConnectionPoint;
  62078. /**
  62079. * Gets the second world row input component
  62080. */
  62081. get world1(): NodeMaterialConnectionPoint;
  62082. /**
  62083. * Gets the third world row input component
  62084. */
  62085. get world2(): NodeMaterialConnectionPoint;
  62086. /**
  62087. * Gets the forth world row input component
  62088. */
  62089. get world3(): NodeMaterialConnectionPoint;
  62090. /**
  62091. * Gets the world input component
  62092. */
  62093. get world(): NodeMaterialConnectionPoint;
  62094. /**
  62095. * Gets the output component
  62096. */
  62097. get output(): NodeMaterialConnectionPoint;
  62098. /**
  62099. * Gets the isntanceID component
  62100. */
  62101. get instanceID(): NodeMaterialConnectionPoint;
  62102. autoConfigure(material: NodeMaterial): void;
  62103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  62104. protected _buildBlock(state: NodeMaterialBuildState): this;
  62105. }
  62106. }
  62107. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  62108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62112. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62113. import { Effect } from "babylonjs/Materials/effect";
  62114. import { Mesh } from "babylonjs/Meshes/mesh";
  62115. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62116. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62117. /**
  62118. * Block used to add morph targets support to vertex shader
  62119. */
  62120. export class MorphTargetsBlock extends NodeMaterialBlock {
  62121. private _repeatableContentAnchor;
  62122. /**
  62123. * Create a new MorphTargetsBlock
  62124. * @param name defines the block name
  62125. */
  62126. constructor(name: string);
  62127. /**
  62128. * Gets the current class name
  62129. * @returns the class name
  62130. */
  62131. getClassName(): string;
  62132. /**
  62133. * Gets the position input component
  62134. */
  62135. get position(): NodeMaterialConnectionPoint;
  62136. /**
  62137. * Gets the normal input component
  62138. */
  62139. get normal(): NodeMaterialConnectionPoint;
  62140. /**
  62141. * Gets the tangent input component
  62142. */
  62143. get tangent(): NodeMaterialConnectionPoint;
  62144. /**
  62145. * Gets the tangent input component
  62146. */
  62147. get uv(): NodeMaterialConnectionPoint;
  62148. /**
  62149. * Gets the position output component
  62150. */
  62151. get positionOutput(): NodeMaterialConnectionPoint;
  62152. /**
  62153. * Gets the normal output component
  62154. */
  62155. get normalOutput(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the tangent output component
  62158. */
  62159. get tangentOutput(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the tangent output component
  62162. */
  62163. get uvOutput(): NodeMaterialConnectionPoint;
  62164. initialize(state: NodeMaterialBuildState): void;
  62165. autoConfigure(material: NodeMaterial): void;
  62166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62167. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62168. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62169. protected _buildBlock(state: NodeMaterialBuildState): this;
  62170. }
  62171. }
  62172. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  62173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62176. import { Nullable } from "babylonjs/types";
  62177. import { Scene } from "babylonjs/scene";
  62178. import { Effect } from "babylonjs/Materials/effect";
  62179. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62180. import { Mesh } from "babylonjs/Meshes/mesh";
  62181. import { Light } from "babylonjs/Lights/light";
  62182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62183. /**
  62184. * Block used to get data information from a light
  62185. */
  62186. export class LightInformationBlock extends NodeMaterialBlock {
  62187. private _lightDataUniformName;
  62188. private _lightColorUniformName;
  62189. private _lightTypeDefineName;
  62190. /**
  62191. * Gets or sets the light associated with this block
  62192. */
  62193. light: Nullable<Light>;
  62194. /**
  62195. * Creates a new LightInformationBlock
  62196. * @param name defines the block name
  62197. */
  62198. constructor(name: string);
  62199. /**
  62200. * Gets the current class name
  62201. * @returns the class name
  62202. */
  62203. getClassName(): string;
  62204. /**
  62205. * Gets the world position input component
  62206. */
  62207. get worldPosition(): NodeMaterialConnectionPoint;
  62208. /**
  62209. * Gets the direction output component
  62210. */
  62211. get direction(): NodeMaterialConnectionPoint;
  62212. /**
  62213. * Gets the direction output component
  62214. */
  62215. get color(): NodeMaterialConnectionPoint;
  62216. /**
  62217. * Gets the direction output component
  62218. */
  62219. get intensity(): NodeMaterialConnectionPoint;
  62220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62222. protected _buildBlock(state: NodeMaterialBuildState): this;
  62223. serialize(): any;
  62224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62225. }
  62226. }
  62227. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  62228. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  62229. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  62230. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  62231. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  62232. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  62233. }
  62234. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  62235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62239. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62240. import { Effect } from "babylonjs/Materials/effect";
  62241. import { Mesh } from "babylonjs/Meshes/mesh";
  62242. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62243. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62244. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62245. /**
  62246. * Block used to add image processing support to fragment shader
  62247. */
  62248. export class ImageProcessingBlock extends NodeMaterialBlock {
  62249. /**
  62250. * Create a new ImageProcessingBlock
  62251. * @param name defines the block name
  62252. */
  62253. constructor(name: string);
  62254. /**
  62255. * Gets the current class name
  62256. * @returns the class name
  62257. */
  62258. getClassName(): string;
  62259. /**
  62260. * Gets the color input component
  62261. */
  62262. get color(): NodeMaterialConnectionPoint;
  62263. /**
  62264. * Gets the output component
  62265. */
  62266. get output(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Initialize the block and prepare the context for build
  62269. * @param state defines the state that will be used for the build
  62270. */
  62271. initialize(state: NodeMaterialBuildState): void;
  62272. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62275. protected _buildBlock(state: NodeMaterialBuildState): this;
  62276. }
  62277. }
  62278. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  62279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62282. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62284. import { Effect } from "babylonjs/Materials/effect";
  62285. import { Mesh } from "babylonjs/Meshes/mesh";
  62286. import { Scene } from "babylonjs/scene";
  62287. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  62288. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  62289. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  62290. /**
  62291. * Block used to pertub normals based on a normal map
  62292. */
  62293. export class PerturbNormalBlock extends NodeMaterialBlock {
  62294. private _tangentSpaceParameterName;
  62295. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62296. invertX: boolean;
  62297. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62298. invertY: boolean;
  62299. /**
  62300. * Create a new PerturbNormalBlock
  62301. * @param name defines the block name
  62302. */
  62303. constructor(name: string);
  62304. /**
  62305. * Gets the current class name
  62306. * @returns the class name
  62307. */
  62308. getClassName(): string;
  62309. /**
  62310. * Gets the world position input component
  62311. */
  62312. get worldPosition(): NodeMaterialConnectionPoint;
  62313. /**
  62314. * Gets the world normal input component
  62315. */
  62316. get worldNormal(): NodeMaterialConnectionPoint;
  62317. /**
  62318. * Gets the world tangent input component
  62319. */
  62320. get worldTangent(): NodeMaterialConnectionPoint;
  62321. /**
  62322. * Gets the uv input component
  62323. */
  62324. get uv(): NodeMaterialConnectionPoint;
  62325. /**
  62326. * Gets the normal map color input component
  62327. */
  62328. get normalMapColor(): NodeMaterialConnectionPoint;
  62329. /**
  62330. * Gets the strength input component
  62331. */
  62332. get strength(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the output component
  62335. */
  62336. get output(): NodeMaterialConnectionPoint;
  62337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62339. autoConfigure(material: NodeMaterial): void;
  62340. protected _buildBlock(state: NodeMaterialBuildState): this;
  62341. protected _dumpPropertiesCode(): string;
  62342. serialize(): any;
  62343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62344. }
  62345. }
  62346. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  62347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62350. /**
  62351. * Block used to discard a pixel if a value is smaller than a cutoff
  62352. */
  62353. export class DiscardBlock extends NodeMaterialBlock {
  62354. /**
  62355. * Create a new DiscardBlock
  62356. * @param name defines the block name
  62357. */
  62358. constructor(name: string);
  62359. /**
  62360. * Gets the current class name
  62361. * @returns the class name
  62362. */
  62363. getClassName(): string;
  62364. /**
  62365. * Gets the color input component
  62366. */
  62367. get value(): NodeMaterialConnectionPoint;
  62368. /**
  62369. * Gets the cutoff input component
  62370. */
  62371. get cutoff(): NodeMaterialConnectionPoint;
  62372. protected _buildBlock(state: NodeMaterialBuildState): this;
  62373. }
  62374. }
  62375. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  62376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62379. /**
  62380. * Block used to test if the fragment shader is front facing
  62381. */
  62382. export class FrontFacingBlock extends NodeMaterialBlock {
  62383. /**
  62384. * Creates a new FrontFacingBlock
  62385. * @param name defines the block name
  62386. */
  62387. constructor(name: string);
  62388. /**
  62389. * Gets the current class name
  62390. * @returns the class name
  62391. */
  62392. getClassName(): string;
  62393. /**
  62394. * Gets the output component
  62395. */
  62396. get output(): NodeMaterialConnectionPoint;
  62397. protected _buildBlock(state: NodeMaterialBuildState): this;
  62398. }
  62399. }
  62400. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  62401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62404. /**
  62405. * Block used to get the derivative value on x and y of a given input
  62406. */
  62407. export class DerivativeBlock extends NodeMaterialBlock {
  62408. /**
  62409. * Create a new DerivativeBlock
  62410. * @param name defines the block name
  62411. */
  62412. constructor(name: string);
  62413. /**
  62414. * Gets the current class name
  62415. * @returns the class name
  62416. */
  62417. getClassName(): string;
  62418. /**
  62419. * Gets the input component
  62420. */
  62421. get input(): NodeMaterialConnectionPoint;
  62422. /**
  62423. * Gets the derivative output on x
  62424. */
  62425. get dx(): NodeMaterialConnectionPoint;
  62426. /**
  62427. * Gets the derivative output on y
  62428. */
  62429. get dy(): NodeMaterialConnectionPoint;
  62430. protected _buildBlock(state: NodeMaterialBuildState): this;
  62431. }
  62432. }
  62433. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  62434. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  62435. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  62436. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  62437. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  62438. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  62439. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  62440. }
  62441. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  62442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62444. import { Mesh } from "babylonjs/Meshes/mesh";
  62445. import { Effect } from "babylonjs/Materials/effect";
  62446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62448. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62449. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  62450. /**
  62451. * Block used to add support for scene fog
  62452. */
  62453. export class FogBlock extends NodeMaterialBlock {
  62454. private _fogDistanceName;
  62455. private _fogParameters;
  62456. /**
  62457. * Create a new FogBlock
  62458. * @param name defines the block name
  62459. */
  62460. constructor(name: string);
  62461. /**
  62462. * Gets the current class name
  62463. * @returns the class name
  62464. */
  62465. getClassName(): string;
  62466. /**
  62467. * Gets the world position input component
  62468. */
  62469. get worldPosition(): NodeMaterialConnectionPoint;
  62470. /**
  62471. * Gets the view input component
  62472. */
  62473. get view(): NodeMaterialConnectionPoint;
  62474. /**
  62475. * Gets the color input component
  62476. */
  62477. get input(): NodeMaterialConnectionPoint;
  62478. /**
  62479. * Gets the fog color input component
  62480. */
  62481. get fogColor(): NodeMaterialConnectionPoint;
  62482. /**
  62483. * Gets the output component
  62484. */
  62485. get output(): NodeMaterialConnectionPoint;
  62486. autoConfigure(material: NodeMaterial): void;
  62487. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62489. protected _buildBlock(state: NodeMaterialBuildState): this;
  62490. }
  62491. }
  62492. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  62493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62494. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62495. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62497. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  62498. import { Effect } from "babylonjs/Materials/effect";
  62499. import { Mesh } from "babylonjs/Meshes/mesh";
  62500. import { Light } from "babylonjs/Lights/light";
  62501. import { Nullable } from "babylonjs/types";
  62502. import { Scene } from "babylonjs/scene";
  62503. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  62504. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  62505. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  62506. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62507. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  62508. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  62509. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  62510. /**
  62511. * Block used to add light in the fragment shader
  62512. */
  62513. export class LightBlock extends NodeMaterialBlock {
  62514. private _lightId;
  62515. /**
  62516. * Gets or sets the light associated with this block
  62517. */
  62518. light: Nullable<Light>;
  62519. /**
  62520. * Create a new LightBlock
  62521. * @param name defines the block name
  62522. */
  62523. constructor(name: string);
  62524. /**
  62525. * Gets the current class name
  62526. * @returns the class name
  62527. */
  62528. getClassName(): string;
  62529. /**
  62530. * Gets the world position input component
  62531. */
  62532. get worldPosition(): NodeMaterialConnectionPoint;
  62533. /**
  62534. * Gets the world normal input component
  62535. */
  62536. get worldNormal(): NodeMaterialConnectionPoint;
  62537. /**
  62538. * Gets the camera (or eye) position component
  62539. */
  62540. get cameraPosition(): NodeMaterialConnectionPoint;
  62541. /**
  62542. * Gets the glossiness component
  62543. */
  62544. get glossiness(): NodeMaterialConnectionPoint;
  62545. /**
  62546. * Gets the glossinness power component
  62547. */
  62548. get glossPower(): NodeMaterialConnectionPoint;
  62549. /**
  62550. * Gets the diffuse color component
  62551. */
  62552. get diffuseColor(): NodeMaterialConnectionPoint;
  62553. /**
  62554. * Gets the specular color component
  62555. */
  62556. get specularColor(): NodeMaterialConnectionPoint;
  62557. /**
  62558. * Gets the diffuse output component
  62559. */
  62560. get diffuseOutput(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the specular output component
  62563. */
  62564. get specularOutput(): NodeMaterialConnectionPoint;
  62565. /**
  62566. * Gets the shadow output component
  62567. */
  62568. get shadow(): NodeMaterialConnectionPoint;
  62569. autoConfigure(material: NodeMaterial): void;
  62570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62571. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62573. private _injectVertexCode;
  62574. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62575. serialize(): any;
  62576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62577. }
  62578. }
  62579. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  62580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62582. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62583. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  62584. /**
  62585. * Block used to read a reflection texture from a sampler
  62586. */
  62587. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62588. /**
  62589. * Create a new ReflectionTextureBlock
  62590. * @param name defines the block name
  62591. */
  62592. constructor(name: string);
  62593. /**
  62594. * Gets the current class name
  62595. * @returns the class name
  62596. */
  62597. getClassName(): string;
  62598. /**
  62599. * Gets the world position input component
  62600. */
  62601. get position(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the world position input component
  62604. */
  62605. get worldPosition(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the world normal input component
  62608. */
  62609. get worldNormal(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the world input component
  62612. */
  62613. get world(): NodeMaterialConnectionPoint;
  62614. /**
  62615. * Gets the camera (or eye) position component
  62616. */
  62617. get cameraPosition(): NodeMaterialConnectionPoint;
  62618. /**
  62619. * Gets the view input component
  62620. */
  62621. get view(): NodeMaterialConnectionPoint;
  62622. /**
  62623. * Gets the rgb output component
  62624. */
  62625. get rgb(): NodeMaterialConnectionPoint;
  62626. /**
  62627. * Gets the r output component
  62628. */
  62629. get r(): NodeMaterialConnectionPoint;
  62630. /**
  62631. * Gets the g output component
  62632. */
  62633. get g(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the b output component
  62636. */
  62637. get b(): NodeMaterialConnectionPoint;
  62638. autoConfigure(material: NodeMaterial): void;
  62639. protected _buildBlock(state: NodeMaterialBuildState): this;
  62640. }
  62641. }
  62642. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62643. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62644. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62645. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62646. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62647. }
  62648. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62649. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62650. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62651. }
  62652. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62656. /**
  62657. * Block used to multiply 2 values
  62658. */
  62659. export class MultiplyBlock extends NodeMaterialBlock {
  62660. /**
  62661. * Creates a new MultiplyBlock
  62662. * @param name defines the block name
  62663. */
  62664. constructor(name: string);
  62665. /**
  62666. * Gets the current class name
  62667. * @returns the class name
  62668. */
  62669. getClassName(): string;
  62670. /**
  62671. * Gets the left operand input component
  62672. */
  62673. get left(): NodeMaterialConnectionPoint;
  62674. /**
  62675. * Gets the right operand input component
  62676. */
  62677. get right(): NodeMaterialConnectionPoint;
  62678. /**
  62679. * Gets the output component
  62680. */
  62681. get output(): NodeMaterialConnectionPoint;
  62682. protected _buildBlock(state: NodeMaterialBuildState): this;
  62683. }
  62684. }
  62685. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62686. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62687. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62688. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62689. /**
  62690. * Block used to add 2 vectors
  62691. */
  62692. export class AddBlock extends NodeMaterialBlock {
  62693. /**
  62694. * Creates a new AddBlock
  62695. * @param name defines the block name
  62696. */
  62697. constructor(name: string);
  62698. /**
  62699. * Gets the current class name
  62700. * @returns the class name
  62701. */
  62702. getClassName(): string;
  62703. /**
  62704. * Gets the left operand input component
  62705. */
  62706. get left(): NodeMaterialConnectionPoint;
  62707. /**
  62708. * Gets the right operand input component
  62709. */
  62710. get right(): NodeMaterialConnectionPoint;
  62711. /**
  62712. * Gets the output component
  62713. */
  62714. get output(): NodeMaterialConnectionPoint;
  62715. protected _buildBlock(state: NodeMaterialBuildState): this;
  62716. }
  62717. }
  62718. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62720. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62721. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62722. /**
  62723. * Block used to scale a vector by a float
  62724. */
  62725. export class ScaleBlock extends NodeMaterialBlock {
  62726. /**
  62727. * Creates a new ScaleBlock
  62728. * @param name defines the block name
  62729. */
  62730. constructor(name: string);
  62731. /**
  62732. * Gets the current class name
  62733. * @returns the class name
  62734. */
  62735. getClassName(): string;
  62736. /**
  62737. * Gets the input component
  62738. */
  62739. get input(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the factor input component
  62742. */
  62743. get factor(): NodeMaterialConnectionPoint;
  62744. /**
  62745. * Gets the output component
  62746. */
  62747. get output(): NodeMaterialConnectionPoint;
  62748. protected _buildBlock(state: NodeMaterialBuildState): this;
  62749. }
  62750. }
  62751. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62752. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62753. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62754. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62755. import { Scene } from "babylonjs/scene";
  62756. /**
  62757. * Block used to clamp a float
  62758. */
  62759. export class ClampBlock extends NodeMaterialBlock {
  62760. /** Gets or sets the minimum range */
  62761. minimum: number;
  62762. /** Gets or sets the maximum range */
  62763. maximum: number;
  62764. /**
  62765. * Creates a new ClampBlock
  62766. * @param name defines the block name
  62767. */
  62768. constructor(name: string);
  62769. /**
  62770. * Gets the current class name
  62771. * @returns the class name
  62772. */
  62773. getClassName(): string;
  62774. /**
  62775. * Gets the value input component
  62776. */
  62777. get value(): NodeMaterialConnectionPoint;
  62778. /**
  62779. * Gets the output component
  62780. */
  62781. get output(): NodeMaterialConnectionPoint;
  62782. protected _buildBlock(state: NodeMaterialBuildState): this;
  62783. protected _dumpPropertiesCode(): string;
  62784. serialize(): any;
  62785. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62786. }
  62787. }
  62788. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62791. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62792. /**
  62793. * Block used to apply a cross product between 2 vectors
  62794. */
  62795. export class CrossBlock extends NodeMaterialBlock {
  62796. /**
  62797. * Creates a new CrossBlock
  62798. * @param name defines the block name
  62799. */
  62800. constructor(name: string);
  62801. /**
  62802. * Gets the current class name
  62803. * @returns the class name
  62804. */
  62805. getClassName(): string;
  62806. /**
  62807. * Gets the left operand input component
  62808. */
  62809. get left(): NodeMaterialConnectionPoint;
  62810. /**
  62811. * Gets the right operand input component
  62812. */
  62813. get right(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the output component
  62816. */
  62817. get output(): NodeMaterialConnectionPoint;
  62818. protected _buildBlock(state: NodeMaterialBuildState): this;
  62819. }
  62820. }
  62821. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62825. /**
  62826. * Block used to apply a dot product between 2 vectors
  62827. */
  62828. export class DotBlock extends NodeMaterialBlock {
  62829. /**
  62830. * Creates a new DotBlock
  62831. * @param name defines the block name
  62832. */
  62833. constructor(name: string);
  62834. /**
  62835. * Gets the current class name
  62836. * @returns the class name
  62837. */
  62838. getClassName(): string;
  62839. /**
  62840. * Gets the left operand input component
  62841. */
  62842. get left(): NodeMaterialConnectionPoint;
  62843. /**
  62844. * Gets the right operand input component
  62845. */
  62846. get right(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the output component
  62849. */
  62850. get output(): NodeMaterialConnectionPoint;
  62851. protected _buildBlock(state: NodeMaterialBuildState): this;
  62852. }
  62853. }
  62854. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62858. import { Vector2 } from "babylonjs/Maths/math.vector";
  62859. import { Scene } from "babylonjs/scene";
  62860. /**
  62861. * Block used to remap a float from a range to a new one
  62862. */
  62863. export class RemapBlock extends NodeMaterialBlock {
  62864. /**
  62865. * Gets or sets the source range
  62866. */
  62867. sourceRange: Vector2;
  62868. /**
  62869. * Gets or sets the target range
  62870. */
  62871. targetRange: Vector2;
  62872. /**
  62873. * Creates a new RemapBlock
  62874. * @param name defines the block name
  62875. */
  62876. constructor(name: string);
  62877. /**
  62878. * Gets the current class name
  62879. * @returns the class name
  62880. */
  62881. getClassName(): string;
  62882. /**
  62883. * Gets the input component
  62884. */
  62885. get input(): NodeMaterialConnectionPoint;
  62886. /**
  62887. * Gets the source min input component
  62888. */
  62889. get sourceMin(): NodeMaterialConnectionPoint;
  62890. /**
  62891. * Gets the source max input component
  62892. */
  62893. get sourceMax(): NodeMaterialConnectionPoint;
  62894. /**
  62895. * Gets the target min input component
  62896. */
  62897. get targetMin(): NodeMaterialConnectionPoint;
  62898. /**
  62899. * Gets the target max input component
  62900. */
  62901. get targetMax(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the output component
  62904. */
  62905. get output(): NodeMaterialConnectionPoint;
  62906. protected _buildBlock(state: NodeMaterialBuildState): this;
  62907. protected _dumpPropertiesCode(): string;
  62908. serialize(): any;
  62909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62910. }
  62911. }
  62912. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62916. /**
  62917. * Block used to normalize a vector
  62918. */
  62919. export class NormalizeBlock extends NodeMaterialBlock {
  62920. /**
  62921. * Creates a new NormalizeBlock
  62922. * @param name defines the block name
  62923. */
  62924. constructor(name: string);
  62925. /**
  62926. * Gets the current class name
  62927. * @returns the class name
  62928. */
  62929. getClassName(): string;
  62930. /**
  62931. * Gets the input component
  62932. */
  62933. get input(): NodeMaterialConnectionPoint;
  62934. /**
  62935. * Gets the output component
  62936. */
  62937. get output(): NodeMaterialConnectionPoint;
  62938. protected _buildBlock(state: NodeMaterialBuildState): this;
  62939. }
  62940. }
  62941. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62945. import { Scene } from "babylonjs/scene";
  62946. /**
  62947. * Operations supported by the Trigonometry block
  62948. */
  62949. export enum TrigonometryBlockOperations {
  62950. /** Cos */
  62951. Cos = 0,
  62952. /** Sin */
  62953. Sin = 1,
  62954. /** Abs */
  62955. Abs = 2,
  62956. /** Exp */
  62957. Exp = 3,
  62958. /** Exp2 */
  62959. Exp2 = 4,
  62960. /** Round */
  62961. Round = 5,
  62962. /** Floor */
  62963. Floor = 6,
  62964. /** Ceiling */
  62965. Ceiling = 7,
  62966. /** Square root */
  62967. Sqrt = 8,
  62968. /** Log */
  62969. Log = 9,
  62970. /** Tangent */
  62971. Tan = 10,
  62972. /** Arc tangent */
  62973. ArcTan = 11,
  62974. /** Arc cosinus */
  62975. ArcCos = 12,
  62976. /** Arc sinus */
  62977. ArcSin = 13,
  62978. /** Fraction */
  62979. Fract = 14,
  62980. /** Sign */
  62981. Sign = 15,
  62982. /** To radians (from degrees) */
  62983. Radians = 16,
  62984. /** To degrees (from radians) */
  62985. Degrees = 17
  62986. }
  62987. /**
  62988. * Block used to apply trigonometry operation to floats
  62989. */
  62990. export class TrigonometryBlock extends NodeMaterialBlock {
  62991. /**
  62992. * Gets or sets the operation applied by the block
  62993. */
  62994. operation: TrigonometryBlockOperations;
  62995. /**
  62996. * Creates a new TrigonometryBlock
  62997. * @param name defines the block name
  62998. */
  62999. constructor(name: string);
  63000. /**
  63001. * Gets the current class name
  63002. * @returns the class name
  63003. */
  63004. getClassName(): string;
  63005. /**
  63006. * Gets the input component
  63007. */
  63008. get input(): NodeMaterialConnectionPoint;
  63009. /**
  63010. * Gets the output component
  63011. */
  63012. get output(): NodeMaterialConnectionPoint;
  63013. protected _buildBlock(state: NodeMaterialBuildState): this;
  63014. serialize(): any;
  63015. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63016. protected _dumpPropertiesCode(): string;
  63017. }
  63018. }
  63019. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  63020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63023. /**
  63024. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63025. */
  63026. export class ColorMergerBlock extends NodeMaterialBlock {
  63027. /**
  63028. * Create a new ColorMergerBlock
  63029. * @param name defines the block name
  63030. */
  63031. constructor(name: string);
  63032. /**
  63033. * Gets the current class name
  63034. * @returns the class name
  63035. */
  63036. getClassName(): string;
  63037. /**
  63038. * Gets the rgb component (input)
  63039. */
  63040. get rgbIn(): NodeMaterialConnectionPoint;
  63041. /**
  63042. * Gets the r component (input)
  63043. */
  63044. get r(): NodeMaterialConnectionPoint;
  63045. /**
  63046. * Gets the g component (input)
  63047. */
  63048. get g(): NodeMaterialConnectionPoint;
  63049. /**
  63050. * Gets the b component (input)
  63051. */
  63052. get b(): NodeMaterialConnectionPoint;
  63053. /**
  63054. * Gets the a component (input)
  63055. */
  63056. get a(): NodeMaterialConnectionPoint;
  63057. /**
  63058. * Gets the rgba component (output)
  63059. */
  63060. get rgba(): NodeMaterialConnectionPoint;
  63061. /**
  63062. * Gets the rgb component (output)
  63063. */
  63064. get rgbOut(): NodeMaterialConnectionPoint;
  63065. /**
  63066. * Gets the rgb component (output)
  63067. * @deprecated Please use rgbOut instead.
  63068. */
  63069. get rgb(): NodeMaterialConnectionPoint;
  63070. protected _buildBlock(state: NodeMaterialBuildState): this;
  63071. }
  63072. }
  63073. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  63074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63077. /**
  63078. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  63079. */
  63080. export class VectorMergerBlock extends NodeMaterialBlock {
  63081. /**
  63082. * Create a new VectorMergerBlock
  63083. * @param name defines the block name
  63084. */
  63085. constructor(name: string);
  63086. /**
  63087. * Gets the current class name
  63088. * @returns the class name
  63089. */
  63090. getClassName(): string;
  63091. /**
  63092. * Gets the xyz component (input)
  63093. */
  63094. get xyzIn(): NodeMaterialConnectionPoint;
  63095. /**
  63096. * Gets the xy component (input)
  63097. */
  63098. get xyIn(): NodeMaterialConnectionPoint;
  63099. /**
  63100. * Gets the x component (input)
  63101. */
  63102. get x(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the y component (input)
  63105. */
  63106. get y(): NodeMaterialConnectionPoint;
  63107. /**
  63108. * Gets the z component (input)
  63109. */
  63110. get z(): NodeMaterialConnectionPoint;
  63111. /**
  63112. * Gets the w component (input)
  63113. */
  63114. get w(): NodeMaterialConnectionPoint;
  63115. /**
  63116. * Gets the xyzw component (output)
  63117. */
  63118. get xyzw(): NodeMaterialConnectionPoint;
  63119. /**
  63120. * Gets the xyz component (output)
  63121. */
  63122. get xyzOut(): NodeMaterialConnectionPoint;
  63123. /**
  63124. * Gets the xy component (output)
  63125. */
  63126. get xyOut(): NodeMaterialConnectionPoint;
  63127. /**
  63128. * Gets the xy component (output)
  63129. * @deprecated Please use xyOut instead.
  63130. */
  63131. get xy(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the xyz component (output)
  63134. * @deprecated Please use xyzOut instead.
  63135. */
  63136. get xyz(): NodeMaterialConnectionPoint;
  63137. protected _buildBlock(state: NodeMaterialBuildState): this;
  63138. }
  63139. }
  63140. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  63141. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63142. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63144. /**
  63145. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  63146. */
  63147. export class ColorSplitterBlock extends NodeMaterialBlock {
  63148. /**
  63149. * Create a new ColorSplitterBlock
  63150. * @param name defines the block name
  63151. */
  63152. constructor(name: string);
  63153. /**
  63154. * Gets the current class name
  63155. * @returns the class name
  63156. */
  63157. getClassName(): string;
  63158. /**
  63159. * Gets the rgba component (input)
  63160. */
  63161. get rgba(): NodeMaterialConnectionPoint;
  63162. /**
  63163. * Gets the rgb component (input)
  63164. */
  63165. get rgbIn(): NodeMaterialConnectionPoint;
  63166. /**
  63167. * Gets the rgb component (output)
  63168. */
  63169. get rgbOut(): NodeMaterialConnectionPoint;
  63170. /**
  63171. * Gets the r component (output)
  63172. */
  63173. get r(): NodeMaterialConnectionPoint;
  63174. /**
  63175. * Gets the g component (output)
  63176. */
  63177. get g(): NodeMaterialConnectionPoint;
  63178. /**
  63179. * Gets the b component (output)
  63180. */
  63181. get b(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the a component (output)
  63184. */
  63185. get a(): NodeMaterialConnectionPoint;
  63186. protected _inputRename(name: string): string;
  63187. protected _outputRename(name: string): string;
  63188. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63189. }
  63190. }
  63191. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  63192. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63193. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63194. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63195. /**
  63196. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63197. */
  63198. export class VectorSplitterBlock extends NodeMaterialBlock {
  63199. /**
  63200. * Create a new VectorSplitterBlock
  63201. * @param name defines the block name
  63202. */
  63203. constructor(name: string);
  63204. /**
  63205. * Gets the current class name
  63206. * @returns the class name
  63207. */
  63208. getClassName(): string;
  63209. /**
  63210. * Gets the xyzw component (input)
  63211. */
  63212. get xyzw(): NodeMaterialConnectionPoint;
  63213. /**
  63214. * Gets the xyz component (input)
  63215. */
  63216. get xyzIn(): NodeMaterialConnectionPoint;
  63217. /**
  63218. * Gets the xy component (input)
  63219. */
  63220. get xyIn(): NodeMaterialConnectionPoint;
  63221. /**
  63222. * Gets the xyz component (output)
  63223. */
  63224. get xyzOut(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the xy component (output)
  63227. */
  63228. get xyOut(): NodeMaterialConnectionPoint;
  63229. /**
  63230. * Gets the x component (output)
  63231. */
  63232. get x(): NodeMaterialConnectionPoint;
  63233. /**
  63234. * Gets the y component (output)
  63235. */
  63236. get y(): NodeMaterialConnectionPoint;
  63237. /**
  63238. * Gets the z component (output)
  63239. */
  63240. get z(): NodeMaterialConnectionPoint;
  63241. /**
  63242. * Gets the w component (output)
  63243. */
  63244. get w(): NodeMaterialConnectionPoint;
  63245. protected _inputRename(name: string): string;
  63246. protected _outputRename(name: string): string;
  63247. protected _buildBlock(state: NodeMaterialBuildState): this;
  63248. }
  63249. }
  63250. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  63251. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63252. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63253. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63254. /**
  63255. * Block used to lerp between 2 values
  63256. */
  63257. export class LerpBlock extends NodeMaterialBlock {
  63258. /**
  63259. * Creates a new LerpBlock
  63260. * @param name defines the block name
  63261. */
  63262. constructor(name: string);
  63263. /**
  63264. * Gets the current class name
  63265. * @returns the class name
  63266. */
  63267. getClassName(): string;
  63268. /**
  63269. * Gets the left operand input component
  63270. */
  63271. get left(): NodeMaterialConnectionPoint;
  63272. /**
  63273. * Gets the right operand input component
  63274. */
  63275. get right(): NodeMaterialConnectionPoint;
  63276. /**
  63277. * Gets the gradient operand input component
  63278. */
  63279. get gradient(): NodeMaterialConnectionPoint;
  63280. /**
  63281. * Gets the output component
  63282. */
  63283. get output(): NodeMaterialConnectionPoint;
  63284. protected _buildBlock(state: NodeMaterialBuildState): this;
  63285. }
  63286. }
  63287. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  63288. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63289. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63290. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63291. /**
  63292. * Block used to divide 2 vectors
  63293. */
  63294. export class DivideBlock extends NodeMaterialBlock {
  63295. /**
  63296. * Creates a new DivideBlock
  63297. * @param name defines the block name
  63298. */
  63299. constructor(name: string);
  63300. /**
  63301. * Gets the current class name
  63302. * @returns the class name
  63303. */
  63304. getClassName(): string;
  63305. /**
  63306. * Gets the left operand input component
  63307. */
  63308. get left(): NodeMaterialConnectionPoint;
  63309. /**
  63310. * Gets the right operand input component
  63311. */
  63312. get right(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the output component
  63315. */
  63316. get output(): NodeMaterialConnectionPoint;
  63317. protected _buildBlock(state: NodeMaterialBuildState): this;
  63318. }
  63319. }
  63320. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  63321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63324. /**
  63325. * Block used to subtract 2 vectors
  63326. */
  63327. export class SubtractBlock extends NodeMaterialBlock {
  63328. /**
  63329. * Creates a new SubtractBlock
  63330. * @param name defines the block name
  63331. */
  63332. constructor(name: string);
  63333. /**
  63334. * Gets the current class name
  63335. * @returns the class name
  63336. */
  63337. getClassName(): string;
  63338. /**
  63339. * Gets the left operand input component
  63340. */
  63341. get left(): NodeMaterialConnectionPoint;
  63342. /**
  63343. * Gets the right operand input component
  63344. */
  63345. get right(): NodeMaterialConnectionPoint;
  63346. /**
  63347. * Gets the output component
  63348. */
  63349. get output(): NodeMaterialConnectionPoint;
  63350. protected _buildBlock(state: NodeMaterialBuildState): this;
  63351. }
  63352. }
  63353. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  63354. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63355. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63356. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63357. /**
  63358. * Block used to step a value
  63359. */
  63360. export class StepBlock extends NodeMaterialBlock {
  63361. /**
  63362. * Creates a new StepBlock
  63363. * @param name defines the block name
  63364. */
  63365. constructor(name: string);
  63366. /**
  63367. * Gets the current class name
  63368. * @returns the class name
  63369. */
  63370. getClassName(): string;
  63371. /**
  63372. * Gets the value operand input component
  63373. */
  63374. get value(): NodeMaterialConnectionPoint;
  63375. /**
  63376. * Gets the edge operand input component
  63377. */
  63378. get edge(): NodeMaterialConnectionPoint;
  63379. /**
  63380. * Gets the output component
  63381. */
  63382. get output(): NodeMaterialConnectionPoint;
  63383. protected _buildBlock(state: NodeMaterialBuildState): this;
  63384. }
  63385. }
  63386. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  63387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63390. /**
  63391. * Block used to get the opposite (1 - x) of a value
  63392. */
  63393. export class OneMinusBlock extends NodeMaterialBlock {
  63394. /**
  63395. * Creates a new OneMinusBlock
  63396. * @param name defines the block name
  63397. */
  63398. constructor(name: string);
  63399. /**
  63400. * Gets the current class name
  63401. * @returns the class name
  63402. */
  63403. getClassName(): string;
  63404. /**
  63405. * Gets the input component
  63406. */
  63407. get input(): NodeMaterialConnectionPoint;
  63408. /**
  63409. * Gets the output component
  63410. */
  63411. get output(): NodeMaterialConnectionPoint;
  63412. protected _buildBlock(state: NodeMaterialBuildState): this;
  63413. }
  63414. }
  63415. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  63416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63419. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63420. /**
  63421. * Block used to get the view direction
  63422. */
  63423. export class ViewDirectionBlock extends NodeMaterialBlock {
  63424. /**
  63425. * Creates a new ViewDirectionBlock
  63426. * @param name defines the block name
  63427. */
  63428. constructor(name: string);
  63429. /**
  63430. * Gets the current class name
  63431. * @returns the class name
  63432. */
  63433. getClassName(): string;
  63434. /**
  63435. * Gets the world position component
  63436. */
  63437. get worldPosition(): NodeMaterialConnectionPoint;
  63438. /**
  63439. * Gets the camera position component
  63440. */
  63441. get cameraPosition(): NodeMaterialConnectionPoint;
  63442. /**
  63443. * Gets the output component
  63444. */
  63445. get output(): NodeMaterialConnectionPoint;
  63446. autoConfigure(material: NodeMaterial): void;
  63447. protected _buildBlock(state: NodeMaterialBuildState): this;
  63448. }
  63449. }
  63450. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  63451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63454. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63455. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  63456. /**
  63457. * Block used to compute fresnel value
  63458. */
  63459. export class FresnelBlock extends NodeMaterialBlock {
  63460. /**
  63461. * Create a new FresnelBlock
  63462. * @param name defines the block name
  63463. */
  63464. constructor(name: string);
  63465. /**
  63466. * Gets the current class name
  63467. * @returns the class name
  63468. */
  63469. getClassName(): string;
  63470. /**
  63471. * Gets the world normal input component
  63472. */
  63473. get worldNormal(): NodeMaterialConnectionPoint;
  63474. /**
  63475. * Gets the view direction input component
  63476. */
  63477. get viewDirection(): NodeMaterialConnectionPoint;
  63478. /**
  63479. * Gets the bias input component
  63480. */
  63481. get bias(): NodeMaterialConnectionPoint;
  63482. /**
  63483. * Gets the camera (or eye) position component
  63484. */
  63485. get power(): NodeMaterialConnectionPoint;
  63486. /**
  63487. * Gets the fresnel output component
  63488. */
  63489. get fresnel(): NodeMaterialConnectionPoint;
  63490. autoConfigure(material: NodeMaterial): void;
  63491. protected _buildBlock(state: NodeMaterialBuildState): this;
  63492. }
  63493. }
  63494. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  63495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63498. /**
  63499. * Block used to get the max of 2 values
  63500. */
  63501. export class MaxBlock extends NodeMaterialBlock {
  63502. /**
  63503. * Creates a new MaxBlock
  63504. * @param name defines the block name
  63505. */
  63506. constructor(name: string);
  63507. /**
  63508. * Gets the current class name
  63509. * @returns the class name
  63510. */
  63511. getClassName(): string;
  63512. /**
  63513. * Gets the left operand input component
  63514. */
  63515. get left(): NodeMaterialConnectionPoint;
  63516. /**
  63517. * Gets the right operand input component
  63518. */
  63519. get right(): NodeMaterialConnectionPoint;
  63520. /**
  63521. * Gets the output component
  63522. */
  63523. get output(): NodeMaterialConnectionPoint;
  63524. protected _buildBlock(state: NodeMaterialBuildState): this;
  63525. }
  63526. }
  63527. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  63528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63531. /**
  63532. * Block used to get the min of 2 values
  63533. */
  63534. export class MinBlock extends NodeMaterialBlock {
  63535. /**
  63536. * Creates a new MinBlock
  63537. * @param name defines the block name
  63538. */
  63539. constructor(name: string);
  63540. /**
  63541. * Gets the current class name
  63542. * @returns the class name
  63543. */
  63544. getClassName(): string;
  63545. /**
  63546. * Gets the left operand input component
  63547. */
  63548. get left(): NodeMaterialConnectionPoint;
  63549. /**
  63550. * Gets the right operand input component
  63551. */
  63552. get right(): NodeMaterialConnectionPoint;
  63553. /**
  63554. * Gets the output component
  63555. */
  63556. get output(): NodeMaterialConnectionPoint;
  63557. protected _buildBlock(state: NodeMaterialBuildState): this;
  63558. }
  63559. }
  63560. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  63561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63564. /**
  63565. * Block used to get the distance between 2 values
  63566. */
  63567. export class DistanceBlock extends NodeMaterialBlock {
  63568. /**
  63569. * Creates a new DistanceBlock
  63570. * @param name defines the block name
  63571. */
  63572. constructor(name: string);
  63573. /**
  63574. * Gets the current class name
  63575. * @returns the class name
  63576. */
  63577. getClassName(): string;
  63578. /**
  63579. * Gets the left operand input component
  63580. */
  63581. get left(): NodeMaterialConnectionPoint;
  63582. /**
  63583. * Gets the right operand input component
  63584. */
  63585. get right(): NodeMaterialConnectionPoint;
  63586. /**
  63587. * Gets the output component
  63588. */
  63589. get output(): NodeMaterialConnectionPoint;
  63590. protected _buildBlock(state: NodeMaterialBuildState): this;
  63591. }
  63592. }
  63593. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  63594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63597. /**
  63598. * Block used to get the length of a vector
  63599. */
  63600. export class LengthBlock extends NodeMaterialBlock {
  63601. /**
  63602. * Creates a new LengthBlock
  63603. * @param name defines the block name
  63604. */
  63605. constructor(name: string);
  63606. /**
  63607. * Gets the current class name
  63608. * @returns the class name
  63609. */
  63610. getClassName(): string;
  63611. /**
  63612. * Gets the value input component
  63613. */
  63614. get value(): NodeMaterialConnectionPoint;
  63615. /**
  63616. * Gets the output component
  63617. */
  63618. get output(): NodeMaterialConnectionPoint;
  63619. protected _buildBlock(state: NodeMaterialBuildState): this;
  63620. }
  63621. }
  63622. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63626. /**
  63627. * Block used to get negative version of a value (i.e. x * -1)
  63628. */
  63629. export class NegateBlock extends NodeMaterialBlock {
  63630. /**
  63631. * Creates a new NegateBlock
  63632. * @param name defines the block name
  63633. */
  63634. constructor(name: string);
  63635. /**
  63636. * Gets the current class name
  63637. * @returns the class name
  63638. */
  63639. getClassName(): string;
  63640. /**
  63641. * Gets the value input component
  63642. */
  63643. get value(): NodeMaterialConnectionPoint;
  63644. /**
  63645. * Gets the output component
  63646. */
  63647. get output(): NodeMaterialConnectionPoint;
  63648. protected _buildBlock(state: NodeMaterialBuildState): this;
  63649. }
  63650. }
  63651. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63655. /**
  63656. * Block used to get the value of the first parameter raised to the power of the second
  63657. */
  63658. export class PowBlock extends NodeMaterialBlock {
  63659. /**
  63660. * Creates a new PowBlock
  63661. * @param name defines the block name
  63662. */
  63663. constructor(name: string);
  63664. /**
  63665. * Gets the current class name
  63666. * @returns the class name
  63667. */
  63668. getClassName(): string;
  63669. /**
  63670. * Gets the value operand input component
  63671. */
  63672. get value(): NodeMaterialConnectionPoint;
  63673. /**
  63674. * Gets the power operand input component
  63675. */
  63676. get power(): NodeMaterialConnectionPoint;
  63677. /**
  63678. * Gets the output component
  63679. */
  63680. get output(): NodeMaterialConnectionPoint;
  63681. protected _buildBlock(state: NodeMaterialBuildState): this;
  63682. }
  63683. }
  63684. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63688. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63689. /**
  63690. * Block used to get a random number
  63691. */
  63692. export class RandomNumberBlock extends NodeMaterialBlock {
  63693. /**
  63694. * Creates a new RandomNumberBlock
  63695. * @param name defines the block name
  63696. */
  63697. constructor(name: string);
  63698. /**
  63699. * Gets the current class name
  63700. * @returns the class name
  63701. */
  63702. getClassName(): string;
  63703. /**
  63704. * Gets the seed input component
  63705. */
  63706. get seed(): NodeMaterialConnectionPoint;
  63707. /**
  63708. * Gets the output component
  63709. */
  63710. get output(): NodeMaterialConnectionPoint;
  63711. protected _buildBlock(state: NodeMaterialBuildState): this;
  63712. }
  63713. }
  63714. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63715. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63716. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63717. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63718. /**
  63719. * Block used to compute arc tangent of 2 values
  63720. */
  63721. export class ArcTan2Block extends NodeMaterialBlock {
  63722. /**
  63723. * Creates a new ArcTan2Block
  63724. * @param name defines the block name
  63725. */
  63726. constructor(name: string);
  63727. /**
  63728. * Gets the current class name
  63729. * @returns the class name
  63730. */
  63731. getClassName(): string;
  63732. /**
  63733. * Gets the x operand input component
  63734. */
  63735. get x(): NodeMaterialConnectionPoint;
  63736. /**
  63737. * Gets the y operand input component
  63738. */
  63739. get y(): NodeMaterialConnectionPoint;
  63740. /**
  63741. * Gets the output component
  63742. */
  63743. get output(): NodeMaterialConnectionPoint;
  63744. protected _buildBlock(state: NodeMaterialBuildState): this;
  63745. }
  63746. }
  63747. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63751. /**
  63752. * Block used to smooth step a value
  63753. */
  63754. export class SmoothStepBlock extends NodeMaterialBlock {
  63755. /**
  63756. * Creates a new SmoothStepBlock
  63757. * @param name defines the block name
  63758. */
  63759. constructor(name: string);
  63760. /**
  63761. * Gets the current class name
  63762. * @returns the class name
  63763. */
  63764. getClassName(): string;
  63765. /**
  63766. * Gets the value operand input component
  63767. */
  63768. get value(): NodeMaterialConnectionPoint;
  63769. /**
  63770. * Gets the first edge operand input component
  63771. */
  63772. get edge0(): NodeMaterialConnectionPoint;
  63773. /**
  63774. * Gets the second edge operand input component
  63775. */
  63776. get edge1(): NodeMaterialConnectionPoint;
  63777. /**
  63778. * Gets the output component
  63779. */
  63780. get output(): NodeMaterialConnectionPoint;
  63781. protected _buildBlock(state: NodeMaterialBuildState): this;
  63782. }
  63783. }
  63784. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63785. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63786. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63787. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63788. /**
  63789. * Block used to get the reciprocal (1 / x) of a value
  63790. */
  63791. export class ReciprocalBlock extends NodeMaterialBlock {
  63792. /**
  63793. * Creates a new ReciprocalBlock
  63794. * @param name defines the block name
  63795. */
  63796. constructor(name: string);
  63797. /**
  63798. * Gets the current class name
  63799. * @returns the class name
  63800. */
  63801. getClassName(): string;
  63802. /**
  63803. * Gets the input component
  63804. */
  63805. get input(): NodeMaterialConnectionPoint;
  63806. /**
  63807. * Gets the output component
  63808. */
  63809. get output(): NodeMaterialConnectionPoint;
  63810. protected _buildBlock(state: NodeMaterialBuildState): this;
  63811. }
  63812. }
  63813. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63817. /**
  63818. * Block used to replace a color by another one
  63819. */
  63820. export class ReplaceColorBlock extends NodeMaterialBlock {
  63821. /**
  63822. * Creates a new ReplaceColorBlock
  63823. * @param name defines the block name
  63824. */
  63825. constructor(name: string);
  63826. /**
  63827. * Gets the current class name
  63828. * @returns the class name
  63829. */
  63830. getClassName(): string;
  63831. /**
  63832. * Gets the value input component
  63833. */
  63834. get value(): NodeMaterialConnectionPoint;
  63835. /**
  63836. * Gets the reference input component
  63837. */
  63838. get reference(): NodeMaterialConnectionPoint;
  63839. /**
  63840. * Gets the distance input component
  63841. */
  63842. get distance(): NodeMaterialConnectionPoint;
  63843. /**
  63844. * Gets the replacement input component
  63845. */
  63846. get replacement(): NodeMaterialConnectionPoint;
  63847. /**
  63848. * Gets the output component
  63849. */
  63850. get output(): NodeMaterialConnectionPoint;
  63851. protected _buildBlock(state: NodeMaterialBuildState): this;
  63852. }
  63853. }
  63854. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63858. /**
  63859. * Block used to posterize a value
  63860. * @see https://en.wikipedia.org/wiki/Posterization
  63861. */
  63862. export class PosterizeBlock extends NodeMaterialBlock {
  63863. /**
  63864. * Creates a new PosterizeBlock
  63865. * @param name defines the block name
  63866. */
  63867. constructor(name: string);
  63868. /**
  63869. * Gets the current class name
  63870. * @returns the class name
  63871. */
  63872. getClassName(): string;
  63873. /**
  63874. * Gets the value input component
  63875. */
  63876. get value(): NodeMaterialConnectionPoint;
  63877. /**
  63878. * Gets the steps input component
  63879. */
  63880. get steps(): NodeMaterialConnectionPoint;
  63881. /**
  63882. * Gets the output component
  63883. */
  63884. get output(): NodeMaterialConnectionPoint;
  63885. protected _buildBlock(state: NodeMaterialBuildState): this;
  63886. }
  63887. }
  63888. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63892. import { Scene } from "babylonjs/scene";
  63893. /**
  63894. * Operations supported by the Wave block
  63895. */
  63896. export enum WaveBlockKind {
  63897. /** SawTooth */
  63898. SawTooth = 0,
  63899. /** Square */
  63900. Square = 1,
  63901. /** Triangle */
  63902. Triangle = 2
  63903. }
  63904. /**
  63905. * Block used to apply wave operation to floats
  63906. */
  63907. export class WaveBlock extends NodeMaterialBlock {
  63908. /**
  63909. * Gets or sets the kibnd of wave to be applied by the block
  63910. */
  63911. kind: WaveBlockKind;
  63912. /**
  63913. * Creates a new WaveBlock
  63914. * @param name defines the block name
  63915. */
  63916. constructor(name: string);
  63917. /**
  63918. * Gets the current class name
  63919. * @returns the class name
  63920. */
  63921. getClassName(): string;
  63922. /**
  63923. * Gets the input component
  63924. */
  63925. get input(): NodeMaterialConnectionPoint;
  63926. /**
  63927. * Gets the output component
  63928. */
  63929. get output(): NodeMaterialConnectionPoint;
  63930. protected _buildBlock(state: NodeMaterialBuildState): this;
  63931. serialize(): any;
  63932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63933. }
  63934. }
  63935. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63939. import { Color3 } from "babylonjs/Maths/math.color";
  63940. import { Scene } from "babylonjs/scene";
  63941. /**
  63942. * Class used to store a color step for the GradientBlock
  63943. */
  63944. export class GradientBlockColorStep {
  63945. /**
  63946. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63947. */
  63948. step: number;
  63949. /**
  63950. * Gets or sets the color associated with this step
  63951. */
  63952. color: Color3;
  63953. /**
  63954. * Creates a new GradientBlockColorStep
  63955. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63956. * @param color defines the color associated with this step
  63957. */
  63958. constructor(
  63959. /**
  63960. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63961. */
  63962. step: number,
  63963. /**
  63964. * Gets or sets the color associated with this step
  63965. */
  63966. color: Color3);
  63967. }
  63968. /**
  63969. * Block used to return a color from a gradient based on an input value between 0 and 1
  63970. */
  63971. export class GradientBlock extends NodeMaterialBlock {
  63972. /**
  63973. * Gets or sets the list of color steps
  63974. */
  63975. colorSteps: GradientBlockColorStep[];
  63976. /**
  63977. * Creates a new GradientBlock
  63978. * @param name defines the block name
  63979. */
  63980. constructor(name: string);
  63981. /**
  63982. * Gets the current class name
  63983. * @returns the class name
  63984. */
  63985. getClassName(): string;
  63986. /**
  63987. * Gets the gradient input component
  63988. */
  63989. get gradient(): NodeMaterialConnectionPoint;
  63990. /**
  63991. * Gets the output component
  63992. */
  63993. get output(): NodeMaterialConnectionPoint;
  63994. private _writeColorConstant;
  63995. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63996. serialize(): any;
  63997. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63998. protected _dumpPropertiesCode(): string;
  63999. }
  64000. }
  64001. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  64002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64005. /**
  64006. * Block used to normalize lerp between 2 values
  64007. */
  64008. export class NLerpBlock extends NodeMaterialBlock {
  64009. /**
  64010. * Creates a new NLerpBlock
  64011. * @param name defines the block name
  64012. */
  64013. constructor(name: string);
  64014. /**
  64015. * Gets the current class name
  64016. * @returns the class name
  64017. */
  64018. getClassName(): string;
  64019. /**
  64020. * Gets the left operand input component
  64021. */
  64022. get left(): NodeMaterialConnectionPoint;
  64023. /**
  64024. * Gets the right operand input component
  64025. */
  64026. get right(): NodeMaterialConnectionPoint;
  64027. /**
  64028. * Gets the gradient operand input component
  64029. */
  64030. get gradient(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the output component
  64033. */
  64034. get output(): NodeMaterialConnectionPoint;
  64035. protected _buildBlock(state: NodeMaterialBuildState): this;
  64036. }
  64037. }
  64038. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  64039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64042. import { Scene } from "babylonjs/scene";
  64043. /**
  64044. * block used to Generate a Worley Noise 3D Noise Pattern
  64045. */
  64046. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64047. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64048. manhattanDistance: boolean;
  64049. /**
  64050. * Creates a new WorleyNoise3DBlock
  64051. * @param name defines the block name
  64052. */
  64053. constructor(name: string);
  64054. /**
  64055. * Gets the current class name
  64056. * @returns the class name
  64057. */
  64058. getClassName(): string;
  64059. /**
  64060. * Gets the seed input component
  64061. */
  64062. get seed(): NodeMaterialConnectionPoint;
  64063. /**
  64064. * Gets the jitter input component
  64065. */
  64066. get jitter(): NodeMaterialConnectionPoint;
  64067. /**
  64068. * Gets the output component
  64069. */
  64070. get output(): NodeMaterialConnectionPoint;
  64071. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64072. /**
  64073. * Exposes the properties to the UI?
  64074. */
  64075. protected _dumpPropertiesCode(): string;
  64076. /**
  64077. * Exposes the properties to the Seralize?
  64078. */
  64079. serialize(): any;
  64080. /**
  64081. * Exposes the properties to the deseralize?
  64082. */
  64083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64084. }
  64085. }
  64086. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  64087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64090. /**
  64091. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64092. */
  64093. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64094. /**
  64095. * Creates a new SimplexPerlin3DBlock
  64096. * @param name defines the block name
  64097. */
  64098. constructor(name: string);
  64099. /**
  64100. * Gets the current class name
  64101. * @returns the class name
  64102. */
  64103. getClassName(): string;
  64104. /**
  64105. * Gets the seed operand input component
  64106. */
  64107. get seed(): NodeMaterialConnectionPoint;
  64108. /**
  64109. * Gets the output component
  64110. */
  64111. get output(): NodeMaterialConnectionPoint;
  64112. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64113. }
  64114. }
  64115. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  64116. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64118. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64119. /**
  64120. * Block used to blend normals
  64121. */
  64122. export class NormalBlendBlock extends NodeMaterialBlock {
  64123. /**
  64124. * Creates a new NormalBlendBlock
  64125. * @param name defines the block name
  64126. */
  64127. constructor(name: string);
  64128. /**
  64129. * Gets the current class name
  64130. * @returns the class name
  64131. */
  64132. getClassName(): string;
  64133. /**
  64134. * Gets the first input component
  64135. */
  64136. get normalMap0(): NodeMaterialConnectionPoint;
  64137. /**
  64138. * Gets the second input component
  64139. */
  64140. get normalMap1(): NodeMaterialConnectionPoint;
  64141. /**
  64142. * Gets the output component
  64143. */
  64144. get output(): NodeMaterialConnectionPoint;
  64145. protected _buildBlock(state: NodeMaterialBuildState): this;
  64146. }
  64147. }
  64148. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  64149. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64150. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64151. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64152. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64153. /**
  64154. * Block used to rotate a 2d vector by a given angle
  64155. */
  64156. export class Rotate2dBlock extends NodeMaterialBlock {
  64157. /**
  64158. * Creates a new Rotate2dBlock
  64159. * @param name defines the block name
  64160. */
  64161. constructor(name: string);
  64162. /**
  64163. * Gets the current class name
  64164. * @returns the class name
  64165. */
  64166. getClassName(): string;
  64167. /**
  64168. * Gets the input vector
  64169. */
  64170. get input(): NodeMaterialConnectionPoint;
  64171. /**
  64172. * Gets the input angle
  64173. */
  64174. get angle(): NodeMaterialConnectionPoint;
  64175. /**
  64176. * Gets the output component
  64177. */
  64178. get output(): NodeMaterialConnectionPoint;
  64179. autoConfigure(material: NodeMaterial): void;
  64180. protected _buildBlock(state: NodeMaterialBuildState): this;
  64181. }
  64182. }
  64183. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  64184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64187. /**
  64188. * Block used to get the reflected vector from a direction and a normal
  64189. */
  64190. export class ReflectBlock extends NodeMaterialBlock {
  64191. /**
  64192. * Creates a new ReflectBlock
  64193. * @param name defines the block name
  64194. */
  64195. constructor(name: string);
  64196. /**
  64197. * Gets the current class name
  64198. * @returns the class name
  64199. */
  64200. getClassName(): string;
  64201. /**
  64202. * Gets the incident component
  64203. */
  64204. get incident(): NodeMaterialConnectionPoint;
  64205. /**
  64206. * Gets the normal component
  64207. */
  64208. get normal(): NodeMaterialConnectionPoint;
  64209. /**
  64210. * Gets the output component
  64211. */
  64212. get output(): NodeMaterialConnectionPoint;
  64213. protected _buildBlock(state: NodeMaterialBuildState): this;
  64214. }
  64215. }
  64216. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  64217. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64219. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64220. /**
  64221. * Block used to get the refracted vector from a direction and a normal
  64222. */
  64223. export class RefractBlock extends NodeMaterialBlock {
  64224. /**
  64225. * Creates a new RefractBlock
  64226. * @param name defines the block name
  64227. */
  64228. constructor(name: string);
  64229. /**
  64230. * Gets the current class name
  64231. * @returns the class name
  64232. */
  64233. getClassName(): string;
  64234. /**
  64235. * Gets the incident component
  64236. */
  64237. get incident(): NodeMaterialConnectionPoint;
  64238. /**
  64239. * Gets the normal component
  64240. */
  64241. get normal(): NodeMaterialConnectionPoint;
  64242. /**
  64243. * Gets the index of refraction component
  64244. */
  64245. get ior(): NodeMaterialConnectionPoint;
  64246. /**
  64247. * Gets the output component
  64248. */
  64249. get output(): NodeMaterialConnectionPoint;
  64250. protected _buildBlock(state: NodeMaterialBuildState): this;
  64251. }
  64252. }
  64253. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  64254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64257. /**
  64258. * Block used to desaturate a color
  64259. */
  64260. export class DesaturateBlock extends NodeMaterialBlock {
  64261. /**
  64262. * Creates a new DesaturateBlock
  64263. * @param name defines the block name
  64264. */
  64265. constructor(name: string);
  64266. /**
  64267. * Gets the current class name
  64268. * @returns the class name
  64269. */
  64270. getClassName(): string;
  64271. /**
  64272. * Gets the color operand input component
  64273. */
  64274. get color(): NodeMaterialConnectionPoint;
  64275. /**
  64276. * Gets the level operand input component
  64277. */
  64278. get level(): NodeMaterialConnectionPoint;
  64279. /**
  64280. * Gets the output component
  64281. */
  64282. get output(): NodeMaterialConnectionPoint;
  64283. protected _buildBlock(state: NodeMaterialBuildState): this;
  64284. }
  64285. }
  64286. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  64287. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64288. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64289. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64290. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64291. import { Nullable } from "babylonjs/types";
  64292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64293. import { Scene } from "babylonjs/scene";
  64294. /**
  64295. * Block used to implement the ambient occlusion module of the PBR material
  64296. */
  64297. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64298. /**
  64299. * Create a new AmbientOcclusionBlock
  64300. * @param name defines the block name
  64301. */
  64302. constructor(name: string);
  64303. /**
  64304. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64305. */
  64306. useAmbientInGrayScale: boolean;
  64307. /**
  64308. * Initialize the block and prepare the context for build
  64309. * @param state defines the state that will be used for the build
  64310. */
  64311. initialize(state: NodeMaterialBuildState): void;
  64312. /**
  64313. * Gets the current class name
  64314. * @returns the class name
  64315. */
  64316. getClassName(): string;
  64317. /**
  64318. * Gets the texture input component
  64319. */
  64320. get texture(): NodeMaterialConnectionPoint;
  64321. /**
  64322. * Gets the texture intensity component
  64323. */
  64324. get intensity(): NodeMaterialConnectionPoint;
  64325. /**
  64326. * Gets the direct light intensity input component
  64327. */
  64328. get directLightIntensity(): NodeMaterialConnectionPoint;
  64329. /**
  64330. * Gets the ambient occlusion object output component
  64331. */
  64332. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64333. /**
  64334. * Gets the main code of the block (fragment side)
  64335. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64336. * @returns the shader code
  64337. */
  64338. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64339. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64340. protected _buildBlock(state: NodeMaterialBuildState): this;
  64341. protected _dumpPropertiesCode(): string;
  64342. serialize(): any;
  64343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64344. }
  64345. }
  64346. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  64347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64349. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64350. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64352. import { Nullable } from "babylonjs/types";
  64353. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64354. import { Mesh } from "babylonjs/Meshes/mesh";
  64355. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64356. import { Effect } from "babylonjs/Materials/effect";
  64357. import { Scene } from "babylonjs/scene";
  64358. /**
  64359. * Block used to implement the reflection module of the PBR material
  64360. */
  64361. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64362. /** @hidden */
  64363. _defineLODReflectionAlpha: string;
  64364. /** @hidden */
  64365. _defineLinearSpecularReflection: string;
  64366. private _vEnvironmentIrradianceName;
  64367. /** @hidden */
  64368. _vReflectionMicrosurfaceInfosName: string;
  64369. /** @hidden */
  64370. _vReflectionInfosName: string;
  64371. private _scene;
  64372. /**
  64373. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64374. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64375. * It's less burden on the user side in the editor part.
  64376. */
  64377. /** @hidden */
  64378. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64379. /** @hidden */
  64380. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64381. /** @hidden */
  64382. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64383. /**
  64384. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64385. * diffuse part of the IBL.
  64386. */
  64387. useSphericalHarmonics: boolean;
  64388. /**
  64389. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64390. */
  64391. forceIrradianceInFragment: boolean;
  64392. /**
  64393. * Create a new ReflectionBlock
  64394. * @param name defines the block name
  64395. */
  64396. constructor(name: string);
  64397. /**
  64398. * Gets the current class name
  64399. * @returns the class name
  64400. */
  64401. getClassName(): string;
  64402. /**
  64403. * Gets the position input component
  64404. */
  64405. get position(): NodeMaterialConnectionPoint;
  64406. /**
  64407. * Gets the world position input component
  64408. */
  64409. get worldPosition(): NodeMaterialConnectionPoint;
  64410. /**
  64411. * Gets the world normal input component
  64412. */
  64413. get worldNormal(): NodeMaterialConnectionPoint;
  64414. /**
  64415. * Gets the world input component
  64416. */
  64417. get world(): NodeMaterialConnectionPoint;
  64418. /**
  64419. * Gets the camera (or eye) position component
  64420. */
  64421. get cameraPosition(): NodeMaterialConnectionPoint;
  64422. /**
  64423. * Gets the view input component
  64424. */
  64425. get view(): NodeMaterialConnectionPoint;
  64426. /**
  64427. * Gets the color input component
  64428. */
  64429. get color(): NodeMaterialConnectionPoint;
  64430. /**
  64431. * Gets the reflection object output component
  64432. */
  64433. get reflection(): NodeMaterialConnectionPoint;
  64434. /**
  64435. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64436. */
  64437. get hasTexture(): boolean;
  64438. /**
  64439. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64440. */
  64441. get reflectionColor(): string;
  64442. protected _getTexture(): Nullable<BaseTexture>;
  64443. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64444. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64445. /**
  64446. * Gets the code to inject in the vertex shader
  64447. * @param state current state of the node material building
  64448. * @returns the shader code
  64449. */
  64450. handleVertexSide(state: NodeMaterialBuildState): string;
  64451. /**
  64452. * Gets the main code of the block (fragment side)
  64453. * @param state current state of the node material building
  64454. * @param normalVarName name of the existing variable corresponding to the normal
  64455. * @returns the shader code
  64456. */
  64457. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64458. protected _buildBlock(state: NodeMaterialBuildState): this;
  64459. protected _dumpPropertiesCode(): string;
  64460. serialize(): any;
  64461. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64462. }
  64463. }
  64464. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  64465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64468. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64470. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64471. import { Scene } from "babylonjs/scene";
  64472. import { Nullable } from "babylonjs/types";
  64473. /**
  64474. * Block used to implement the sheen module of the PBR material
  64475. */
  64476. export class SheenBlock extends NodeMaterialBlock {
  64477. /**
  64478. * Create a new SheenBlock
  64479. * @param name defines the block name
  64480. */
  64481. constructor(name: string);
  64482. /**
  64483. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64484. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64485. * making it easier to setup and tweak the effect
  64486. */
  64487. albedoScaling: boolean;
  64488. /**
  64489. * Defines if the sheen is linked to the sheen color.
  64490. */
  64491. linkSheenWithAlbedo: boolean;
  64492. /**
  64493. * Initialize the block and prepare the context for build
  64494. * @param state defines the state that will be used for the build
  64495. */
  64496. initialize(state: NodeMaterialBuildState): void;
  64497. /**
  64498. * Gets the current class name
  64499. * @returns the class name
  64500. */
  64501. getClassName(): string;
  64502. /**
  64503. * Gets the intensity input component
  64504. */
  64505. get intensity(): NodeMaterialConnectionPoint;
  64506. /**
  64507. * Gets the color input component
  64508. */
  64509. get color(): NodeMaterialConnectionPoint;
  64510. /**
  64511. * Gets the roughness input component
  64512. */
  64513. get roughness(): NodeMaterialConnectionPoint;
  64514. /**
  64515. * Gets the texture input component
  64516. */
  64517. get texture(): NodeMaterialConnectionPoint;
  64518. /**
  64519. * Gets the sheen object output component
  64520. */
  64521. get sheen(): NodeMaterialConnectionPoint;
  64522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64523. /**
  64524. * Gets the main code of the block (fragment side)
  64525. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64526. * @returns the shader code
  64527. */
  64528. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64529. protected _buildBlock(state: NodeMaterialBuildState): this;
  64530. protected _dumpPropertiesCode(): string;
  64531. serialize(): any;
  64532. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64533. }
  64534. }
  64535. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  64536. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64541. import { Scene } from "babylonjs/scene";
  64542. /**
  64543. * Block used to implement the reflectivity module of the PBR material
  64544. */
  64545. export class ReflectivityBlock extends NodeMaterialBlock {
  64546. /**
  64547. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64548. */
  64549. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64550. /**
  64551. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64552. */
  64553. useMetallnessFromMetallicTextureBlue: boolean;
  64554. /**
  64555. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64556. */
  64557. useRoughnessFromMetallicTextureAlpha: boolean;
  64558. /**
  64559. * Specifies if the metallic texture contains the roughness information in its green channel.
  64560. */
  64561. useRoughnessFromMetallicTextureGreen: boolean;
  64562. /**
  64563. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  64564. */
  64565. useMetallicF0FactorFromMetallicTexture: boolean;
  64566. /**
  64567. * Create a new ReflectivityBlock
  64568. * @param name defines the block name
  64569. */
  64570. constructor(name: string);
  64571. /**
  64572. * Initialize the block and prepare the context for build
  64573. * @param state defines the state that will be used for the build
  64574. */
  64575. initialize(state: NodeMaterialBuildState): void;
  64576. /**
  64577. * Gets the current class name
  64578. * @returns the class name
  64579. */
  64580. getClassName(): string;
  64581. /**
  64582. * Gets the metallic input component
  64583. */
  64584. get metallic(): NodeMaterialConnectionPoint;
  64585. /**
  64586. * Gets the roughness input component
  64587. */
  64588. get roughness(): NodeMaterialConnectionPoint;
  64589. /**
  64590. * Gets the texture input component
  64591. */
  64592. get texture(): NodeMaterialConnectionPoint;
  64593. /**
  64594. * Gets the reflectivity object output component
  64595. */
  64596. get reflectivity(): NodeMaterialConnectionPoint;
  64597. /**
  64598. * Gets the main code of the block (fragment side)
  64599. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64600. * @returns the shader code
  64601. */
  64602. getCode(aoIntensityVarName: string): string;
  64603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64604. protected _buildBlock(state: NodeMaterialBuildState): this;
  64605. protected _dumpPropertiesCode(): string;
  64606. serialize(): any;
  64607. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64608. }
  64609. }
  64610. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  64611. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64616. /**
  64617. * Block used to implement the anisotropy module of the PBR material
  64618. */
  64619. export class AnisotropyBlock extends NodeMaterialBlock {
  64620. /**
  64621. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64622. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64623. * It's less burden on the user side in the editor part.
  64624. */
  64625. /** @hidden */
  64626. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64627. /** @hidden */
  64628. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64629. /**
  64630. * Create a new AnisotropyBlock
  64631. * @param name defines the block name
  64632. */
  64633. constructor(name: string);
  64634. /**
  64635. * Initialize the block and prepare the context for build
  64636. * @param state defines the state that will be used for the build
  64637. */
  64638. initialize(state: NodeMaterialBuildState): void;
  64639. /**
  64640. * Gets the current class name
  64641. * @returns the class name
  64642. */
  64643. getClassName(): string;
  64644. /**
  64645. * Gets the intensity input component
  64646. */
  64647. get intensity(): NodeMaterialConnectionPoint;
  64648. /**
  64649. * Gets the direction input component
  64650. */
  64651. get direction(): NodeMaterialConnectionPoint;
  64652. /**
  64653. * Gets the texture input component
  64654. */
  64655. get texture(): NodeMaterialConnectionPoint;
  64656. /**
  64657. * Gets the uv input component
  64658. */
  64659. get uv(): NodeMaterialConnectionPoint;
  64660. /**
  64661. * Gets the worldTangent input component
  64662. */
  64663. get worldTangent(): NodeMaterialConnectionPoint;
  64664. /**
  64665. * Gets the anisotropy object output component
  64666. */
  64667. get anisotropy(): NodeMaterialConnectionPoint;
  64668. private _generateTBNSpace;
  64669. /**
  64670. * Gets the main code of the block (fragment side)
  64671. * @param state current state of the node material building
  64672. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64673. * @returns the shader code
  64674. */
  64675. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64676. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64677. protected _buildBlock(state: NodeMaterialBuildState): this;
  64678. }
  64679. }
  64680. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  64681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64684. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64686. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64687. import { Nullable } from "babylonjs/types";
  64688. import { Mesh } from "babylonjs/Meshes/mesh";
  64689. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64690. import { Effect } from "babylonjs/Materials/effect";
  64691. /**
  64692. * Block used to implement the clear coat module of the PBR material
  64693. */
  64694. export class ClearCoatBlock extends NodeMaterialBlock {
  64695. private _scene;
  64696. /**
  64697. * Create a new ClearCoatBlock
  64698. * @param name defines the block name
  64699. */
  64700. constructor(name: string);
  64701. /**
  64702. * Initialize the block and prepare the context for build
  64703. * @param state defines the state that will be used for the build
  64704. */
  64705. initialize(state: NodeMaterialBuildState): void;
  64706. /**
  64707. * Gets the current class name
  64708. * @returns the class name
  64709. */
  64710. getClassName(): string;
  64711. /**
  64712. * Gets the intensity input component
  64713. */
  64714. get intensity(): NodeMaterialConnectionPoint;
  64715. /**
  64716. * Gets the roughness input component
  64717. */
  64718. get roughness(): NodeMaterialConnectionPoint;
  64719. /**
  64720. * Gets the ior input component
  64721. */
  64722. get ior(): NodeMaterialConnectionPoint;
  64723. /**
  64724. * Gets the texture input component
  64725. */
  64726. get texture(): NodeMaterialConnectionPoint;
  64727. /**
  64728. * Gets the bump texture input component
  64729. */
  64730. get bumpTexture(): NodeMaterialConnectionPoint;
  64731. /**
  64732. * Gets the uv input component
  64733. */
  64734. get uv(): NodeMaterialConnectionPoint;
  64735. /**
  64736. * Gets the tint color input component
  64737. */
  64738. get tintColor(): NodeMaterialConnectionPoint;
  64739. /**
  64740. * Gets the tint "at distance" input component
  64741. */
  64742. get tintAtDistance(): NodeMaterialConnectionPoint;
  64743. /**
  64744. * Gets the tint thickness input component
  64745. */
  64746. get tintThickness(): NodeMaterialConnectionPoint;
  64747. /**
  64748. * Gets the tint texture input component
  64749. */
  64750. get tintTexture(): NodeMaterialConnectionPoint;
  64751. /**
  64752. * Gets the world tangent input component
  64753. */
  64754. get worldTangent(): NodeMaterialConnectionPoint;
  64755. /**
  64756. * Gets the clear coat object output component
  64757. */
  64758. get clearcoat(): NodeMaterialConnectionPoint;
  64759. autoConfigure(material: NodeMaterial): void;
  64760. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64761. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64762. private _generateTBNSpace;
  64763. /**
  64764. * Gets the main code of the block (fragment side)
  64765. * @param state current state of the node material building
  64766. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64767. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64768. * @param worldPosVarName name of the variable holding the world position
  64769. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64770. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64771. * @param worldNormalVarName name of the variable holding the world normal
  64772. * @returns the shader code
  64773. */
  64774. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64775. protected _buildBlock(state: NodeMaterialBuildState): this;
  64776. }
  64777. }
  64778. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  64779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64782. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64784. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  64785. import { Nullable } from "babylonjs/types";
  64786. /**
  64787. * Block used to implement the sub surface module of the PBR material
  64788. */
  64789. export class SubSurfaceBlock extends NodeMaterialBlock {
  64790. /**
  64791. * Create a new SubSurfaceBlock
  64792. * @param name defines the block name
  64793. */
  64794. constructor(name: string);
  64795. /**
  64796. * Stores the intensity of the different subsurface effects in the thickness texture.
  64797. * * the green channel is the translucency intensity.
  64798. * * the blue channel is the scattering intensity.
  64799. * * the alpha channel is the refraction intensity.
  64800. */
  64801. useMaskFromThicknessTexture: boolean;
  64802. /**
  64803. * Initialize the block and prepare the context for build
  64804. * @param state defines the state that will be used for the build
  64805. */
  64806. initialize(state: NodeMaterialBuildState): void;
  64807. /**
  64808. * Gets the current class name
  64809. * @returns the class name
  64810. */
  64811. getClassName(): string;
  64812. /**
  64813. * Gets the min thickness input component
  64814. */
  64815. get minThickness(): NodeMaterialConnectionPoint;
  64816. /**
  64817. * Gets the max thickness input component
  64818. */
  64819. get maxThickness(): NodeMaterialConnectionPoint;
  64820. /**
  64821. * Gets the thickness texture component
  64822. */
  64823. get thicknessTexture(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the tint color input component
  64826. */
  64827. get tintColor(): NodeMaterialConnectionPoint;
  64828. /**
  64829. * Gets the translucency intensity input component
  64830. */
  64831. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64832. /**
  64833. * Gets the translucency diffusion distance input component
  64834. */
  64835. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64836. /**
  64837. * Gets the refraction object parameters
  64838. */
  64839. get refraction(): NodeMaterialConnectionPoint;
  64840. /**
  64841. * Gets the sub surface object output component
  64842. */
  64843. get subsurface(): NodeMaterialConnectionPoint;
  64844. autoConfigure(material: NodeMaterial): void;
  64845. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64846. /**
  64847. * Gets the main code of the block (fragment side)
  64848. * @param state current state of the node material building
  64849. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64850. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64851. * @param worldPosVarName name of the variable holding the world position
  64852. * @returns the shader code
  64853. */
  64854. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64855. protected _buildBlock(state: NodeMaterialBuildState): this;
  64856. }
  64857. }
  64858. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  64859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64860. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64862. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64863. import { Light } from "babylonjs/Lights/light";
  64864. import { Nullable } from "babylonjs/types";
  64865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64866. import { Effect } from "babylonjs/Materials/effect";
  64867. import { Mesh } from "babylonjs/Meshes/mesh";
  64868. import { Scene } from "babylonjs/scene";
  64869. /**
  64870. * Block used to implement the PBR metallic/roughness model
  64871. */
  64872. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64873. /**
  64874. * Gets or sets the light associated with this block
  64875. */
  64876. light: Nullable<Light>;
  64877. private _lightId;
  64878. private _scene;
  64879. private _environmentBRDFTexture;
  64880. private _environmentBrdfSamplerName;
  64881. private _vNormalWName;
  64882. private _invertNormalName;
  64883. /**
  64884. * Create a new ReflectionBlock
  64885. * @param name defines the block name
  64886. */
  64887. constructor(name: string);
  64888. /**
  64889. * Intensity of the direct lights e.g. the four lights available in your scene.
  64890. * This impacts both the direct diffuse and specular highlights.
  64891. */
  64892. directIntensity: number;
  64893. /**
  64894. * Intensity of the environment e.g. how much the environment will light the object
  64895. * either through harmonics for rough material or through the refelction for shiny ones.
  64896. */
  64897. environmentIntensity: number;
  64898. /**
  64899. * This is a special control allowing the reduction of the specular highlights coming from the
  64900. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64901. */
  64902. specularIntensity: number;
  64903. /**
  64904. * Defines the falloff type used in this material.
  64905. * It by default is Physical.
  64906. */
  64907. lightFalloff: number;
  64908. /**
  64909. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64910. */
  64911. useAlphaFromAlbedoTexture: boolean;
  64912. /**
  64913. * Specifies that alpha test should be used
  64914. */
  64915. useAlphaTest: boolean;
  64916. /**
  64917. * Defines the alpha limits in alpha test mode.
  64918. */
  64919. alphaTestCutoff: number;
  64920. /**
  64921. * Specifies that alpha blending should be used
  64922. */
  64923. useAlphaBlending: boolean;
  64924. /**
  64925. * Defines if the alpha value should be determined via the rgb values.
  64926. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64927. */
  64928. opacityRGB: boolean;
  64929. /**
  64930. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64931. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64932. */
  64933. useRadianceOverAlpha: boolean;
  64934. /**
  64935. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64936. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64937. */
  64938. useSpecularOverAlpha: boolean;
  64939. /**
  64940. * Enables specular anti aliasing in the PBR shader.
  64941. * It will both interacts on the Geometry for analytical and IBL lighting.
  64942. * It also prefilter the roughness map based on the bump values.
  64943. */
  64944. enableSpecularAntiAliasing: boolean;
  64945. /**
  64946. * Defines if the material uses energy conservation.
  64947. */
  64948. useEnergyConservation: boolean;
  64949. /**
  64950. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64951. * too much the area relying on ambient texture to define their ambient occlusion.
  64952. */
  64953. useRadianceOcclusion: boolean;
  64954. /**
  64955. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64956. * makes the reflect vector face the model (under horizon).
  64957. */
  64958. useHorizonOcclusion: boolean;
  64959. /**
  64960. * If set to true, no lighting calculations will be applied.
  64961. */
  64962. unlit: boolean;
  64963. /**
  64964. * Force normal to face away from face.
  64965. */
  64966. forceNormalForward: boolean;
  64967. /**
  64968. * Defines the material debug mode.
  64969. * It helps seeing only some components of the material while troubleshooting.
  64970. */
  64971. debugMode: number;
  64972. /**
  64973. * Specify from where on screen the debug mode should start.
  64974. * The value goes from -1 (full screen) to 1 (not visible)
  64975. * It helps with side by side comparison against the final render
  64976. * This defaults to 0
  64977. */
  64978. debugLimit: number;
  64979. /**
  64980. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64981. * You can use the factor to better multiply the final value.
  64982. */
  64983. debugFactor: number;
  64984. /**
  64985. * Initialize the block and prepare the context for build
  64986. * @param state defines the state that will be used for the build
  64987. */
  64988. initialize(state: NodeMaterialBuildState): void;
  64989. /**
  64990. * Gets the current class name
  64991. * @returns the class name
  64992. */
  64993. getClassName(): string;
  64994. /**
  64995. * Gets the world position input component
  64996. */
  64997. get worldPosition(): NodeMaterialConnectionPoint;
  64998. /**
  64999. * Gets the world normal input component
  65000. */
  65001. get worldNormal(): NodeMaterialConnectionPoint;
  65002. /**
  65003. * Gets the perturbed normal input component
  65004. */
  65005. get perturbedNormal(): NodeMaterialConnectionPoint;
  65006. /**
  65007. * Gets the camera position input component
  65008. */
  65009. get cameraPosition(): NodeMaterialConnectionPoint;
  65010. /**
  65011. * Gets the base color input component
  65012. */
  65013. get baseColor(): NodeMaterialConnectionPoint;
  65014. /**
  65015. * Gets the base texture input component
  65016. */
  65017. get baseTexture(): NodeMaterialConnectionPoint;
  65018. /**
  65019. * Gets the opacity texture input component
  65020. */
  65021. get opacityTexture(): NodeMaterialConnectionPoint;
  65022. /**
  65023. * Gets the ambient color input component
  65024. */
  65025. get ambientColor(): NodeMaterialConnectionPoint;
  65026. /**
  65027. * Gets the reflectivity object parameters
  65028. */
  65029. get reflectivity(): NodeMaterialConnectionPoint;
  65030. /**
  65031. * Gets the ambient occlusion object parameters
  65032. */
  65033. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65034. /**
  65035. * Gets the reflection object parameters
  65036. */
  65037. get reflection(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the sheen object parameters
  65040. */
  65041. get sheen(): NodeMaterialConnectionPoint;
  65042. /**
  65043. * Gets the clear coat object parameters
  65044. */
  65045. get clearcoat(): NodeMaterialConnectionPoint;
  65046. /**
  65047. * Gets the sub surface object parameters
  65048. */
  65049. get subsurface(): NodeMaterialConnectionPoint;
  65050. /**
  65051. * Gets the anisotropy object parameters
  65052. */
  65053. get anisotropy(): NodeMaterialConnectionPoint;
  65054. /**
  65055. * Gets the ambient output component
  65056. */
  65057. get ambient(): NodeMaterialConnectionPoint;
  65058. /**
  65059. * Gets the diffuse output component
  65060. */
  65061. get diffuse(): NodeMaterialConnectionPoint;
  65062. /**
  65063. * Gets the specular output component
  65064. */
  65065. get specular(): NodeMaterialConnectionPoint;
  65066. /**
  65067. * Gets the sheen output component
  65068. */
  65069. get sheenDir(): NodeMaterialConnectionPoint;
  65070. /**
  65071. * Gets the clear coat output component
  65072. */
  65073. get clearcoatDir(): NodeMaterialConnectionPoint;
  65074. /**
  65075. * Gets the indirect diffuse output component
  65076. */
  65077. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65078. /**
  65079. * Gets the indirect specular output component
  65080. */
  65081. get specularIndirect(): NodeMaterialConnectionPoint;
  65082. /**
  65083. * Gets the indirect sheen output component
  65084. */
  65085. get sheenIndirect(): NodeMaterialConnectionPoint;
  65086. /**
  65087. * Gets the indirect clear coat output component
  65088. */
  65089. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65090. /**
  65091. * Gets the refraction output component
  65092. */
  65093. get refraction(): NodeMaterialConnectionPoint;
  65094. /**
  65095. * Gets the global lighting output component
  65096. */
  65097. get lighting(): NodeMaterialConnectionPoint;
  65098. /**
  65099. * Gets the shadow output component
  65100. */
  65101. get shadow(): NodeMaterialConnectionPoint;
  65102. /**
  65103. * Gets the alpha output component
  65104. */
  65105. get alpha(): NodeMaterialConnectionPoint;
  65106. autoConfigure(material: NodeMaterial): void;
  65107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65108. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65109. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65110. private _injectVertexCode;
  65111. /**
  65112. * Gets the code corresponding to the albedo/opacity module
  65113. * @returns the shader code
  65114. */
  65115. getAlbedoOpacityCode(): string;
  65116. protected _buildBlock(state: NodeMaterialBuildState): this;
  65117. protected _dumpPropertiesCode(): string;
  65118. serialize(): any;
  65119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65120. }
  65121. }
  65122. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  65123. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  65124. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  65125. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  65126. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  65127. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  65128. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  65129. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  65130. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  65131. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  65132. }
  65133. declare module "babylonjs/Materials/Node/Blocks/index" {
  65134. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  65135. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  65136. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  65137. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  65138. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  65139. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  65140. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  65141. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  65142. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  65143. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  65144. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  65145. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  65146. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  65147. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  65148. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  65149. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  65150. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  65151. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  65152. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  65153. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  65154. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  65155. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  65156. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  65157. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  65158. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  65159. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  65160. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  65161. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  65162. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  65163. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  65164. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  65165. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  65166. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  65167. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  65168. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  65169. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  65170. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  65171. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  65172. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  65173. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  65174. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  65175. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  65176. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  65177. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  65178. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  65179. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  65180. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  65181. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  65182. }
  65183. declare module "babylonjs/Materials/Node/Optimizers/index" {
  65184. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  65185. }
  65186. declare module "babylonjs/Materials/Node/index" {
  65187. export * from "babylonjs/Materials/Node/Enums/index";
  65188. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65189. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  65190. export * from "babylonjs/Materials/Node/nodeMaterial";
  65191. export * from "babylonjs/Materials/Node/Blocks/index";
  65192. export * from "babylonjs/Materials/Node/Optimizers/index";
  65193. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  65194. }
  65195. declare module "babylonjs/Materials/effectRenderer" {
  65196. import { Nullable } from "babylonjs/types";
  65197. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65198. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65199. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65200. import { Viewport } from "babylonjs/Maths/math.viewport";
  65201. import { Observable } from "babylonjs/Misc/observable";
  65202. import { Effect } from "babylonjs/Materials/effect";
  65203. import "babylonjs/Shaders/postprocess.vertex";
  65204. /**
  65205. * Effect Render Options
  65206. */
  65207. export interface IEffectRendererOptions {
  65208. /**
  65209. * Defines the vertices positions.
  65210. */
  65211. positions?: number[];
  65212. /**
  65213. * Defines the indices.
  65214. */
  65215. indices?: number[];
  65216. }
  65217. /**
  65218. * Helper class to render one or more effects.
  65219. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65220. */
  65221. export class EffectRenderer {
  65222. private engine;
  65223. private static _DefaultOptions;
  65224. private _vertexBuffers;
  65225. private _indexBuffer;
  65226. private _fullscreenViewport;
  65227. /**
  65228. * Creates an effect renderer
  65229. * @param engine the engine to use for rendering
  65230. * @param options defines the options of the effect renderer
  65231. */
  65232. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65233. /**
  65234. * Sets the current viewport in normalized coordinates 0-1
  65235. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65236. */
  65237. setViewport(viewport?: Viewport): void;
  65238. /**
  65239. * Binds the embedded attributes buffer to the effect.
  65240. * @param effect Defines the effect to bind the attributes for
  65241. */
  65242. bindBuffers(effect: Effect): void;
  65243. /**
  65244. * Sets the current effect wrapper to use during draw.
  65245. * The effect needs to be ready before calling this api.
  65246. * This also sets the default full screen position attribute.
  65247. * @param effectWrapper Defines the effect to draw with
  65248. */
  65249. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65250. /**
  65251. * Draws a full screen quad.
  65252. */
  65253. draw(): void;
  65254. private isRenderTargetTexture;
  65255. /**
  65256. * renders one or more effects to a specified texture
  65257. * @param effectWrapper the effect to renderer
  65258. * @param outputTexture texture to draw to, if null it will render to the screen.
  65259. */
  65260. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65261. /**
  65262. * Disposes of the effect renderer
  65263. */
  65264. dispose(): void;
  65265. }
  65266. /**
  65267. * Options to create an EffectWrapper
  65268. */
  65269. interface EffectWrapperCreationOptions {
  65270. /**
  65271. * Engine to use to create the effect
  65272. */
  65273. engine: ThinEngine;
  65274. /**
  65275. * Fragment shader for the effect
  65276. */
  65277. fragmentShader: string;
  65278. /**
  65279. * Vertex shader for the effect
  65280. */
  65281. vertexShader?: string;
  65282. /**
  65283. * Attributes to use in the shader
  65284. */
  65285. attributeNames?: Array<string>;
  65286. /**
  65287. * Uniforms to use in the shader
  65288. */
  65289. uniformNames?: Array<string>;
  65290. /**
  65291. * Texture sampler names to use in the shader
  65292. */
  65293. samplerNames?: Array<string>;
  65294. /**
  65295. * The friendly name of the effect displayed in Spector.
  65296. */
  65297. name?: string;
  65298. }
  65299. /**
  65300. * Wraps an effect to be used for rendering
  65301. */
  65302. export class EffectWrapper {
  65303. /**
  65304. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65305. */
  65306. onApplyObservable: Observable<{}>;
  65307. /**
  65308. * The underlying effect
  65309. */
  65310. effect: Effect;
  65311. /**
  65312. * Creates an effect to be renderer
  65313. * @param creationOptions options to create the effect
  65314. */
  65315. constructor(creationOptions: EffectWrapperCreationOptions);
  65316. /**
  65317. * Disposes of the effect wrapper
  65318. */
  65319. dispose(): void;
  65320. }
  65321. }
  65322. declare module "babylonjs/Materials/index" {
  65323. export * from "babylonjs/Materials/Background/index";
  65324. export * from "babylonjs/Materials/colorCurves";
  65325. export * from "babylonjs/Materials/iEffectFallbacks";
  65326. export * from "babylonjs/Materials/effectFallbacks";
  65327. export * from "babylonjs/Materials/effect";
  65328. export * from "babylonjs/Materials/fresnelParameters";
  65329. export * from "babylonjs/Materials/imageProcessingConfiguration";
  65330. export * from "babylonjs/Materials/material";
  65331. export * from "babylonjs/Materials/materialDefines";
  65332. export * from "babylonjs/Materials/materialHelper";
  65333. export * from "babylonjs/Materials/multiMaterial";
  65334. export * from "babylonjs/Materials/PBR/index";
  65335. export * from "babylonjs/Materials/pushMaterial";
  65336. export * from "babylonjs/Materials/shaderMaterial";
  65337. export * from "babylonjs/Materials/standardMaterial";
  65338. export * from "babylonjs/Materials/Textures/index";
  65339. export * from "babylonjs/Materials/uniformBuffer";
  65340. export * from "babylonjs/Materials/materialFlags";
  65341. export * from "babylonjs/Materials/Node/index";
  65342. export * from "babylonjs/Materials/effectRenderer";
  65343. export * from "babylonjs/Materials/shadowDepthWrapper";
  65344. }
  65345. declare module "babylonjs/Maths/index" {
  65346. export * from "babylonjs/Maths/math.scalar";
  65347. export * from "babylonjs/Maths/math";
  65348. export * from "babylonjs/Maths/sphericalPolynomial";
  65349. }
  65350. declare module "babylonjs/Misc/workerPool" {
  65351. import { IDisposable } from "babylonjs/scene";
  65352. /**
  65353. * Helper class to push actions to a pool of workers.
  65354. */
  65355. export class WorkerPool implements IDisposable {
  65356. private _workerInfos;
  65357. private _pendingActions;
  65358. /**
  65359. * Constructor
  65360. * @param workers Array of workers to use for actions
  65361. */
  65362. constructor(workers: Array<Worker>);
  65363. /**
  65364. * Terminates all workers and clears any pending actions.
  65365. */
  65366. dispose(): void;
  65367. /**
  65368. * Pushes an action to the worker pool. If all the workers are active, the action will be
  65369. * pended until a worker has completed its action.
  65370. * @param action The action to perform. Call onComplete when the action is complete.
  65371. */
  65372. push(action: (worker: Worker, onComplete: () => void) => void): void;
  65373. private _execute;
  65374. }
  65375. }
  65376. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  65377. import { IDisposable } from "babylonjs/scene";
  65378. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65379. /**
  65380. * Configuration for Draco compression
  65381. */
  65382. export interface IDracoCompressionConfiguration {
  65383. /**
  65384. * Configuration for the decoder.
  65385. */
  65386. decoder: {
  65387. /**
  65388. * The url to the WebAssembly module.
  65389. */
  65390. wasmUrl?: string;
  65391. /**
  65392. * The url to the WebAssembly binary.
  65393. */
  65394. wasmBinaryUrl?: string;
  65395. /**
  65396. * The url to the fallback JavaScript module.
  65397. */
  65398. fallbackUrl?: string;
  65399. };
  65400. }
  65401. /**
  65402. * Draco compression (https://google.github.io/draco/)
  65403. *
  65404. * This class wraps the Draco module.
  65405. *
  65406. * **Encoder**
  65407. *
  65408. * The encoder is not currently implemented.
  65409. *
  65410. * **Decoder**
  65411. *
  65412. * 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.
  65413. *
  65414. * To update the configuration, use the following code:
  65415. * ```javascript
  65416. * DracoCompression.Configuration = {
  65417. * decoder: {
  65418. * wasmUrl: "<url to the WebAssembly library>",
  65419. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65420. * fallbackUrl: "<url to the fallback JavaScript library>",
  65421. * }
  65422. * };
  65423. * ```
  65424. *
  65425. * 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.
  65426. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65427. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65428. *
  65429. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65430. * ```javascript
  65431. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65432. * ```
  65433. *
  65434. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65435. */
  65436. export class DracoCompression implements IDisposable {
  65437. private _workerPoolPromise?;
  65438. private _decoderModulePromise?;
  65439. /**
  65440. * The configuration. Defaults to the following urls:
  65441. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65442. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65443. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65444. */
  65445. static Configuration: IDracoCompressionConfiguration;
  65446. /**
  65447. * Returns true if the decoder configuration is available.
  65448. */
  65449. static get DecoderAvailable(): boolean;
  65450. /**
  65451. * Default number of workers to create when creating the draco compression object.
  65452. */
  65453. static DefaultNumWorkers: number;
  65454. private static GetDefaultNumWorkers;
  65455. private static _Default;
  65456. /**
  65457. * Default instance for the draco compression object.
  65458. */
  65459. static get Default(): DracoCompression;
  65460. /**
  65461. * Constructor
  65462. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65463. */
  65464. constructor(numWorkers?: number);
  65465. /**
  65466. * Stop all async operations and release resources.
  65467. */
  65468. dispose(): void;
  65469. /**
  65470. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65471. * @returns a promise that resolves when ready
  65472. */
  65473. whenReadyAsync(): Promise<void>;
  65474. /**
  65475. * Decode Draco compressed mesh data to vertex data.
  65476. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65477. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65478. * @returns A promise that resolves with the decoded vertex data
  65479. */
  65480. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65481. [kind: string]: number;
  65482. }): Promise<VertexData>;
  65483. }
  65484. }
  65485. declare module "babylonjs/Meshes/Compression/index" {
  65486. export * from "babylonjs/Meshes/Compression/dracoCompression";
  65487. }
  65488. declare module "babylonjs/Meshes/csg" {
  65489. import { Nullable } from "babylonjs/types";
  65490. import { Scene } from "babylonjs/scene";
  65491. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  65492. import { Mesh } from "babylonjs/Meshes/mesh";
  65493. import { Material } from "babylonjs/Materials/material";
  65494. /**
  65495. * Class for building Constructive Solid Geometry
  65496. */
  65497. export class CSG {
  65498. private polygons;
  65499. /**
  65500. * The world matrix
  65501. */
  65502. matrix: Matrix;
  65503. /**
  65504. * Stores the position
  65505. */
  65506. position: Vector3;
  65507. /**
  65508. * Stores the rotation
  65509. */
  65510. rotation: Vector3;
  65511. /**
  65512. * Stores the rotation quaternion
  65513. */
  65514. rotationQuaternion: Nullable<Quaternion>;
  65515. /**
  65516. * Stores the scaling vector
  65517. */
  65518. scaling: Vector3;
  65519. /**
  65520. * Convert the Mesh to CSG
  65521. * @param mesh The Mesh to convert to CSG
  65522. * @returns A new CSG from the Mesh
  65523. */
  65524. static FromMesh(mesh: Mesh): CSG;
  65525. /**
  65526. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65527. * @param polygons Polygons used to construct a CSG solid
  65528. */
  65529. private static FromPolygons;
  65530. /**
  65531. * Clones, or makes a deep copy, of the CSG
  65532. * @returns A new CSG
  65533. */
  65534. clone(): CSG;
  65535. /**
  65536. * Unions this CSG with another CSG
  65537. * @param csg The CSG to union against this CSG
  65538. * @returns The unioned CSG
  65539. */
  65540. union(csg: CSG): CSG;
  65541. /**
  65542. * Unions this CSG with another CSG in place
  65543. * @param csg The CSG to union against this CSG
  65544. */
  65545. unionInPlace(csg: CSG): void;
  65546. /**
  65547. * Subtracts this CSG with another CSG
  65548. * @param csg The CSG to subtract against this CSG
  65549. * @returns A new CSG
  65550. */
  65551. subtract(csg: CSG): CSG;
  65552. /**
  65553. * Subtracts this CSG with another CSG in place
  65554. * @param csg The CSG to subtact against this CSG
  65555. */
  65556. subtractInPlace(csg: CSG): void;
  65557. /**
  65558. * Intersect this CSG with another CSG
  65559. * @param csg The CSG to intersect against this CSG
  65560. * @returns A new CSG
  65561. */
  65562. intersect(csg: CSG): CSG;
  65563. /**
  65564. * Intersects this CSG with another CSG in place
  65565. * @param csg The CSG to intersect against this CSG
  65566. */
  65567. intersectInPlace(csg: CSG): void;
  65568. /**
  65569. * Return a new CSG solid with solid and empty space switched. This solid is
  65570. * not modified.
  65571. * @returns A new CSG solid with solid and empty space switched
  65572. */
  65573. inverse(): CSG;
  65574. /**
  65575. * Inverses the CSG in place
  65576. */
  65577. inverseInPlace(): void;
  65578. /**
  65579. * This is used to keep meshes transformations so they can be restored
  65580. * when we build back a Babylon Mesh
  65581. * NB : All CSG operations are performed in world coordinates
  65582. * @param csg The CSG to copy the transform attributes from
  65583. * @returns This CSG
  65584. */
  65585. copyTransformAttributes(csg: CSG): CSG;
  65586. /**
  65587. * Build Raw mesh from CSG
  65588. * Coordinates here are in world space
  65589. * @param name The name of the mesh geometry
  65590. * @param scene The Scene
  65591. * @param keepSubMeshes Specifies if the submeshes should be kept
  65592. * @returns A new Mesh
  65593. */
  65594. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65595. /**
  65596. * Build Mesh from CSG taking material and transforms into account
  65597. * @param name The name of the Mesh
  65598. * @param material The material of the Mesh
  65599. * @param scene The Scene
  65600. * @param keepSubMeshes Specifies if submeshes should be kept
  65601. * @returns The new Mesh
  65602. */
  65603. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65604. }
  65605. }
  65606. declare module "babylonjs/Meshes/trailMesh" {
  65607. import { Mesh } from "babylonjs/Meshes/mesh";
  65608. import { Scene } from "babylonjs/scene";
  65609. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65610. /**
  65611. * Class used to create a trail following a mesh
  65612. */
  65613. export class TrailMesh extends Mesh {
  65614. private _generator;
  65615. private _autoStart;
  65616. private _running;
  65617. private _diameter;
  65618. private _length;
  65619. private _sectionPolygonPointsCount;
  65620. private _sectionVectors;
  65621. private _sectionNormalVectors;
  65622. private _beforeRenderObserver;
  65623. /**
  65624. * @constructor
  65625. * @param name The value used by scene.getMeshByName() to do a lookup.
  65626. * @param generator The mesh or transform node to generate a trail.
  65627. * @param scene The scene to add this mesh to.
  65628. * @param diameter Diameter of trailing mesh. Default is 1.
  65629. * @param length Length of trailing mesh. Default is 60.
  65630. * @param autoStart Automatically start trailing mesh. Default true.
  65631. */
  65632. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65633. /**
  65634. * "TrailMesh"
  65635. * @returns "TrailMesh"
  65636. */
  65637. getClassName(): string;
  65638. private _createMesh;
  65639. /**
  65640. * Start trailing mesh.
  65641. */
  65642. start(): void;
  65643. /**
  65644. * Stop trailing mesh.
  65645. */
  65646. stop(): void;
  65647. /**
  65648. * Update trailing mesh geometry.
  65649. */
  65650. update(): void;
  65651. /**
  65652. * Returns a new TrailMesh object.
  65653. * @param name is a string, the name given to the new mesh
  65654. * @param newGenerator use new generator object for cloned trail mesh
  65655. * @returns a new mesh
  65656. */
  65657. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65658. /**
  65659. * Serializes this trail mesh
  65660. * @param serializationObject object to write serialization to
  65661. */
  65662. serialize(serializationObject: any): void;
  65663. /**
  65664. * Parses a serialized trail mesh
  65665. * @param parsedMesh the serialized mesh
  65666. * @param scene the scene to create the trail mesh in
  65667. * @returns the created trail mesh
  65668. */
  65669. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65670. }
  65671. }
  65672. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  65673. import { Nullable } from "babylonjs/types";
  65674. import { Scene } from "babylonjs/scene";
  65675. import { Vector4 } from "babylonjs/Maths/math.vector";
  65676. import { Color4 } from "babylonjs/Maths/math.color";
  65677. import { Mesh } from "babylonjs/Meshes/mesh";
  65678. /**
  65679. * Class containing static functions to help procedurally build meshes
  65680. */
  65681. export class TiledBoxBuilder {
  65682. /**
  65683. * Creates a box mesh
  65684. * 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)
  65685. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65689. * @param name defines the name of the mesh
  65690. * @param options defines the options used to create the mesh
  65691. * @param scene defines the hosting scene
  65692. * @returns the box mesh
  65693. */
  65694. static CreateTiledBox(name: string, options: {
  65695. pattern?: number;
  65696. width?: number;
  65697. height?: number;
  65698. depth?: number;
  65699. tileSize?: number;
  65700. tileWidth?: number;
  65701. tileHeight?: number;
  65702. alignHorizontal?: number;
  65703. alignVertical?: number;
  65704. faceUV?: Vector4[];
  65705. faceColors?: Color4[];
  65706. sideOrientation?: number;
  65707. updatable?: boolean;
  65708. }, scene?: Nullable<Scene>): Mesh;
  65709. }
  65710. }
  65711. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  65712. import { Vector4 } from "babylonjs/Maths/math.vector";
  65713. import { Mesh } from "babylonjs/Meshes/mesh";
  65714. /**
  65715. * Class containing static functions to help procedurally build meshes
  65716. */
  65717. export class TorusKnotBuilder {
  65718. /**
  65719. * Creates a torus knot mesh
  65720. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65721. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65722. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65723. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65727. * @param name defines the name of the mesh
  65728. * @param options defines the options used to create the mesh
  65729. * @param scene defines the hosting scene
  65730. * @returns the torus knot mesh
  65731. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65732. */
  65733. static CreateTorusKnot(name: string, options: {
  65734. radius?: number;
  65735. tube?: number;
  65736. radialSegments?: number;
  65737. tubularSegments?: number;
  65738. p?: number;
  65739. q?: number;
  65740. updatable?: boolean;
  65741. sideOrientation?: number;
  65742. frontUVs?: Vector4;
  65743. backUVs?: Vector4;
  65744. }, scene: any): Mesh;
  65745. }
  65746. }
  65747. declare module "babylonjs/Meshes/polygonMesh" {
  65748. import { Scene } from "babylonjs/scene";
  65749. import { Vector2 } from "babylonjs/Maths/math.vector";
  65750. import { Mesh } from "babylonjs/Meshes/mesh";
  65751. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  65752. import { Path2 } from "babylonjs/Maths/math.path";
  65753. /**
  65754. * Polygon
  65755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65756. */
  65757. export class Polygon {
  65758. /**
  65759. * Creates a rectangle
  65760. * @param xmin bottom X coord
  65761. * @param ymin bottom Y coord
  65762. * @param xmax top X coord
  65763. * @param ymax top Y coord
  65764. * @returns points that make the resulting rectation
  65765. */
  65766. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65767. /**
  65768. * Creates a circle
  65769. * @param radius radius of circle
  65770. * @param cx scale in x
  65771. * @param cy scale in y
  65772. * @param numberOfSides number of sides that make up the circle
  65773. * @returns points that make the resulting circle
  65774. */
  65775. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65776. /**
  65777. * Creates a polygon from input string
  65778. * @param input Input polygon data
  65779. * @returns the parsed points
  65780. */
  65781. static Parse(input: string): Vector2[];
  65782. /**
  65783. * Starts building a polygon from x and y coordinates
  65784. * @param x x coordinate
  65785. * @param y y coordinate
  65786. * @returns the started path2
  65787. */
  65788. static StartingAt(x: number, y: number): Path2;
  65789. }
  65790. /**
  65791. * Builds a polygon
  65792. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65793. */
  65794. export class PolygonMeshBuilder {
  65795. private _points;
  65796. private _outlinepoints;
  65797. private _holes;
  65798. private _name;
  65799. private _scene;
  65800. private _epoints;
  65801. private _eholes;
  65802. private _addToepoint;
  65803. /**
  65804. * Babylon reference to the earcut plugin.
  65805. */
  65806. bjsEarcut: any;
  65807. /**
  65808. * Creates a PolygonMeshBuilder
  65809. * @param name name of the builder
  65810. * @param contours Path of the polygon
  65811. * @param scene scene to add to when creating the mesh
  65812. * @param earcutInjection can be used to inject your own earcut reference
  65813. */
  65814. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65815. /**
  65816. * Adds a whole within the polygon
  65817. * @param hole Array of points defining the hole
  65818. * @returns this
  65819. */
  65820. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65821. /**
  65822. * Creates the polygon
  65823. * @param updatable If the mesh should be updatable
  65824. * @param depth The depth of the mesh created
  65825. * @returns the created mesh
  65826. */
  65827. build(updatable?: boolean, depth?: number): Mesh;
  65828. /**
  65829. * Creates the polygon
  65830. * @param depth The depth of the mesh created
  65831. * @returns the created VertexData
  65832. */
  65833. buildVertexData(depth?: number): VertexData;
  65834. /**
  65835. * Adds a side to the polygon
  65836. * @param positions points that make the polygon
  65837. * @param normals normals of the polygon
  65838. * @param uvs uvs of the polygon
  65839. * @param indices indices of the polygon
  65840. * @param bounds bounds of the polygon
  65841. * @param points points of the polygon
  65842. * @param depth depth of the polygon
  65843. * @param flip flip of the polygon
  65844. */
  65845. private addSide;
  65846. }
  65847. }
  65848. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  65849. import { Scene } from "babylonjs/scene";
  65850. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  65851. import { Color4 } from "babylonjs/Maths/math.color";
  65852. import { Mesh } from "babylonjs/Meshes/mesh";
  65853. import { Nullable } from "babylonjs/types";
  65854. /**
  65855. * Class containing static functions to help procedurally build meshes
  65856. */
  65857. export class PolygonBuilder {
  65858. /**
  65859. * Creates a polygon mesh
  65860. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65861. * * 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
  65862. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65865. * * Remember you can only change the shape positions, not their number when updating a polygon
  65866. * @param name defines the name of the mesh
  65867. * @param options defines the options used to create the mesh
  65868. * @param scene defines the hosting scene
  65869. * @param earcutInjection can be used to inject your own earcut reference
  65870. * @returns the polygon mesh
  65871. */
  65872. static CreatePolygon(name: string, options: {
  65873. shape: Vector3[];
  65874. holes?: Vector3[][];
  65875. depth?: number;
  65876. faceUV?: Vector4[];
  65877. faceColors?: Color4[];
  65878. updatable?: boolean;
  65879. sideOrientation?: number;
  65880. frontUVs?: Vector4;
  65881. backUVs?: Vector4;
  65882. wrap?: boolean;
  65883. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65884. /**
  65885. * Creates an extruded polygon mesh, with depth in the Y direction.
  65886. * * 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)
  65887. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65888. * @param name defines the name of the mesh
  65889. * @param options defines the options used to create the mesh
  65890. * @param scene defines the hosting scene
  65891. * @param earcutInjection can be used to inject your own earcut reference
  65892. * @returns the polygon mesh
  65893. */
  65894. static ExtrudePolygon(name: string, options: {
  65895. shape: Vector3[];
  65896. holes?: Vector3[][];
  65897. depth?: number;
  65898. faceUV?: Vector4[];
  65899. faceColors?: Color4[];
  65900. updatable?: boolean;
  65901. sideOrientation?: number;
  65902. frontUVs?: Vector4;
  65903. backUVs?: Vector4;
  65904. wrap?: boolean;
  65905. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65906. }
  65907. }
  65908. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  65909. import { Scene } from "babylonjs/scene";
  65910. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  65911. import { Mesh } from "babylonjs/Meshes/mesh";
  65912. import { Nullable } from "babylonjs/types";
  65913. /**
  65914. * Class containing static functions to help procedurally build meshes
  65915. */
  65916. export class LatheBuilder {
  65917. /**
  65918. * Creates lathe mesh.
  65919. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65920. * * 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
  65921. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65922. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65923. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65924. * * 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
  65925. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65926. * * 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
  65927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65929. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65931. * @param name defines the name of the mesh
  65932. * @param options defines the options used to create the mesh
  65933. * @param scene defines the hosting scene
  65934. * @returns the lathe mesh
  65935. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65936. */
  65937. static CreateLathe(name: string, options: {
  65938. shape: Vector3[];
  65939. radius?: number;
  65940. tessellation?: number;
  65941. clip?: number;
  65942. arc?: number;
  65943. closed?: boolean;
  65944. updatable?: boolean;
  65945. sideOrientation?: number;
  65946. frontUVs?: Vector4;
  65947. backUVs?: Vector4;
  65948. cap?: number;
  65949. invertUV?: boolean;
  65950. }, scene?: Nullable<Scene>): Mesh;
  65951. }
  65952. }
  65953. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  65954. import { Nullable } from "babylonjs/types";
  65955. import { Scene } from "babylonjs/scene";
  65956. import { Vector4 } from "babylonjs/Maths/math.vector";
  65957. import { Mesh } from "babylonjs/Meshes/mesh";
  65958. /**
  65959. * Class containing static functions to help procedurally build meshes
  65960. */
  65961. export class TiledPlaneBuilder {
  65962. /**
  65963. * Creates a tiled plane mesh
  65964. * * The parameter `pattern` will, depending on value, do nothing or
  65965. * * * flip (reflect about central vertical) alternate tiles across and up
  65966. * * * flip every tile on alternate rows
  65967. * * * rotate (180 degs) alternate tiles across and up
  65968. * * * rotate every tile on alternate rows
  65969. * * * flip and rotate alternate tiles across and up
  65970. * * * flip and rotate every tile on alternate rows
  65971. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65972. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65974. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65975. * * 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)
  65976. * * 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)
  65977. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65978. * @param name defines the name of the mesh
  65979. * @param options defines the options used to create the mesh
  65980. * @param scene defines the hosting scene
  65981. * @returns the box mesh
  65982. */
  65983. static CreateTiledPlane(name: string, options: {
  65984. pattern?: number;
  65985. tileSize?: number;
  65986. tileWidth?: number;
  65987. tileHeight?: number;
  65988. size?: number;
  65989. width?: number;
  65990. height?: number;
  65991. alignHorizontal?: number;
  65992. alignVertical?: number;
  65993. sideOrientation?: number;
  65994. frontUVs?: Vector4;
  65995. backUVs?: Vector4;
  65996. updatable?: boolean;
  65997. }, scene?: Nullable<Scene>): Mesh;
  65998. }
  65999. }
  66000. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  66001. import { Nullable } from "babylonjs/types";
  66002. import { Scene } from "babylonjs/scene";
  66003. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  66004. import { Mesh } from "babylonjs/Meshes/mesh";
  66005. /**
  66006. * Class containing static functions to help procedurally build meshes
  66007. */
  66008. export class TubeBuilder {
  66009. /**
  66010. * Creates a tube mesh.
  66011. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66012. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66013. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66014. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66015. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66016. * * 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)
  66017. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66018. * * 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
  66019. * * 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
  66020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66022. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66024. * @param name defines the name of the mesh
  66025. * @param options defines the options used to create the mesh
  66026. * @param scene defines the hosting scene
  66027. * @returns the tube mesh
  66028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66029. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66030. */
  66031. static CreateTube(name: string, options: {
  66032. path: Vector3[];
  66033. radius?: number;
  66034. tessellation?: number;
  66035. radiusFunction?: {
  66036. (i: number, distance: number): number;
  66037. };
  66038. cap?: number;
  66039. arc?: number;
  66040. updatable?: boolean;
  66041. sideOrientation?: number;
  66042. frontUVs?: Vector4;
  66043. backUVs?: Vector4;
  66044. instance?: Mesh;
  66045. invertUV?: boolean;
  66046. }, scene?: Nullable<Scene>): Mesh;
  66047. }
  66048. }
  66049. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  66050. import { Scene } from "babylonjs/scene";
  66051. import { Vector4 } from "babylonjs/Maths/math.vector";
  66052. import { Mesh } from "babylonjs/Meshes/mesh";
  66053. import { Nullable } from "babylonjs/types";
  66054. /**
  66055. * Class containing static functions to help procedurally build meshes
  66056. */
  66057. export class IcoSphereBuilder {
  66058. /**
  66059. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66060. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66061. * * 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`)
  66062. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66063. * * 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
  66064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66067. * @param name defines the name of the mesh
  66068. * @param options defines the options used to create the mesh
  66069. * @param scene defines the hosting scene
  66070. * @returns the icosahedron mesh
  66071. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66072. */
  66073. static CreateIcoSphere(name: string, options: {
  66074. radius?: number;
  66075. radiusX?: number;
  66076. radiusY?: number;
  66077. radiusZ?: number;
  66078. flat?: boolean;
  66079. subdivisions?: number;
  66080. sideOrientation?: number;
  66081. frontUVs?: Vector4;
  66082. backUVs?: Vector4;
  66083. updatable?: boolean;
  66084. }, scene?: Nullable<Scene>): Mesh;
  66085. }
  66086. }
  66087. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  66088. import { Vector3 } from "babylonjs/Maths/math.vector";
  66089. import { Mesh } from "babylonjs/Meshes/mesh";
  66090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66091. /**
  66092. * Class containing static functions to help procedurally build meshes
  66093. */
  66094. export class DecalBuilder {
  66095. /**
  66096. * Creates a decal mesh.
  66097. * 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
  66098. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66099. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66100. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66101. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66102. * @param name defines the name of the mesh
  66103. * @param sourceMesh defines the mesh where the decal must be applied
  66104. * @param options defines the options used to create the mesh
  66105. * @param scene defines the hosting scene
  66106. * @returns the decal mesh
  66107. * @see https://doc.babylonjs.com/how_to/decals
  66108. */
  66109. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66110. position?: Vector3;
  66111. normal?: Vector3;
  66112. size?: Vector3;
  66113. angle?: number;
  66114. }): Mesh;
  66115. }
  66116. }
  66117. declare module "babylonjs/Meshes/meshBuilder" {
  66118. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  66119. import { Nullable } from "babylonjs/types";
  66120. import { Scene } from "babylonjs/scene";
  66121. import { Mesh } from "babylonjs/Meshes/mesh";
  66122. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  66123. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  66124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66125. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66126. import { Plane } from "babylonjs/Maths/math.plane";
  66127. /**
  66128. * Class containing static functions to help procedurally build meshes
  66129. */
  66130. export class MeshBuilder {
  66131. /**
  66132. * Creates a box mesh
  66133. * * The parameter `size` sets the size (float) of each box side (default 1)
  66134. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66135. * * 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)
  66136. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66140. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66141. * @param name defines the name of the mesh
  66142. * @param options defines the options used to create the mesh
  66143. * @param scene defines the hosting scene
  66144. * @returns the box mesh
  66145. */
  66146. static CreateBox(name: string, options: {
  66147. size?: number;
  66148. width?: number;
  66149. height?: number;
  66150. depth?: number;
  66151. faceUV?: Vector4[];
  66152. faceColors?: Color4[];
  66153. sideOrientation?: number;
  66154. frontUVs?: Vector4;
  66155. backUVs?: Vector4;
  66156. wrap?: boolean;
  66157. topBaseAt?: number;
  66158. bottomBaseAt?: number;
  66159. updatable?: boolean;
  66160. }, scene?: Nullable<Scene>): Mesh;
  66161. /**
  66162. * Creates a tiled box mesh
  66163. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66165. * @param name defines the name of the mesh
  66166. * @param options defines the options used to create the mesh
  66167. * @param scene defines the hosting scene
  66168. * @returns the tiled box mesh
  66169. */
  66170. static CreateTiledBox(name: string, options: {
  66171. pattern?: number;
  66172. size?: number;
  66173. width?: number;
  66174. height?: number;
  66175. depth: number;
  66176. tileSize?: number;
  66177. tileWidth?: number;
  66178. tileHeight?: number;
  66179. faceUV?: Vector4[];
  66180. faceColors?: Color4[];
  66181. alignHorizontal?: number;
  66182. alignVertical?: number;
  66183. sideOrientation?: number;
  66184. updatable?: boolean;
  66185. }, scene?: Nullable<Scene>): Mesh;
  66186. /**
  66187. * Creates a sphere mesh
  66188. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66189. * * 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`)
  66190. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66191. * * 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
  66192. * * 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)
  66193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66196. * @param name defines the name of the mesh
  66197. * @param options defines the options used to create the mesh
  66198. * @param scene defines the hosting scene
  66199. * @returns the sphere mesh
  66200. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66201. */
  66202. static CreateSphere(name: string, options: {
  66203. segments?: number;
  66204. diameter?: number;
  66205. diameterX?: number;
  66206. diameterY?: number;
  66207. diameterZ?: number;
  66208. arc?: number;
  66209. slice?: number;
  66210. sideOrientation?: number;
  66211. frontUVs?: Vector4;
  66212. backUVs?: Vector4;
  66213. updatable?: boolean;
  66214. }, scene?: Nullable<Scene>): Mesh;
  66215. /**
  66216. * Creates a plane polygonal mesh. By default, this is a disc
  66217. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66218. * * 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
  66219. * * 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
  66220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66223. * @param name defines the name of the mesh
  66224. * @param options defines the options used to create the mesh
  66225. * @param scene defines the hosting scene
  66226. * @returns the plane polygonal mesh
  66227. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66228. */
  66229. static CreateDisc(name: string, options: {
  66230. radius?: number;
  66231. tessellation?: number;
  66232. arc?: number;
  66233. updatable?: boolean;
  66234. sideOrientation?: number;
  66235. frontUVs?: Vector4;
  66236. backUVs?: Vector4;
  66237. }, scene?: Nullable<Scene>): Mesh;
  66238. /**
  66239. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66240. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66241. * * 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`)
  66242. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66243. * * 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
  66244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66247. * @param name defines the name of the mesh
  66248. * @param options defines the options used to create the mesh
  66249. * @param scene defines the hosting scene
  66250. * @returns the icosahedron mesh
  66251. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66252. */
  66253. static CreateIcoSphere(name: string, options: {
  66254. radius?: number;
  66255. radiusX?: number;
  66256. radiusY?: number;
  66257. radiusZ?: number;
  66258. flat?: boolean;
  66259. subdivisions?: number;
  66260. sideOrientation?: number;
  66261. frontUVs?: Vector4;
  66262. backUVs?: Vector4;
  66263. updatable?: boolean;
  66264. }, scene?: Nullable<Scene>): Mesh;
  66265. /**
  66266. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66267. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66268. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66269. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66270. * * 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
  66271. * * 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
  66272. * * 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
  66273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66276. * * 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
  66277. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66278. * * 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
  66279. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66281. * @param name defines the name of the mesh
  66282. * @param options defines the options used to create the mesh
  66283. * @param scene defines the hosting scene
  66284. * @returns the ribbon mesh
  66285. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66286. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66287. */
  66288. static CreateRibbon(name: string, options: {
  66289. pathArray: Vector3[][];
  66290. closeArray?: boolean;
  66291. closePath?: boolean;
  66292. offset?: number;
  66293. updatable?: boolean;
  66294. sideOrientation?: number;
  66295. frontUVs?: Vector4;
  66296. backUVs?: Vector4;
  66297. instance?: Mesh;
  66298. invertUV?: boolean;
  66299. uvs?: Vector2[];
  66300. colors?: Color4[];
  66301. }, scene?: Nullable<Scene>): Mesh;
  66302. /**
  66303. * Creates a cylinder or a cone mesh
  66304. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66305. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66306. * * 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.
  66307. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66308. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66309. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66310. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66311. * * 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).
  66312. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66313. * * 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).
  66314. * * 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
  66315. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66316. * * 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
  66317. * * 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.
  66318. * * If `enclose` is false, a ring surface is one element.
  66319. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66320. * * 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
  66321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66324. * @param name defines the name of the mesh
  66325. * @param options defines the options used to create the mesh
  66326. * @param scene defines the hosting scene
  66327. * @returns the cylinder mesh
  66328. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66329. */
  66330. static CreateCylinder(name: string, options: {
  66331. height?: number;
  66332. diameterTop?: number;
  66333. diameterBottom?: number;
  66334. diameter?: number;
  66335. tessellation?: number;
  66336. subdivisions?: number;
  66337. arc?: number;
  66338. faceColors?: Color4[];
  66339. faceUV?: Vector4[];
  66340. updatable?: boolean;
  66341. hasRings?: boolean;
  66342. enclose?: boolean;
  66343. cap?: number;
  66344. sideOrientation?: number;
  66345. frontUVs?: Vector4;
  66346. backUVs?: Vector4;
  66347. }, scene?: Nullable<Scene>): Mesh;
  66348. /**
  66349. * Creates a torus mesh
  66350. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66351. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66352. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66356. * @param name defines the name of the mesh
  66357. * @param options defines the options used to create the mesh
  66358. * @param scene defines the hosting scene
  66359. * @returns the torus mesh
  66360. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66361. */
  66362. static CreateTorus(name: string, options: {
  66363. diameter?: number;
  66364. thickness?: number;
  66365. tessellation?: number;
  66366. updatable?: boolean;
  66367. sideOrientation?: number;
  66368. frontUVs?: Vector4;
  66369. backUVs?: Vector4;
  66370. }, scene?: Nullable<Scene>): Mesh;
  66371. /**
  66372. * Creates a torus knot mesh
  66373. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66374. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66375. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66376. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66380. * @param name defines the name of the mesh
  66381. * @param options defines the options used to create the mesh
  66382. * @param scene defines the hosting scene
  66383. * @returns the torus knot mesh
  66384. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66385. */
  66386. static CreateTorusKnot(name: string, options: {
  66387. radius?: number;
  66388. tube?: number;
  66389. radialSegments?: number;
  66390. tubularSegments?: number;
  66391. p?: number;
  66392. q?: number;
  66393. updatable?: boolean;
  66394. sideOrientation?: number;
  66395. frontUVs?: Vector4;
  66396. backUVs?: Vector4;
  66397. }, scene?: Nullable<Scene>): Mesh;
  66398. /**
  66399. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66400. * * 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
  66401. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66402. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66403. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66404. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66405. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66406. * * 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
  66407. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66410. * @param name defines the name of the new line system
  66411. * @param options defines the options used to create the line system
  66412. * @param scene defines the hosting scene
  66413. * @returns a new line system mesh
  66414. */
  66415. static CreateLineSystem(name: string, options: {
  66416. lines: Vector3[][];
  66417. updatable?: boolean;
  66418. instance?: Nullable<LinesMesh>;
  66419. colors?: Nullable<Color4[][]>;
  66420. useVertexAlpha?: boolean;
  66421. }, scene: Nullable<Scene>): LinesMesh;
  66422. /**
  66423. * Creates a line mesh
  66424. * 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
  66425. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66426. * * The parameter `points` is an array successive Vector3
  66427. * * 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
  66428. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66429. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66430. * * When updating an instance, remember that only point positions can change, not the number of points
  66431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66433. * @param name defines the name of the new line system
  66434. * @param options defines the options used to create the line system
  66435. * @param scene defines the hosting scene
  66436. * @returns a new line mesh
  66437. */
  66438. static CreateLines(name: string, options: {
  66439. points: Vector3[];
  66440. updatable?: boolean;
  66441. instance?: Nullable<LinesMesh>;
  66442. colors?: Color4[];
  66443. useVertexAlpha?: boolean;
  66444. }, scene?: Nullable<Scene>): LinesMesh;
  66445. /**
  66446. * Creates a dashed line mesh
  66447. * * 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
  66448. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66449. * * The parameter `points` is an array successive Vector3
  66450. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66451. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66452. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66453. * * 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
  66454. * * When updating an instance, remember that only point positions can change, not the number of points
  66455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66456. * @param name defines the name of the mesh
  66457. * @param options defines the options used to create the mesh
  66458. * @param scene defines the hosting scene
  66459. * @returns the dashed line mesh
  66460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66461. */
  66462. static CreateDashedLines(name: string, options: {
  66463. points: Vector3[];
  66464. dashSize?: number;
  66465. gapSize?: number;
  66466. dashNb?: number;
  66467. updatable?: boolean;
  66468. instance?: LinesMesh;
  66469. }, scene?: Nullable<Scene>): LinesMesh;
  66470. /**
  66471. * 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.
  66472. * * 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.
  66473. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66474. * * 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.
  66475. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66476. * * 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
  66477. * * 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
  66478. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66483. * @param name defines the name of the mesh
  66484. * @param options defines the options used to create the mesh
  66485. * @param scene defines the hosting scene
  66486. * @returns the extruded shape mesh
  66487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66489. */
  66490. static ExtrudeShape(name: string, options: {
  66491. shape: Vector3[];
  66492. path: Vector3[];
  66493. scale?: number;
  66494. rotation?: number;
  66495. cap?: number;
  66496. updatable?: boolean;
  66497. sideOrientation?: number;
  66498. frontUVs?: Vector4;
  66499. backUVs?: Vector4;
  66500. instance?: Mesh;
  66501. invertUV?: boolean;
  66502. }, scene?: Nullable<Scene>): Mesh;
  66503. /**
  66504. * Creates an custom extruded shape mesh.
  66505. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66506. * * 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.
  66507. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66508. * * 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
  66509. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66510. * * 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
  66511. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66512. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66513. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66514. * * 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
  66515. * * 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
  66516. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66521. * @param name defines the name of the mesh
  66522. * @param options defines the options used to create the mesh
  66523. * @param scene defines the hosting scene
  66524. * @returns the custom extruded shape mesh
  66525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66528. */
  66529. static ExtrudeShapeCustom(name: string, options: {
  66530. shape: Vector3[];
  66531. path: Vector3[];
  66532. scaleFunction?: any;
  66533. rotationFunction?: any;
  66534. ribbonCloseArray?: boolean;
  66535. ribbonClosePath?: boolean;
  66536. cap?: number;
  66537. updatable?: boolean;
  66538. sideOrientation?: number;
  66539. frontUVs?: Vector4;
  66540. backUVs?: Vector4;
  66541. instance?: Mesh;
  66542. invertUV?: boolean;
  66543. }, scene?: Nullable<Scene>): Mesh;
  66544. /**
  66545. * Creates lathe mesh.
  66546. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66547. * * 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
  66548. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66549. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66550. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66551. * * 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
  66552. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66553. * * 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
  66554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66558. * @param name defines the name of the mesh
  66559. * @param options defines the options used to create the mesh
  66560. * @param scene defines the hosting scene
  66561. * @returns the lathe mesh
  66562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66563. */
  66564. static CreateLathe(name: string, options: {
  66565. shape: Vector3[];
  66566. radius?: number;
  66567. tessellation?: number;
  66568. clip?: number;
  66569. arc?: number;
  66570. closed?: boolean;
  66571. updatable?: boolean;
  66572. sideOrientation?: number;
  66573. frontUVs?: Vector4;
  66574. backUVs?: Vector4;
  66575. cap?: number;
  66576. invertUV?: boolean;
  66577. }, scene?: Nullable<Scene>): Mesh;
  66578. /**
  66579. * Creates a tiled plane mesh
  66580. * * You can set a limited pattern arrangement with the tiles
  66581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66584. * @param name defines the name of the mesh
  66585. * @param options defines the options used to create the mesh
  66586. * @param scene defines the hosting scene
  66587. * @returns the plane mesh
  66588. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66589. */
  66590. static CreateTiledPlane(name: string, options: {
  66591. pattern?: number;
  66592. tileSize?: number;
  66593. tileWidth?: number;
  66594. tileHeight?: number;
  66595. size?: number;
  66596. width?: number;
  66597. height?: number;
  66598. alignHorizontal?: number;
  66599. alignVertical?: number;
  66600. sideOrientation?: number;
  66601. frontUVs?: Vector4;
  66602. backUVs?: Vector4;
  66603. updatable?: boolean;
  66604. }, scene?: Nullable<Scene>): Mesh;
  66605. /**
  66606. * Creates a plane mesh
  66607. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66608. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66609. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66613. * @param name defines the name of the mesh
  66614. * @param options defines the options used to create the mesh
  66615. * @param scene defines the hosting scene
  66616. * @returns the plane mesh
  66617. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66618. */
  66619. static CreatePlane(name: string, options: {
  66620. size?: number;
  66621. width?: number;
  66622. height?: number;
  66623. sideOrientation?: number;
  66624. frontUVs?: Vector4;
  66625. backUVs?: Vector4;
  66626. updatable?: boolean;
  66627. sourcePlane?: Plane;
  66628. }, scene?: Nullable<Scene>): Mesh;
  66629. /**
  66630. * Creates a ground mesh
  66631. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66632. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66634. * @param name defines the name of the mesh
  66635. * @param options defines the options used to create the mesh
  66636. * @param scene defines the hosting scene
  66637. * @returns the ground mesh
  66638. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66639. */
  66640. static CreateGround(name: string, options: {
  66641. width?: number;
  66642. height?: number;
  66643. subdivisions?: number;
  66644. subdivisionsX?: number;
  66645. subdivisionsY?: number;
  66646. updatable?: boolean;
  66647. }, scene?: Nullable<Scene>): Mesh;
  66648. /**
  66649. * Creates a tiled ground mesh
  66650. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66651. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66652. * * 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
  66653. * * 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
  66654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66655. * @param name defines the name of the mesh
  66656. * @param options defines the options used to create the mesh
  66657. * @param scene defines the hosting scene
  66658. * @returns the tiled ground mesh
  66659. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66660. */
  66661. static CreateTiledGround(name: string, options: {
  66662. xmin: number;
  66663. zmin: number;
  66664. xmax: number;
  66665. zmax: number;
  66666. subdivisions?: {
  66667. w: number;
  66668. h: number;
  66669. };
  66670. precision?: {
  66671. w: number;
  66672. h: number;
  66673. };
  66674. updatable?: boolean;
  66675. }, scene?: Nullable<Scene>): Mesh;
  66676. /**
  66677. * Creates a ground mesh from a height map
  66678. * * The parameter `url` sets the URL of the height map image resource.
  66679. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66680. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66681. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66682. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66683. * * 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.
  66684. * * 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).
  66685. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66687. * @param name defines the name of the mesh
  66688. * @param url defines the url to the height map
  66689. * @param options defines the options used to create the mesh
  66690. * @param scene defines the hosting scene
  66691. * @returns the ground mesh
  66692. * @see https://doc.babylonjs.com/babylon101/height_map
  66693. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66694. */
  66695. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66696. width?: number;
  66697. height?: number;
  66698. subdivisions?: number;
  66699. minHeight?: number;
  66700. maxHeight?: number;
  66701. colorFilter?: Color3;
  66702. alphaFilter?: number;
  66703. updatable?: boolean;
  66704. onReady?: (mesh: GroundMesh) => void;
  66705. }, scene?: Nullable<Scene>): GroundMesh;
  66706. /**
  66707. * Creates a polygon mesh
  66708. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66709. * * 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
  66710. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  66713. * * Remember you can only change the shape positions, not their number when updating a polygon
  66714. * @param name defines the name of the mesh
  66715. * @param options defines the options used to create the mesh
  66716. * @param scene defines the hosting scene
  66717. * @param earcutInjection can be used to inject your own earcut reference
  66718. * @returns the polygon mesh
  66719. */
  66720. static CreatePolygon(name: string, options: {
  66721. shape: Vector3[];
  66722. holes?: Vector3[][];
  66723. depth?: number;
  66724. faceUV?: Vector4[];
  66725. faceColors?: Color4[];
  66726. updatable?: boolean;
  66727. sideOrientation?: number;
  66728. frontUVs?: Vector4;
  66729. backUVs?: Vector4;
  66730. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66731. /**
  66732. * Creates an extruded polygon mesh, with depth in the Y direction.
  66733. * * 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)
  66734. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66735. * @param name defines the name of the mesh
  66736. * @param options defines the options used to create the mesh
  66737. * @param scene defines the hosting scene
  66738. * @param earcutInjection can be used to inject your own earcut reference
  66739. * @returns the polygon mesh
  66740. */
  66741. static ExtrudePolygon(name: string, options: {
  66742. shape: Vector3[];
  66743. holes?: Vector3[][];
  66744. depth?: number;
  66745. faceUV?: Vector4[];
  66746. faceColors?: Color4[];
  66747. updatable?: boolean;
  66748. sideOrientation?: number;
  66749. frontUVs?: Vector4;
  66750. backUVs?: Vector4;
  66751. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66752. /**
  66753. * Creates a tube mesh.
  66754. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66755. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66756. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66757. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66758. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66759. * * 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)
  66760. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66761. * * 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
  66762. * * 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
  66763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66767. * @param name defines the name of the mesh
  66768. * @param options defines the options used to create the mesh
  66769. * @param scene defines the hosting scene
  66770. * @returns the tube mesh
  66771. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66772. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66773. */
  66774. static CreateTube(name: string, options: {
  66775. path: Vector3[];
  66776. radius?: number;
  66777. tessellation?: number;
  66778. radiusFunction?: {
  66779. (i: number, distance: number): number;
  66780. };
  66781. cap?: number;
  66782. arc?: number;
  66783. updatable?: boolean;
  66784. sideOrientation?: number;
  66785. frontUVs?: Vector4;
  66786. backUVs?: Vector4;
  66787. instance?: Mesh;
  66788. invertUV?: boolean;
  66789. }, scene?: Nullable<Scene>): Mesh;
  66790. /**
  66791. * Creates a polyhedron mesh
  66792. * * 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
  66793. * * The parameter `size` (positive float, default 1) sets the polygon size
  66794. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66795. * * 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`
  66796. * * 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
  66797. * * 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)`)
  66798. * * 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
  66799. * * 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
  66800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66803. * @param name defines the name of the mesh
  66804. * @param options defines the options used to create the mesh
  66805. * @param scene defines the hosting scene
  66806. * @returns the polyhedron mesh
  66807. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66808. */
  66809. static CreatePolyhedron(name: string, options: {
  66810. type?: number;
  66811. size?: number;
  66812. sizeX?: number;
  66813. sizeY?: number;
  66814. sizeZ?: number;
  66815. custom?: any;
  66816. faceUV?: Vector4[];
  66817. faceColors?: Color4[];
  66818. flat?: boolean;
  66819. updatable?: boolean;
  66820. sideOrientation?: number;
  66821. frontUVs?: Vector4;
  66822. backUVs?: Vector4;
  66823. }, scene?: Nullable<Scene>): Mesh;
  66824. /**
  66825. * Creates a decal mesh.
  66826. * 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
  66827. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66828. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66829. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66830. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66831. * @param name defines the name of the mesh
  66832. * @param sourceMesh defines the mesh where the decal must be applied
  66833. * @param options defines the options used to create the mesh
  66834. * @param scene defines the hosting scene
  66835. * @returns the decal mesh
  66836. * @see https://doc.babylonjs.com/how_to/decals
  66837. */
  66838. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66839. position?: Vector3;
  66840. normal?: Vector3;
  66841. size?: Vector3;
  66842. angle?: number;
  66843. }): Mesh;
  66844. }
  66845. }
  66846. declare module "babylonjs/Meshes/meshSimplification" {
  66847. import { Mesh } from "babylonjs/Meshes/mesh";
  66848. /**
  66849. * A simplifier interface for future simplification implementations
  66850. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66851. */
  66852. export interface ISimplifier {
  66853. /**
  66854. * Simplification of a given mesh according to the given settings.
  66855. * Since this requires computation, it is assumed that the function runs async.
  66856. * @param settings The settings of the simplification, including quality and distance
  66857. * @param successCallback A callback that will be called after the mesh was simplified.
  66858. * @param errorCallback in case of an error, this callback will be called. optional.
  66859. */
  66860. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66861. }
  66862. /**
  66863. * Expected simplification settings.
  66864. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66865. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66866. */
  66867. export interface ISimplificationSettings {
  66868. /**
  66869. * Gets or sets the expected quality
  66870. */
  66871. quality: number;
  66872. /**
  66873. * Gets or sets the distance when this optimized version should be used
  66874. */
  66875. distance: number;
  66876. /**
  66877. * Gets an already optimized mesh
  66878. */
  66879. optimizeMesh?: boolean;
  66880. }
  66881. /**
  66882. * Class used to specify simplification options
  66883. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66884. */
  66885. export class SimplificationSettings implements ISimplificationSettings {
  66886. /** expected quality */
  66887. quality: number;
  66888. /** distance when this optimized version should be used */
  66889. distance: number;
  66890. /** already optimized mesh */
  66891. optimizeMesh?: boolean | undefined;
  66892. /**
  66893. * Creates a SimplificationSettings
  66894. * @param quality expected quality
  66895. * @param distance distance when this optimized version should be used
  66896. * @param optimizeMesh already optimized mesh
  66897. */
  66898. constructor(
  66899. /** expected quality */
  66900. quality: number,
  66901. /** distance when this optimized version should be used */
  66902. distance: number,
  66903. /** already optimized mesh */
  66904. optimizeMesh?: boolean | undefined);
  66905. }
  66906. /**
  66907. * Interface used to define a simplification task
  66908. */
  66909. export interface ISimplificationTask {
  66910. /**
  66911. * Array of settings
  66912. */
  66913. settings: Array<ISimplificationSettings>;
  66914. /**
  66915. * Simplification type
  66916. */
  66917. simplificationType: SimplificationType;
  66918. /**
  66919. * Mesh to simplify
  66920. */
  66921. mesh: Mesh;
  66922. /**
  66923. * Callback called on success
  66924. */
  66925. successCallback?: () => void;
  66926. /**
  66927. * Defines if parallel processing can be used
  66928. */
  66929. parallelProcessing: boolean;
  66930. }
  66931. /**
  66932. * Queue used to order the simplification tasks
  66933. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66934. */
  66935. export class SimplificationQueue {
  66936. private _simplificationArray;
  66937. /**
  66938. * Gets a boolean indicating that the process is still running
  66939. */
  66940. running: boolean;
  66941. /**
  66942. * Creates a new queue
  66943. */
  66944. constructor();
  66945. /**
  66946. * Adds a new simplification task
  66947. * @param task defines a task to add
  66948. */
  66949. addTask(task: ISimplificationTask): void;
  66950. /**
  66951. * Execute next task
  66952. */
  66953. executeNext(): void;
  66954. /**
  66955. * Execute a simplification task
  66956. * @param task defines the task to run
  66957. */
  66958. runSimplification(task: ISimplificationTask): void;
  66959. private getSimplifier;
  66960. }
  66961. /**
  66962. * The implemented types of simplification
  66963. * At the moment only Quadratic Error Decimation is implemented
  66964. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66965. */
  66966. export enum SimplificationType {
  66967. /** Quadratic error decimation */
  66968. QUADRATIC = 0
  66969. }
  66970. /**
  66971. * An implementation of the Quadratic Error simplification algorithm.
  66972. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66973. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66974. * @author RaananW
  66975. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66976. */
  66977. export class QuadraticErrorSimplification implements ISimplifier {
  66978. private _mesh;
  66979. private triangles;
  66980. private vertices;
  66981. private references;
  66982. private _reconstructedMesh;
  66983. /** Gets or sets the number pf sync interations */
  66984. syncIterations: number;
  66985. /** Gets or sets the aggressiveness of the simplifier */
  66986. aggressiveness: number;
  66987. /** Gets or sets the number of allowed iterations for decimation */
  66988. decimationIterations: number;
  66989. /** Gets or sets the espilon to use for bounding box computation */
  66990. boundingBoxEpsilon: number;
  66991. /**
  66992. * Creates a new QuadraticErrorSimplification
  66993. * @param _mesh defines the target mesh
  66994. */
  66995. constructor(_mesh: Mesh);
  66996. /**
  66997. * Simplification of a given mesh according to the given settings.
  66998. * Since this requires computation, it is assumed that the function runs async.
  66999. * @param settings The settings of the simplification, including quality and distance
  67000. * @param successCallback A callback that will be called after the mesh was simplified.
  67001. */
  67002. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67003. private runDecimation;
  67004. private initWithMesh;
  67005. private init;
  67006. private reconstructMesh;
  67007. private initDecimatedMesh;
  67008. private isFlipped;
  67009. private updateTriangles;
  67010. private identifyBorder;
  67011. private updateMesh;
  67012. private vertexError;
  67013. private calculateError;
  67014. }
  67015. }
  67016. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  67017. import { Scene } from "babylonjs/scene";
  67018. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  67019. import { ISceneComponent } from "babylonjs/sceneComponent";
  67020. module "babylonjs/scene" {
  67021. interface Scene {
  67022. /** @hidden (Backing field) */
  67023. _simplificationQueue: SimplificationQueue;
  67024. /**
  67025. * Gets or sets the simplification queue attached to the scene
  67026. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67027. */
  67028. simplificationQueue: SimplificationQueue;
  67029. }
  67030. }
  67031. module "babylonjs/Meshes/mesh" {
  67032. interface Mesh {
  67033. /**
  67034. * Simplify the mesh according to the given array of settings.
  67035. * Function will return immediately and will simplify async
  67036. * @param settings a collection of simplification settings
  67037. * @param parallelProcessing should all levels calculate parallel or one after the other
  67038. * @param simplificationType the type of simplification to run
  67039. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67040. * @returns the current mesh
  67041. */
  67042. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67043. }
  67044. }
  67045. /**
  67046. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67047. * created in a scene
  67048. */
  67049. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67050. /**
  67051. * The component name helpfull to identify the component in the list of scene components.
  67052. */
  67053. readonly name: string;
  67054. /**
  67055. * The scene the component belongs to.
  67056. */
  67057. scene: Scene;
  67058. /**
  67059. * Creates a new instance of the component for the given scene
  67060. * @param scene Defines the scene to register the component in
  67061. */
  67062. constructor(scene: Scene);
  67063. /**
  67064. * Registers the component in a given scene
  67065. */
  67066. register(): void;
  67067. /**
  67068. * Rebuilds the elements related to this component in case of
  67069. * context lost for instance.
  67070. */
  67071. rebuild(): void;
  67072. /**
  67073. * Disposes the component and the associated ressources
  67074. */
  67075. dispose(): void;
  67076. private _beforeCameraUpdate;
  67077. }
  67078. }
  67079. declare module "babylonjs/Meshes/Builders/index" {
  67080. export * from "babylonjs/Meshes/Builders/boxBuilder";
  67081. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  67082. export * from "babylonjs/Meshes/Builders/discBuilder";
  67083. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  67084. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  67085. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  67086. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  67087. export * from "babylonjs/Meshes/Builders/torusBuilder";
  67088. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  67089. export * from "babylonjs/Meshes/Builders/linesBuilder";
  67090. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  67091. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  67092. export * from "babylonjs/Meshes/Builders/latheBuilder";
  67093. export * from "babylonjs/Meshes/Builders/planeBuilder";
  67094. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  67095. export * from "babylonjs/Meshes/Builders/groundBuilder";
  67096. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  67097. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  67098. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  67099. export * from "babylonjs/Meshes/Builders/decalBuilder";
  67100. }
  67101. declare module "babylonjs/Meshes/index" {
  67102. export * from "babylonjs/Meshes/abstractMesh";
  67103. export * from "babylonjs/Meshes/buffer";
  67104. export * from "babylonjs/Meshes/Compression/index";
  67105. export * from "babylonjs/Meshes/csg";
  67106. export * from "babylonjs/Meshes/geometry";
  67107. export * from "babylonjs/Meshes/groundMesh";
  67108. export * from "babylonjs/Meshes/trailMesh";
  67109. export * from "babylonjs/Meshes/instancedMesh";
  67110. export * from "babylonjs/Meshes/linesMesh";
  67111. export * from "babylonjs/Meshes/mesh";
  67112. export * from "babylonjs/Meshes/mesh.vertexData";
  67113. export * from "babylonjs/Meshes/meshBuilder";
  67114. export * from "babylonjs/Meshes/meshSimplification";
  67115. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  67116. export * from "babylonjs/Meshes/polygonMesh";
  67117. export * from "babylonjs/Meshes/subMesh";
  67118. export * from "babylonjs/Meshes/meshLODLevel";
  67119. export * from "babylonjs/Meshes/transformNode";
  67120. export * from "babylonjs/Meshes/Builders/index";
  67121. export * from "babylonjs/Meshes/dataBuffer";
  67122. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  67123. }
  67124. declare module "babylonjs/Morph/index" {
  67125. export * from "babylonjs/Morph/morphTarget";
  67126. export * from "babylonjs/Morph/morphTargetManager";
  67127. }
  67128. declare module "babylonjs/Navigation/INavigationEngine" {
  67129. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67130. import { Vector3 } from "babylonjs/Maths/math";
  67131. import { Mesh } from "babylonjs/Meshes/mesh";
  67132. import { Scene } from "babylonjs/scene";
  67133. /**
  67134. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67135. */
  67136. export interface INavigationEnginePlugin {
  67137. /**
  67138. * plugin name
  67139. */
  67140. name: string;
  67141. /**
  67142. * Creates a navigation mesh
  67143. * @param meshes array of all the geometry used to compute the navigatio mesh
  67144. * @param parameters bunch of parameters used to filter geometry
  67145. */
  67146. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67147. /**
  67148. * Create a navigation mesh debug mesh
  67149. * @param scene is where the mesh will be added
  67150. * @returns debug display mesh
  67151. */
  67152. createDebugNavMesh(scene: Scene): Mesh;
  67153. /**
  67154. * Get a navigation mesh constrained position, closest to the parameter position
  67155. * @param position world position
  67156. * @returns the closest point to position constrained by the navigation mesh
  67157. */
  67158. getClosestPoint(position: Vector3): Vector3;
  67159. /**
  67160. * Get a navigation mesh constrained position, closest to the parameter position
  67161. * @param position world position
  67162. * @param result output the closest point to position constrained by the navigation mesh
  67163. */
  67164. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67165. /**
  67166. * Get a navigation mesh constrained position, within a particular radius
  67167. * @param position world position
  67168. * @param maxRadius the maximum distance to the constrained world position
  67169. * @returns the closest point to position constrained by the navigation mesh
  67170. */
  67171. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67172. /**
  67173. * Get a navigation mesh constrained position, within a particular radius
  67174. * @param position world position
  67175. * @param maxRadius the maximum distance to the constrained world position
  67176. * @param result output the closest point to position constrained by the navigation mesh
  67177. */
  67178. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67179. /**
  67180. * Compute the final position from a segment made of destination-position
  67181. * @param position world position
  67182. * @param destination world position
  67183. * @returns the resulting point along the navmesh
  67184. */
  67185. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67186. /**
  67187. * Compute the final position from a segment made of destination-position
  67188. * @param position world position
  67189. * @param destination world position
  67190. * @param result output the resulting point along the navmesh
  67191. */
  67192. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67193. /**
  67194. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67195. * @param start world position
  67196. * @param end world position
  67197. * @returns array containing world position composing the path
  67198. */
  67199. computePath(start: Vector3, end: Vector3): Vector3[];
  67200. /**
  67201. * If this plugin is supported
  67202. * @returns true if plugin is supported
  67203. */
  67204. isSupported(): boolean;
  67205. /**
  67206. * Create a new Crowd so you can add agents
  67207. * @param maxAgents the maximum agent count in the crowd
  67208. * @param maxAgentRadius the maximum radius an agent can have
  67209. * @param scene to attach the crowd to
  67210. * @returns the crowd you can add agents to
  67211. */
  67212. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67213. /**
  67214. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67215. * The queries will try to find a solution within those bounds
  67216. * default is (1,1,1)
  67217. * @param extent x,y,z value that define the extent around the queries point of reference
  67218. */
  67219. setDefaultQueryExtent(extent: Vector3): void;
  67220. /**
  67221. * Get the Bounding box extent specified by setDefaultQueryExtent
  67222. * @returns the box extent values
  67223. */
  67224. getDefaultQueryExtent(): Vector3;
  67225. /**
  67226. * build the navmesh from a previously saved state using getNavmeshData
  67227. * @param data the Uint8Array returned by getNavmeshData
  67228. */
  67229. buildFromNavmeshData(data: Uint8Array): void;
  67230. /**
  67231. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67232. * @returns data the Uint8Array that can be saved and reused
  67233. */
  67234. getNavmeshData(): Uint8Array;
  67235. /**
  67236. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67237. * @param result output the box extent values
  67238. */
  67239. getDefaultQueryExtentToRef(result: Vector3): void;
  67240. /**
  67241. * Release all resources
  67242. */
  67243. dispose(): void;
  67244. }
  67245. /**
  67246. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67247. */
  67248. export interface ICrowd {
  67249. /**
  67250. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67251. * You can attach anything to that node. The node position is updated in the scene update tick.
  67252. * @param pos world position that will be constrained by the navigation mesh
  67253. * @param parameters agent parameters
  67254. * @param transform hooked to the agent that will be update by the scene
  67255. * @returns agent index
  67256. */
  67257. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67258. /**
  67259. * Returns the agent position in world space
  67260. * @param index agent index returned by addAgent
  67261. * @returns world space position
  67262. */
  67263. getAgentPosition(index: number): Vector3;
  67264. /**
  67265. * Gets the agent position result in world space
  67266. * @param index agent index returned by addAgent
  67267. * @param result output world space position
  67268. */
  67269. getAgentPositionToRef(index: number, result: Vector3): void;
  67270. /**
  67271. * Gets the agent velocity in world space
  67272. * @param index agent index returned by addAgent
  67273. * @returns world space velocity
  67274. */
  67275. getAgentVelocity(index: number): Vector3;
  67276. /**
  67277. * Gets the agent velocity result in world space
  67278. * @param index agent index returned by addAgent
  67279. * @param result output world space velocity
  67280. */
  67281. getAgentVelocityToRef(index: number, result: Vector3): void;
  67282. /**
  67283. * remove a particular agent previously created
  67284. * @param index agent index returned by addAgent
  67285. */
  67286. removeAgent(index: number): void;
  67287. /**
  67288. * get the list of all agents attached to this crowd
  67289. * @returns list of agent indices
  67290. */
  67291. getAgents(): number[];
  67292. /**
  67293. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67294. * @param deltaTime in seconds
  67295. */
  67296. update(deltaTime: number): void;
  67297. /**
  67298. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67299. * @param index agent index returned by addAgent
  67300. * @param destination targeted world position
  67301. */
  67302. agentGoto(index: number, destination: Vector3): void;
  67303. /**
  67304. * Teleport the agent to a new position
  67305. * @param index agent index returned by addAgent
  67306. * @param destination targeted world position
  67307. */
  67308. agentTeleport(index: number, destination: Vector3): void;
  67309. /**
  67310. * Update agent parameters
  67311. * @param index agent index returned by addAgent
  67312. * @param parameters agent parameters
  67313. */
  67314. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67315. /**
  67316. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67317. * The queries will try to find a solution within those bounds
  67318. * default is (1,1,1)
  67319. * @param extent x,y,z value that define the extent around the queries point of reference
  67320. */
  67321. setDefaultQueryExtent(extent: Vector3): void;
  67322. /**
  67323. * Get the Bounding box extent specified by setDefaultQueryExtent
  67324. * @returns the box extent values
  67325. */
  67326. getDefaultQueryExtent(): Vector3;
  67327. /**
  67328. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67329. * @param result output the box extent values
  67330. */
  67331. getDefaultQueryExtentToRef(result: Vector3): void;
  67332. /**
  67333. * Release all resources
  67334. */
  67335. dispose(): void;
  67336. }
  67337. /**
  67338. * Configures an agent
  67339. */
  67340. export interface IAgentParameters {
  67341. /**
  67342. * Agent radius. [Limit: >= 0]
  67343. */
  67344. radius: number;
  67345. /**
  67346. * Agent height. [Limit: > 0]
  67347. */
  67348. height: number;
  67349. /**
  67350. * Maximum allowed acceleration. [Limit: >= 0]
  67351. */
  67352. maxAcceleration: number;
  67353. /**
  67354. * Maximum allowed speed. [Limit: >= 0]
  67355. */
  67356. maxSpeed: number;
  67357. /**
  67358. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67359. */
  67360. collisionQueryRange: number;
  67361. /**
  67362. * The path visibility optimization range. [Limit: > 0]
  67363. */
  67364. pathOptimizationRange: number;
  67365. /**
  67366. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67367. */
  67368. separationWeight: number;
  67369. }
  67370. /**
  67371. * Configures the navigation mesh creation
  67372. */
  67373. export interface INavMeshParameters {
  67374. /**
  67375. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67376. */
  67377. cs: number;
  67378. /**
  67379. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67380. */
  67381. ch: number;
  67382. /**
  67383. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67384. */
  67385. walkableSlopeAngle: number;
  67386. /**
  67387. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67388. * be considered walkable. [Limit: >= 3] [Units: vx]
  67389. */
  67390. walkableHeight: number;
  67391. /**
  67392. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67393. */
  67394. walkableClimb: number;
  67395. /**
  67396. * The distance to erode/shrink the walkable area of the heightfield away from
  67397. * obstructions. [Limit: >=0] [Units: vx]
  67398. */
  67399. walkableRadius: number;
  67400. /**
  67401. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67402. */
  67403. maxEdgeLen: number;
  67404. /**
  67405. * The maximum distance a simplfied contour's border edges should deviate
  67406. * the original raw contour. [Limit: >=0] [Units: vx]
  67407. */
  67408. maxSimplificationError: number;
  67409. /**
  67410. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67411. */
  67412. minRegionArea: number;
  67413. /**
  67414. * Any regions with a span count smaller than this value will, if possible,
  67415. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67416. */
  67417. mergeRegionArea: number;
  67418. /**
  67419. * The maximum number of vertices allowed for polygons generated during the
  67420. * contour to polygon conversion process. [Limit: >= 3]
  67421. */
  67422. maxVertsPerPoly: number;
  67423. /**
  67424. * Sets the sampling distance to use when generating the detail mesh.
  67425. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67426. */
  67427. detailSampleDist: number;
  67428. /**
  67429. * The maximum distance the detail mesh surface should deviate from heightfield
  67430. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67431. */
  67432. detailSampleMaxError: number;
  67433. }
  67434. }
  67435. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  67436. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  67437. import { Mesh } from "babylonjs/Meshes/mesh";
  67438. import { Scene } from "babylonjs/scene";
  67439. import { Vector3 } from "babylonjs/Maths/math";
  67440. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67441. /**
  67442. * RecastJS navigation plugin
  67443. */
  67444. export class RecastJSPlugin implements INavigationEnginePlugin {
  67445. /**
  67446. * Reference to the Recast library
  67447. */
  67448. bjsRECAST: any;
  67449. /**
  67450. * plugin name
  67451. */
  67452. name: string;
  67453. /**
  67454. * the first navmesh created. We might extend this to support multiple navmeshes
  67455. */
  67456. navMesh: any;
  67457. /**
  67458. * Initializes the recastJS plugin
  67459. * @param recastInjection can be used to inject your own recast reference
  67460. */
  67461. constructor(recastInjection?: any);
  67462. /**
  67463. * Creates a navigation mesh
  67464. * @param meshes array of all the geometry used to compute the navigatio mesh
  67465. * @param parameters bunch of parameters used to filter geometry
  67466. */
  67467. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67468. /**
  67469. * Create a navigation mesh debug mesh
  67470. * @param scene is where the mesh will be added
  67471. * @returns debug display mesh
  67472. */
  67473. createDebugNavMesh(scene: Scene): Mesh;
  67474. /**
  67475. * Get a navigation mesh constrained position, closest to the parameter position
  67476. * @param position world position
  67477. * @returns the closest point to position constrained by the navigation mesh
  67478. */
  67479. getClosestPoint(position: Vector3): Vector3;
  67480. /**
  67481. * Get a navigation mesh constrained position, closest to the parameter position
  67482. * @param position world position
  67483. * @param result output the closest point to position constrained by the navigation mesh
  67484. */
  67485. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67486. /**
  67487. * Get a navigation mesh constrained position, within a particular radius
  67488. * @param position world position
  67489. * @param maxRadius the maximum distance to the constrained world position
  67490. * @returns the closest point to position constrained by the navigation mesh
  67491. */
  67492. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67493. /**
  67494. * Get a navigation mesh constrained position, within a particular radius
  67495. * @param position world position
  67496. * @param maxRadius the maximum distance to the constrained world position
  67497. * @param result output the closest point to position constrained by the navigation mesh
  67498. */
  67499. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67500. /**
  67501. * Compute the final position from a segment made of destination-position
  67502. * @param position world position
  67503. * @param destination world position
  67504. * @returns the resulting point along the navmesh
  67505. */
  67506. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67507. /**
  67508. * Compute the final position from a segment made of destination-position
  67509. * @param position world position
  67510. * @param destination world position
  67511. * @param result output the resulting point along the navmesh
  67512. */
  67513. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67514. /**
  67515. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67516. * @param start world position
  67517. * @param end world position
  67518. * @returns array containing world position composing the path
  67519. */
  67520. computePath(start: Vector3, end: Vector3): Vector3[];
  67521. /**
  67522. * Create a new Crowd so you can add agents
  67523. * @param maxAgents the maximum agent count in the crowd
  67524. * @param maxAgentRadius the maximum radius an agent can have
  67525. * @param scene to attach the crowd to
  67526. * @returns the crowd you can add agents to
  67527. */
  67528. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67529. /**
  67530. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67531. * The queries will try to find a solution within those bounds
  67532. * default is (1,1,1)
  67533. * @param extent x,y,z value that define the extent around the queries point of reference
  67534. */
  67535. setDefaultQueryExtent(extent: Vector3): void;
  67536. /**
  67537. * Get the Bounding box extent specified by setDefaultQueryExtent
  67538. * @returns the box extent values
  67539. */
  67540. getDefaultQueryExtent(): Vector3;
  67541. /**
  67542. * build the navmesh from a previously saved state using getNavmeshData
  67543. * @param data the Uint8Array returned by getNavmeshData
  67544. */
  67545. buildFromNavmeshData(data: Uint8Array): void;
  67546. /**
  67547. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67548. * @returns data the Uint8Array that can be saved and reused
  67549. */
  67550. getNavmeshData(): Uint8Array;
  67551. /**
  67552. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67553. * @param result output the box extent values
  67554. */
  67555. getDefaultQueryExtentToRef(result: Vector3): void;
  67556. /**
  67557. * Disposes
  67558. */
  67559. dispose(): void;
  67560. /**
  67561. * If this plugin is supported
  67562. * @returns true if plugin is supported
  67563. */
  67564. isSupported(): boolean;
  67565. }
  67566. /**
  67567. * Recast detour crowd implementation
  67568. */
  67569. export class RecastJSCrowd implements ICrowd {
  67570. /**
  67571. * Recast/detour plugin
  67572. */
  67573. bjsRECASTPlugin: RecastJSPlugin;
  67574. /**
  67575. * Link to the detour crowd
  67576. */
  67577. recastCrowd: any;
  67578. /**
  67579. * One transform per agent
  67580. */
  67581. transforms: TransformNode[];
  67582. /**
  67583. * All agents created
  67584. */
  67585. agents: number[];
  67586. /**
  67587. * Link to the scene is kept to unregister the crowd from the scene
  67588. */
  67589. private _scene;
  67590. /**
  67591. * Observer for crowd updates
  67592. */
  67593. private _onBeforeAnimationsObserver;
  67594. /**
  67595. * Constructor
  67596. * @param plugin recastJS plugin
  67597. * @param maxAgents the maximum agent count in the crowd
  67598. * @param maxAgentRadius the maximum radius an agent can have
  67599. * @param scene to attach the crowd to
  67600. * @returns the crowd you can add agents to
  67601. */
  67602. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67603. /**
  67604. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67605. * You can attach anything to that node. The node position is updated in the scene update tick.
  67606. * @param pos world position that will be constrained by the navigation mesh
  67607. * @param parameters agent parameters
  67608. * @param transform hooked to the agent that will be update by the scene
  67609. * @returns agent index
  67610. */
  67611. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67612. /**
  67613. * Returns the agent position in world space
  67614. * @param index agent index returned by addAgent
  67615. * @returns world space position
  67616. */
  67617. getAgentPosition(index: number): Vector3;
  67618. /**
  67619. * Returns the agent position result in world space
  67620. * @param index agent index returned by addAgent
  67621. * @param result output world space position
  67622. */
  67623. getAgentPositionToRef(index: number, result: Vector3): void;
  67624. /**
  67625. * Returns the agent velocity in world space
  67626. * @param index agent index returned by addAgent
  67627. * @returns world space velocity
  67628. */
  67629. getAgentVelocity(index: number): Vector3;
  67630. /**
  67631. * Returns the agent velocity result in world space
  67632. * @param index agent index returned by addAgent
  67633. * @param result output world space velocity
  67634. */
  67635. getAgentVelocityToRef(index: number, result: Vector3): void;
  67636. /**
  67637. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67638. * @param index agent index returned by addAgent
  67639. * @param destination targeted world position
  67640. */
  67641. agentGoto(index: number, destination: Vector3): void;
  67642. /**
  67643. * Teleport the agent to a new position
  67644. * @param index agent index returned by addAgent
  67645. * @param destination targeted world position
  67646. */
  67647. agentTeleport(index: number, destination: Vector3): void;
  67648. /**
  67649. * Update agent parameters
  67650. * @param index agent index returned by addAgent
  67651. * @param parameters agent parameters
  67652. */
  67653. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67654. /**
  67655. * remove a particular agent previously created
  67656. * @param index agent index returned by addAgent
  67657. */
  67658. removeAgent(index: number): void;
  67659. /**
  67660. * get the list of all agents attached to this crowd
  67661. * @returns list of agent indices
  67662. */
  67663. getAgents(): number[];
  67664. /**
  67665. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67666. * @param deltaTime in seconds
  67667. */
  67668. update(deltaTime: number): void;
  67669. /**
  67670. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67671. * The queries will try to find a solution within those bounds
  67672. * default is (1,1,1)
  67673. * @param extent x,y,z value that define the extent around the queries point of reference
  67674. */
  67675. setDefaultQueryExtent(extent: Vector3): void;
  67676. /**
  67677. * Get the Bounding box extent specified by setDefaultQueryExtent
  67678. * @returns the box extent values
  67679. */
  67680. getDefaultQueryExtent(): Vector3;
  67681. /**
  67682. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67683. * @param result output the box extent values
  67684. */
  67685. getDefaultQueryExtentToRef(result: Vector3): void;
  67686. /**
  67687. * Release all resources
  67688. */
  67689. dispose(): void;
  67690. }
  67691. }
  67692. declare module "babylonjs/Navigation/Plugins/index" {
  67693. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  67694. }
  67695. declare module "babylonjs/Navigation/index" {
  67696. export * from "babylonjs/Navigation/INavigationEngine";
  67697. export * from "babylonjs/Navigation/Plugins/index";
  67698. }
  67699. declare module "babylonjs/Offline/database" {
  67700. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  67701. /**
  67702. * Class used to enable access to IndexedDB
  67703. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67704. */
  67705. export class Database implements IOfflineProvider {
  67706. private _callbackManifestChecked;
  67707. private _currentSceneUrl;
  67708. private _db;
  67709. private _enableSceneOffline;
  67710. private _enableTexturesOffline;
  67711. private _manifestVersionFound;
  67712. private _mustUpdateRessources;
  67713. private _hasReachedQuota;
  67714. private _isSupported;
  67715. private _idbFactory;
  67716. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67717. private static IsUASupportingBlobStorage;
  67718. /**
  67719. * Gets a boolean indicating if Database storate is enabled (off by default)
  67720. */
  67721. static IDBStorageEnabled: boolean;
  67722. /**
  67723. * Gets a boolean indicating if scene must be saved in the database
  67724. */
  67725. get enableSceneOffline(): boolean;
  67726. /**
  67727. * Gets a boolean indicating if textures must be saved in the database
  67728. */
  67729. get enableTexturesOffline(): boolean;
  67730. /**
  67731. * Creates a new Database
  67732. * @param urlToScene defines the url to load the scene
  67733. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67734. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67735. */
  67736. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67737. private static _ParseURL;
  67738. private static _ReturnFullUrlLocation;
  67739. private _checkManifestFile;
  67740. /**
  67741. * Open the database and make it available
  67742. * @param successCallback defines the callback to call on success
  67743. * @param errorCallback defines the callback to call on error
  67744. */
  67745. open(successCallback: () => void, errorCallback: () => void): void;
  67746. /**
  67747. * Loads an image from the database
  67748. * @param url defines the url to load from
  67749. * @param image defines the target DOM image
  67750. */
  67751. loadImage(url: string, image: HTMLImageElement): void;
  67752. private _loadImageFromDBAsync;
  67753. private _saveImageIntoDBAsync;
  67754. private _checkVersionFromDB;
  67755. private _loadVersionFromDBAsync;
  67756. private _saveVersionIntoDBAsync;
  67757. /**
  67758. * Loads a file from database
  67759. * @param url defines the URL to load from
  67760. * @param sceneLoaded defines a callback to call on success
  67761. * @param progressCallBack defines a callback to call when progress changed
  67762. * @param errorCallback defines a callback to call on error
  67763. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67764. */
  67765. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67766. private _loadFileAsync;
  67767. private _saveFileAsync;
  67768. /**
  67769. * Validates if xhr data is correct
  67770. * @param xhr defines the request to validate
  67771. * @param dataType defines the expected data type
  67772. * @returns true if data is correct
  67773. */
  67774. private static _ValidateXHRData;
  67775. }
  67776. }
  67777. declare module "babylonjs/Offline/index" {
  67778. export * from "babylonjs/Offline/database";
  67779. export * from "babylonjs/Offline/IOfflineProvider";
  67780. }
  67781. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  67782. /** @hidden */
  67783. export var gpuUpdateParticlesPixelShader: {
  67784. name: string;
  67785. shader: string;
  67786. };
  67787. }
  67788. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  67789. /** @hidden */
  67790. export var gpuUpdateParticlesVertexShader: {
  67791. name: string;
  67792. shader: string;
  67793. };
  67794. }
  67795. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  67796. /** @hidden */
  67797. export var clipPlaneFragmentDeclaration2: {
  67798. name: string;
  67799. shader: string;
  67800. };
  67801. }
  67802. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  67803. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  67804. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67805. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67806. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67807. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  67808. /** @hidden */
  67809. export var gpuRenderParticlesPixelShader: {
  67810. name: string;
  67811. shader: string;
  67812. };
  67813. }
  67814. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  67815. /** @hidden */
  67816. export var clipPlaneVertexDeclaration2: {
  67817. name: string;
  67818. shader: string;
  67819. };
  67820. }
  67821. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  67822. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  67823. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  67824. /** @hidden */
  67825. export var gpuRenderParticlesVertexShader: {
  67826. name: string;
  67827. shader: string;
  67828. };
  67829. }
  67830. declare module "babylonjs/Particles/gpuParticleSystem" {
  67831. import { Nullable } from "babylonjs/types";
  67832. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  67833. import { Observable } from "babylonjs/Misc/observable";
  67834. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67835. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67836. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  67837. import { Scene, IDisposable } from "babylonjs/scene";
  67838. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  67839. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67840. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  67841. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  67842. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  67843. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  67844. /**
  67845. * This represents a GPU particle system in Babylon
  67846. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67847. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67848. */
  67849. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67850. /**
  67851. * The layer mask we are rendering the particles through.
  67852. */
  67853. layerMask: number;
  67854. private _capacity;
  67855. private _activeCount;
  67856. private _currentActiveCount;
  67857. private _accumulatedCount;
  67858. private _renderEffect;
  67859. private _updateEffect;
  67860. private _buffer0;
  67861. private _buffer1;
  67862. private _spriteBuffer;
  67863. private _updateVAO;
  67864. private _renderVAO;
  67865. private _targetIndex;
  67866. private _sourceBuffer;
  67867. private _targetBuffer;
  67868. private _engine;
  67869. private _currentRenderId;
  67870. private _started;
  67871. private _stopped;
  67872. private _timeDelta;
  67873. private _randomTexture;
  67874. private _randomTexture2;
  67875. private _attributesStrideSize;
  67876. private _updateEffectOptions;
  67877. private _randomTextureSize;
  67878. private _actualFrame;
  67879. private readonly _rawTextureWidth;
  67880. /**
  67881. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67882. */
  67883. static get IsSupported(): boolean;
  67884. /**
  67885. * An event triggered when the system is disposed.
  67886. */
  67887. onDisposeObservable: Observable<GPUParticleSystem>;
  67888. /**
  67889. * Gets the maximum number of particles active at the same time.
  67890. * @returns The max number of active particles.
  67891. */
  67892. getCapacity(): number;
  67893. /**
  67894. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67895. * to override the particles.
  67896. */
  67897. forceDepthWrite: boolean;
  67898. /**
  67899. * Gets or set the number of active particles
  67900. */
  67901. get activeParticleCount(): number;
  67902. set activeParticleCount(value: number);
  67903. private _preWarmDone;
  67904. /**
  67905. * Specifies if the particles are updated in emitter local space or world space.
  67906. */
  67907. isLocal: boolean;
  67908. /**
  67909. * Is this system ready to be used/rendered
  67910. * @return true if the system is ready
  67911. */
  67912. isReady(): boolean;
  67913. /**
  67914. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67915. * @returns True if it has been started, otherwise false.
  67916. */
  67917. isStarted(): boolean;
  67918. /**
  67919. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67920. * @returns True if it has been stopped, otherwise false.
  67921. */
  67922. isStopped(): boolean;
  67923. /**
  67924. * Gets a boolean indicating that the system is stopping
  67925. * @returns true if the system is currently stopping
  67926. */
  67927. isStopping(): boolean;
  67928. /**
  67929. * Gets the number of particles active at the same time.
  67930. * @returns The number of active particles.
  67931. */
  67932. getActiveCount(): number;
  67933. /**
  67934. * Starts the particle system and begins to emit
  67935. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67936. */
  67937. start(delay?: number): void;
  67938. /**
  67939. * Stops the particle system.
  67940. */
  67941. stop(): void;
  67942. /**
  67943. * Remove all active particles
  67944. */
  67945. reset(): void;
  67946. /**
  67947. * Returns the string "GPUParticleSystem"
  67948. * @returns a string containing the class name
  67949. */
  67950. getClassName(): string;
  67951. private _colorGradientsTexture;
  67952. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67953. /**
  67954. * Adds a new color gradient
  67955. * @param gradient defines the gradient to use (between 0 and 1)
  67956. * @param color1 defines the color to affect to the specified gradient
  67957. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67958. * @returns the current particle system
  67959. */
  67960. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67961. private _refreshColorGradient;
  67962. /** Force the system to rebuild all gradients that need to be resync */
  67963. forceRefreshGradients(): void;
  67964. /**
  67965. * Remove a specific color gradient
  67966. * @param gradient defines the gradient to remove
  67967. * @returns the current particle system
  67968. */
  67969. removeColorGradient(gradient: number): GPUParticleSystem;
  67970. private _angularSpeedGradientsTexture;
  67971. private _sizeGradientsTexture;
  67972. private _velocityGradientsTexture;
  67973. private _limitVelocityGradientsTexture;
  67974. private _dragGradientsTexture;
  67975. private _addFactorGradient;
  67976. /**
  67977. * Adds a new size gradient
  67978. * @param gradient defines the gradient to use (between 0 and 1)
  67979. * @param factor defines the size factor to affect to the specified gradient
  67980. * @returns the current particle system
  67981. */
  67982. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67983. /**
  67984. * Remove a specific size gradient
  67985. * @param gradient defines the gradient to remove
  67986. * @returns the current particle system
  67987. */
  67988. removeSizeGradient(gradient: number): GPUParticleSystem;
  67989. private _refreshFactorGradient;
  67990. /**
  67991. * Adds a new angular speed gradient
  67992. * @param gradient defines the gradient to use (between 0 and 1)
  67993. * @param factor defines the angular speed to affect to the specified gradient
  67994. * @returns the current particle system
  67995. */
  67996. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67997. /**
  67998. * Remove a specific angular speed gradient
  67999. * @param gradient defines the gradient to remove
  68000. * @returns the current particle system
  68001. */
  68002. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68003. /**
  68004. * Adds a new velocity gradient
  68005. * @param gradient defines the gradient to use (between 0 and 1)
  68006. * @param factor defines the velocity to affect to the specified gradient
  68007. * @returns the current particle system
  68008. */
  68009. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68010. /**
  68011. * Remove a specific velocity gradient
  68012. * @param gradient defines the gradient to remove
  68013. * @returns the current particle system
  68014. */
  68015. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68016. /**
  68017. * Adds a new limit velocity gradient
  68018. * @param gradient defines the gradient to use (between 0 and 1)
  68019. * @param factor defines the limit velocity value to affect to the specified gradient
  68020. * @returns the current particle system
  68021. */
  68022. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68023. /**
  68024. * Remove a specific limit velocity gradient
  68025. * @param gradient defines the gradient to remove
  68026. * @returns the current particle system
  68027. */
  68028. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68029. /**
  68030. * Adds a new drag gradient
  68031. * @param gradient defines the gradient to use (between 0 and 1)
  68032. * @param factor defines the drag value to affect to the specified gradient
  68033. * @returns the current particle system
  68034. */
  68035. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68036. /**
  68037. * Remove a specific drag gradient
  68038. * @param gradient defines the gradient to remove
  68039. * @returns the current particle system
  68040. */
  68041. removeDragGradient(gradient: number): GPUParticleSystem;
  68042. /**
  68043. * Not supported by GPUParticleSystem
  68044. * @param gradient defines the gradient to use (between 0 and 1)
  68045. * @param factor defines the emit rate value to affect to the specified gradient
  68046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68047. * @returns the current particle system
  68048. */
  68049. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68050. /**
  68051. * Not supported by GPUParticleSystem
  68052. * @param gradient defines the gradient to remove
  68053. * @returns the current particle system
  68054. */
  68055. removeEmitRateGradient(gradient: number): IParticleSystem;
  68056. /**
  68057. * Not supported by GPUParticleSystem
  68058. * @param gradient defines the gradient to use (between 0 and 1)
  68059. * @param factor defines the start size value to affect to the specified gradient
  68060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68061. * @returns the current particle system
  68062. */
  68063. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68064. /**
  68065. * Not supported by GPUParticleSystem
  68066. * @param gradient defines the gradient to remove
  68067. * @returns the current particle system
  68068. */
  68069. removeStartSizeGradient(gradient: number): IParticleSystem;
  68070. /**
  68071. * Not supported by GPUParticleSystem
  68072. * @param gradient defines the gradient to use (between 0 and 1)
  68073. * @param min defines the color remap minimal range
  68074. * @param max defines the color remap maximal range
  68075. * @returns the current particle system
  68076. */
  68077. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68078. /**
  68079. * Not supported by GPUParticleSystem
  68080. * @param gradient defines the gradient to remove
  68081. * @returns the current particle system
  68082. */
  68083. removeColorRemapGradient(): IParticleSystem;
  68084. /**
  68085. * Not supported by GPUParticleSystem
  68086. * @param gradient defines the gradient to use (between 0 and 1)
  68087. * @param min defines the alpha remap minimal range
  68088. * @param max defines the alpha remap maximal range
  68089. * @returns the current particle system
  68090. */
  68091. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68092. /**
  68093. * Not supported by GPUParticleSystem
  68094. * @param gradient defines the gradient to remove
  68095. * @returns the current particle system
  68096. */
  68097. removeAlphaRemapGradient(): IParticleSystem;
  68098. /**
  68099. * Not supported by GPUParticleSystem
  68100. * @param gradient defines the gradient to use (between 0 and 1)
  68101. * @param color defines the color to affect to the specified gradient
  68102. * @returns the current particle system
  68103. */
  68104. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68105. /**
  68106. * Not supported by GPUParticleSystem
  68107. * @param gradient defines the gradient to remove
  68108. * @returns the current particle system
  68109. */
  68110. removeRampGradient(): IParticleSystem;
  68111. /**
  68112. * Not supported by GPUParticleSystem
  68113. * @returns the list of ramp gradients
  68114. */
  68115. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68116. /**
  68117. * Not supported by GPUParticleSystem
  68118. * Gets or sets a boolean indicating that ramp gradients must be used
  68119. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68120. */
  68121. get useRampGradients(): boolean;
  68122. set useRampGradients(value: boolean);
  68123. /**
  68124. * Not supported by GPUParticleSystem
  68125. * @param gradient defines the gradient to use (between 0 and 1)
  68126. * @param factor defines the life time factor to affect to the specified gradient
  68127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68128. * @returns the current particle system
  68129. */
  68130. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68131. /**
  68132. * Not supported by GPUParticleSystem
  68133. * @param gradient defines the gradient to remove
  68134. * @returns the current particle system
  68135. */
  68136. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68137. /**
  68138. * Instantiates a GPU particle system.
  68139. * 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.
  68140. * @param name The name of the particle system
  68141. * @param options The options used to create the system
  68142. * @param scene The scene the particle system belongs to
  68143. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68144. */
  68145. constructor(name: string, options: Partial<{
  68146. capacity: number;
  68147. randomTextureSize: number;
  68148. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  68149. protected _reset(): void;
  68150. private _createUpdateVAO;
  68151. private _createRenderVAO;
  68152. private _initialize;
  68153. /** @hidden */
  68154. _recreateUpdateEffect(): void;
  68155. /** @hidden */
  68156. _recreateRenderEffect(): void;
  68157. /**
  68158. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68159. * @param preWarm defines if we are in the pre-warmimg phase
  68160. */
  68161. animate(preWarm?: boolean): void;
  68162. private _createFactorGradientTexture;
  68163. private _createSizeGradientTexture;
  68164. private _createAngularSpeedGradientTexture;
  68165. private _createVelocityGradientTexture;
  68166. private _createLimitVelocityGradientTexture;
  68167. private _createDragGradientTexture;
  68168. private _createColorGradientTexture;
  68169. /**
  68170. * Renders the particle system in its current state
  68171. * @param preWarm defines if the system should only update the particles but not render them
  68172. * @returns the current number of particles
  68173. */
  68174. render(preWarm?: boolean): number;
  68175. /**
  68176. * Rebuilds the particle system
  68177. */
  68178. rebuild(): void;
  68179. private _releaseBuffers;
  68180. private _releaseVAOs;
  68181. /**
  68182. * Disposes the particle system and free the associated resources
  68183. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68184. */
  68185. dispose(disposeTexture?: boolean): void;
  68186. /**
  68187. * Clones the particle system.
  68188. * @param name The name of the cloned object
  68189. * @param newEmitter The new emitter to use
  68190. * @returns the cloned particle system
  68191. */
  68192. clone(name: string, newEmitter: any): GPUParticleSystem;
  68193. /**
  68194. * Serializes the particle system to a JSON object
  68195. * @param serializeTexture defines if the texture must be serialized as well
  68196. * @returns the JSON object
  68197. */
  68198. serialize(serializeTexture?: boolean): any;
  68199. /**
  68200. * Parses a JSON object to create a GPU particle system.
  68201. * @param parsedParticleSystem The JSON object to parse
  68202. * @param scene The scene to create the particle system in
  68203. * @param rootUrl The root url to use to load external dependencies like texture
  68204. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68205. * @returns the parsed GPU particle system
  68206. */
  68207. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68208. }
  68209. }
  68210. declare module "babylonjs/Particles/particleSystemSet" {
  68211. import { Nullable } from "babylonjs/types";
  68212. import { Color3 } from "babylonjs/Maths/math.color";
  68213. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68215. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68216. import { Scene, IDisposable } from "babylonjs/scene";
  68217. /**
  68218. * Represents a set of particle systems working together to create a specific effect
  68219. */
  68220. export class ParticleSystemSet implements IDisposable {
  68221. /**
  68222. * Gets or sets base Assets URL
  68223. */
  68224. static BaseAssetsUrl: string;
  68225. private _emitterCreationOptions;
  68226. private _emitterNode;
  68227. /**
  68228. * Gets the particle system list
  68229. */
  68230. systems: IParticleSystem[];
  68231. /**
  68232. * Gets the emitter node used with this set
  68233. */
  68234. get emitterNode(): Nullable<TransformNode>;
  68235. /**
  68236. * Creates a new emitter mesh as a sphere
  68237. * @param options defines the options used to create the sphere
  68238. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68239. * @param scene defines the hosting scene
  68240. */
  68241. setEmitterAsSphere(options: {
  68242. diameter: number;
  68243. segments: number;
  68244. color: Color3;
  68245. }, renderingGroupId: number, scene: Scene): void;
  68246. /**
  68247. * Starts all particle systems of the set
  68248. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68249. */
  68250. start(emitter?: AbstractMesh): void;
  68251. /**
  68252. * Release all associated resources
  68253. */
  68254. dispose(): void;
  68255. /**
  68256. * Serialize the set into a JSON compatible object
  68257. * @param serializeTexture defines if the texture must be serialized as well
  68258. * @returns a JSON compatible representation of the set
  68259. */
  68260. serialize(serializeTexture?: boolean): any;
  68261. /**
  68262. * Parse a new ParticleSystemSet from a serialized source
  68263. * @param data defines a JSON compatible representation of the set
  68264. * @param scene defines the hosting scene
  68265. * @param gpu defines if we want GPU particles or CPU particles
  68266. * @returns a new ParticleSystemSet
  68267. */
  68268. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68269. }
  68270. }
  68271. declare module "babylonjs/Particles/particleHelper" {
  68272. import { Nullable } from "babylonjs/types";
  68273. import { Scene } from "babylonjs/scene";
  68274. import { Vector3 } from "babylonjs/Maths/math.vector";
  68275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68276. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68277. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  68278. /**
  68279. * This class is made for on one-liner static method to help creating particle system set.
  68280. */
  68281. export class ParticleHelper {
  68282. /**
  68283. * Gets or sets base Assets URL
  68284. */
  68285. static BaseAssetsUrl: string;
  68286. /** Define the Url to load snippets */
  68287. static SnippetUrl: string;
  68288. /**
  68289. * Create a default particle system that you can tweak
  68290. * @param emitter defines the emitter to use
  68291. * @param capacity defines the system capacity (default is 500 particles)
  68292. * @param scene defines the hosting scene
  68293. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68294. * @returns the new Particle system
  68295. */
  68296. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68297. /**
  68298. * This is the main static method (one-liner) of this helper to create different particle systems
  68299. * @param type This string represents the type to the particle system to create
  68300. * @param scene The scene where the particle system should live
  68301. * @param gpu If the system will use gpu
  68302. * @returns the ParticleSystemSet created
  68303. */
  68304. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68305. /**
  68306. * Static function used to export a particle system to a ParticleSystemSet variable.
  68307. * Please note that the emitter shape is not exported
  68308. * @param systems defines the particle systems to export
  68309. * @returns the created particle system set
  68310. */
  68311. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68312. /**
  68313. * Creates a particle system from a snippet saved in a remote file
  68314. * @param name defines the name of the particle system to create
  68315. * @param url defines the url to load from
  68316. * @param scene defines the hosting scene
  68317. * @param gpu If the system will use gpu
  68318. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68319. * @returns a promise that will resolve to the new particle system
  68320. */
  68321. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68322. /**
  68323. * Creates a particle system from a snippet saved by the particle system editor
  68324. * @param snippetId defines the snippet to load
  68325. * @param scene defines the hosting scene
  68326. * @param gpu If the system will use gpu
  68327. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68328. * @returns a promise that will resolve to the new particle system
  68329. */
  68330. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68331. }
  68332. }
  68333. declare module "babylonjs/Particles/particleSystemComponent" {
  68334. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68335. import { Effect } from "babylonjs/Materials/effect";
  68336. import "babylonjs/Shaders/particles.vertex";
  68337. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  68338. module "babylonjs/Engines/engine" {
  68339. interface Engine {
  68340. /**
  68341. * Create an effect to use with particle systems.
  68342. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  68343. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68344. * @param uniformsNames defines a list of attribute names
  68345. * @param samplers defines an array of string used to represent textures
  68346. * @param defines defines the string containing the defines to use to compile the shaders
  68347. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68348. * @param onCompiled defines a function to call when the effect creation is successful
  68349. * @param onError defines a function to call when the effect creation has failed
  68350. * @returns the new Effect
  68351. */
  68352. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  68353. }
  68354. }
  68355. module "babylonjs/Meshes/mesh" {
  68356. interface Mesh {
  68357. /**
  68358. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68359. * @returns an array of IParticleSystem
  68360. */
  68361. getEmittedParticleSystems(): IParticleSystem[];
  68362. /**
  68363. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68364. * @returns an array of IParticleSystem
  68365. */
  68366. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68367. }
  68368. }
  68369. /**
  68370. * @hidden
  68371. */
  68372. export var _IDoNeedToBeInTheBuild: number;
  68373. }
  68374. declare module "babylonjs/Particles/pointsCloudSystem" {
  68375. import { Color4 } from "babylonjs/Maths/math";
  68376. import { Mesh } from "babylonjs/Meshes/mesh";
  68377. import { Scene, IDisposable } from "babylonjs/scene";
  68378. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  68379. /** Defines the 4 color options */
  68380. export enum PointColor {
  68381. /** color value */
  68382. Color = 2,
  68383. /** uv value */
  68384. UV = 1,
  68385. /** random value */
  68386. Random = 0,
  68387. /** stated value */
  68388. Stated = 3
  68389. }
  68390. /**
  68391. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68392. * 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.
  68393. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68394. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68395. *
  68396. * Full documentation here : TO BE ENTERED
  68397. */
  68398. export class PointsCloudSystem implements IDisposable {
  68399. /**
  68400. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68401. * Example : var p = SPS.particles[i];
  68402. */
  68403. particles: CloudPoint[];
  68404. /**
  68405. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68406. */
  68407. nbParticles: number;
  68408. /**
  68409. * This a counter for your own usage. It's not set by any SPS functions.
  68410. */
  68411. counter: number;
  68412. /**
  68413. * The PCS name. This name is also given to the underlying mesh.
  68414. */
  68415. name: string;
  68416. /**
  68417. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68418. */
  68419. mesh: Mesh;
  68420. /**
  68421. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68422. * Please read :
  68423. */
  68424. vars: any;
  68425. /**
  68426. * @hidden
  68427. */
  68428. _size: number;
  68429. private _scene;
  68430. private _promises;
  68431. private _positions;
  68432. private _indices;
  68433. private _normals;
  68434. private _colors;
  68435. private _uvs;
  68436. private _indices32;
  68437. private _positions32;
  68438. private _colors32;
  68439. private _uvs32;
  68440. private _updatable;
  68441. private _isVisibilityBoxLocked;
  68442. private _alwaysVisible;
  68443. private _groups;
  68444. private _groupCounter;
  68445. private _computeParticleColor;
  68446. private _computeParticleTexture;
  68447. private _computeParticleRotation;
  68448. private _computeBoundingBox;
  68449. private _isReady;
  68450. /**
  68451. * Creates a PCS (Points Cloud System) object
  68452. * @param name (String) is the PCS name, this will be the underlying mesh name
  68453. * @param pointSize (number) is the size for each point
  68454. * @param scene (Scene) is the scene in which the PCS is added
  68455. * @param options defines the options of the PCS e.g.
  68456. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68457. */
  68458. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68459. updatable?: boolean;
  68460. });
  68461. /**
  68462. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68463. * If no points were added to the PCS, the returned mesh is just a single point.
  68464. * @returns a promise for the created mesh
  68465. */
  68466. buildMeshAsync(): Promise<Mesh>;
  68467. /**
  68468. * @hidden
  68469. */
  68470. private _buildMesh;
  68471. private _addParticle;
  68472. private _randomUnitVector;
  68473. private _getColorIndicesForCoord;
  68474. private _setPointsColorOrUV;
  68475. private _colorFromTexture;
  68476. private _calculateDensity;
  68477. /**
  68478. * Adds points to the PCS in random positions within a unit sphere
  68479. * @param nb (positive integer) the number of particles to be created from this model
  68480. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68481. * @returns the number of groups in the system
  68482. */
  68483. addPoints(nb: number, pointFunction?: any): number;
  68484. /**
  68485. * Adds points to the PCS from the surface of the model shape
  68486. * @param mesh is any Mesh object that will be used as a surface model for the points
  68487. * @param nb (positive integer) the number of particles to be created from this model
  68488. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68489. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68490. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68491. * @returns the number of groups in the system
  68492. */
  68493. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68494. /**
  68495. * Adds points to the PCS inside the model shape
  68496. * @param mesh is any Mesh object that will be used as a surface model for the points
  68497. * @param nb (positive integer) the number of particles to be created from this model
  68498. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68499. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68500. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68501. * @returns the number of groups in the system
  68502. */
  68503. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68504. /**
  68505. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68506. * This method calls `updateParticle()` for each particle of the SPS.
  68507. * For an animated SPS, it is usually called within the render loop.
  68508. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68509. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68510. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68511. * @returns the PCS.
  68512. */
  68513. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68514. /**
  68515. * Disposes the PCS.
  68516. */
  68517. dispose(): void;
  68518. /**
  68519. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68520. * doc :
  68521. * @returns the PCS.
  68522. */
  68523. refreshVisibleSize(): PointsCloudSystem;
  68524. /**
  68525. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68526. * @param size the size (float) of the visibility box
  68527. * note : this doesn't lock the PCS mesh bounding box.
  68528. * doc :
  68529. */
  68530. setVisibilityBox(size: number): void;
  68531. /**
  68532. * Gets whether the PCS is always visible or not
  68533. * doc :
  68534. */
  68535. get isAlwaysVisible(): boolean;
  68536. /**
  68537. * Sets the PCS as always visible or not
  68538. * doc :
  68539. */
  68540. set isAlwaysVisible(val: boolean);
  68541. /**
  68542. * Tells to `setParticles()` to compute the particle rotations or not
  68543. * Default value : false. The PCS is faster when it's set to false
  68544. * Note : particle rotations are only applied to parent particles
  68545. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68546. */
  68547. set computeParticleRotation(val: boolean);
  68548. /**
  68549. * Tells to `setParticles()` to compute the particle colors or not.
  68550. * Default value : true. The PCS is faster when it's set to false.
  68551. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68552. */
  68553. set computeParticleColor(val: boolean);
  68554. set computeParticleTexture(val: boolean);
  68555. /**
  68556. * Gets if `setParticles()` computes the particle colors or not.
  68557. * Default value : false. The PCS is faster when it's set to false.
  68558. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68559. */
  68560. get computeParticleColor(): boolean;
  68561. /**
  68562. * Gets if `setParticles()` computes the particle textures or not.
  68563. * Default value : false. The PCS is faster when it's set to false.
  68564. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68565. */
  68566. get computeParticleTexture(): boolean;
  68567. /**
  68568. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68569. */
  68570. set computeBoundingBox(val: boolean);
  68571. /**
  68572. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68573. */
  68574. get computeBoundingBox(): boolean;
  68575. /**
  68576. * This function does nothing. It may be overwritten to set all the particle first values.
  68577. * The PCS doesn't call this function, you may have to call it by your own.
  68578. * doc :
  68579. */
  68580. initParticles(): void;
  68581. /**
  68582. * This function does nothing. It may be overwritten to recycle a particle
  68583. * The PCS doesn't call this function, you can to call it
  68584. * doc :
  68585. * @param particle The particle to recycle
  68586. * @returns the recycled particle
  68587. */
  68588. recycleParticle(particle: CloudPoint): CloudPoint;
  68589. /**
  68590. * Updates a particle : this function should be overwritten by the user.
  68591. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68592. * doc :
  68593. * @example : just set a particle position or velocity and recycle conditions
  68594. * @param particle The particle to update
  68595. * @returns the updated particle
  68596. */
  68597. updateParticle(particle: CloudPoint): CloudPoint;
  68598. /**
  68599. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68600. * This does nothing and may be overwritten by the user.
  68601. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68602. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68603. * @param update the boolean update value actually passed to setParticles()
  68604. */
  68605. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68606. /**
  68607. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68608. * This will be passed three parameters.
  68609. * This does nothing and may be overwritten by the user.
  68610. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68611. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68612. * @param update the boolean update value actually passed to setParticles()
  68613. */
  68614. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68615. }
  68616. }
  68617. declare module "babylonjs/Particles/cloudPoint" {
  68618. import { Nullable } from "babylonjs/types";
  68619. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  68620. import { Mesh } from "babylonjs/Meshes/mesh";
  68621. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  68622. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  68623. /**
  68624. * Represents one particle of a points cloud system.
  68625. */
  68626. export class CloudPoint {
  68627. /**
  68628. * particle global index
  68629. */
  68630. idx: number;
  68631. /**
  68632. * The color of the particle
  68633. */
  68634. color: Nullable<Color4>;
  68635. /**
  68636. * The world space position of the particle.
  68637. */
  68638. position: Vector3;
  68639. /**
  68640. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68641. */
  68642. rotation: Vector3;
  68643. /**
  68644. * The world space rotation quaternion of the particle.
  68645. */
  68646. rotationQuaternion: Nullable<Quaternion>;
  68647. /**
  68648. * The uv of the particle.
  68649. */
  68650. uv: Nullable<Vector2>;
  68651. /**
  68652. * The current speed of the particle.
  68653. */
  68654. velocity: Vector3;
  68655. /**
  68656. * The pivot point in the particle local space.
  68657. */
  68658. pivot: Vector3;
  68659. /**
  68660. * Must the particle be translated from its pivot point in its local space ?
  68661. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68662. * Default : false
  68663. */
  68664. translateFromPivot: boolean;
  68665. /**
  68666. * Index of this particle in the global "positions" array (Internal use)
  68667. * @hidden
  68668. */
  68669. _pos: number;
  68670. /**
  68671. * @hidden Index of this particle in the global "indices" array (Internal use)
  68672. */
  68673. _ind: number;
  68674. /**
  68675. * Group this particle belongs to
  68676. */
  68677. _group: PointsGroup;
  68678. /**
  68679. * Group id of this particle
  68680. */
  68681. groupId: number;
  68682. /**
  68683. * Index of the particle in its group id (Internal use)
  68684. */
  68685. idxInGroup: number;
  68686. /**
  68687. * @hidden Particle BoundingInfo object (Internal use)
  68688. */
  68689. _boundingInfo: BoundingInfo;
  68690. /**
  68691. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68692. */
  68693. _pcs: PointsCloudSystem;
  68694. /**
  68695. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68696. */
  68697. _stillInvisible: boolean;
  68698. /**
  68699. * @hidden Last computed particle rotation matrix
  68700. */
  68701. _rotationMatrix: number[];
  68702. /**
  68703. * Parent particle Id, if any.
  68704. * Default null.
  68705. */
  68706. parentId: Nullable<number>;
  68707. /**
  68708. * @hidden Internal global position in the PCS.
  68709. */
  68710. _globalPosition: Vector3;
  68711. /**
  68712. * Creates a Point Cloud object.
  68713. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68714. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68715. * @param group (PointsGroup) is the group the particle belongs to
  68716. * @param groupId (integer) is the group identifier in the PCS.
  68717. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68718. * @param pcs defines the PCS it is associated to
  68719. */
  68720. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68721. /**
  68722. * get point size
  68723. */
  68724. get size(): Vector3;
  68725. /**
  68726. * Set point size
  68727. */
  68728. set size(scale: Vector3);
  68729. /**
  68730. * Legacy support, changed quaternion to rotationQuaternion
  68731. */
  68732. get quaternion(): Nullable<Quaternion>;
  68733. /**
  68734. * Legacy support, changed quaternion to rotationQuaternion
  68735. */
  68736. set quaternion(q: Nullable<Quaternion>);
  68737. /**
  68738. * Returns a boolean. True if the particle intersects a mesh, else false
  68739. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68740. * @param target is the object (point or mesh) what the intersection is computed against
  68741. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68742. * @returns true if it intersects
  68743. */
  68744. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68745. /**
  68746. * get the rotation matrix of the particle
  68747. * @hidden
  68748. */
  68749. getRotationMatrix(m: Matrix): void;
  68750. }
  68751. /**
  68752. * Represents a group of points in a points cloud system
  68753. * * PCS internal tool, don't use it manually.
  68754. */
  68755. export class PointsGroup {
  68756. /**
  68757. * The group id
  68758. * @hidden
  68759. */
  68760. groupID: number;
  68761. /**
  68762. * image data for group (internal use)
  68763. * @hidden
  68764. */
  68765. _groupImageData: Nullable<ArrayBufferView>;
  68766. /**
  68767. * Image Width (internal use)
  68768. * @hidden
  68769. */
  68770. _groupImgWidth: number;
  68771. /**
  68772. * Image Height (internal use)
  68773. * @hidden
  68774. */
  68775. _groupImgHeight: number;
  68776. /**
  68777. * Custom position function (internal use)
  68778. * @hidden
  68779. */
  68780. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68781. /**
  68782. * density per facet for surface points
  68783. * @hidden
  68784. */
  68785. _groupDensity: number[];
  68786. /**
  68787. * Only when points are colored by texture carries pointer to texture list array
  68788. * @hidden
  68789. */
  68790. _textureNb: number;
  68791. /**
  68792. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68793. * PCS internal tool, don't use it manually.
  68794. * @hidden
  68795. */
  68796. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68797. }
  68798. }
  68799. declare module "babylonjs/Particles/index" {
  68800. export * from "babylonjs/Particles/baseParticleSystem";
  68801. export * from "babylonjs/Particles/EmitterTypes/index";
  68802. export * from "babylonjs/Particles/gpuParticleSystem";
  68803. export * from "babylonjs/Particles/IParticleSystem";
  68804. export * from "babylonjs/Particles/particle";
  68805. export * from "babylonjs/Particles/particleHelper";
  68806. export * from "babylonjs/Particles/particleSystem";
  68807. export * from "babylonjs/Particles/particleSystemComponent";
  68808. export * from "babylonjs/Particles/particleSystemSet";
  68809. export * from "babylonjs/Particles/solidParticle";
  68810. export * from "babylonjs/Particles/solidParticleSystem";
  68811. export * from "babylonjs/Particles/cloudPoint";
  68812. export * from "babylonjs/Particles/pointsCloudSystem";
  68813. export * from "babylonjs/Particles/subEmitter";
  68814. }
  68815. declare module "babylonjs/Physics/physicsEngineComponent" {
  68816. import { Nullable } from "babylonjs/types";
  68817. import { Observable, Observer } from "babylonjs/Misc/observable";
  68818. import { Vector3 } from "babylonjs/Maths/math.vector";
  68819. import { Mesh } from "babylonjs/Meshes/mesh";
  68820. import { ISceneComponent } from "babylonjs/sceneComponent";
  68821. import { Scene } from "babylonjs/scene";
  68822. import { Node } from "babylonjs/node";
  68823. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  68824. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68825. module "babylonjs/scene" {
  68826. interface Scene {
  68827. /** @hidden (Backing field) */
  68828. _physicsEngine: Nullable<IPhysicsEngine>;
  68829. /** @hidden */
  68830. _physicsTimeAccumulator: number;
  68831. /**
  68832. * Gets the current physics engine
  68833. * @returns a IPhysicsEngine or null if none attached
  68834. */
  68835. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68836. /**
  68837. * Enables physics to the current scene
  68838. * @param gravity defines the scene's gravity for the physics engine
  68839. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68840. * @return a boolean indicating if the physics engine was initialized
  68841. */
  68842. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68843. /**
  68844. * Disables and disposes the physics engine associated with the scene
  68845. */
  68846. disablePhysicsEngine(): void;
  68847. /**
  68848. * Gets a boolean indicating if there is an active physics engine
  68849. * @returns a boolean indicating if there is an active physics engine
  68850. */
  68851. isPhysicsEnabled(): boolean;
  68852. /**
  68853. * Deletes a physics compound impostor
  68854. * @param compound defines the compound to delete
  68855. */
  68856. deleteCompoundImpostor(compound: any): void;
  68857. /**
  68858. * An event triggered when physic simulation is about to be run
  68859. */
  68860. onBeforePhysicsObservable: Observable<Scene>;
  68861. /**
  68862. * An event triggered when physic simulation has been done
  68863. */
  68864. onAfterPhysicsObservable: Observable<Scene>;
  68865. }
  68866. }
  68867. module "babylonjs/Meshes/abstractMesh" {
  68868. interface AbstractMesh {
  68869. /** @hidden */
  68870. _physicsImpostor: Nullable<PhysicsImpostor>;
  68871. /**
  68872. * Gets or sets impostor used for physic simulation
  68873. * @see http://doc.babylonjs.com/features/physics_engine
  68874. */
  68875. physicsImpostor: Nullable<PhysicsImpostor>;
  68876. /**
  68877. * Gets the current physics impostor
  68878. * @see http://doc.babylonjs.com/features/physics_engine
  68879. * @returns a physics impostor or null
  68880. */
  68881. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68882. /** Apply a physic impulse to the mesh
  68883. * @param force defines the force to apply
  68884. * @param contactPoint defines where to apply the force
  68885. * @returns the current mesh
  68886. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  68887. */
  68888. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68889. /**
  68890. * Creates a physic joint between two meshes
  68891. * @param otherMesh defines the other mesh to use
  68892. * @param pivot1 defines the pivot to use on this mesh
  68893. * @param pivot2 defines the pivot to use on the other mesh
  68894. * @param options defines additional options (can be plugin dependent)
  68895. * @returns the current mesh
  68896. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68897. */
  68898. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68899. /** @hidden */
  68900. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68901. }
  68902. }
  68903. /**
  68904. * Defines the physics engine scene component responsible to manage a physics engine
  68905. */
  68906. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68907. /**
  68908. * The component name helpful to identify the component in the list of scene components.
  68909. */
  68910. readonly name: string;
  68911. /**
  68912. * The scene the component belongs to.
  68913. */
  68914. scene: Scene;
  68915. /**
  68916. * Creates a new instance of the component for the given scene
  68917. * @param scene Defines the scene to register the component in
  68918. */
  68919. constructor(scene: Scene);
  68920. /**
  68921. * Registers the component in a given scene
  68922. */
  68923. register(): void;
  68924. /**
  68925. * Rebuilds the elements related to this component in case of
  68926. * context lost for instance.
  68927. */
  68928. rebuild(): void;
  68929. /**
  68930. * Disposes the component and the associated ressources
  68931. */
  68932. dispose(): void;
  68933. }
  68934. }
  68935. declare module "babylonjs/Physics/physicsHelper" {
  68936. import { Nullable } from "babylonjs/types";
  68937. import { Vector3 } from "babylonjs/Maths/math.vector";
  68938. import { Mesh } from "babylonjs/Meshes/mesh";
  68939. import { Scene } from "babylonjs/scene";
  68940. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  68941. /**
  68942. * A helper for physics simulations
  68943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68944. */
  68945. export class PhysicsHelper {
  68946. private _scene;
  68947. private _physicsEngine;
  68948. /**
  68949. * Initializes the Physics helper
  68950. * @param scene Babylon.js scene
  68951. */
  68952. constructor(scene: Scene);
  68953. /**
  68954. * Applies a radial explosion impulse
  68955. * @param origin the origin of the explosion
  68956. * @param radiusOrEventOptions the radius or the options of radial explosion
  68957. * @param strength the explosion strength
  68958. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68959. * @returns A physics radial explosion event, or null
  68960. */
  68961. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68962. /**
  68963. * Applies a radial explosion force
  68964. * @param origin the origin of the explosion
  68965. * @param radiusOrEventOptions the radius or the options of radial explosion
  68966. * @param strength the explosion strength
  68967. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68968. * @returns A physics radial explosion event, or null
  68969. */
  68970. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68971. /**
  68972. * Creates a gravitational field
  68973. * @param origin the origin of the explosion
  68974. * @param radiusOrEventOptions the radius or the options of radial explosion
  68975. * @param strength the explosion strength
  68976. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68977. * @returns A physics gravitational field event, or null
  68978. */
  68979. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68980. /**
  68981. * Creates a physics updraft event
  68982. * @param origin the origin of the updraft
  68983. * @param radiusOrEventOptions the radius or the options of the updraft
  68984. * @param strength the strength of the updraft
  68985. * @param height the height of the updraft
  68986. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68987. * @returns A physics updraft event, or null
  68988. */
  68989. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68990. /**
  68991. * Creates a physics vortex event
  68992. * @param origin the of the vortex
  68993. * @param radiusOrEventOptions the radius or the options of the vortex
  68994. * @param strength the strength of the vortex
  68995. * @param height the height of the vortex
  68996. * @returns a Physics vortex event, or null
  68997. * A physics vortex event or null
  68998. */
  68999. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69000. }
  69001. /**
  69002. * Represents a physics radial explosion event
  69003. */
  69004. class PhysicsRadialExplosionEvent {
  69005. private _scene;
  69006. private _options;
  69007. private _sphere;
  69008. private _dataFetched;
  69009. /**
  69010. * Initializes a radial explosioin event
  69011. * @param _scene BabylonJS scene
  69012. * @param _options The options for the vortex event
  69013. */
  69014. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69015. /**
  69016. * Returns the data related to the radial explosion event (sphere).
  69017. * @returns The radial explosion event data
  69018. */
  69019. getData(): PhysicsRadialExplosionEventData;
  69020. /**
  69021. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69022. * @param impostor A physics imposter
  69023. * @param origin the origin of the explosion
  69024. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69025. */
  69026. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69027. /**
  69028. * Triggers affecterd impostors callbacks
  69029. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69030. */
  69031. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69032. /**
  69033. * Disposes the sphere.
  69034. * @param force Specifies if the sphere should be disposed by force
  69035. */
  69036. dispose(force?: boolean): void;
  69037. /*** Helpers ***/
  69038. private _prepareSphere;
  69039. private _intersectsWithSphere;
  69040. }
  69041. /**
  69042. * Represents a gravitational field event
  69043. */
  69044. class PhysicsGravitationalFieldEvent {
  69045. private _physicsHelper;
  69046. private _scene;
  69047. private _origin;
  69048. private _options;
  69049. private _tickCallback;
  69050. private _sphere;
  69051. private _dataFetched;
  69052. /**
  69053. * Initializes the physics gravitational field event
  69054. * @param _physicsHelper A physics helper
  69055. * @param _scene BabylonJS scene
  69056. * @param _origin The origin position of the gravitational field event
  69057. * @param _options The options for the vortex event
  69058. */
  69059. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69060. /**
  69061. * Returns the data related to the gravitational field event (sphere).
  69062. * @returns A gravitational field event
  69063. */
  69064. getData(): PhysicsGravitationalFieldEventData;
  69065. /**
  69066. * Enables the gravitational field.
  69067. */
  69068. enable(): void;
  69069. /**
  69070. * Disables the gravitational field.
  69071. */
  69072. disable(): void;
  69073. /**
  69074. * Disposes the sphere.
  69075. * @param force The force to dispose from the gravitational field event
  69076. */
  69077. dispose(force?: boolean): void;
  69078. private _tick;
  69079. }
  69080. /**
  69081. * Represents a physics updraft event
  69082. */
  69083. class PhysicsUpdraftEvent {
  69084. private _scene;
  69085. private _origin;
  69086. private _options;
  69087. private _physicsEngine;
  69088. private _originTop;
  69089. private _originDirection;
  69090. private _tickCallback;
  69091. private _cylinder;
  69092. private _cylinderPosition;
  69093. private _dataFetched;
  69094. /**
  69095. * Initializes the physics updraft event
  69096. * @param _scene BabylonJS scene
  69097. * @param _origin The origin position of the updraft
  69098. * @param _options The options for the updraft event
  69099. */
  69100. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69101. /**
  69102. * Returns the data related to the updraft event (cylinder).
  69103. * @returns A physics updraft event
  69104. */
  69105. getData(): PhysicsUpdraftEventData;
  69106. /**
  69107. * Enables the updraft.
  69108. */
  69109. enable(): void;
  69110. /**
  69111. * Disables the updraft.
  69112. */
  69113. disable(): void;
  69114. /**
  69115. * Disposes the cylinder.
  69116. * @param force Specifies if the updraft should be disposed by force
  69117. */
  69118. dispose(force?: boolean): void;
  69119. private getImpostorHitData;
  69120. private _tick;
  69121. /*** Helpers ***/
  69122. private _prepareCylinder;
  69123. private _intersectsWithCylinder;
  69124. }
  69125. /**
  69126. * Represents a physics vortex event
  69127. */
  69128. class PhysicsVortexEvent {
  69129. private _scene;
  69130. private _origin;
  69131. private _options;
  69132. private _physicsEngine;
  69133. private _originTop;
  69134. private _tickCallback;
  69135. private _cylinder;
  69136. private _cylinderPosition;
  69137. private _dataFetched;
  69138. /**
  69139. * Initializes the physics vortex event
  69140. * @param _scene The BabylonJS scene
  69141. * @param _origin The origin position of the vortex
  69142. * @param _options The options for the vortex event
  69143. */
  69144. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69145. /**
  69146. * Returns the data related to the vortex event (cylinder).
  69147. * @returns The physics vortex event data
  69148. */
  69149. getData(): PhysicsVortexEventData;
  69150. /**
  69151. * Enables the vortex.
  69152. */
  69153. enable(): void;
  69154. /**
  69155. * Disables the cortex.
  69156. */
  69157. disable(): void;
  69158. /**
  69159. * Disposes the sphere.
  69160. * @param force
  69161. */
  69162. dispose(force?: boolean): void;
  69163. private getImpostorHitData;
  69164. private _tick;
  69165. /*** Helpers ***/
  69166. private _prepareCylinder;
  69167. private _intersectsWithCylinder;
  69168. }
  69169. /**
  69170. * Options fot the radial explosion event
  69171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69172. */
  69173. export class PhysicsRadialExplosionEventOptions {
  69174. /**
  69175. * The radius of the sphere for the radial explosion.
  69176. */
  69177. radius: number;
  69178. /**
  69179. * The strenth of the explosion.
  69180. */
  69181. strength: number;
  69182. /**
  69183. * The strenght of the force in correspondence to the distance of the affected object
  69184. */
  69185. falloff: PhysicsRadialImpulseFalloff;
  69186. /**
  69187. * Sphere options for the radial explosion.
  69188. */
  69189. sphere: {
  69190. segments: number;
  69191. diameter: number;
  69192. };
  69193. /**
  69194. * Sphere options for the radial explosion.
  69195. */
  69196. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69197. }
  69198. /**
  69199. * Options fot the updraft event
  69200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69201. */
  69202. export class PhysicsUpdraftEventOptions {
  69203. /**
  69204. * The radius of the cylinder for the vortex
  69205. */
  69206. radius: number;
  69207. /**
  69208. * The strenth of the updraft.
  69209. */
  69210. strength: number;
  69211. /**
  69212. * The height of the cylinder for the updraft.
  69213. */
  69214. height: number;
  69215. /**
  69216. * The mode for the the updraft.
  69217. */
  69218. updraftMode: PhysicsUpdraftMode;
  69219. }
  69220. /**
  69221. * Options fot the vortex event
  69222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69223. */
  69224. export class PhysicsVortexEventOptions {
  69225. /**
  69226. * The radius of the cylinder for the vortex
  69227. */
  69228. radius: number;
  69229. /**
  69230. * The strenth of the vortex.
  69231. */
  69232. strength: number;
  69233. /**
  69234. * The height of the cylinder for the vortex.
  69235. */
  69236. height: number;
  69237. /**
  69238. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69239. */
  69240. centripetalForceThreshold: number;
  69241. /**
  69242. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69243. */
  69244. centripetalForceMultiplier: number;
  69245. /**
  69246. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69247. */
  69248. centrifugalForceMultiplier: number;
  69249. /**
  69250. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69251. */
  69252. updraftForceMultiplier: number;
  69253. }
  69254. /**
  69255. * The strenght of the force in correspondence to the distance of the affected object
  69256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69257. */
  69258. export enum PhysicsRadialImpulseFalloff {
  69259. /** Defines that impulse is constant in strength across it's whole radius */
  69260. Constant = 0,
  69261. /** Defines that impulse gets weaker if it's further from the origin */
  69262. Linear = 1
  69263. }
  69264. /**
  69265. * The strength of the force in correspondence to the distance of the affected object
  69266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69267. */
  69268. export enum PhysicsUpdraftMode {
  69269. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69270. Center = 0,
  69271. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69272. Perpendicular = 1
  69273. }
  69274. /**
  69275. * Interface for a physics hit data
  69276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69277. */
  69278. export interface PhysicsHitData {
  69279. /**
  69280. * The force applied at the contact point
  69281. */
  69282. force: Vector3;
  69283. /**
  69284. * The contact point
  69285. */
  69286. contactPoint: Vector3;
  69287. /**
  69288. * The distance from the origin to the contact point
  69289. */
  69290. distanceFromOrigin: number;
  69291. }
  69292. /**
  69293. * Interface for radial explosion event data
  69294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69295. */
  69296. export interface PhysicsRadialExplosionEventData {
  69297. /**
  69298. * A sphere used for the radial explosion event
  69299. */
  69300. sphere: Mesh;
  69301. }
  69302. /**
  69303. * Interface for gravitational field event data
  69304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69305. */
  69306. export interface PhysicsGravitationalFieldEventData {
  69307. /**
  69308. * A sphere mesh used for the gravitational field event
  69309. */
  69310. sphere: Mesh;
  69311. }
  69312. /**
  69313. * Interface for updraft event data
  69314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69315. */
  69316. export interface PhysicsUpdraftEventData {
  69317. /**
  69318. * A cylinder used for the updraft event
  69319. */
  69320. cylinder: Mesh;
  69321. }
  69322. /**
  69323. * Interface for vortex event data
  69324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69325. */
  69326. export interface PhysicsVortexEventData {
  69327. /**
  69328. * A cylinder used for the vortex event
  69329. */
  69330. cylinder: Mesh;
  69331. }
  69332. /**
  69333. * Interface for an affected physics impostor
  69334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69335. */
  69336. export interface PhysicsAffectedImpostorWithData {
  69337. /**
  69338. * The impostor affected by the effect
  69339. */
  69340. impostor: PhysicsImpostor;
  69341. /**
  69342. * The data about the hit/horce from the explosion
  69343. */
  69344. hitData: PhysicsHitData;
  69345. }
  69346. }
  69347. declare module "babylonjs/Physics/Plugins/index" {
  69348. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  69349. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  69350. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  69351. }
  69352. declare module "babylonjs/Physics/index" {
  69353. export * from "babylonjs/Physics/IPhysicsEngine";
  69354. export * from "babylonjs/Physics/physicsEngine";
  69355. export * from "babylonjs/Physics/physicsEngineComponent";
  69356. export * from "babylonjs/Physics/physicsHelper";
  69357. export * from "babylonjs/Physics/physicsImpostor";
  69358. export * from "babylonjs/Physics/physicsJoint";
  69359. export * from "babylonjs/Physics/Plugins/index";
  69360. }
  69361. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  69362. /** @hidden */
  69363. export var blackAndWhitePixelShader: {
  69364. name: string;
  69365. shader: string;
  69366. };
  69367. }
  69368. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  69369. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69370. import { Camera } from "babylonjs/Cameras/camera";
  69371. import { Engine } from "babylonjs/Engines/engine";
  69372. import "babylonjs/Shaders/blackAndWhite.fragment";
  69373. /**
  69374. * Post process used to render in black and white
  69375. */
  69376. export class BlackAndWhitePostProcess extends PostProcess {
  69377. /**
  69378. * Linear about to convert he result to black and white (default: 1)
  69379. */
  69380. degree: number;
  69381. /**
  69382. * Creates a black and white post process
  69383. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69384. * @param name The name of the effect.
  69385. * @param options The required width/height ratio to downsize to before computing the render pass.
  69386. * @param camera The camera to apply the render pass to.
  69387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69388. * @param engine The engine which the post process will be applied. (default: current engine)
  69389. * @param reusable If the post process can be reused on the same frame. (default: false)
  69390. */
  69391. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69392. }
  69393. }
  69394. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  69395. import { Nullable } from "babylonjs/types";
  69396. import { Camera } from "babylonjs/Cameras/camera";
  69397. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69398. import { Engine } from "babylonjs/Engines/engine";
  69399. /**
  69400. * This represents a set of one or more post processes in Babylon.
  69401. * A post process can be used to apply a shader to a texture after it is rendered.
  69402. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69403. */
  69404. export class PostProcessRenderEffect {
  69405. private _postProcesses;
  69406. private _getPostProcesses;
  69407. private _singleInstance;
  69408. private _cameras;
  69409. private _indicesForCamera;
  69410. /**
  69411. * Name of the effect
  69412. * @hidden
  69413. */
  69414. _name: string;
  69415. /**
  69416. * Instantiates a post process render effect.
  69417. * A post process can be used to apply a shader to a texture after it is rendered.
  69418. * @param engine The engine the effect is tied to
  69419. * @param name The name of the effect
  69420. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69421. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69422. */
  69423. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69424. /**
  69425. * Checks if all the post processes in the effect are supported.
  69426. */
  69427. get isSupported(): boolean;
  69428. /**
  69429. * Updates the current state of the effect
  69430. * @hidden
  69431. */
  69432. _update(): void;
  69433. /**
  69434. * Attaches the effect on cameras
  69435. * @param cameras The camera to attach to.
  69436. * @hidden
  69437. */
  69438. _attachCameras(cameras: Camera): void;
  69439. /**
  69440. * Attaches the effect on cameras
  69441. * @param cameras The camera to attach to.
  69442. * @hidden
  69443. */
  69444. _attachCameras(cameras: Camera[]): void;
  69445. /**
  69446. * Detaches the effect on cameras
  69447. * @param cameras The camera to detatch from.
  69448. * @hidden
  69449. */
  69450. _detachCameras(cameras: Camera): void;
  69451. /**
  69452. * Detatches the effect on cameras
  69453. * @param cameras The camera to detatch from.
  69454. * @hidden
  69455. */
  69456. _detachCameras(cameras: Camera[]): void;
  69457. /**
  69458. * Enables the effect on given cameras
  69459. * @param cameras The camera to enable.
  69460. * @hidden
  69461. */
  69462. _enable(cameras: Camera): void;
  69463. /**
  69464. * Enables the effect on given cameras
  69465. * @param cameras The camera to enable.
  69466. * @hidden
  69467. */
  69468. _enable(cameras: Nullable<Camera[]>): void;
  69469. /**
  69470. * Disables the effect on the given cameras
  69471. * @param cameras The camera to disable.
  69472. * @hidden
  69473. */
  69474. _disable(cameras: Camera): void;
  69475. /**
  69476. * Disables the effect on the given cameras
  69477. * @param cameras The camera to disable.
  69478. * @hidden
  69479. */
  69480. _disable(cameras: Nullable<Camera[]>): void;
  69481. /**
  69482. * Gets a list of the post processes contained in the effect.
  69483. * @param camera The camera to get the post processes on.
  69484. * @returns The list of the post processes in the effect.
  69485. */
  69486. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69487. }
  69488. }
  69489. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  69490. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69491. /** @hidden */
  69492. export var extractHighlightsPixelShader: {
  69493. name: string;
  69494. shader: string;
  69495. };
  69496. }
  69497. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  69498. import { Nullable } from "babylonjs/types";
  69499. import { Camera } from "babylonjs/Cameras/camera";
  69500. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69501. import { Engine } from "babylonjs/Engines/engine";
  69502. import "babylonjs/Shaders/extractHighlights.fragment";
  69503. /**
  69504. * 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.
  69505. */
  69506. export class ExtractHighlightsPostProcess extends PostProcess {
  69507. /**
  69508. * The luminance threshold, pixels below this value will be set to black.
  69509. */
  69510. threshold: number;
  69511. /** @hidden */
  69512. _exposure: number;
  69513. /**
  69514. * Post process which has the input texture to be used when performing highlight extraction
  69515. * @hidden
  69516. */
  69517. _inputPostProcess: Nullable<PostProcess>;
  69518. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69519. }
  69520. }
  69521. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  69522. /** @hidden */
  69523. export var bloomMergePixelShader: {
  69524. name: string;
  69525. shader: string;
  69526. };
  69527. }
  69528. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  69529. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69530. import { Nullable } from "babylonjs/types";
  69531. import { Engine } from "babylonjs/Engines/engine";
  69532. import { Camera } from "babylonjs/Cameras/camera";
  69533. import "babylonjs/Shaders/bloomMerge.fragment";
  69534. /**
  69535. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69536. */
  69537. export class BloomMergePostProcess extends PostProcess {
  69538. /** Weight of the bloom to be added to the original input. */
  69539. weight: number;
  69540. /**
  69541. * Creates a new instance of @see BloomMergePostProcess
  69542. * @param name The name of the effect.
  69543. * @param originalFromInput Post process which's input will be used for the merge.
  69544. * @param blurred Blurred highlights post process which's output will be used.
  69545. * @param weight Weight of the bloom to be added to the original input.
  69546. * @param options The required width/height ratio to downsize to before computing the render pass.
  69547. * @param camera The camera to apply the render pass to.
  69548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69549. * @param engine The engine which the post process will be applied. (default: current engine)
  69550. * @param reusable If the post process can be reused on the same frame. (default: false)
  69551. * @param textureType Type of textures used when performing the post process. (default: 0)
  69552. * @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)
  69553. */
  69554. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69555. /** Weight of the bloom to be added to the original input. */
  69556. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69557. }
  69558. }
  69559. declare module "babylonjs/PostProcesses/bloomEffect" {
  69560. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69561. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69562. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69563. import { Camera } from "babylonjs/Cameras/camera";
  69564. import { Scene } from "babylonjs/scene";
  69565. /**
  69566. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69567. */
  69568. export class BloomEffect extends PostProcessRenderEffect {
  69569. private bloomScale;
  69570. /**
  69571. * @hidden Internal
  69572. */
  69573. _effects: Array<PostProcess>;
  69574. /**
  69575. * @hidden Internal
  69576. */
  69577. _downscale: ExtractHighlightsPostProcess;
  69578. private _blurX;
  69579. private _blurY;
  69580. private _merge;
  69581. /**
  69582. * The luminance threshold to find bright areas of the image to bloom.
  69583. */
  69584. get threshold(): number;
  69585. set threshold(value: number);
  69586. /**
  69587. * The strength of the bloom.
  69588. */
  69589. get weight(): number;
  69590. set weight(value: number);
  69591. /**
  69592. * Specifies the size of the bloom blur kernel, relative to the final output size
  69593. */
  69594. get kernel(): number;
  69595. set kernel(value: number);
  69596. /**
  69597. * Creates a new instance of @see BloomEffect
  69598. * @param scene The scene the effect belongs to.
  69599. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69600. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69601. * @param bloomWeight The the strength of bloom.
  69602. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69603. * @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)
  69604. */
  69605. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69606. /**
  69607. * Disposes each of the internal effects for a given camera.
  69608. * @param camera The camera to dispose the effect on.
  69609. */
  69610. disposeEffects(camera: Camera): void;
  69611. /**
  69612. * @hidden Internal
  69613. */
  69614. _updateEffects(): void;
  69615. /**
  69616. * Internal
  69617. * @returns if all the contained post processes are ready.
  69618. * @hidden
  69619. */
  69620. _isReady(): boolean;
  69621. }
  69622. }
  69623. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  69624. /** @hidden */
  69625. export var chromaticAberrationPixelShader: {
  69626. name: string;
  69627. shader: string;
  69628. };
  69629. }
  69630. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  69631. import { Vector2 } from "babylonjs/Maths/math.vector";
  69632. import { Nullable } from "babylonjs/types";
  69633. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69634. import { Camera } from "babylonjs/Cameras/camera";
  69635. import { Engine } from "babylonjs/Engines/engine";
  69636. import "babylonjs/Shaders/chromaticAberration.fragment";
  69637. /**
  69638. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69639. */
  69640. export class ChromaticAberrationPostProcess extends PostProcess {
  69641. /**
  69642. * The amount of seperation of rgb channels (default: 30)
  69643. */
  69644. aberrationAmount: number;
  69645. /**
  69646. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69647. */
  69648. radialIntensity: number;
  69649. /**
  69650. * 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))
  69651. */
  69652. direction: Vector2;
  69653. /**
  69654. * 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))
  69655. */
  69656. centerPosition: Vector2;
  69657. /**
  69658. * Creates a new instance ChromaticAberrationPostProcess
  69659. * @param name The name of the effect.
  69660. * @param screenWidth The width of the screen to apply the effect on.
  69661. * @param screenHeight The height of the screen to apply the effect on.
  69662. * @param options The required width/height ratio to downsize to before computing the render pass.
  69663. * @param camera The camera to apply the render pass to.
  69664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69665. * @param engine The engine which the post process will be applied. (default: current engine)
  69666. * @param reusable If the post process can be reused on the same frame. (default: false)
  69667. * @param textureType Type of textures used when performing the post process. (default: 0)
  69668. * @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)
  69669. */
  69670. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69671. }
  69672. }
  69673. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  69674. /** @hidden */
  69675. export var circleOfConfusionPixelShader: {
  69676. name: string;
  69677. shader: string;
  69678. };
  69679. }
  69680. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  69681. import { Nullable } from "babylonjs/types";
  69682. import { Engine } from "babylonjs/Engines/engine";
  69683. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69684. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69685. import { Camera } from "babylonjs/Cameras/camera";
  69686. import "babylonjs/Shaders/circleOfConfusion.fragment";
  69687. /**
  69688. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69689. */
  69690. export class CircleOfConfusionPostProcess extends PostProcess {
  69691. /**
  69692. * 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.
  69693. */
  69694. lensSize: number;
  69695. /**
  69696. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69697. */
  69698. fStop: number;
  69699. /**
  69700. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69701. */
  69702. focusDistance: number;
  69703. /**
  69704. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69705. */
  69706. focalLength: number;
  69707. private _depthTexture;
  69708. /**
  69709. * Creates a new instance CircleOfConfusionPostProcess
  69710. * @param name The name of the effect.
  69711. * @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.
  69712. * @param options The required width/height ratio to downsize to before computing the render pass.
  69713. * @param camera The camera to apply the render pass to.
  69714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69715. * @param engine The engine which the post process will be applied. (default: current engine)
  69716. * @param reusable If the post process can be reused on the same frame. (default: false)
  69717. * @param textureType Type of textures used when performing the post process. (default: 0)
  69718. * @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)
  69719. */
  69720. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69721. /**
  69722. * 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.
  69723. */
  69724. set depthTexture(value: RenderTargetTexture);
  69725. }
  69726. }
  69727. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  69728. /** @hidden */
  69729. export var colorCorrectionPixelShader: {
  69730. name: string;
  69731. shader: string;
  69732. };
  69733. }
  69734. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  69735. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69736. import { Engine } from "babylonjs/Engines/engine";
  69737. import { Camera } from "babylonjs/Cameras/camera";
  69738. import "babylonjs/Shaders/colorCorrection.fragment";
  69739. /**
  69740. *
  69741. * This post-process allows the modification of rendered colors by using
  69742. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69743. *
  69744. * The object needs to be provided an url to a texture containing the color
  69745. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69746. * Use an image editing software to tweak the LUT to match your needs.
  69747. *
  69748. * For an example of a color LUT, see here:
  69749. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69750. * For explanations on color grading, see here:
  69751. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69752. *
  69753. */
  69754. export class ColorCorrectionPostProcess extends PostProcess {
  69755. private _colorTableTexture;
  69756. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69757. }
  69758. }
  69759. declare module "babylonjs/Shaders/convolution.fragment" {
  69760. /** @hidden */
  69761. export var convolutionPixelShader: {
  69762. name: string;
  69763. shader: string;
  69764. };
  69765. }
  69766. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  69767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69768. import { Nullable } from "babylonjs/types";
  69769. import { Camera } from "babylonjs/Cameras/camera";
  69770. import { Engine } from "babylonjs/Engines/engine";
  69771. import "babylonjs/Shaders/convolution.fragment";
  69772. /**
  69773. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69774. * input texture to perform effects such as edge detection or sharpening
  69775. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69776. */
  69777. export class ConvolutionPostProcess extends PostProcess {
  69778. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69779. kernel: number[];
  69780. /**
  69781. * Creates a new instance ConvolutionPostProcess
  69782. * @param name The name of the effect.
  69783. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69784. * @param options The required width/height ratio to downsize to before computing the render pass.
  69785. * @param camera The camera to apply the render pass to.
  69786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69787. * @param engine The engine which the post process will be applied. (default: current engine)
  69788. * @param reusable If the post process can be reused on the same frame. (default: false)
  69789. * @param textureType Type of textures used when performing the post process. (default: 0)
  69790. */
  69791. constructor(name: string,
  69792. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69793. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69794. /**
  69795. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69796. */
  69797. static EdgeDetect0Kernel: number[];
  69798. /**
  69799. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69800. */
  69801. static EdgeDetect1Kernel: number[];
  69802. /**
  69803. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69804. */
  69805. static EdgeDetect2Kernel: number[];
  69806. /**
  69807. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69808. */
  69809. static SharpenKernel: number[];
  69810. /**
  69811. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69812. */
  69813. static EmbossKernel: number[];
  69814. /**
  69815. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69816. */
  69817. static GaussianKernel: number[];
  69818. }
  69819. }
  69820. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  69821. import { Nullable } from "babylonjs/types";
  69822. import { Vector2 } from "babylonjs/Maths/math.vector";
  69823. import { Camera } from "babylonjs/Cameras/camera";
  69824. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69825. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69826. import { Engine } from "babylonjs/Engines/engine";
  69827. import { Scene } from "babylonjs/scene";
  69828. /**
  69829. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69830. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69831. * based on samples that have a large difference in distance than the center pixel.
  69832. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69833. */
  69834. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69835. direction: Vector2;
  69836. /**
  69837. * Creates a new instance CircleOfConfusionPostProcess
  69838. * @param name The name of the effect.
  69839. * @param scene The scene the effect belongs to.
  69840. * @param direction The direction the blur should be applied.
  69841. * @param kernel The size of the kernel used to blur.
  69842. * @param options The required width/height ratio to downsize to before computing the render pass.
  69843. * @param camera The camera to apply the render pass to.
  69844. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69845. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69847. * @param engine The engine which the post process will be applied. (default: current engine)
  69848. * @param reusable If the post process can be reused on the same frame. (default: false)
  69849. * @param textureType Type of textures used when performing the post process. (default: 0)
  69850. * @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)
  69851. */
  69852. 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);
  69853. }
  69854. }
  69855. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  69856. /** @hidden */
  69857. export var depthOfFieldMergePixelShader: {
  69858. name: string;
  69859. shader: string;
  69860. };
  69861. }
  69862. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  69863. import { Nullable } from "babylonjs/types";
  69864. import { Camera } from "babylonjs/Cameras/camera";
  69865. import { Effect } from "babylonjs/Materials/effect";
  69866. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69867. import { Engine } from "babylonjs/Engines/engine";
  69868. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  69869. /**
  69870. * Options to be set when merging outputs from the default pipeline.
  69871. */
  69872. export class DepthOfFieldMergePostProcessOptions {
  69873. /**
  69874. * The original image to merge on top of
  69875. */
  69876. originalFromInput: PostProcess;
  69877. /**
  69878. * Parameters to perform the merge of the depth of field effect
  69879. */
  69880. depthOfField?: {
  69881. circleOfConfusion: PostProcess;
  69882. blurSteps: Array<PostProcess>;
  69883. };
  69884. /**
  69885. * Parameters to perform the merge of bloom effect
  69886. */
  69887. bloom?: {
  69888. blurred: PostProcess;
  69889. weight: number;
  69890. };
  69891. }
  69892. /**
  69893. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69894. */
  69895. export class DepthOfFieldMergePostProcess extends PostProcess {
  69896. private blurSteps;
  69897. /**
  69898. * Creates a new instance of DepthOfFieldMergePostProcess
  69899. * @param name The name of the effect.
  69900. * @param originalFromInput Post process which's input will be used for the merge.
  69901. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69902. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69903. * @param options The required width/height ratio to downsize to before computing the render pass.
  69904. * @param camera The camera to apply the render pass to.
  69905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69906. * @param engine The engine which the post process will be applied. (default: current engine)
  69907. * @param reusable If the post process can be reused on the same frame. (default: false)
  69908. * @param textureType Type of textures used when performing the post process. (default: 0)
  69909. * @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)
  69910. */
  69911. 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);
  69912. /**
  69913. * Updates the effect with the current post process compile time values and recompiles the shader.
  69914. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69915. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69916. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69917. * @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
  69918. * @param onCompiled Called when the shader has been compiled.
  69919. * @param onError Called if there is an error when compiling a shader.
  69920. */
  69921. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69922. }
  69923. }
  69924. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  69925. import { Nullable } from "babylonjs/types";
  69926. import { Camera } from "babylonjs/Cameras/camera";
  69927. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69928. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69929. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69930. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69931. import { Scene } from "babylonjs/scene";
  69932. /**
  69933. * Specifies the level of max blur that should be applied when using the depth of field effect
  69934. */
  69935. export enum DepthOfFieldEffectBlurLevel {
  69936. /**
  69937. * Subtle blur
  69938. */
  69939. Low = 0,
  69940. /**
  69941. * Medium blur
  69942. */
  69943. Medium = 1,
  69944. /**
  69945. * Large blur
  69946. */
  69947. High = 2
  69948. }
  69949. /**
  69950. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69951. */
  69952. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69953. private _circleOfConfusion;
  69954. /**
  69955. * @hidden Internal, blurs from high to low
  69956. */
  69957. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69958. private _depthOfFieldBlurY;
  69959. private _dofMerge;
  69960. /**
  69961. * @hidden Internal post processes in depth of field effect
  69962. */
  69963. _effects: Array<PostProcess>;
  69964. /**
  69965. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69966. */
  69967. set focalLength(value: number);
  69968. get focalLength(): number;
  69969. /**
  69970. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69971. */
  69972. set fStop(value: number);
  69973. get fStop(): number;
  69974. /**
  69975. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69976. */
  69977. set focusDistance(value: number);
  69978. get focusDistance(): number;
  69979. /**
  69980. * 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.
  69981. */
  69982. set lensSize(value: number);
  69983. get lensSize(): number;
  69984. /**
  69985. * Creates a new instance DepthOfFieldEffect
  69986. * @param scene The scene the effect belongs to.
  69987. * @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.
  69988. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69989. * @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)
  69990. */
  69991. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69992. /**
  69993. * Get the current class name of the current effet
  69994. * @returns "DepthOfFieldEffect"
  69995. */
  69996. getClassName(): string;
  69997. /**
  69998. * 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.
  69999. */
  70000. set depthTexture(value: RenderTargetTexture);
  70001. /**
  70002. * Disposes each of the internal effects for a given camera.
  70003. * @param camera The camera to dispose the effect on.
  70004. */
  70005. disposeEffects(camera: Camera): void;
  70006. /**
  70007. * @hidden Internal
  70008. */
  70009. _updateEffects(): void;
  70010. /**
  70011. * Internal
  70012. * @returns if all the contained post processes are ready.
  70013. * @hidden
  70014. */
  70015. _isReady(): boolean;
  70016. }
  70017. }
  70018. declare module "babylonjs/Shaders/displayPass.fragment" {
  70019. /** @hidden */
  70020. export var displayPassPixelShader: {
  70021. name: string;
  70022. shader: string;
  70023. };
  70024. }
  70025. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  70026. import { Nullable } from "babylonjs/types";
  70027. import { Camera } from "babylonjs/Cameras/camera";
  70028. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70029. import { Engine } from "babylonjs/Engines/engine";
  70030. import "babylonjs/Shaders/displayPass.fragment";
  70031. /**
  70032. * DisplayPassPostProcess which produces an output the same as it's input
  70033. */
  70034. export class DisplayPassPostProcess extends PostProcess {
  70035. /**
  70036. * Creates the DisplayPassPostProcess
  70037. * @param name The name of the effect.
  70038. * @param options The required width/height ratio to downsize to before computing the render pass.
  70039. * @param camera The camera to apply the render pass to.
  70040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70041. * @param engine The engine which the post process will be applied. (default: current engine)
  70042. * @param reusable If the post process can be reused on the same frame. (default: false)
  70043. */
  70044. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70045. }
  70046. }
  70047. declare module "babylonjs/Shaders/filter.fragment" {
  70048. /** @hidden */
  70049. export var filterPixelShader: {
  70050. name: string;
  70051. shader: string;
  70052. };
  70053. }
  70054. declare module "babylonjs/PostProcesses/filterPostProcess" {
  70055. import { Nullable } from "babylonjs/types";
  70056. import { Matrix } from "babylonjs/Maths/math.vector";
  70057. import { Camera } from "babylonjs/Cameras/camera";
  70058. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70059. import { Engine } from "babylonjs/Engines/engine";
  70060. import "babylonjs/Shaders/filter.fragment";
  70061. /**
  70062. * Applies a kernel filter to the image
  70063. */
  70064. export class FilterPostProcess extends PostProcess {
  70065. /** The matrix to be applied to the image */
  70066. kernelMatrix: Matrix;
  70067. /**
  70068. *
  70069. * @param name The name of the effect.
  70070. * @param kernelMatrix The matrix to be applied to the image
  70071. * @param options The required width/height ratio to downsize to before computing the render pass.
  70072. * @param camera The camera to apply the render pass to.
  70073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70074. * @param engine The engine which the post process will be applied. (default: current engine)
  70075. * @param reusable If the post process can be reused on the same frame. (default: false)
  70076. */
  70077. constructor(name: string,
  70078. /** The matrix to be applied to the image */
  70079. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70080. }
  70081. }
  70082. declare module "babylonjs/Shaders/fxaa.fragment" {
  70083. /** @hidden */
  70084. export var fxaaPixelShader: {
  70085. name: string;
  70086. shader: string;
  70087. };
  70088. }
  70089. declare module "babylonjs/Shaders/fxaa.vertex" {
  70090. /** @hidden */
  70091. export var fxaaVertexShader: {
  70092. name: string;
  70093. shader: string;
  70094. };
  70095. }
  70096. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  70097. import { Nullable } from "babylonjs/types";
  70098. import { Camera } from "babylonjs/Cameras/camera";
  70099. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70100. import { Engine } from "babylonjs/Engines/engine";
  70101. import "babylonjs/Shaders/fxaa.fragment";
  70102. import "babylonjs/Shaders/fxaa.vertex";
  70103. /**
  70104. * Fxaa post process
  70105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70106. */
  70107. export class FxaaPostProcess extends PostProcess {
  70108. /** @hidden */
  70109. texelWidth: number;
  70110. /** @hidden */
  70111. texelHeight: number;
  70112. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70113. private _getDefines;
  70114. }
  70115. }
  70116. declare module "babylonjs/Shaders/grain.fragment" {
  70117. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70118. /** @hidden */
  70119. export var grainPixelShader: {
  70120. name: string;
  70121. shader: string;
  70122. };
  70123. }
  70124. declare module "babylonjs/PostProcesses/grainPostProcess" {
  70125. import { Nullable } from "babylonjs/types";
  70126. import { Camera } from "babylonjs/Cameras/camera";
  70127. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70128. import { Engine } from "babylonjs/Engines/engine";
  70129. import "babylonjs/Shaders/grain.fragment";
  70130. /**
  70131. * The GrainPostProcess adds noise to the image at mid luminance levels
  70132. */
  70133. export class GrainPostProcess extends PostProcess {
  70134. /**
  70135. * The intensity of the grain added (default: 30)
  70136. */
  70137. intensity: number;
  70138. /**
  70139. * If the grain should be randomized on every frame
  70140. */
  70141. animated: boolean;
  70142. /**
  70143. * Creates a new instance of @see GrainPostProcess
  70144. * @param name The name of the effect.
  70145. * @param options The required width/height ratio to downsize to before computing the render pass.
  70146. * @param camera The camera to apply the render pass to.
  70147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70148. * @param engine The engine which the post process will be applied. (default: current engine)
  70149. * @param reusable If the post process can be reused on the same frame. (default: false)
  70150. * @param textureType Type of textures used when performing the post process. (default: 0)
  70151. * @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)
  70152. */
  70153. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70154. }
  70155. }
  70156. declare module "babylonjs/Shaders/highlights.fragment" {
  70157. /** @hidden */
  70158. export var highlightsPixelShader: {
  70159. name: string;
  70160. shader: string;
  70161. };
  70162. }
  70163. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  70164. import { Nullable } from "babylonjs/types";
  70165. import { Camera } from "babylonjs/Cameras/camera";
  70166. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70167. import { Engine } from "babylonjs/Engines/engine";
  70168. import "babylonjs/Shaders/highlights.fragment";
  70169. /**
  70170. * Extracts highlights from the image
  70171. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70172. */
  70173. export class HighlightsPostProcess extends PostProcess {
  70174. /**
  70175. * Extracts highlights from the image
  70176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70177. * @param name The name of the effect.
  70178. * @param options The required width/height ratio to downsize to before computing the render pass.
  70179. * @param camera The camera to apply the render pass to.
  70180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70181. * @param engine The engine which the post process will be applied. (default: current engine)
  70182. * @param reusable If the post process can be reused on the same frame. (default: false)
  70183. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70184. */
  70185. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70186. }
  70187. }
  70188. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  70189. /** @hidden */
  70190. export var mrtFragmentDeclaration: {
  70191. name: string;
  70192. shader: string;
  70193. };
  70194. }
  70195. declare module "babylonjs/Shaders/geometry.fragment" {
  70196. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  70197. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  70198. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  70199. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  70200. /** @hidden */
  70201. export var geometryPixelShader: {
  70202. name: string;
  70203. shader: string;
  70204. };
  70205. }
  70206. declare module "babylonjs/Shaders/geometry.vertex" {
  70207. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70208. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70209. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70210. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70211. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70212. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70213. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70214. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  70215. /** @hidden */
  70216. export var geometryVertexShader: {
  70217. name: string;
  70218. shader: string;
  70219. };
  70220. }
  70221. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  70222. import { Matrix } from "babylonjs/Maths/math.vector";
  70223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70224. import { Mesh } from "babylonjs/Meshes/mesh";
  70225. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  70226. import { Effect } from "babylonjs/Materials/effect";
  70227. import { Scene } from "babylonjs/scene";
  70228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70229. import "babylonjs/Shaders/geometry.fragment";
  70230. import "babylonjs/Shaders/geometry.vertex";
  70231. /** @hidden */
  70232. interface ISavedTransformationMatrix {
  70233. world: Matrix;
  70234. viewProjection: Matrix;
  70235. }
  70236. /**
  70237. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  70238. */
  70239. export class GeometryBufferRenderer {
  70240. /**
  70241. * Constant used to retrieve the position texture index in the G-Buffer textures array
  70242. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  70243. */
  70244. static readonly POSITION_TEXTURE_TYPE: number;
  70245. /**
  70246. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  70247. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  70248. */
  70249. static readonly VELOCITY_TEXTURE_TYPE: number;
  70250. /**
  70251. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  70252. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  70253. */
  70254. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  70255. /**
  70256. * Dictionary used to store the previous transformation matrices of each rendered mesh
  70257. * in order to compute objects velocities when enableVelocity is set to "true"
  70258. * @hidden
  70259. */
  70260. _previousTransformationMatrices: {
  70261. [index: number]: ISavedTransformationMatrix;
  70262. };
  70263. /**
  70264. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  70265. * in order to compute objects velocities when enableVelocity is set to "true"
  70266. * @hidden
  70267. */
  70268. _previousBonesTransformationMatrices: {
  70269. [index: number]: Float32Array;
  70270. };
  70271. /**
  70272. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  70273. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  70274. */
  70275. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  70276. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  70277. renderTransparentMeshes: boolean;
  70278. private _scene;
  70279. private _multiRenderTarget;
  70280. private _ratio;
  70281. private _enablePosition;
  70282. private _enableVelocity;
  70283. private _enableReflectivity;
  70284. private _positionIndex;
  70285. private _velocityIndex;
  70286. private _reflectivityIndex;
  70287. protected _effect: Effect;
  70288. protected _cachedDefines: string;
  70289. /**
  70290. * Set the render list (meshes to be rendered) used in the G buffer.
  70291. */
  70292. set renderList(meshes: Mesh[]);
  70293. /**
  70294. * Gets wether or not G buffer are supported by the running hardware.
  70295. * This requires draw buffer supports
  70296. */
  70297. get isSupported(): boolean;
  70298. /**
  70299. * Returns the index of the given texture type in the G-Buffer textures array
  70300. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  70301. * @returns the index of the given texture type in the G-Buffer textures array
  70302. */
  70303. getTextureIndex(textureType: number): number;
  70304. /**
  70305. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70306. */
  70307. get enablePosition(): boolean;
  70308. /**
  70309. * Sets whether or not objects positions are enabled for the G buffer.
  70310. */
  70311. set enablePosition(enable: boolean);
  70312. /**
  70313. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70314. */
  70315. get enableVelocity(): boolean;
  70316. /**
  70317. * Sets wether or not objects velocities are enabled for the G buffer.
  70318. */
  70319. set enableVelocity(enable: boolean);
  70320. /**
  70321. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70322. */
  70323. get enableReflectivity(): boolean;
  70324. /**
  70325. * Sets wether or not objects roughness are enabled for the G buffer.
  70326. */
  70327. set enableReflectivity(enable: boolean);
  70328. /**
  70329. * Gets the scene associated with the buffer.
  70330. */
  70331. get scene(): Scene;
  70332. /**
  70333. * Gets the ratio used by the buffer during its creation.
  70334. * How big is the buffer related to the main canvas.
  70335. */
  70336. get ratio(): number;
  70337. /** @hidden */
  70338. static _SceneComponentInitialization: (scene: Scene) => void;
  70339. /**
  70340. * Creates a new G Buffer for the scene
  70341. * @param scene The scene the buffer belongs to
  70342. * @param ratio How big is the buffer related to the main canvas.
  70343. */
  70344. constructor(scene: Scene, ratio?: number);
  70345. /**
  70346. * Checks wether everything is ready to render a submesh to the G buffer.
  70347. * @param subMesh the submesh to check readiness for
  70348. * @param useInstances is the mesh drawn using instance or not
  70349. * @returns true if ready otherwise false
  70350. */
  70351. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70352. /**
  70353. * Gets the current underlying G Buffer.
  70354. * @returns the buffer
  70355. */
  70356. getGBuffer(): MultiRenderTarget;
  70357. /**
  70358. * Gets the number of samples used to render the buffer (anti aliasing).
  70359. */
  70360. get samples(): number;
  70361. /**
  70362. * Sets the number of samples used to render the buffer (anti aliasing).
  70363. */
  70364. set samples(value: number);
  70365. /**
  70366. * Disposes the renderer and frees up associated resources.
  70367. */
  70368. dispose(): void;
  70369. protected _createRenderTargets(): void;
  70370. private _copyBonesTransformationMatrices;
  70371. }
  70372. }
  70373. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  70374. import { Nullable } from "babylonjs/types";
  70375. import { Scene } from "babylonjs/scene";
  70376. import { ISceneComponent } from "babylonjs/sceneComponent";
  70377. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  70378. module "babylonjs/scene" {
  70379. interface Scene {
  70380. /** @hidden (Backing field) */
  70381. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70382. /**
  70383. * Gets or Sets the current geometry buffer associated to the scene.
  70384. */
  70385. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70386. /**
  70387. * Enables a GeometryBufferRender and associates it with the scene
  70388. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70389. * @returns the GeometryBufferRenderer
  70390. */
  70391. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70392. /**
  70393. * Disables the GeometryBufferRender associated with the scene
  70394. */
  70395. disableGeometryBufferRenderer(): void;
  70396. }
  70397. }
  70398. /**
  70399. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70400. * in several rendering techniques.
  70401. */
  70402. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70403. /**
  70404. * The component name helpful to identify the component in the list of scene components.
  70405. */
  70406. readonly name: string;
  70407. /**
  70408. * The scene the component belongs to.
  70409. */
  70410. scene: Scene;
  70411. /**
  70412. * Creates a new instance of the component for the given scene
  70413. * @param scene Defines the scene to register the component in
  70414. */
  70415. constructor(scene: Scene);
  70416. /**
  70417. * Registers the component in a given scene
  70418. */
  70419. register(): void;
  70420. /**
  70421. * Rebuilds the elements related to this component in case of
  70422. * context lost for instance.
  70423. */
  70424. rebuild(): void;
  70425. /**
  70426. * Disposes the component and the associated ressources
  70427. */
  70428. dispose(): void;
  70429. private _gatherRenderTargets;
  70430. }
  70431. }
  70432. declare module "babylonjs/Shaders/motionBlur.fragment" {
  70433. /** @hidden */
  70434. export var motionBlurPixelShader: {
  70435. name: string;
  70436. shader: string;
  70437. };
  70438. }
  70439. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  70440. import { Nullable } from "babylonjs/types";
  70441. import { Camera } from "babylonjs/Cameras/camera";
  70442. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70443. import { Scene } from "babylonjs/scene";
  70444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70445. import "babylonjs/Animations/animatable";
  70446. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70447. import "babylonjs/Shaders/motionBlur.fragment";
  70448. import { Engine } from "babylonjs/Engines/engine";
  70449. /**
  70450. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70451. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70452. * As an example, all you have to do is to create the post-process:
  70453. * var mb = new BABYLON.MotionBlurPostProcess(
  70454. * 'mb', // The name of the effect.
  70455. * scene, // The scene containing the objects to blur according to their velocity.
  70456. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70457. * camera // The camera to apply the render pass to.
  70458. * );
  70459. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70460. */
  70461. export class MotionBlurPostProcess extends PostProcess {
  70462. /**
  70463. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70464. */
  70465. motionStrength: number;
  70466. /**
  70467. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70468. */
  70469. get motionBlurSamples(): number;
  70470. /**
  70471. * Sets the number of iterations to be used for motion blur quality
  70472. */
  70473. set motionBlurSamples(samples: number);
  70474. private _motionBlurSamples;
  70475. private _geometryBufferRenderer;
  70476. /**
  70477. * Creates a new instance MotionBlurPostProcess
  70478. * @param name The name of the effect.
  70479. * @param scene The scene containing the objects to blur according to their velocity.
  70480. * @param options The required width/height ratio to downsize to before computing the render pass.
  70481. * @param camera The camera to apply the render pass to.
  70482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70483. * @param engine The engine which the post process will be applied. (default: current engine)
  70484. * @param reusable If the post process can be reused on the same frame. (default: false)
  70485. * @param textureType Type of textures used when performing the post process. (default: 0)
  70486. * @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)
  70487. */
  70488. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70489. /**
  70490. * Excludes the given skinned mesh from computing bones velocities.
  70491. * 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.
  70492. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70493. */
  70494. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70495. /**
  70496. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70497. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70498. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70499. */
  70500. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70501. /**
  70502. * Disposes the post process.
  70503. * @param camera The camera to dispose the post process on.
  70504. */
  70505. dispose(camera?: Camera): void;
  70506. }
  70507. }
  70508. declare module "babylonjs/Shaders/refraction.fragment" {
  70509. /** @hidden */
  70510. export var refractionPixelShader: {
  70511. name: string;
  70512. shader: string;
  70513. };
  70514. }
  70515. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  70516. import { Color3 } from "babylonjs/Maths/math.color";
  70517. import { Camera } from "babylonjs/Cameras/camera";
  70518. import { Texture } from "babylonjs/Materials/Textures/texture";
  70519. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70520. import { Engine } from "babylonjs/Engines/engine";
  70521. import "babylonjs/Shaders/refraction.fragment";
  70522. /**
  70523. * Post process which applies a refractin texture
  70524. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70525. */
  70526. export class RefractionPostProcess extends PostProcess {
  70527. /** the base color of the refraction (used to taint the rendering) */
  70528. color: Color3;
  70529. /** simulated refraction depth */
  70530. depth: number;
  70531. /** the coefficient of the base color (0 to remove base color tainting) */
  70532. colorLevel: number;
  70533. private _refTexture;
  70534. private _ownRefractionTexture;
  70535. /**
  70536. * Gets or sets the refraction texture
  70537. * Please note that you are responsible for disposing the texture if you set it manually
  70538. */
  70539. get refractionTexture(): Texture;
  70540. set refractionTexture(value: Texture);
  70541. /**
  70542. * Initializes the RefractionPostProcess
  70543. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70544. * @param name The name of the effect.
  70545. * @param refractionTextureUrl Url of the refraction texture to use
  70546. * @param color the base color of the refraction (used to taint the rendering)
  70547. * @param depth simulated refraction depth
  70548. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70549. * @param camera The camera to apply the render pass to.
  70550. * @param options The required width/height ratio to downsize to before computing the render pass.
  70551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70552. * @param engine The engine which the post process will be applied. (default: current engine)
  70553. * @param reusable If the post process can be reused on the same frame. (default: false)
  70554. */
  70555. constructor(name: string, refractionTextureUrl: string,
  70556. /** the base color of the refraction (used to taint the rendering) */
  70557. color: Color3,
  70558. /** simulated refraction depth */
  70559. depth: number,
  70560. /** the coefficient of the base color (0 to remove base color tainting) */
  70561. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70562. /**
  70563. * Disposes of the post process
  70564. * @param camera Camera to dispose post process on
  70565. */
  70566. dispose(camera: Camera): void;
  70567. }
  70568. }
  70569. declare module "babylonjs/Shaders/sharpen.fragment" {
  70570. /** @hidden */
  70571. export var sharpenPixelShader: {
  70572. name: string;
  70573. shader: string;
  70574. };
  70575. }
  70576. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  70577. import { Nullable } from "babylonjs/types";
  70578. import { Camera } from "babylonjs/Cameras/camera";
  70579. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70580. import "babylonjs/Shaders/sharpen.fragment";
  70581. import { Engine } from "babylonjs/Engines/engine";
  70582. /**
  70583. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70584. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70585. */
  70586. export class SharpenPostProcess extends PostProcess {
  70587. /**
  70588. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70589. */
  70590. colorAmount: number;
  70591. /**
  70592. * How much sharpness should be applied (default: 0.3)
  70593. */
  70594. edgeAmount: number;
  70595. /**
  70596. * Creates a new instance ConvolutionPostProcess
  70597. * @param name The name of the effect.
  70598. * @param options The required width/height ratio to downsize to before computing the render pass.
  70599. * @param camera The camera to apply the render pass to.
  70600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70601. * @param engine The engine which the post process will be applied. (default: current engine)
  70602. * @param reusable If the post process can be reused on the same frame. (default: false)
  70603. * @param textureType Type of textures used when performing the post process. (default: 0)
  70604. * @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)
  70605. */
  70606. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70607. }
  70608. }
  70609. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  70610. import { Nullable } from "babylonjs/types";
  70611. import { Camera } from "babylonjs/Cameras/camera";
  70612. import { Engine } from "babylonjs/Engines/engine";
  70613. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70614. import { IInspectable } from "babylonjs/Misc/iInspectable";
  70615. /**
  70616. * PostProcessRenderPipeline
  70617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70618. */
  70619. export class PostProcessRenderPipeline {
  70620. private engine;
  70621. private _renderEffects;
  70622. private _renderEffectsForIsolatedPass;
  70623. /**
  70624. * List of inspectable custom properties (used by the Inspector)
  70625. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70626. */
  70627. inspectableCustomProperties: IInspectable[];
  70628. /**
  70629. * @hidden
  70630. */
  70631. protected _cameras: Camera[];
  70632. /** @hidden */
  70633. _name: string;
  70634. /**
  70635. * Gets pipeline name
  70636. */
  70637. get name(): string;
  70638. /** Gets the list of attached cameras */
  70639. get cameras(): Camera[];
  70640. /**
  70641. * Initializes a PostProcessRenderPipeline
  70642. * @param engine engine to add the pipeline to
  70643. * @param name name of the pipeline
  70644. */
  70645. constructor(engine: Engine, name: string);
  70646. /**
  70647. * Gets the class name
  70648. * @returns "PostProcessRenderPipeline"
  70649. */
  70650. getClassName(): string;
  70651. /**
  70652. * If all the render effects in the pipeline are supported
  70653. */
  70654. get isSupported(): boolean;
  70655. /**
  70656. * Adds an effect to the pipeline
  70657. * @param renderEffect the effect to add
  70658. */
  70659. addEffect(renderEffect: PostProcessRenderEffect): void;
  70660. /** @hidden */
  70661. _rebuild(): void;
  70662. /** @hidden */
  70663. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70664. /** @hidden */
  70665. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70666. /** @hidden */
  70667. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70668. /** @hidden */
  70669. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70670. /** @hidden */
  70671. _attachCameras(cameras: Camera, unique: boolean): void;
  70672. /** @hidden */
  70673. _attachCameras(cameras: Camera[], unique: boolean): void;
  70674. /** @hidden */
  70675. _detachCameras(cameras: Camera): void;
  70676. /** @hidden */
  70677. _detachCameras(cameras: Nullable<Camera[]>): void;
  70678. /** @hidden */
  70679. _update(): void;
  70680. /** @hidden */
  70681. _reset(): void;
  70682. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70683. /**
  70684. * Disposes of the pipeline
  70685. */
  70686. dispose(): void;
  70687. }
  70688. }
  70689. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  70690. import { Camera } from "babylonjs/Cameras/camera";
  70691. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70692. /**
  70693. * PostProcessRenderPipelineManager class
  70694. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70695. */
  70696. export class PostProcessRenderPipelineManager {
  70697. private _renderPipelines;
  70698. /**
  70699. * Initializes a PostProcessRenderPipelineManager
  70700. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70701. */
  70702. constructor();
  70703. /**
  70704. * Gets the list of supported render pipelines
  70705. */
  70706. get supportedPipelines(): PostProcessRenderPipeline[];
  70707. /**
  70708. * Adds a pipeline to the manager
  70709. * @param renderPipeline The pipeline to add
  70710. */
  70711. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70712. /**
  70713. * Attaches a camera to the pipeline
  70714. * @param renderPipelineName The name of the pipeline to attach to
  70715. * @param cameras the camera to attach
  70716. * @param unique if the camera can be attached multiple times to the pipeline
  70717. */
  70718. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70719. /**
  70720. * Detaches a camera from the pipeline
  70721. * @param renderPipelineName The name of the pipeline to detach from
  70722. * @param cameras the camera to detach
  70723. */
  70724. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70725. /**
  70726. * Enables an effect by name on a pipeline
  70727. * @param renderPipelineName the name of the pipeline to enable the effect in
  70728. * @param renderEffectName the name of the effect to enable
  70729. * @param cameras the cameras that the effect should be enabled on
  70730. */
  70731. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70732. /**
  70733. * Disables an effect by name on a pipeline
  70734. * @param renderPipelineName the name of the pipeline to disable the effect in
  70735. * @param renderEffectName the name of the effect to disable
  70736. * @param cameras the cameras that the effect should be disabled on
  70737. */
  70738. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70739. /**
  70740. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70741. */
  70742. update(): void;
  70743. /** @hidden */
  70744. _rebuild(): void;
  70745. /**
  70746. * Disposes of the manager and pipelines
  70747. */
  70748. dispose(): void;
  70749. }
  70750. }
  70751. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  70752. import { ISceneComponent } from "babylonjs/sceneComponent";
  70753. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70754. import { Scene } from "babylonjs/scene";
  70755. module "babylonjs/scene" {
  70756. interface Scene {
  70757. /** @hidden (Backing field) */
  70758. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70759. /**
  70760. * Gets the postprocess render pipeline manager
  70761. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70762. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70763. */
  70764. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70765. }
  70766. }
  70767. /**
  70768. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70769. */
  70770. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70771. /**
  70772. * The component name helpfull to identify the component in the list of scene components.
  70773. */
  70774. readonly name: string;
  70775. /**
  70776. * The scene the component belongs to.
  70777. */
  70778. scene: Scene;
  70779. /**
  70780. * Creates a new instance of the component for the given scene
  70781. * @param scene Defines the scene to register the component in
  70782. */
  70783. constructor(scene: Scene);
  70784. /**
  70785. * Registers the component in a given scene
  70786. */
  70787. register(): void;
  70788. /**
  70789. * Rebuilds the elements related to this component in case of
  70790. * context lost for instance.
  70791. */
  70792. rebuild(): void;
  70793. /**
  70794. * Disposes the component and the associated ressources
  70795. */
  70796. dispose(): void;
  70797. private _gatherRenderTargets;
  70798. }
  70799. }
  70800. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  70801. import { Nullable } from "babylonjs/types";
  70802. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70803. import { Camera } from "babylonjs/Cameras/camera";
  70804. import { IDisposable } from "babylonjs/scene";
  70805. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  70806. import { Scene } from "babylonjs/scene";
  70807. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  70808. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70809. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70810. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  70811. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70812. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70813. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  70814. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70815. import { Animation } from "babylonjs/Animations/animation";
  70816. /**
  70817. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70818. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70819. */
  70820. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70821. private _scene;
  70822. private _camerasToBeAttached;
  70823. /**
  70824. * ID of the sharpen post process,
  70825. */
  70826. private readonly SharpenPostProcessId;
  70827. /**
  70828. * @ignore
  70829. * ID of the image processing post process;
  70830. */
  70831. readonly ImageProcessingPostProcessId: string;
  70832. /**
  70833. * @ignore
  70834. * ID of the Fast Approximate Anti-Aliasing post process;
  70835. */
  70836. readonly FxaaPostProcessId: string;
  70837. /**
  70838. * ID of the chromatic aberration post process,
  70839. */
  70840. private readonly ChromaticAberrationPostProcessId;
  70841. /**
  70842. * ID of the grain post process
  70843. */
  70844. private readonly GrainPostProcessId;
  70845. /**
  70846. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70847. */
  70848. sharpen: SharpenPostProcess;
  70849. private _sharpenEffect;
  70850. private bloom;
  70851. /**
  70852. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70853. */
  70854. depthOfField: DepthOfFieldEffect;
  70855. /**
  70856. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70857. */
  70858. fxaa: FxaaPostProcess;
  70859. /**
  70860. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70861. */
  70862. imageProcessing: ImageProcessingPostProcess;
  70863. /**
  70864. * Chromatic aberration post process which will shift rgb colors in the image
  70865. */
  70866. chromaticAberration: ChromaticAberrationPostProcess;
  70867. private _chromaticAberrationEffect;
  70868. /**
  70869. * Grain post process which add noise to the image
  70870. */
  70871. grain: GrainPostProcess;
  70872. private _grainEffect;
  70873. /**
  70874. * Glow post process which adds a glow to emissive areas of the image
  70875. */
  70876. private _glowLayer;
  70877. /**
  70878. * Animations which can be used to tweak settings over a period of time
  70879. */
  70880. animations: Animation[];
  70881. private _imageProcessingConfigurationObserver;
  70882. private _sharpenEnabled;
  70883. private _bloomEnabled;
  70884. private _depthOfFieldEnabled;
  70885. private _depthOfFieldBlurLevel;
  70886. private _fxaaEnabled;
  70887. private _imageProcessingEnabled;
  70888. private _defaultPipelineTextureType;
  70889. private _bloomScale;
  70890. private _chromaticAberrationEnabled;
  70891. private _grainEnabled;
  70892. private _buildAllowed;
  70893. /**
  70894. * Gets active scene
  70895. */
  70896. get scene(): Scene;
  70897. /**
  70898. * Enable or disable the sharpen process from the pipeline
  70899. */
  70900. set sharpenEnabled(enabled: boolean);
  70901. get sharpenEnabled(): boolean;
  70902. private _resizeObserver;
  70903. private _hardwareScaleLevel;
  70904. private _bloomKernel;
  70905. /**
  70906. * Specifies the size of the bloom blur kernel, relative to the final output size
  70907. */
  70908. get bloomKernel(): number;
  70909. set bloomKernel(value: number);
  70910. /**
  70911. * Specifies the weight of the bloom in the final rendering
  70912. */
  70913. private _bloomWeight;
  70914. /**
  70915. * Specifies the luma threshold for the area that will be blurred by the bloom
  70916. */
  70917. private _bloomThreshold;
  70918. private _hdr;
  70919. /**
  70920. * The strength of the bloom.
  70921. */
  70922. set bloomWeight(value: number);
  70923. get bloomWeight(): number;
  70924. /**
  70925. * The strength of the bloom.
  70926. */
  70927. set bloomThreshold(value: number);
  70928. get bloomThreshold(): number;
  70929. /**
  70930. * The scale of the bloom, lower value will provide better performance.
  70931. */
  70932. set bloomScale(value: number);
  70933. get bloomScale(): number;
  70934. /**
  70935. * Enable or disable the bloom from the pipeline
  70936. */
  70937. set bloomEnabled(enabled: boolean);
  70938. get bloomEnabled(): boolean;
  70939. private _rebuildBloom;
  70940. /**
  70941. * If the depth of field is enabled.
  70942. */
  70943. get depthOfFieldEnabled(): boolean;
  70944. set depthOfFieldEnabled(enabled: boolean);
  70945. /**
  70946. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70947. */
  70948. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70949. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70950. /**
  70951. * If the anti aliasing is enabled.
  70952. */
  70953. set fxaaEnabled(enabled: boolean);
  70954. get fxaaEnabled(): boolean;
  70955. private _samples;
  70956. /**
  70957. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70958. */
  70959. set samples(sampleCount: number);
  70960. get samples(): number;
  70961. /**
  70962. * If image processing is enabled.
  70963. */
  70964. set imageProcessingEnabled(enabled: boolean);
  70965. get imageProcessingEnabled(): boolean;
  70966. /**
  70967. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70968. */
  70969. set glowLayerEnabled(enabled: boolean);
  70970. get glowLayerEnabled(): boolean;
  70971. /**
  70972. * Gets the glow layer (or null if not defined)
  70973. */
  70974. get glowLayer(): Nullable<GlowLayer>;
  70975. /**
  70976. * Enable or disable the chromaticAberration process from the pipeline
  70977. */
  70978. set chromaticAberrationEnabled(enabled: boolean);
  70979. get chromaticAberrationEnabled(): boolean;
  70980. /**
  70981. * Enable or disable the grain process from the pipeline
  70982. */
  70983. set grainEnabled(enabled: boolean);
  70984. get grainEnabled(): boolean;
  70985. /**
  70986. * @constructor
  70987. * @param name - The rendering pipeline name (default: "")
  70988. * @param hdr - If high dynamic range textures should be used (default: true)
  70989. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70990. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70991. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70992. */
  70993. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70994. /**
  70995. * Get the class name
  70996. * @returns "DefaultRenderingPipeline"
  70997. */
  70998. getClassName(): string;
  70999. /**
  71000. * Force the compilation of the entire pipeline.
  71001. */
  71002. prepare(): void;
  71003. private _hasCleared;
  71004. private _prevPostProcess;
  71005. private _prevPrevPostProcess;
  71006. private _setAutoClearAndTextureSharing;
  71007. private _depthOfFieldSceneObserver;
  71008. private _buildPipeline;
  71009. private _disposePostProcesses;
  71010. /**
  71011. * Adds a camera to the pipeline
  71012. * @param camera the camera to be added
  71013. */
  71014. addCamera(camera: Camera): void;
  71015. /**
  71016. * Removes a camera from the pipeline
  71017. * @param camera the camera to remove
  71018. */
  71019. removeCamera(camera: Camera): void;
  71020. /**
  71021. * Dispose of the pipeline and stop all post processes
  71022. */
  71023. dispose(): void;
  71024. /**
  71025. * Serialize the rendering pipeline (Used when exporting)
  71026. * @returns the serialized object
  71027. */
  71028. serialize(): any;
  71029. /**
  71030. * Parse the serialized pipeline
  71031. * @param source Source pipeline.
  71032. * @param scene The scene to load the pipeline to.
  71033. * @param rootUrl The URL of the serialized pipeline.
  71034. * @returns An instantiated pipeline from the serialized object.
  71035. */
  71036. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71037. }
  71038. }
  71039. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  71040. /** @hidden */
  71041. export var lensHighlightsPixelShader: {
  71042. name: string;
  71043. shader: string;
  71044. };
  71045. }
  71046. declare module "babylonjs/Shaders/depthOfField.fragment" {
  71047. /** @hidden */
  71048. export var depthOfFieldPixelShader: {
  71049. name: string;
  71050. shader: string;
  71051. };
  71052. }
  71053. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  71054. import { Camera } from "babylonjs/Cameras/camera";
  71055. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71056. import { Scene } from "babylonjs/scene";
  71057. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71058. import "babylonjs/Shaders/chromaticAberration.fragment";
  71059. import "babylonjs/Shaders/lensHighlights.fragment";
  71060. import "babylonjs/Shaders/depthOfField.fragment";
  71061. /**
  71062. * BABYLON.JS Chromatic Aberration GLSL Shader
  71063. * Author: Olivier Guyot
  71064. * Separates very slightly R, G and B colors on the edges of the screen
  71065. * Inspired by Francois Tarlier & Martins Upitis
  71066. */
  71067. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71068. /**
  71069. * @ignore
  71070. * The chromatic aberration PostProcess id in the pipeline
  71071. */
  71072. LensChromaticAberrationEffect: string;
  71073. /**
  71074. * @ignore
  71075. * The highlights enhancing PostProcess id in the pipeline
  71076. */
  71077. HighlightsEnhancingEffect: string;
  71078. /**
  71079. * @ignore
  71080. * The depth-of-field PostProcess id in the pipeline
  71081. */
  71082. LensDepthOfFieldEffect: string;
  71083. private _scene;
  71084. private _depthTexture;
  71085. private _grainTexture;
  71086. private _chromaticAberrationPostProcess;
  71087. private _highlightsPostProcess;
  71088. private _depthOfFieldPostProcess;
  71089. private _edgeBlur;
  71090. private _grainAmount;
  71091. private _chromaticAberration;
  71092. private _distortion;
  71093. private _highlightsGain;
  71094. private _highlightsThreshold;
  71095. private _dofDistance;
  71096. private _dofAperture;
  71097. private _dofDarken;
  71098. private _dofPentagon;
  71099. private _blurNoise;
  71100. /**
  71101. * @constructor
  71102. *
  71103. * Effect parameters are as follow:
  71104. * {
  71105. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71106. * edge_blur: number; // from 0 to x (1 for realism)
  71107. * distortion: number; // from 0 to x (1 for realism)
  71108. * grain_amount: number; // from 0 to 1
  71109. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71110. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71111. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71112. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71113. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71114. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71115. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71116. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71117. * }
  71118. * Note: if an effect parameter is unset, effect is disabled
  71119. *
  71120. * @param name The rendering pipeline name
  71121. * @param parameters - An object containing all parameters (see above)
  71122. * @param scene The scene linked to this pipeline
  71123. * @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)
  71124. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71125. */
  71126. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71127. /**
  71128. * Get the class name
  71129. * @returns "LensRenderingPipeline"
  71130. */
  71131. getClassName(): string;
  71132. /**
  71133. * Gets associated scene
  71134. */
  71135. get scene(): Scene;
  71136. /**
  71137. * Gets or sets the edge blur
  71138. */
  71139. get edgeBlur(): number;
  71140. set edgeBlur(value: number);
  71141. /**
  71142. * Gets or sets the grain amount
  71143. */
  71144. get grainAmount(): number;
  71145. set grainAmount(value: number);
  71146. /**
  71147. * Gets or sets the chromatic aberration amount
  71148. */
  71149. get chromaticAberration(): number;
  71150. set chromaticAberration(value: number);
  71151. /**
  71152. * Gets or sets the depth of field aperture
  71153. */
  71154. get dofAperture(): number;
  71155. set dofAperture(value: number);
  71156. /**
  71157. * Gets or sets the edge distortion
  71158. */
  71159. get edgeDistortion(): number;
  71160. set edgeDistortion(value: number);
  71161. /**
  71162. * Gets or sets the depth of field distortion
  71163. */
  71164. get dofDistortion(): number;
  71165. set dofDistortion(value: number);
  71166. /**
  71167. * Gets or sets the darken out of focus amount
  71168. */
  71169. get darkenOutOfFocus(): number;
  71170. set darkenOutOfFocus(value: number);
  71171. /**
  71172. * Gets or sets a boolean indicating if blur noise is enabled
  71173. */
  71174. get blurNoise(): boolean;
  71175. set blurNoise(value: boolean);
  71176. /**
  71177. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71178. */
  71179. get pentagonBokeh(): boolean;
  71180. set pentagonBokeh(value: boolean);
  71181. /**
  71182. * Gets or sets the highlight grain amount
  71183. */
  71184. get highlightsGain(): number;
  71185. set highlightsGain(value: number);
  71186. /**
  71187. * Gets or sets the highlight threshold
  71188. */
  71189. get highlightsThreshold(): number;
  71190. set highlightsThreshold(value: number);
  71191. /**
  71192. * Sets the amount of blur at the edges
  71193. * @param amount blur amount
  71194. */
  71195. setEdgeBlur(amount: number): void;
  71196. /**
  71197. * Sets edge blur to 0
  71198. */
  71199. disableEdgeBlur(): void;
  71200. /**
  71201. * Sets the amout of grain
  71202. * @param amount Amount of grain
  71203. */
  71204. setGrainAmount(amount: number): void;
  71205. /**
  71206. * Set grain amount to 0
  71207. */
  71208. disableGrain(): void;
  71209. /**
  71210. * Sets the chromatic aberration amount
  71211. * @param amount amount of chromatic aberration
  71212. */
  71213. setChromaticAberration(amount: number): void;
  71214. /**
  71215. * Sets chromatic aberration amount to 0
  71216. */
  71217. disableChromaticAberration(): void;
  71218. /**
  71219. * Sets the EdgeDistortion amount
  71220. * @param amount amount of EdgeDistortion
  71221. */
  71222. setEdgeDistortion(amount: number): void;
  71223. /**
  71224. * Sets edge distortion to 0
  71225. */
  71226. disableEdgeDistortion(): void;
  71227. /**
  71228. * Sets the FocusDistance amount
  71229. * @param amount amount of FocusDistance
  71230. */
  71231. setFocusDistance(amount: number): void;
  71232. /**
  71233. * Disables depth of field
  71234. */
  71235. disableDepthOfField(): void;
  71236. /**
  71237. * Sets the Aperture amount
  71238. * @param amount amount of Aperture
  71239. */
  71240. setAperture(amount: number): void;
  71241. /**
  71242. * Sets the DarkenOutOfFocus amount
  71243. * @param amount amount of DarkenOutOfFocus
  71244. */
  71245. setDarkenOutOfFocus(amount: number): void;
  71246. private _pentagonBokehIsEnabled;
  71247. /**
  71248. * Creates a pentagon bokeh effect
  71249. */
  71250. enablePentagonBokeh(): void;
  71251. /**
  71252. * Disables the pentagon bokeh effect
  71253. */
  71254. disablePentagonBokeh(): void;
  71255. /**
  71256. * Enables noise blur
  71257. */
  71258. enableNoiseBlur(): void;
  71259. /**
  71260. * Disables noise blur
  71261. */
  71262. disableNoiseBlur(): void;
  71263. /**
  71264. * Sets the HighlightsGain amount
  71265. * @param amount amount of HighlightsGain
  71266. */
  71267. setHighlightsGain(amount: number): void;
  71268. /**
  71269. * Sets the HighlightsThreshold amount
  71270. * @param amount amount of HighlightsThreshold
  71271. */
  71272. setHighlightsThreshold(amount: number): void;
  71273. /**
  71274. * Disables highlights
  71275. */
  71276. disableHighlights(): void;
  71277. /**
  71278. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71279. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71280. */
  71281. dispose(disableDepthRender?: boolean): void;
  71282. private _createChromaticAberrationPostProcess;
  71283. private _createHighlightsPostProcess;
  71284. private _createDepthOfFieldPostProcess;
  71285. private _createGrainTexture;
  71286. }
  71287. }
  71288. declare module "babylonjs/Shaders/ssao2.fragment" {
  71289. /** @hidden */
  71290. export var ssao2PixelShader: {
  71291. name: string;
  71292. shader: string;
  71293. };
  71294. }
  71295. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  71296. /** @hidden */
  71297. export var ssaoCombinePixelShader: {
  71298. name: string;
  71299. shader: string;
  71300. };
  71301. }
  71302. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  71303. import { Camera } from "babylonjs/Cameras/camera";
  71304. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71305. import { Scene } from "babylonjs/scene";
  71306. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71307. import "babylonjs/Shaders/ssao2.fragment";
  71308. import "babylonjs/Shaders/ssaoCombine.fragment";
  71309. /**
  71310. * Render pipeline to produce ssao effect
  71311. */
  71312. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71313. /**
  71314. * @ignore
  71315. * The PassPostProcess id in the pipeline that contains the original scene color
  71316. */
  71317. SSAOOriginalSceneColorEffect: string;
  71318. /**
  71319. * @ignore
  71320. * The SSAO PostProcess id in the pipeline
  71321. */
  71322. SSAORenderEffect: string;
  71323. /**
  71324. * @ignore
  71325. * The horizontal blur PostProcess id in the pipeline
  71326. */
  71327. SSAOBlurHRenderEffect: string;
  71328. /**
  71329. * @ignore
  71330. * The vertical blur PostProcess id in the pipeline
  71331. */
  71332. SSAOBlurVRenderEffect: string;
  71333. /**
  71334. * @ignore
  71335. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71336. */
  71337. SSAOCombineRenderEffect: string;
  71338. /**
  71339. * The output strength of the SSAO post-process. Default value is 1.0.
  71340. */
  71341. totalStrength: number;
  71342. /**
  71343. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71344. */
  71345. maxZ: number;
  71346. /**
  71347. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71348. */
  71349. minZAspect: number;
  71350. private _samples;
  71351. /**
  71352. * Number of samples used for the SSAO calculations. Default value is 8
  71353. */
  71354. set samples(n: number);
  71355. get samples(): number;
  71356. private _textureSamples;
  71357. /**
  71358. * Number of samples to use for antialiasing
  71359. */
  71360. set textureSamples(n: number);
  71361. get textureSamples(): number;
  71362. /**
  71363. * Ratio object used for SSAO ratio and blur ratio
  71364. */
  71365. private _ratio;
  71366. /**
  71367. * Dynamically generated sphere sampler.
  71368. */
  71369. private _sampleSphere;
  71370. /**
  71371. * Blur filter offsets
  71372. */
  71373. private _samplerOffsets;
  71374. private _expensiveBlur;
  71375. /**
  71376. * If bilateral blur should be used
  71377. */
  71378. set expensiveBlur(b: boolean);
  71379. get expensiveBlur(): boolean;
  71380. /**
  71381. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71382. */
  71383. radius: number;
  71384. /**
  71385. * The base color of the SSAO post-process
  71386. * The final result is "base + ssao" between [0, 1]
  71387. */
  71388. base: number;
  71389. /**
  71390. * Support test.
  71391. */
  71392. static get IsSupported(): boolean;
  71393. private _scene;
  71394. private _depthTexture;
  71395. private _normalTexture;
  71396. private _randomTexture;
  71397. private _originalColorPostProcess;
  71398. private _ssaoPostProcess;
  71399. private _blurHPostProcess;
  71400. private _blurVPostProcess;
  71401. private _ssaoCombinePostProcess;
  71402. /**
  71403. * Gets active scene
  71404. */
  71405. get scene(): Scene;
  71406. /**
  71407. * @constructor
  71408. * @param name The rendering pipeline name
  71409. * @param scene The scene linked to this pipeline
  71410. * @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 }
  71411. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71412. */
  71413. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71414. /**
  71415. * Get the class name
  71416. * @returns "SSAO2RenderingPipeline"
  71417. */
  71418. getClassName(): string;
  71419. /**
  71420. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71421. */
  71422. dispose(disableGeometryBufferRenderer?: boolean): void;
  71423. private _createBlurPostProcess;
  71424. /** @hidden */
  71425. _rebuild(): void;
  71426. private _bits;
  71427. private _radicalInverse_VdC;
  71428. private _hammersley;
  71429. private _hemisphereSample_uniform;
  71430. private _generateHemisphere;
  71431. private _createSSAOPostProcess;
  71432. private _createSSAOCombinePostProcess;
  71433. private _createRandomTexture;
  71434. /**
  71435. * Serialize the rendering pipeline (Used when exporting)
  71436. * @returns the serialized object
  71437. */
  71438. serialize(): any;
  71439. /**
  71440. * Parse the serialized pipeline
  71441. * @param source Source pipeline.
  71442. * @param scene The scene to load the pipeline to.
  71443. * @param rootUrl The URL of the serialized pipeline.
  71444. * @returns An instantiated pipeline from the serialized object.
  71445. */
  71446. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71447. }
  71448. }
  71449. declare module "babylonjs/Shaders/ssao.fragment" {
  71450. /** @hidden */
  71451. export var ssaoPixelShader: {
  71452. name: string;
  71453. shader: string;
  71454. };
  71455. }
  71456. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  71457. import { Camera } from "babylonjs/Cameras/camera";
  71458. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71459. import { Scene } from "babylonjs/scene";
  71460. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71461. import "babylonjs/Shaders/ssao.fragment";
  71462. import "babylonjs/Shaders/ssaoCombine.fragment";
  71463. /**
  71464. * Render pipeline to produce ssao effect
  71465. */
  71466. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71467. /**
  71468. * @ignore
  71469. * The PassPostProcess id in the pipeline that contains the original scene color
  71470. */
  71471. SSAOOriginalSceneColorEffect: string;
  71472. /**
  71473. * @ignore
  71474. * The SSAO PostProcess id in the pipeline
  71475. */
  71476. SSAORenderEffect: string;
  71477. /**
  71478. * @ignore
  71479. * The horizontal blur PostProcess id in the pipeline
  71480. */
  71481. SSAOBlurHRenderEffect: string;
  71482. /**
  71483. * @ignore
  71484. * The vertical blur PostProcess id in the pipeline
  71485. */
  71486. SSAOBlurVRenderEffect: string;
  71487. /**
  71488. * @ignore
  71489. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71490. */
  71491. SSAOCombineRenderEffect: string;
  71492. /**
  71493. * The output strength of the SSAO post-process. Default value is 1.0.
  71494. */
  71495. totalStrength: number;
  71496. /**
  71497. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71498. */
  71499. radius: number;
  71500. /**
  71501. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71502. * Must not be equal to fallOff and superior to fallOff.
  71503. * Default value is 0.0075
  71504. */
  71505. area: number;
  71506. /**
  71507. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71508. * Must not be equal to area and inferior to area.
  71509. * Default value is 0.000001
  71510. */
  71511. fallOff: number;
  71512. /**
  71513. * The base color of the SSAO post-process
  71514. * The final result is "base + ssao" between [0, 1]
  71515. */
  71516. base: number;
  71517. private _scene;
  71518. private _depthTexture;
  71519. private _randomTexture;
  71520. private _originalColorPostProcess;
  71521. private _ssaoPostProcess;
  71522. private _blurHPostProcess;
  71523. private _blurVPostProcess;
  71524. private _ssaoCombinePostProcess;
  71525. private _firstUpdate;
  71526. /**
  71527. * Gets active scene
  71528. */
  71529. get scene(): Scene;
  71530. /**
  71531. * @constructor
  71532. * @param name - The rendering pipeline name
  71533. * @param scene - The scene linked to this pipeline
  71534. * @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 }
  71535. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71536. */
  71537. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71538. /**
  71539. * Get the class name
  71540. * @returns "SSAORenderingPipeline"
  71541. */
  71542. getClassName(): string;
  71543. /**
  71544. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71545. */
  71546. dispose(disableDepthRender?: boolean): void;
  71547. private _createBlurPostProcess;
  71548. /** @hidden */
  71549. _rebuild(): void;
  71550. private _createSSAOPostProcess;
  71551. private _createSSAOCombinePostProcess;
  71552. private _createRandomTexture;
  71553. }
  71554. }
  71555. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  71556. /** @hidden */
  71557. export var screenSpaceReflectionPixelShader: {
  71558. name: string;
  71559. shader: string;
  71560. };
  71561. }
  71562. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  71563. import { Nullable } from "babylonjs/types";
  71564. import { Camera } from "babylonjs/Cameras/camera";
  71565. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71566. import { Scene } from "babylonjs/scene";
  71567. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  71568. import { Engine } from "babylonjs/Engines/engine";
  71569. /**
  71570. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71571. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71572. */
  71573. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71574. /**
  71575. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71576. */
  71577. threshold: number;
  71578. /**
  71579. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71580. */
  71581. strength: number;
  71582. /**
  71583. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71584. */
  71585. reflectionSpecularFalloffExponent: number;
  71586. /**
  71587. * 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]
  71588. */
  71589. step: number;
  71590. /**
  71591. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71592. */
  71593. roughnessFactor: number;
  71594. private _geometryBufferRenderer;
  71595. private _enableSmoothReflections;
  71596. private _reflectionSamples;
  71597. private _smoothSteps;
  71598. /**
  71599. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71600. * @param name The name of the effect.
  71601. * @param scene The scene containing the objects to calculate reflections.
  71602. * @param options The required width/height ratio to downsize to before computing the render pass.
  71603. * @param camera The camera to apply the render pass to.
  71604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71605. * @param engine The engine which the post process will be applied. (default: current engine)
  71606. * @param reusable If the post process can be reused on the same frame. (default: false)
  71607. * @param textureType Type of textures used when performing the post process. (default: 0)
  71608. * @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)
  71609. */
  71610. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71611. /**
  71612. * Gets wether or not smoothing reflections is enabled.
  71613. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71614. */
  71615. get enableSmoothReflections(): boolean;
  71616. /**
  71617. * Sets wether or not smoothing reflections is enabled.
  71618. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71619. */
  71620. set enableSmoothReflections(enabled: boolean);
  71621. /**
  71622. * Gets the number of samples taken while computing reflections. More samples count is high,
  71623. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71624. */
  71625. get reflectionSamples(): number;
  71626. /**
  71627. * Sets the number of samples taken while computing reflections. More samples count is high,
  71628. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71629. */
  71630. set reflectionSamples(samples: number);
  71631. /**
  71632. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71633. * more the post-process will require GPU power and can generate a drop in FPS.
  71634. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71635. */
  71636. get smoothSteps(): number;
  71637. set smoothSteps(steps: number);
  71638. private _updateEffectDefines;
  71639. }
  71640. }
  71641. declare module "babylonjs/Shaders/standard.fragment" {
  71642. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  71643. /** @hidden */
  71644. export var standardPixelShader: {
  71645. name: string;
  71646. shader: string;
  71647. };
  71648. }
  71649. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  71650. import { Nullable } from "babylonjs/types";
  71651. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71652. import { Camera } from "babylonjs/Cameras/camera";
  71653. import { Texture } from "babylonjs/Materials/Textures/texture";
  71654. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71655. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  71656. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71657. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  71658. import { IDisposable } from "babylonjs/scene";
  71659. import { SpotLight } from "babylonjs/Lights/spotLight";
  71660. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  71661. import { Scene } from "babylonjs/scene";
  71662. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  71663. import { Animation } from "babylonjs/Animations/animation";
  71664. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  71665. import "babylonjs/Shaders/standard.fragment";
  71666. /**
  71667. * Standard rendering pipeline
  71668. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71669. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71670. */
  71671. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71672. /**
  71673. * Public members
  71674. */
  71675. /**
  71676. * Post-process which contains the original scene color before the pipeline applies all the effects
  71677. */
  71678. originalPostProcess: Nullable<PostProcess>;
  71679. /**
  71680. * Post-process used to down scale an image x4
  71681. */
  71682. downSampleX4PostProcess: Nullable<PostProcess>;
  71683. /**
  71684. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71685. */
  71686. brightPassPostProcess: Nullable<PostProcess>;
  71687. /**
  71688. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71689. */
  71690. blurHPostProcesses: PostProcess[];
  71691. /**
  71692. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71693. */
  71694. blurVPostProcesses: PostProcess[];
  71695. /**
  71696. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71697. */
  71698. textureAdderPostProcess: Nullable<PostProcess>;
  71699. /**
  71700. * Post-process used to create volumetric lighting effect
  71701. */
  71702. volumetricLightPostProcess: Nullable<PostProcess>;
  71703. /**
  71704. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71705. */
  71706. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71707. /**
  71708. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71709. */
  71710. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71711. /**
  71712. * Post-process used to merge the volumetric light effect and the real scene color
  71713. */
  71714. volumetricLightMergePostProces: Nullable<PostProcess>;
  71715. /**
  71716. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71717. */
  71718. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71719. /**
  71720. * Base post-process used to calculate the average luminance of the final image for HDR
  71721. */
  71722. luminancePostProcess: Nullable<PostProcess>;
  71723. /**
  71724. * Post-processes used to create down sample post-processes in order to get
  71725. * the average luminance of the final image for HDR
  71726. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71727. */
  71728. luminanceDownSamplePostProcesses: PostProcess[];
  71729. /**
  71730. * Post-process used to create a HDR effect (light adaptation)
  71731. */
  71732. hdrPostProcess: Nullable<PostProcess>;
  71733. /**
  71734. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71735. */
  71736. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71737. /**
  71738. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71739. */
  71740. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71741. /**
  71742. * Post-process used to merge the final HDR post-process and the real scene color
  71743. */
  71744. hdrFinalPostProcess: Nullable<PostProcess>;
  71745. /**
  71746. * Post-process used to create a lens flare effect
  71747. */
  71748. lensFlarePostProcess: Nullable<PostProcess>;
  71749. /**
  71750. * Post-process that merges the result of the lens flare post-process and the real scene color
  71751. */
  71752. lensFlareComposePostProcess: Nullable<PostProcess>;
  71753. /**
  71754. * Post-process used to create a motion blur effect
  71755. */
  71756. motionBlurPostProcess: Nullable<PostProcess>;
  71757. /**
  71758. * Post-process used to create a depth of field effect
  71759. */
  71760. depthOfFieldPostProcess: Nullable<PostProcess>;
  71761. /**
  71762. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71763. */
  71764. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71765. /**
  71766. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71767. */
  71768. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71769. /**
  71770. * Represents the brightness threshold in order to configure the illuminated surfaces
  71771. */
  71772. brightThreshold: number;
  71773. /**
  71774. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71775. */
  71776. blurWidth: number;
  71777. /**
  71778. * Sets if the blur for highlighted surfaces must be only horizontal
  71779. */
  71780. horizontalBlur: boolean;
  71781. /**
  71782. * Gets the overall exposure used by the pipeline
  71783. */
  71784. get exposure(): number;
  71785. /**
  71786. * Sets the overall exposure used by the pipeline
  71787. */
  71788. set exposure(value: number);
  71789. /**
  71790. * Texture used typically to simulate "dirty" on camera lens
  71791. */
  71792. lensTexture: Nullable<Texture>;
  71793. /**
  71794. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71795. */
  71796. volumetricLightCoefficient: number;
  71797. /**
  71798. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71799. */
  71800. volumetricLightPower: number;
  71801. /**
  71802. * Used the set the blur intensity to smooth the volumetric lights
  71803. */
  71804. volumetricLightBlurScale: number;
  71805. /**
  71806. * Light (spot or directional) used to generate the volumetric lights rays
  71807. * The source light must have a shadow generate so the pipeline can get its
  71808. * depth map
  71809. */
  71810. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71811. /**
  71812. * For eye adaptation, represents the minimum luminance the eye can see
  71813. */
  71814. hdrMinimumLuminance: number;
  71815. /**
  71816. * For eye adaptation, represents the decrease luminance speed
  71817. */
  71818. hdrDecreaseRate: number;
  71819. /**
  71820. * For eye adaptation, represents the increase luminance speed
  71821. */
  71822. hdrIncreaseRate: number;
  71823. /**
  71824. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71825. */
  71826. get hdrAutoExposure(): boolean;
  71827. /**
  71828. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71829. */
  71830. set hdrAutoExposure(value: boolean);
  71831. /**
  71832. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71833. */
  71834. lensColorTexture: Nullable<Texture>;
  71835. /**
  71836. * The overall strengh for the lens flare effect
  71837. */
  71838. lensFlareStrength: number;
  71839. /**
  71840. * Dispersion coefficient for lens flare ghosts
  71841. */
  71842. lensFlareGhostDispersal: number;
  71843. /**
  71844. * Main lens flare halo width
  71845. */
  71846. lensFlareHaloWidth: number;
  71847. /**
  71848. * Based on the lens distortion effect, defines how much the lens flare result
  71849. * is distorted
  71850. */
  71851. lensFlareDistortionStrength: number;
  71852. /**
  71853. * Configures the blur intensity used for for lens flare (halo)
  71854. */
  71855. lensFlareBlurWidth: number;
  71856. /**
  71857. * Lens star texture must be used to simulate rays on the flares and is available
  71858. * in the documentation
  71859. */
  71860. lensStarTexture: Nullable<Texture>;
  71861. /**
  71862. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71863. * flare effect by taking account of the dirt texture
  71864. */
  71865. lensFlareDirtTexture: Nullable<Texture>;
  71866. /**
  71867. * Represents the focal length for the depth of field effect
  71868. */
  71869. depthOfFieldDistance: number;
  71870. /**
  71871. * Represents the blur intensity for the blurred part of the depth of field effect
  71872. */
  71873. depthOfFieldBlurWidth: number;
  71874. /**
  71875. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71876. */
  71877. get motionStrength(): number;
  71878. /**
  71879. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71880. */
  71881. set motionStrength(strength: number);
  71882. /**
  71883. * Gets wether or not the motion blur post-process is object based or screen based.
  71884. */
  71885. get objectBasedMotionBlur(): boolean;
  71886. /**
  71887. * Sets wether or not the motion blur post-process should be object based or screen based
  71888. */
  71889. set objectBasedMotionBlur(value: boolean);
  71890. /**
  71891. * List of animations for the pipeline (IAnimatable implementation)
  71892. */
  71893. animations: Animation[];
  71894. /**
  71895. * Private members
  71896. */
  71897. private _scene;
  71898. private _currentDepthOfFieldSource;
  71899. private _basePostProcess;
  71900. private _fixedExposure;
  71901. private _currentExposure;
  71902. private _hdrAutoExposure;
  71903. private _hdrCurrentLuminance;
  71904. private _motionStrength;
  71905. private _isObjectBasedMotionBlur;
  71906. private _floatTextureType;
  71907. private _camerasToBeAttached;
  71908. private _ratio;
  71909. private _bloomEnabled;
  71910. private _depthOfFieldEnabled;
  71911. private _vlsEnabled;
  71912. private _lensFlareEnabled;
  71913. private _hdrEnabled;
  71914. private _motionBlurEnabled;
  71915. private _fxaaEnabled;
  71916. private _screenSpaceReflectionsEnabled;
  71917. private _motionBlurSamples;
  71918. private _volumetricLightStepsCount;
  71919. private _samples;
  71920. /**
  71921. * @ignore
  71922. * Specifies if the bloom pipeline is enabled
  71923. */
  71924. get BloomEnabled(): boolean;
  71925. set BloomEnabled(enabled: boolean);
  71926. /**
  71927. * @ignore
  71928. * Specifies if the depth of field pipeline is enabed
  71929. */
  71930. get DepthOfFieldEnabled(): boolean;
  71931. set DepthOfFieldEnabled(enabled: boolean);
  71932. /**
  71933. * @ignore
  71934. * Specifies if the lens flare pipeline is enabed
  71935. */
  71936. get LensFlareEnabled(): boolean;
  71937. set LensFlareEnabled(enabled: boolean);
  71938. /**
  71939. * @ignore
  71940. * Specifies if the HDR pipeline is enabled
  71941. */
  71942. get HDREnabled(): boolean;
  71943. set HDREnabled(enabled: boolean);
  71944. /**
  71945. * @ignore
  71946. * Specifies if the volumetric lights scattering effect is enabled
  71947. */
  71948. get VLSEnabled(): boolean;
  71949. set VLSEnabled(enabled: boolean);
  71950. /**
  71951. * @ignore
  71952. * Specifies if the motion blur effect is enabled
  71953. */
  71954. get MotionBlurEnabled(): boolean;
  71955. set MotionBlurEnabled(enabled: boolean);
  71956. /**
  71957. * Specifies if anti-aliasing is enabled
  71958. */
  71959. get fxaaEnabled(): boolean;
  71960. set fxaaEnabled(enabled: boolean);
  71961. /**
  71962. * Specifies if screen space reflections are enabled.
  71963. */
  71964. get screenSpaceReflectionsEnabled(): boolean;
  71965. set screenSpaceReflectionsEnabled(enabled: boolean);
  71966. /**
  71967. * Specifies the number of steps used to calculate the volumetric lights
  71968. * Typically in interval [50, 200]
  71969. */
  71970. get volumetricLightStepsCount(): number;
  71971. set volumetricLightStepsCount(count: number);
  71972. /**
  71973. * Specifies the number of samples used for the motion blur effect
  71974. * Typically in interval [16, 64]
  71975. */
  71976. get motionBlurSamples(): number;
  71977. set motionBlurSamples(samples: number);
  71978. /**
  71979. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71980. */
  71981. get samples(): number;
  71982. set samples(sampleCount: number);
  71983. /**
  71984. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71985. * @constructor
  71986. * @param name The rendering pipeline name
  71987. * @param scene The scene linked to this pipeline
  71988. * @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)
  71989. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71990. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71991. */
  71992. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71993. private _buildPipeline;
  71994. private _createDownSampleX4PostProcess;
  71995. private _createBrightPassPostProcess;
  71996. private _createBlurPostProcesses;
  71997. private _createTextureAdderPostProcess;
  71998. private _createVolumetricLightPostProcess;
  71999. private _createLuminancePostProcesses;
  72000. private _createHdrPostProcess;
  72001. private _createLensFlarePostProcess;
  72002. private _createDepthOfFieldPostProcess;
  72003. private _createMotionBlurPostProcess;
  72004. private _getDepthTexture;
  72005. private _disposePostProcesses;
  72006. /**
  72007. * Dispose of the pipeline and stop all post processes
  72008. */
  72009. dispose(): void;
  72010. /**
  72011. * Serialize the rendering pipeline (Used when exporting)
  72012. * @returns the serialized object
  72013. */
  72014. serialize(): any;
  72015. /**
  72016. * Parse the serialized pipeline
  72017. * @param source Source pipeline.
  72018. * @param scene The scene to load the pipeline to.
  72019. * @param rootUrl The URL of the serialized pipeline.
  72020. * @returns An instantiated pipeline from the serialized object.
  72021. */
  72022. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72023. /**
  72024. * Luminance steps
  72025. */
  72026. static LuminanceSteps: number;
  72027. }
  72028. }
  72029. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  72030. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  72031. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  72032. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  72033. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  72034. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  72035. }
  72036. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  72037. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  72038. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72039. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72040. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72041. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72042. }
  72043. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  72044. /** @hidden */
  72045. export var stereoscopicInterlacePixelShader: {
  72046. name: string;
  72047. shader: string;
  72048. };
  72049. }
  72050. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  72051. import { Camera } from "babylonjs/Cameras/camera";
  72052. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72053. import { Engine } from "babylonjs/Engines/engine";
  72054. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  72055. /**
  72056. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72057. */
  72058. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72059. private _stepSize;
  72060. private _passedProcess;
  72061. /**
  72062. * Initializes a StereoscopicInterlacePostProcessI
  72063. * @param name The name of the effect.
  72064. * @param rigCameras The rig cameras to be appled to the post process
  72065. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72066. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72068. * @param engine The engine which the post process will be applied. (default: current engine)
  72069. * @param reusable If the post process can be reused on the same frame. (default: false)
  72070. */
  72071. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72072. }
  72073. /**
  72074. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72075. */
  72076. export class StereoscopicInterlacePostProcess extends PostProcess {
  72077. private _stepSize;
  72078. private _passedProcess;
  72079. /**
  72080. * Initializes a StereoscopicInterlacePostProcess
  72081. * @param name The name of the effect.
  72082. * @param rigCameras The rig cameras to be appled to the post process
  72083. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72085. * @param engine The engine which the post process will be applied. (default: current engine)
  72086. * @param reusable If the post process can be reused on the same frame. (default: false)
  72087. */
  72088. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72089. }
  72090. }
  72091. declare module "babylonjs/Shaders/tonemap.fragment" {
  72092. /** @hidden */
  72093. export var tonemapPixelShader: {
  72094. name: string;
  72095. shader: string;
  72096. };
  72097. }
  72098. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  72099. import { Camera } from "babylonjs/Cameras/camera";
  72100. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72101. import "babylonjs/Shaders/tonemap.fragment";
  72102. import { Engine } from "babylonjs/Engines/engine";
  72103. /** Defines operator used for tonemapping */
  72104. export enum TonemappingOperator {
  72105. /** Hable */
  72106. Hable = 0,
  72107. /** Reinhard */
  72108. Reinhard = 1,
  72109. /** HejiDawson */
  72110. HejiDawson = 2,
  72111. /** Photographic */
  72112. Photographic = 3
  72113. }
  72114. /**
  72115. * Defines a post process to apply tone mapping
  72116. */
  72117. export class TonemapPostProcess extends PostProcess {
  72118. private _operator;
  72119. /** Defines the required exposure adjustement */
  72120. exposureAdjustment: number;
  72121. /**
  72122. * Creates a new TonemapPostProcess
  72123. * @param name defines the name of the postprocess
  72124. * @param _operator defines the operator to use
  72125. * @param exposureAdjustment defines the required exposure adjustement
  72126. * @param camera defines the camera to use (can be null)
  72127. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72128. * @param engine defines the hosting engine (can be ignore if camera is set)
  72129. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72130. */
  72131. constructor(name: string, _operator: TonemappingOperator,
  72132. /** Defines the required exposure adjustement */
  72133. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72134. }
  72135. }
  72136. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  72137. /** @hidden */
  72138. export var volumetricLightScatteringPixelShader: {
  72139. name: string;
  72140. shader: string;
  72141. };
  72142. }
  72143. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  72144. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72145. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72146. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72147. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72148. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72149. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72150. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72151. /** @hidden */
  72152. export var volumetricLightScatteringPassVertexShader: {
  72153. name: string;
  72154. shader: string;
  72155. };
  72156. }
  72157. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  72158. /** @hidden */
  72159. export var volumetricLightScatteringPassPixelShader: {
  72160. name: string;
  72161. shader: string;
  72162. };
  72163. }
  72164. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  72165. import { Vector3 } from "babylonjs/Maths/math.vector";
  72166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72167. import { Mesh } from "babylonjs/Meshes/mesh";
  72168. import { Camera } from "babylonjs/Cameras/camera";
  72169. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72170. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72171. import { Scene } from "babylonjs/scene";
  72172. import "babylonjs/Meshes/Builders/planeBuilder";
  72173. import "babylonjs/Shaders/depth.vertex";
  72174. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  72175. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  72176. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  72177. import { Engine } from "babylonjs/Engines/engine";
  72178. /**
  72179. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72180. */
  72181. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72182. private _volumetricLightScatteringPass;
  72183. private _volumetricLightScatteringRTT;
  72184. private _viewPort;
  72185. private _screenCoordinates;
  72186. private _cachedDefines;
  72187. /**
  72188. * If not undefined, the mesh position is computed from the attached node position
  72189. */
  72190. attachedNode: {
  72191. position: Vector3;
  72192. };
  72193. /**
  72194. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72195. */
  72196. customMeshPosition: Vector3;
  72197. /**
  72198. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72199. */
  72200. useCustomMeshPosition: boolean;
  72201. /**
  72202. * If the post-process should inverse the light scattering direction
  72203. */
  72204. invert: boolean;
  72205. /**
  72206. * The internal mesh used by the post-process
  72207. */
  72208. mesh: Mesh;
  72209. /**
  72210. * @hidden
  72211. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72212. */
  72213. get useDiffuseColor(): boolean;
  72214. set useDiffuseColor(useDiffuseColor: boolean);
  72215. /**
  72216. * Array containing the excluded meshes not rendered in the internal pass
  72217. */
  72218. excludedMeshes: AbstractMesh[];
  72219. /**
  72220. * Controls the overall intensity of the post-process
  72221. */
  72222. exposure: number;
  72223. /**
  72224. * Dissipates each sample's contribution in range [0, 1]
  72225. */
  72226. decay: number;
  72227. /**
  72228. * Controls the overall intensity of each sample
  72229. */
  72230. weight: number;
  72231. /**
  72232. * Controls the density of each sample
  72233. */
  72234. density: number;
  72235. /**
  72236. * @constructor
  72237. * @param name The post-process name
  72238. * @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)
  72239. * @param camera The camera that the post-process will be attached to
  72240. * @param mesh The mesh used to create the light scattering
  72241. * @param samples The post-process quality, default 100
  72242. * @param samplingModeThe post-process filtering mode
  72243. * @param engine The babylon engine
  72244. * @param reusable If the post-process is reusable
  72245. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72246. */
  72247. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72248. /**
  72249. * Returns the string "VolumetricLightScatteringPostProcess"
  72250. * @returns "VolumetricLightScatteringPostProcess"
  72251. */
  72252. getClassName(): string;
  72253. private _isReady;
  72254. /**
  72255. * Sets the new light position for light scattering effect
  72256. * @param position The new custom light position
  72257. */
  72258. setCustomMeshPosition(position: Vector3): void;
  72259. /**
  72260. * Returns the light position for light scattering effect
  72261. * @return Vector3 The custom light position
  72262. */
  72263. getCustomMeshPosition(): Vector3;
  72264. /**
  72265. * Disposes the internal assets and detaches the post-process from the camera
  72266. */
  72267. dispose(camera: Camera): void;
  72268. /**
  72269. * Returns the render target texture used by the post-process
  72270. * @return the render target texture used by the post-process
  72271. */
  72272. getPass(): RenderTargetTexture;
  72273. private _meshExcluded;
  72274. private _createPass;
  72275. private _updateMeshScreenCoordinates;
  72276. /**
  72277. * Creates a default mesh for the Volumeric Light Scattering post-process
  72278. * @param name The mesh name
  72279. * @param scene The scene where to create the mesh
  72280. * @return the default mesh
  72281. */
  72282. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72283. }
  72284. }
  72285. declare module "babylonjs/PostProcesses/index" {
  72286. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  72287. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  72288. export * from "babylonjs/PostProcesses/bloomEffect";
  72289. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  72290. export * from "babylonjs/PostProcesses/blurPostProcess";
  72291. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72292. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  72293. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  72294. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  72295. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72296. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  72297. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  72298. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  72299. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72300. export * from "babylonjs/PostProcesses/filterPostProcess";
  72301. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  72302. export * from "babylonjs/PostProcesses/grainPostProcess";
  72303. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  72304. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72305. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  72306. export * from "babylonjs/PostProcesses/passPostProcess";
  72307. export * from "babylonjs/PostProcesses/postProcess";
  72308. export * from "babylonjs/PostProcesses/postProcessManager";
  72309. export * from "babylonjs/PostProcesses/refractionPostProcess";
  72310. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  72311. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  72312. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  72313. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  72314. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  72315. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  72316. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  72317. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  72318. }
  72319. declare module "babylonjs/Probes/index" {
  72320. export * from "babylonjs/Probes/reflectionProbe";
  72321. }
  72322. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  72323. import { Scene } from "babylonjs/scene";
  72324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72325. import { SmartArray } from "babylonjs/Misc/smartArray";
  72326. import { ISceneComponent } from "babylonjs/sceneComponent";
  72327. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  72328. import "babylonjs/Meshes/Builders/boxBuilder";
  72329. import "babylonjs/Shaders/color.fragment";
  72330. import "babylonjs/Shaders/color.vertex";
  72331. import { Color3 } from "babylonjs/Maths/math.color";
  72332. module "babylonjs/scene" {
  72333. interface Scene {
  72334. /** @hidden (Backing field) */
  72335. _boundingBoxRenderer: BoundingBoxRenderer;
  72336. /** @hidden (Backing field) */
  72337. _forceShowBoundingBoxes: boolean;
  72338. /**
  72339. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72340. */
  72341. forceShowBoundingBoxes: boolean;
  72342. /**
  72343. * Gets the bounding box renderer associated with the scene
  72344. * @returns a BoundingBoxRenderer
  72345. */
  72346. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72347. }
  72348. }
  72349. module "babylonjs/Meshes/abstractMesh" {
  72350. interface AbstractMesh {
  72351. /** @hidden (Backing field) */
  72352. _showBoundingBox: boolean;
  72353. /**
  72354. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72355. */
  72356. showBoundingBox: boolean;
  72357. }
  72358. }
  72359. /**
  72360. * Component responsible of rendering the bounding box of the meshes in a scene.
  72361. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72362. */
  72363. export class BoundingBoxRenderer implements ISceneComponent {
  72364. /**
  72365. * The component name helpfull to identify the component in the list of scene components.
  72366. */
  72367. readonly name: string;
  72368. /**
  72369. * The scene the component belongs to.
  72370. */
  72371. scene: Scene;
  72372. /**
  72373. * Color of the bounding box lines placed in front of an object
  72374. */
  72375. frontColor: Color3;
  72376. /**
  72377. * Color of the bounding box lines placed behind an object
  72378. */
  72379. backColor: Color3;
  72380. /**
  72381. * Defines if the renderer should show the back lines or not
  72382. */
  72383. showBackLines: boolean;
  72384. /**
  72385. * @hidden
  72386. */
  72387. renderList: SmartArray<BoundingBox>;
  72388. private _colorShader;
  72389. private _vertexBuffers;
  72390. private _indexBuffer;
  72391. private _fillIndexBuffer;
  72392. private _fillIndexData;
  72393. /**
  72394. * Instantiates a new bounding box renderer in a scene.
  72395. * @param scene the scene the renderer renders in
  72396. */
  72397. constructor(scene: Scene);
  72398. /**
  72399. * Registers the component in a given scene
  72400. */
  72401. register(): void;
  72402. private _evaluateSubMesh;
  72403. private _activeMesh;
  72404. private _prepareRessources;
  72405. private _createIndexBuffer;
  72406. /**
  72407. * Rebuilds the elements related to this component in case of
  72408. * context lost for instance.
  72409. */
  72410. rebuild(): void;
  72411. /**
  72412. * @hidden
  72413. */
  72414. reset(): void;
  72415. /**
  72416. * Render the bounding boxes of a specific rendering group
  72417. * @param renderingGroupId defines the rendering group to render
  72418. */
  72419. render(renderingGroupId: number): void;
  72420. /**
  72421. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72422. * @param mesh Define the mesh to render the occlusion bounding box for
  72423. */
  72424. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72425. /**
  72426. * Dispose and release the resources attached to this renderer.
  72427. */
  72428. dispose(): void;
  72429. }
  72430. }
  72431. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  72432. import { Nullable } from "babylonjs/types";
  72433. import { Scene } from "babylonjs/scene";
  72434. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  72435. import { Camera } from "babylonjs/Cameras/camera";
  72436. import { ISceneComponent } from "babylonjs/sceneComponent";
  72437. module "babylonjs/scene" {
  72438. interface Scene {
  72439. /** @hidden (Backing field) */
  72440. _depthRenderer: {
  72441. [id: string]: DepthRenderer;
  72442. };
  72443. /**
  72444. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72445. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72446. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72447. * @returns the created depth renderer
  72448. */
  72449. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  72450. /**
  72451. * Disables a depth renderer for a given camera
  72452. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72453. */
  72454. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72455. }
  72456. }
  72457. /**
  72458. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72459. * in several rendering techniques.
  72460. */
  72461. export class DepthRendererSceneComponent implements ISceneComponent {
  72462. /**
  72463. * The component name helpfull to identify the component in the list of scene components.
  72464. */
  72465. readonly name: string;
  72466. /**
  72467. * The scene the component belongs to.
  72468. */
  72469. scene: Scene;
  72470. /**
  72471. * Creates a new instance of the component for the given scene
  72472. * @param scene Defines the scene to register the component in
  72473. */
  72474. constructor(scene: Scene);
  72475. /**
  72476. * Registers the component in a given scene
  72477. */
  72478. register(): void;
  72479. /**
  72480. * Rebuilds the elements related to this component in case of
  72481. * context lost for instance.
  72482. */
  72483. rebuild(): void;
  72484. /**
  72485. * Disposes the component and the associated ressources
  72486. */
  72487. dispose(): void;
  72488. private _gatherRenderTargets;
  72489. private _gatherActiveCameraRenderTargets;
  72490. }
  72491. }
  72492. declare module "babylonjs/Shaders/outline.fragment" {
  72493. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72494. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  72495. /** @hidden */
  72496. export var outlinePixelShader: {
  72497. name: string;
  72498. shader: string;
  72499. };
  72500. }
  72501. declare module "babylonjs/Shaders/outline.vertex" {
  72502. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72504. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72505. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72506. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  72507. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72508. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72509. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72510. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  72511. /** @hidden */
  72512. export var outlineVertexShader: {
  72513. name: string;
  72514. shader: string;
  72515. };
  72516. }
  72517. declare module "babylonjs/Rendering/outlineRenderer" {
  72518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72519. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  72520. import { Scene } from "babylonjs/scene";
  72521. import { ISceneComponent } from "babylonjs/sceneComponent";
  72522. import "babylonjs/Shaders/outline.fragment";
  72523. import "babylonjs/Shaders/outline.vertex";
  72524. module "babylonjs/scene" {
  72525. interface Scene {
  72526. /** @hidden */
  72527. _outlineRenderer: OutlineRenderer;
  72528. /**
  72529. * Gets the outline renderer associated with the scene
  72530. * @returns a OutlineRenderer
  72531. */
  72532. getOutlineRenderer(): OutlineRenderer;
  72533. }
  72534. }
  72535. module "babylonjs/Meshes/abstractMesh" {
  72536. interface AbstractMesh {
  72537. /** @hidden (Backing field) */
  72538. _renderOutline: boolean;
  72539. /**
  72540. * Gets or sets a boolean indicating if the outline must be rendered as well
  72541. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72542. */
  72543. renderOutline: boolean;
  72544. /** @hidden (Backing field) */
  72545. _renderOverlay: boolean;
  72546. /**
  72547. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72548. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72549. */
  72550. renderOverlay: boolean;
  72551. }
  72552. }
  72553. /**
  72554. * This class is responsible to draw bothe outline/overlay of meshes.
  72555. * It should not be used directly but through the available method on mesh.
  72556. */
  72557. export class OutlineRenderer implements ISceneComponent {
  72558. /**
  72559. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72560. */
  72561. private static _StencilReference;
  72562. /**
  72563. * The name of the component. Each component must have a unique name.
  72564. */
  72565. name: string;
  72566. /**
  72567. * The scene the component belongs to.
  72568. */
  72569. scene: Scene;
  72570. /**
  72571. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72572. */
  72573. zOffset: number;
  72574. private _engine;
  72575. private _effect;
  72576. private _cachedDefines;
  72577. private _savedDepthWrite;
  72578. /**
  72579. * Instantiates a new outline renderer. (There could be only one per scene).
  72580. * @param scene Defines the scene it belongs to
  72581. */
  72582. constructor(scene: Scene);
  72583. /**
  72584. * Register the component to one instance of a scene.
  72585. */
  72586. register(): void;
  72587. /**
  72588. * Rebuilds the elements related to this component in case of
  72589. * context lost for instance.
  72590. */
  72591. rebuild(): void;
  72592. /**
  72593. * Disposes the component and the associated ressources.
  72594. */
  72595. dispose(): void;
  72596. /**
  72597. * Renders the outline in the canvas.
  72598. * @param subMesh Defines the sumesh to render
  72599. * @param batch Defines the batch of meshes in case of instances
  72600. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72601. */
  72602. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72603. /**
  72604. * Returns whether or not the outline renderer is ready for a given submesh.
  72605. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72606. * @param subMesh Defines the submesh to check readyness for
  72607. * @param useInstances Defines wheter wee are trying to render instances or not
  72608. * @returns true if ready otherwise false
  72609. */
  72610. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72611. private _beforeRenderingMesh;
  72612. private _afterRenderingMesh;
  72613. }
  72614. }
  72615. declare module "babylonjs/Rendering/index" {
  72616. export * from "babylonjs/Rendering/boundingBoxRenderer";
  72617. export * from "babylonjs/Rendering/depthRenderer";
  72618. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  72619. export * from "babylonjs/Rendering/edgesRenderer";
  72620. export * from "babylonjs/Rendering/geometryBufferRenderer";
  72621. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72622. export * from "babylonjs/Rendering/outlineRenderer";
  72623. export * from "babylonjs/Rendering/renderingGroup";
  72624. export * from "babylonjs/Rendering/renderingManager";
  72625. export * from "babylonjs/Rendering/utilityLayerRenderer";
  72626. }
  72627. declare module "babylonjs/Sprites/ISprites" {
  72628. /**
  72629. * Defines the basic options interface of a Sprite Frame Source Size.
  72630. */
  72631. export interface ISpriteJSONSpriteSourceSize {
  72632. /**
  72633. * number of the original width of the Frame
  72634. */
  72635. w: number;
  72636. /**
  72637. * number of the original height of the Frame
  72638. */
  72639. h: number;
  72640. }
  72641. /**
  72642. * Defines the basic options interface of a Sprite Frame Data.
  72643. */
  72644. export interface ISpriteJSONSpriteFrameData {
  72645. /**
  72646. * number of the x offset of the Frame
  72647. */
  72648. x: number;
  72649. /**
  72650. * number of the y offset of the Frame
  72651. */
  72652. y: number;
  72653. /**
  72654. * number of the width of the Frame
  72655. */
  72656. w: number;
  72657. /**
  72658. * number of the height of the Frame
  72659. */
  72660. h: number;
  72661. }
  72662. /**
  72663. * Defines the basic options interface of a JSON Sprite.
  72664. */
  72665. export interface ISpriteJSONSprite {
  72666. /**
  72667. * string name of the Frame
  72668. */
  72669. filename: string;
  72670. /**
  72671. * ISpriteJSONSpriteFrame basic object of the frame data
  72672. */
  72673. frame: ISpriteJSONSpriteFrameData;
  72674. /**
  72675. * boolean to flag is the frame was rotated.
  72676. */
  72677. rotated: boolean;
  72678. /**
  72679. * boolean to flag is the frame was trimmed.
  72680. */
  72681. trimmed: boolean;
  72682. /**
  72683. * ISpriteJSONSpriteFrame basic object of the source data
  72684. */
  72685. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72686. /**
  72687. * ISpriteJSONSpriteFrame basic object of the source data
  72688. */
  72689. sourceSize: ISpriteJSONSpriteSourceSize;
  72690. }
  72691. /**
  72692. * Defines the basic options interface of a JSON atlas.
  72693. */
  72694. export interface ISpriteJSONAtlas {
  72695. /**
  72696. * Array of objects that contain the frame data.
  72697. */
  72698. frames: Array<ISpriteJSONSprite>;
  72699. /**
  72700. * object basic object containing the sprite meta data.
  72701. */
  72702. meta?: object;
  72703. }
  72704. }
  72705. declare module "babylonjs/Shaders/spriteMap.fragment" {
  72706. /** @hidden */
  72707. export var spriteMapPixelShader: {
  72708. name: string;
  72709. shader: string;
  72710. };
  72711. }
  72712. declare module "babylonjs/Shaders/spriteMap.vertex" {
  72713. /** @hidden */
  72714. export var spriteMapVertexShader: {
  72715. name: string;
  72716. shader: string;
  72717. };
  72718. }
  72719. declare module "babylonjs/Sprites/spriteMap" {
  72720. import { IDisposable, Scene } from "babylonjs/scene";
  72721. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  72722. import { Texture } from "babylonjs/Materials/Textures/texture";
  72723. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72724. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  72725. import "babylonjs/Meshes/Builders/planeBuilder";
  72726. import "babylonjs/Shaders/spriteMap.fragment";
  72727. import "babylonjs/Shaders/spriteMap.vertex";
  72728. /**
  72729. * Defines the basic options interface of a SpriteMap
  72730. */
  72731. export interface ISpriteMapOptions {
  72732. /**
  72733. * Vector2 of the number of cells in the grid.
  72734. */
  72735. stageSize?: Vector2;
  72736. /**
  72737. * Vector2 of the size of the output plane in World Units.
  72738. */
  72739. outputSize?: Vector2;
  72740. /**
  72741. * Vector3 of the position of the output plane in World Units.
  72742. */
  72743. outputPosition?: Vector3;
  72744. /**
  72745. * Vector3 of the rotation of the output plane.
  72746. */
  72747. outputRotation?: Vector3;
  72748. /**
  72749. * number of layers that the system will reserve in resources.
  72750. */
  72751. layerCount?: number;
  72752. /**
  72753. * number of max animation frames a single cell will reserve in resources.
  72754. */
  72755. maxAnimationFrames?: number;
  72756. /**
  72757. * number cell index of the base tile when the system compiles.
  72758. */
  72759. baseTile?: number;
  72760. /**
  72761. * boolean flip the sprite after its been repositioned by the framing data.
  72762. */
  72763. flipU?: boolean;
  72764. /**
  72765. * Vector3 scalar of the global RGB values of the SpriteMap.
  72766. */
  72767. colorMultiply?: Vector3;
  72768. }
  72769. /**
  72770. * Defines the IDisposable interface in order to be cleanable from resources.
  72771. */
  72772. export interface ISpriteMap extends IDisposable {
  72773. /**
  72774. * String name of the SpriteMap.
  72775. */
  72776. name: string;
  72777. /**
  72778. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72779. */
  72780. atlasJSON: ISpriteJSONAtlas;
  72781. /**
  72782. * Texture of the SpriteMap.
  72783. */
  72784. spriteSheet: Texture;
  72785. /**
  72786. * The parameters to initialize the SpriteMap with.
  72787. */
  72788. options: ISpriteMapOptions;
  72789. }
  72790. /**
  72791. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72792. */
  72793. export class SpriteMap implements ISpriteMap {
  72794. /** The Name of the spriteMap */
  72795. name: string;
  72796. /** The JSON file with the frame and meta data */
  72797. atlasJSON: ISpriteJSONAtlas;
  72798. /** The systems Sprite Sheet Texture */
  72799. spriteSheet: Texture;
  72800. /** Arguments passed with the Constructor */
  72801. options: ISpriteMapOptions;
  72802. /** Public Sprite Storage array, parsed from atlasJSON */
  72803. sprites: Array<ISpriteJSONSprite>;
  72804. /** Returns the Number of Sprites in the System */
  72805. get spriteCount(): number;
  72806. /** Returns the Position of Output Plane*/
  72807. get position(): Vector3;
  72808. /** Returns the Position of Output Plane*/
  72809. set position(v: Vector3);
  72810. /** Returns the Rotation of Output Plane*/
  72811. get rotation(): Vector3;
  72812. /** Returns the Rotation of Output Plane*/
  72813. set rotation(v: Vector3);
  72814. /** Sets the AnimationMap*/
  72815. get animationMap(): RawTexture;
  72816. /** Sets the AnimationMap*/
  72817. set animationMap(v: RawTexture);
  72818. /** Scene that the SpriteMap was created in */
  72819. private _scene;
  72820. /** Texture Buffer of Float32 that holds tile frame data*/
  72821. private _frameMap;
  72822. /** Texture Buffers of Float32 that holds tileMap data*/
  72823. private _tileMaps;
  72824. /** Texture Buffer of Float32 that holds Animation Data*/
  72825. private _animationMap;
  72826. /** Custom ShaderMaterial Central to the System*/
  72827. private _material;
  72828. /** Custom ShaderMaterial Central to the System*/
  72829. private _output;
  72830. /** Systems Time Ticker*/
  72831. private _time;
  72832. /**
  72833. * Creates a new SpriteMap
  72834. * @param name defines the SpriteMaps Name
  72835. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72836. * @param spriteSheet is the Texture that the Sprites are on.
  72837. * @param options a basic deployment configuration
  72838. * @param scene The Scene that the map is deployed on
  72839. */
  72840. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72841. /**
  72842. * Returns tileID location
  72843. * @returns Vector2 the cell position ID
  72844. */
  72845. getTileID(): Vector2;
  72846. /**
  72847. * Gets the UV location of the mouse over the SpriteMap.
  72848. * @returns Vector2 the UV position of the mouse interaction
  72849. */
  72850. getMousePosition(): Vector2;
  72851. /**
  72852. * Creates the "frame" texture Buffer
  72853. * -------------------------------------
  72854. * Structure of frames
  72855. * "filename": "Falling-Water-2.png",
  72856. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72857. * "rotated": true,
  72858. * "trimmed": true,
  72859. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72860. * "sourceSize": {"w":32,"h":32}
  72861. * @returns RawTexture of the frameMap
  72862. */
  72863. private _createFrameBuffer;
  72864. /**
  72865. * Creates the tileMap texture Buffer
  72866. * @param buffer normally and array of numbers, or a false to generate from scratch
  72867. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72868. * @returns RawTexture of the tileMap
  72869. */
  72870. private _createTileBuffer;
  72871. /**
  72872. * Modifies the data of the tileMaps
  72873. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72874. * @param pos is the iVector2 Coordinates of the Tile
  72875. * @param tile The SpriteIndex of the new Tile
  72876. */
  72877. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72878. /**
  72879. * Creates the animationMap texture Buffer
  72880. * @param buffer normally and array of numbers, or a false to generate from scratch
  72881. * @returns RawTexture of the animationMap
  72882. */
  72883. private _createTileAnimationBuffer;
  72884. /**
  72885. * Modifies the data of the animationMap
  72886. * @param cellID is the Index of the Sprite
  72887. * @param _frame is the target Animation frame
  72888. * @param toCell is the Target Index of the next frame of the animation
  72889. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72890. * @param speed is a global scalar of the time variable on the map.
  72891. */
  72892. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72893. /**
  72894. * Exports the .tilemaps file
  72895. */
  72896. saveTileMaps(): void;
  72897. /**
  72898. * Imports the .tilemaps file
  72899. * @param url of the .tilemaps file
  72900. */
  72901. loadTileMaps(url: string): void;
  72902. /**
  72903. * Release associated resources
  72904. */
  72905. dispose(): void;
  72906. }
  72907. }
  72908. declare module "babylonjs/Sprites/spritePackedManager" {
  72909. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  72910. import { Scene } from "babylonjs/scene";
  72911. /**
  72912. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72913. * @see http://doc.babylonjs.com/babylon101/sprites
  72914. */
  72915. export class SpritePackedManager extends SpriteManager {
  72916. /** defines the packed manager's name */
  72917. name: string;
  72918. /**
  72919. * Creates a new sprite manager from a packed sprite sheet
  72920. * @param name defines the manager's name
  72921. * @param imgUrl defines the sprite sheet url
  72922. * @param capacity defines the maximum allowed number of sprites
  72923. * @param scene defines the hosting scene
  72924. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72925. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72926. * @param samplingMode defines the smapling mode to use with spritesheet
  72927. * @param fromPacked set to true; do not alter
  72928. */
  72929. constructor(
  72930. /** defines the packed manager's name */
  72931. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72932. }
  72933. }
  72934. declare module "babylonjs/Sprites/index" {
  72935. export * from "babylonjs/Sprites/sprite";
  72936. export * from "babylonjs/Sprites/ISprites";
  72937. export * from "babylonjs/Sprites/spriteManager";
  72938. export * from "babylonjs/Sprites/spriteMap";
  72939. export * from "babylonjs/Sprites/spritePackedManager";
  72940. export * from "babylonjs/Sprites/spriteSceneComponent";
  72941. }
  72942. declare module "babylonjs/States/index" {
  72943. export * from "babylonjs/States/alphaCullingState";
  72944. export * from "babylonjs/States/depthCullingState";
  72945. export * from "babylonjs/States/stencilState";
  72946. }
  72947. declare module "babylonjs/Misc/assetsManager" {
  72948. import { Scene } from "babylonjs/scene";
  72949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72950. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72951. import { Skeleton } from "babylonjs/Bones/skeleton";
  72952. import { Observable } from "babylonjs/Misc/observable";
  72953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  72954. import { Texture } from "babylonjs/Materials/Textures/texture";
  72955. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  72956. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  72957. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  72958. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  72959. /**
  72960. * Defines the list of states available for a task inside a AssetsManager
  72961. */
  72962. export enum AssetTaskState {
  72963. /**
  72964. * Initialization
  72965. */
  72966. INIT = 0,
  72967. /**
  72968. * Running
  72969. */
  72970. RUNNING = 1,
  72971. /**
  72972. * Done
  72973. */
  72974. DONE = 2,
  72975. /**
  72976. * Error
  72977. */
  72978. ERROR = 3
  72979. }
  72980. /**
  72981. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72982. */
  72983. export abstract class AbstractAssetTask {
  72984. /**
  72985. * Task name
  72986. */ name: string;
  72987. /**
  72988. * Callback called when the task is successful
  72989. */
  72990. onSuccess: (task: any) => void;
  72991. /**
  72992. * Callback called when the task is not successful
  72993. */
  72994. onError: (task: any, message?: string, exception?: any) => void;
  72995. /**
  72996. * Creates a new AssetsManager
  72997. * @param name defines the name of the task
  72998. */
  72999. constructor(
  73000. /**
  73001. * Task name
  73002. */ name: string);
  73003. private _isCompleted;
  73004. private _taskState;
  73005. private _errorObject;
  73006. /**
  73007. * Get if the task is completed
  73008. */
  73009. get isCompleted(): boolean;
  73010. /**
  73011. * Gets the current state of the task
  73012. */
  73013. get taskState(): AssetTaskState;
  73014. /**
  73015. * Gets the current error object (if task is in error)
  73016. */
  73017. get errorObject(): {
  73018. message?: string;
  73019. exception?: any;
  73020. };
  73021. /**
  73022. * Internal only
  73023. * @hidden
  73024. */
  73025. _setErrorObject(message?: string, exception?: any): void;
  73026. /**
  73027. * Execute the current task
  73028. * @param scene defines the scene where you want your assets to be loaded
  73029. * @param onSuccess is a callback called when the task is successfully executed
  73030. * @param onError is a callback called if an error occurs
  73031. */
  73032. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73033. /**
  73034. * Execute the current task
  73035. * @param scene defines the scene where you want your assets to be loaded
  73036. * @param onSuccess is a callback called when the task is successfully executed
  73037. * @param onError is a callback called if an error occurs
  73038. */
  73039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73040. /**
  73041. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73042. * This can be used with failed tasks that have the reason for failure fixed.
  73043. */
  73044. reset(): void;
  73045. private onErrorCallback;
  73046. private onDoneCallback;
  73047. }
  73048. /**
  73049. * Define the interface used by progress events raised during assets loading
  73050. */
  73051. export interface IAssetsProgressEvent {
  73052. /**
  73053. * Defines the number of remaining tasks to process
  73054. */
  73055. remainingCount: number;
  73056. /**
  73057. * Defines the total number of tasks
  73058. */
  73059. totalCount: number;
  73060. /**
  73061. * Defines the task that was just processed
  73062. */
  73063. task: AbstractAssetTask;
  73064. }
  73065. /**
  73066. * Class used to share progress information about assets loading
  73067. */
  73068. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73069. /**
  73070. * Defines the number of remaining tasks to process
  73071. */
  73072. remainingCount: number;
  73073. /**
  73074. * Defines the total number of tasks
  73075. */
  73076. totalCount: number;
  73077. /**
  73078. * Defines the task that was just processed
  73079. */
  73080. task: AbstractAssetTask;
  73081. /**
  73082. * Creates a AssetsProgressEvent
  73083. * @param remainingCount defines the number of remaining tasks to process
  73084. * @param totalCount defines the total number of tasks
  73085. * @param task defines the task that was just processed
  73086. */
  73087. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73088. }
  73089. /**
  73090. * Define a task used by AssetsManager to load meshes
  73091. */
  73092. export class MeshAssetTask extends AbstractAssetTask {
  73093. /**
  73094. * Defines the name of the task
  73095. */
  73096. name: string;
  73097. /**
  73098. * Defines the list of mesh's names you want to load
  73099. */
  73100. meshesNames: any;
  73101. /**
  73102. * Defines the root url to use as a base to load your meshes and associated resources
  73103. */
  73104. rootUrl: string;
  73105. /**
  73106. * Defines the filename or File of the scene to load from
  73107. */
  73108. sceneFilename: string | File;
  73109. /**
  73110. * Gets the list of loaded meshes
  73111. */
  73112. loadedMeshes: Array<AbstractMesh>;
  73113. /**
  73114. * Gets the list of loaded particle systems
  73115. */
  73116. loadedParticleSystems: Array<IParticleSystem>;
  73117. /**
  73118. * Gets the list of loaded skeletons
  73119. */
  73120. loadedSkeletons: Array<Skeleton>;
  73121. /**
  73122. * Gets the list of loaded animation groups
  73123. */
  73124. loadedAnimationGroups: Array<AnimationGroup>;
  73125. /**
  73126. * Callback called when the task is successful
  73127. */
  73128. onSuccess: (task: MeshAssetTask) => void;
  73129. /**
  73130. * Callback called when the task is successful
  73131. */
  73132. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73133. /**
  73134. * Creates a new MeshAssetTask
  73135. * @param name defines the name of the task
  73136. * @param meshesNames defines the list of mesh's names you want to load
  73137. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73138. * @param sceneFilename defines the filename or File of the scene to load from
  73139. */
  73140. constructor(
  73141. /**
  73142. * Defines the name of the task
  73143. */
  73144. name: string,
  73145. /**
  73146. * Defines the list of mesh's names you want to load
  73147. */
  73148. meshesNames: any,
  73149. /**
  73150. * Defines the root url to use as a base to load your meshes and associated resources
  73151. */
  73152. rootUrl: string,
  73153. /**
  73154. * Defines the filename or File of the scene to load from
  73155. */
  73156. sceneFilename: string | File);
  73157. /**
  73158. * Execute the current task
  73159. * @param scene defines the scene where you want your assets to be loaded
  73160. * @param onSuccess is a callback called when the task is successfully executed
  73161. * @param onError is a callback called if an error occurs
  73162. */
  73163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73164. }
  73165. /**
  73166. * Define a task used by AssetsManager to load text content
  73167. */
  73168. export class TextFileAssetTask extends AbstractAssetTask {
  73169. /**
  73170. * Defines the name of the task
  73171. */
  73172. name: string;
  73173. /**
  73174. * Defines the location of the file to load
  73175. */
  73176. url: string;
  73177. /**
  73178. * Gets the loaded text string
  73179. */
  73180. text: string;
  73181. /**
  73182. * Callback called when the task is successful
  73183. */
  73184. onSuccess: (task: TextFileAssetTask) => void;
  73185. /**
  73186. * Callback called when the task is successful
  73187. */
  73188. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73189. /**
  73190. * Creates a new TextFileAssetTask object
  73191. * @param name defines the name of the task
  73192. * @param url defines the location of the file to load
  73193. */
  73194. constructor(
  73195. /**
  73196. * Defines the name of the task
  73197. */
  73198. name: string,
  73199. /**
  73200. * Defines the location of the file to load
  73201. */
  73202. url: string);
  73203. /**
  73204. * Execute the current task
  73205. * @param scene defines the scene where you want your assets to be loaded
  73206. * @param onSuccess is a callback called when the task is successfully executed
  73207. * @param onError is a callback called if an error occurs
  73208. */
  73209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73210. }
  73211. /**
  73212. * Define a task used by AssetsManager to load binary data
  73213. */
  73214. export class BinaryFileAssetTask extends AbstractAssetTask {
  73215. /**
  73216. * Defines the name of the task
  73217. */
  73218. name: string;
  73219. /**
  73220. * Defines the location of the file to load
  73221. */
  73222. url: string;
  73223. /**
  73224. * Gets the lodaded data (as an array buffer)
  73225. */
  73226. data: ArrayBuffer;
  73227. /**
  73228. * Callback called when the task is successful
  73229. */
  73230. onSuccess: (task: BinaryFileAssetTask) => void;
  73231. /**
  73232. * Callback called when the task is successful
  73233. */
  73234. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73235. /**
  73236. * Creates a new BinaryFileAssetTask object
  73237. * @param name defines the name of the new task
  73238. * @param url defines the location of the file to load
  73239. */
  73240. constructor(
  73241. /**
  73242. * Defines the name of the task
  73243. */
  73244. name: string,
  73245. /**
  73246. * Defines the location of the file to load
  73247. */
  73248. url: string);
  73249. /**
  73250. * Execute the current task
  73251. * @param scene defines the scene where you want your assets to be loaded
  73252. * @param onSuccess is a callback called when the task is successfully executed
  73253. * @param onError is a callback called if an error occurs
  73254. */
  73255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73256. }
  73257. /**
  73258. * Define a task used by AssetsManager to load images
  73259. */
  73260. export class ImageAssetTask extends AbstractAssetTask {
  73261. /**
  73262. * Defines the name of the task
  73263. */
  73264. name: string;
  73265. /**
  73266. * Defines the location of the image to load
  73267. */
  73268. url: string;
  73269. /**
  73270. * Gets the loaded images
  73271. */
  73272. image: HTMLImageElement;
  73273. /**
  73274. * Callback called when the task is successful
  73275. */
  73276. onSuccess: (task: ImageAssetTask) => void;
  73277. /**
  73278. * Callback called when the task is successful
  73279. */
  73280. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73281. /**
  73282. * Creates a new ImageAssetTask
  73283. * @param name defines the name of the task
  73284. * @param url defines the location of the image to load
  73285. */
  73286. constructor(
  73287. /**
  73288. * Defines the name of the task
  73289. */
  73290. name: string,
  73291. /**
  73292. * Defines the location of the image to load
  73293. */
  73294. url: string);
  73295. /**
  73296. * Execute the current task
  73297. * @param scene defines the scene where you want your assets to be loaded
  73298. * @param onSuccess is a callback called when the task is successfully executed
  73299. * @param onError is a callback called if an error occurs
  73300. */
  73301. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73302. }
  73303. /**
  73304. * Defines the interface used by texture loading tasks
  73305. */
  73306. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73307. /**
  73308. * Gets the loaded texture
  73309. */
  73310. texture: TEX;
  73311. }
  73312. /**
  73313. * Define a task used by AssetsManager to load 2D textures
  73314. */
  73315. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73316. /**
  73317. * Defines the name of the task
  73318. */
  73319. name: string;
  73320. /**
  73321. * Defines the location of the file to load
  73322. */
  73323. url: string;
  73324. /**
  73325. * Defines if mipmap should not be generated (default is false)
  73326. */
  73327. noMipmap?: boolean | undefined;
  73328. /**
  73329. * Defines if texture must be inverted on Y axis (default is true)
  73330. */
  73331. invertY: boolean;
  73332. /**
  73333. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73334. */
  73335. samplingMode: number;
  73336. /**
  73337. * Gets the loaded texture
  73338. */
  73339. texture: Texture;
  73340. /**
  73341. * Callback called when the task is successful
  73342. */
  73343. onSuccess: (task: TextureAssetTask) => void;
  73344. /**
  73345. * Callback called when the task is successful
  73346. */
  73347. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73348. /**
  73349. * Creates a new TextureAssetTask object
  73350. * @param name defines the name of the task
  73351. * @param url defines the location of the file to load
  73352. * @param noMipmap defines if mipmap should not be generated (default is false)
  73353. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73354. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73355. */
  73356. constructor(
  73357. /**
  73358. * Defines the name of the task
  73359. */
  73360. name: string,
  73361. /**
  73362. * Defines the location of the file to load
  73363. */
  73364. url: string,
  73365. /**
  73366. * Defines if mipmap should not be generated (default is false)
  73367. */
  73368. noMipmap?: boolean | undefined,
  73369. /**
  73370. * Defines if texture must be inverted on Y axis (default is true)
  73371. */
  73372. invertY?: boolean,
  73373. /**
  73374. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73375. */
  73376. samplingMode?: number);
  73377. /**
  73378. * Execute the current task
  73379. * @param scene defines the scene where you want your assets to be loaded
  73380. * @param onSuccess is a callback called when the task is successfully executed
  73381. * @param onError is a callback called if an error occurs
  73382. */
  73383. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73384. }
  73385. /**
  73386. * Define a task used by AssetsManager to load cube textures
  73387. */
  73388. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73389. /**
  73390. * Defines the name of the task
  73391. */
  73392. name: string;
  73393. /**
  73394. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73395. */
  73396. url: string;
  73397. /**
  73398. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73399. */
  73400. extensions?: string[] | undefined;
  73401. /**
  73402. * Defines if mipmaps should not be generated (default is false)
  73403. */
  73404. noMipmap?: boolean | undefined;
  73405. /**
  73406. * Defines the explicit list of files (undefined by default)
  73407. */
  73408. files?: string[] | undefined;
  73409. /**
  73410. * Gets the loaded texture
  73411. */
  73412. texture: CubeTexture;
  73413. /**
  73414. * Callback called when the task is successful
  73415. */
  73416. onSuccess: (task: CubeTextureAssetTask) => void;
  73417. /**
  73418. * Callback called when the task is successful
  73419. */
  73420. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73421. /**
  73422. * Creates a new CubeTextureAssetTask
  73423. * @param name defines the name of the task
  73424. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73425. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73426. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73427. * @param files defines the explicit list of files (undefined by default)
  73428. */
  73429. constructor(
  73430. /**
  73431. * Defines the name of the task
  73432. */
  73433. name: string,
  73434. /**
  73435. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73436. */
  73437. url: string,
  73438. /**
  73439. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73440. */
  73441. extensions?: string[] | undefined,
  73442. /**
  73443. * Defines if mipmaps should not be generated (default is false)
  73444. */
  73445. noMipmap?: boolean | undefined,
  73446. /**
  73447. * Defines the explicit list of files (undefined by default)
  73448. */
  73449. files?: string[] | undefined);
  73450. /**
  73451. * Execute the current task
  73452. * @param scene defines the scene where you want your assets to be loaded
  73453. * @param onSuccess is a callback called when the task is successfully executed
  73454. * @param onError is a callback called if an error occurs
  73455. */
  73456. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73457. }
  73458. /**
  73459. * Define a task used by AssetsManager to load HDR cube textures
  73460. */
  73461. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73462. /**
  73463. * Defines the name of the task
  73464. */
  73465. name: string;
  73466. /**
  73467. * Defines the location of the file to load
  73468. */
  73469. url: string;
  73470. /**
  73471. * Defines the desired size (the more it increases the longer the generation will be)
  73472. */
  73473. size: number;
  73474. /**
  73475. * Defines if mipmaps should not be generated (default is false)
  73476. */
  73477. noMipmap: boolean;
  73478. /**
  73479. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73480. */
  73481. generateHarmonics: boolean;
  73482. /**
  73483. * 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)
  73484. */
  73485. gammaSpace: boolean;
  73486. /**
  73487. * Internal Use Only
  73488. */
  73489. reserved: boolean;
  73490. /**
  73491. * Gets the loaded texture
  73492. */
  73493. texture: HDRCubeTexture;
  73494. /**
  73495. * Callback called when the task is successful
  73496. */
  73497. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73498. /**
  73499. * Callback called when the task is successful
  73500. */
  73501. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73502. /**
  73503. * Creates a new HDRCubeTextureAssetTask object
  73504. * @param name defines the name of the task
  73505. * @param url defines the location of the file to load
  73506. * @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.
  73507. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73508. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73509. * @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)
  73510. * @param reserved Internal use only
  73511. */
  73512. constructor(
  73513. /**
  73514. * Defines the name of the task
  73515. */
  73516. name: string,
  73517. /**
  73518. * Defines the location of the file to load
  73519. */
  73520. url: string,
  73521. /**
  73522. * Defines the desired size (the more it increases the longer the generation will be)
  73523. */
  73524. size: number,
  73525. /**
  73526. * Defines if mipmaps should not be generated (default is false)
  73527. */
  73528. noMipmap?: boolean,
  73529. /**
  73530. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73531. */
  73532. generateHarmonics?: boolean,
  73533. /**
  73534. * 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)
  73535. */
  73536. gammaSpace?: boolean,
  73537. /**
  73538. * Internal Use Only
  73539. */
  73540. reserved?: boolean);
  73541. /**
  73542. * Execute the current task
  73543. * @param scene defines the scene where you want your assets to be loaded
  73544. * @param onSuccess is a callback called when the task is successfully executed
  73545. * @param onError is a callback called if an error occurs
  73546. */
  73547. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73548. }
  73549. /**
  73550. * Define a task used by AssetsManager to load Equirectangular cube textures
  73551. */
  73552. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73553. /**
  73554. * Defines the name of the task
  73555. */
  73556. name: string;
  73557. /**
  73558. * Defines the location of the file to load
  73559. */
  73560. url: string;
  73561. /**
  73562. * Defines the desired size (the more it increases the longer the generation will be)
  73563. */
  73564. size: number;
  73565. /**
  73566. * Defines if mipmaps should not be generated (default is false)
  73567. */
  73568. noMipmap: boolean;
  73569. /**
  73570. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73571. * but the standard material would require them in Gamma space) (default is true)
  73572. */
  73573. gammaSpace: boolean;
  73574. /**
  73575. * Gets the loaded texture
  73576. */
  73577. texture: EquiRectangularCubeTexture;
  73578. /**
  73579. * Callback called when the task is successful
  73580. */
  73581. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73582. /**
  73583. * Callback called when the task is successful
  73584. */
  73585. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73586. /**
  73587. * Creates a new EquiRectangularCubeTextureAssetTask object
  73588. * @param name defines the name of the task
  73589. * @param url defines the location of the file to load
  73590. * @param size defines the desired size (the more it increases the longer the generation will be)
  73591. * If the size is omitted this implies you are using a preprocessed cubemap.
  73592. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73593. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73594. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73595. * (default is true)
  73596. */
  73597. constructor(
  73598. /**
  73599. * Defines the name of the task
  73600. */
  73601. name: string,
  73602. /**
  73603. * Defines the location of the file to load
  73604. */
  73605. url: string,
  73606. /**
  73607. * Defines the desired size (the more it increases the longer the generation will be)
  73608. */
  73609. size: number,
  73610. /**
  73611. * Defines if mipmaps should not be generated (default is false)
  73612. */
  73613. noMipmap?: boolean,
  73614. /**
  73615. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73616. * but the standard material would require them in Gamma space) (default is true)
  73617. */
  73618. gammaSpace?: boolean);
  73619. /**
  73620. * Execute the current task
  73621. * @param scene defines the scene where you want your assets to be loaded
  73622. * @param onSuccess is a callback called when the task is successfully executed
  73623. * @param onError is a callback called if an error occurs
  73624. */
  73625. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73626. }
  73627. /**
  73628. * This class can be used to easily import assets into a scene
  73629. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73630. */
  73631. export class AssetsManager {
  73632. private _scene;
  73633. private _isLoading;
  73634. protected _tasks: AbstractAssetTask[];
  73635. protected _waitingTasksCount: number;
  73636. protected _totalTasksCount: number;
  73637. /**
  73638. * Callback called when all tasks are processed
  73639. */
  73640. onFinish: (tasks: AbstractAssetTask[]) => void;
  73641. /**
  73642. * Callback called when a task is successful
  73643. */
  73644. onTaskSuccess: (task: AbstractAssetTask) => void;
  73645. /**
  73646. * Callback called when a task had an error
  73647. */
  73648. onTaskError: (task: AbstractAssetTask) => void;
  73649. /**
  73650. * Callback called when a task is done (whatever the result is)
  73651. */
  73652. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73653. /**
  73654. * Observable called when all tasks are processed
  73655. */
  73656. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73657. /**
  73658. * Observable called when a task had an error
  73659. */
  73660. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73661. /**
  73662. * Observable called when all tasks were executed
  73663. */
  73664. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73665. /**
  73666. * Observable called when a task is done (whatever the result is)
  73667. */
  73668. onProgressObservable: Observable<IAssetsProgressEvent>;
  73669. /**
  73670. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73671. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73672. */
  73673. useDefaultLoadingScreen: boolean;
  73674. /**
  73675. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73676. * when all assets have been downloaded.
  73677. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73678. */
  73679. autoHideLoadingUI: boolean;
  73680. /**
  73681. * Creates a new AssetsManager
  73682. * @param scene defines the scene to work on
  73683. */
  73684. constructor(scene: Scene);
  73685. /**
  73686. * Add a MeshAssetTask to the list of active tasks
  73687. * @param taskName defines the name of the new task
  73688. * @param meshesNames defines the name of meshes to load
  73689. * @param rootUrl defines the root url to use to locate files
  73690. * @param sceneFilename defines the filename of the scene file
  73691. * @returns a new MeshAssetTask object
  73692. */
  73693. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73694. /**
  73695. * Add a TextFileAssetTask to the list of active tasks
  73696. * @param taskName defines the name of the new task
  73697. * @param url defines the url of the file to load
  73698. * @returns a new TextFileAssetTask object
  73699. */
  73700. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73701. /**
  73702. * Add a BinaryFileAssetTask to the list of active tasks
  73703. * @param taskName defines the name of the new task
  73704. * @param url defines the url of the file to load
  73705. * @returns a new BinaryFileAssetTask object
  73706. */
  73707. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73708. /**
  73709. * Add a ImageAssetTask to the list of active tasks
  73710. * @param taskName defines the name of the new task
  73711. * @param url defines the url of the file to load
  73712. * @returns a new ImageAssetTask object
  73713. */
  73714. addImageTask(taskName: string, url: string): ImageAssetTask;
  73715. /**
  73716. * Add a TextureAssetTask to the list of active tasks
  73717. * @param taskName defines the name of the new task
  73718. * @param url defines the url of the file to load
  73719. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73720. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73721. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73722. * @returns a new TextureAssetTask object
  73723. */
  73724. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73725. /**
  73726. * Add a CubeTextureAssetTask to the list of active tasks
  73727. * @param taskName defines the name of the new task
  73728. * @param url defines the url of the file to load
  73729. * @param extensions defines the extension to use to load the cube map (can be null)
  73730. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73731. * @param files defines the list of files to load (can be null)
  73732. * @returns a new CubeTextureAssetTask object
  73733. */
  73734. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73735. /**
  73736. *
  73737. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73738. * @param taskName defines the name of the new task
  73739. * @param url defines the url of the file to load
  73740. * @param size defines the size you want for the cubemap (can be null)
  73741. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73742. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73743. * @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)
  73744. * @param reserved Internal use only
  73745. * @returns a new HDRCubeTextureAssetTask object
  73746. */
  73747. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73748. /**
  73749. *
  73750. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73751. * @param taskName defines the name of the new task
  73752. * @param url defines the url of the file to load
  73753. * @param size defines the size you want for the cubemap (can be null)
  73754. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73755. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73756. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73757. * @returns a new EquiRectangularCubeTextureAssetTask object
  73758. */
  73759. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73760. /**
  73761. * Remove a task from the assets manager.
  73762. * @param task the task to remove
  73763. */
  73764. removeTask(task: AbstractAssetTask): void;
  73765. private _decreaseWaitingTasksCount;
  73766. private _runTask;
  73767. /**
  73768. * Reset the AssetsManager and remove all tasks
  73769. * @return the current instance of the AssetsManager
  73770. */
  73771. reset(): AssetsManager;
  73772. /**
  73773. * Start the loading process
  73774. * @return the current instance of the AssetsManager
  73775. */
  73776. load(): AssetsManager;
  73777. /**
  73778. * Start the loading process as an async operation
  73779. * @return a promise returning the list of failed tasks
  73780. */
  73781. loadAsync(): Promise<void>;
  73782. }
  73783. }
  73784. declare module "babylonjs/Misc/deferred" {
  73785. /**
  73786. * Wrapper class for promise with external resolve and reject.
  73787. */
  73788. export class Deferred<T> {
  73789. /**
  73790. * The promise associated with this deferred object.
  73791. */
  73792. readonly promise: Promise<T>;
  73793. private _resolve;
  73794. private _reject;
  73795. /**
  73796. * The resolve method of the promise associated with this deferred object.
  73797. */
  73798. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73799. /**
  73800. * The reject method of the promise associated with this deferred object.
  73801. */
  73802. get reject(): (reason?: any) => void;
  73803. /**
  73804. * Constructor for this deferred object.
  73805. */
  73806. constructor();
  73807. }
  73808. }
  73809. declare module "babylonjs/Misc/meshExploder" {
  73810. import { Mesh } from "babylonjs/Meshes/mesh";
  73811. /**
  73812. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73813. */
  73814. export class MeshExploder {
  73815. private _centerMesh;
  73816. private _meshes;
  73817. private _meshesOrigins;
  73818. private _toCenterVectors;
  73819. private _scaledDirection;
  73820. private _newPosition;
  73821. private _centerPosition;
  73822. /**
  73823. * Explodes meshes from a center mesh.
  73824. * @param meshes The meshes to explode.
  73825. * @param centerMesh The mesh to be center of explosion.
  73826. */
  73827. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73828. private _setCenterMesh;
  73829. /**
  73830. * Get class name
  73831. * @returns "MeshExploder"
  73832. */
  73833. getClassName(): string;
  73834. /**
  73835. * "Exploded meshes"
  73836. * @returns Array of meshes with the centerMesh at index 0.
  73837. */
  73838. getMeshes(): Array<Mesh>;
  73839. /**
  73840. * Explodes meshes giving a specific direction
  73841. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73842. */
  73843. explode(direction?: number): void;
  73844. }
  73845. }
  73846. declare module "babylonjs/Misc/filesInput" {
  73847. import { Engine } from "babylonjs/Engines/engine";
  73848. import { Scene } from "babylonjs/scene";
  73849. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  73850. /**
  73851. * Class used to help managing file picking and drag'n'drop
  73852. */
  73853. export class FilesInput {
  73854. /**
  73855. * List of files ready to be loaded
  73856. */
  73857. static get FilesToLoad(): {
  73858. [key: string]: File;
  73859. };
  73860. /**
  73861. * Callback called when a file is processed
  73862. */
  73863. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  73864. private _engine;
  73865. private _currentScene;
  73866. private _sceneLoadedCallback;
  73867. private _progressCallback;
  73868. private _additionalRenderLoopLogicCallback;
  73869. private _textureLoadingCallback;
  73870. private _startingProcessingFilesCallback;
  73871. private _onReloadCallback;
  73872. private _errorCallback;
  73873. private _elementToMonitor;
  73874. private _sceneFileToLoad;
  73875. private _filesToLoad;
  73876. /**
  73877. * Creates a new FilesInput
  73878. * @param engine defines the rendering engine
  73879. * @param scene defines the hosting scene
  73880. * @param sceneLoadedCallback callback called when scene is loaded
  73881. * @param progressCallback callback called to track progress
  73882. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73883. * @param textureLoadingCallback callback called when a texture is loading
  73884. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73885. * @param onReloadCallback callback called when a reload is requested
  73886. * @param errorCallback callback call if an error occurs
  73887. */
  73888. 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);
  73889. private _dragEnterHandler;
  73890. private _dragOverHandler;
  73891. private _dropHandler;
  73892. /**
  73893. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73894. * @param elementToMonitor defines the DOM element to track
  73895. */
  73896. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73897. /**
  73898. * Release all associated resources
  73899. */
  73900. dispose(): void;
  73901. private renderFunction;
  73902. private drag;
  73903. private drop;
  73904. private _traverseFolder;
  73905. private _processFiles;
  73906. /**
  73907. * Load files from a drop event
  73908. * @param event defines the drop event to use as source
  73909. */
  73910. loadFiles(event: any): void;
  73911. private _processReload;
  73912. /**
  73913. * Reload the current scene from the loaded files
  73914. */
  73915. reload(): void;
  73916. }
  73917. }
  73918. declare module "babylonjs/Misc/HighDynamicRange/index" {
  73919. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  73920. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  73921. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  73922. }
  73923. declare module "babylonjs/Misc/sceneOptimizer" {
  73924. import { Scene, IDisposable } from "babylonjs/scene";
  73925. import { Observable } from "babylonjs/Misc/observable";
  73926. /**
  73927. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73929. */
  73930. export class SceneOptimization {
  73931. /**
  73932. * Defines the priority of this optimization (0 by default which means first in the list)
  73933. */
  73934. priority: number;
  73935. /**
  73936. * Gets a string describing the action executed by the current optimization
  73937. * @returns description string
  73938. */
  73939. getDescription(): string;
  73940. /**
  73941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73942. * @param scene defines the current scene where to apply this optimization
  73943. * @param optimizer defines the current optimizer
  73944. * @returns true if everything that can be done was applied
  73945. */
  73946. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73947. /**
  73948. * Creates the SceneOptimization object
  73949. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73950. * @param desc defines the description associated with the optimization
  73951. */
  73952. constructor(
  73953. /**
  73954. * Defines the priority of this optimization (0 by default which means first in the list)
  73955. */
  73956. priority?: number);
  73957. }
  73958. /**
  73959. * Defines an optimization used to reduce the size of render target textures
  73960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73961. */
  73962. export class TextureOptimization extends SceneOptimization {
  73963. /**
  73964. * Defines the priority of this optimization (0 by default which means first in the list)
  73965. */
  73966. priority: number;
  73967. /**
  73968. * 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
  73969. */
  73970. maximumSize: number;
  73971. /**
  73972. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73973. */
  73974. step: number;
  73975. /**
  73976. * Gets a string describing the action executed by the current optimization
  73977. * @returns description string
  73978. */
  73979. getDescription(): string;
  73980. /**
  73981. * Creates the TextureOptimization object
  73982. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73983. * @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
  73984. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73985. */
  73986. constructor(
  73987. /**
  73988. * Defines the priority of this optimization (0 by default which means first in the list)
  73989. */
  73990. priority?: number,
  73991. /**
  73992. * 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
  73993. */
  73994. maximumSize?: number,
  73995. /**
  73996. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73997. */
  73998. step?: number);
  73999. /**
  74000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74001. * @param scene defines the current scene where to apply this optimization
  74002. * @param optimizer defines the current optimizer
  74003. * @returns true if everything that can be done was applied
  74004. */
  74005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74006. }
  74007. /**
  74008. * Defines an optimization used to increase or decrease the rendering resolution
  74009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74010. */
  74011. export class HardwareScalingOptimization extends SceneOptimization {
  74012. /**
  74013. * Defines the priority of this optimization (0 by default which means first in the list)
  74014. */
  74015. priority: number;
  74016. /**
  74017. * Defines the maximum scale to use (2 by default)
  74018. */
  74019. maximumScale: number;
  74020. /**
  74021. * Defines the step to use between two passes (0.5 by default)
  74022. */
  74023. step: number;
  74024. private _currentScale;
  74025. private _directionOffset;
  74026. /**
  74027. * Gets a string describing the action executed by the current optimization
  74028. * @return description string
  74029. */
  74030. getDescription(): string;
  74031. /**
  74032. * Creates the HardwareScalingOptimization object
  74033. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74034. * @param maximumScale defines the maximum scale to use (2 by default)
  74035. * @param step defines the step to use between two passes (0.5 by default)
  74036. */
  74037. constructor(
  74038. /**
  74039. * Defines the priority of this optimization (0 by default which means first in the list)
  74040. */
  74041. priority?: number,
  74042. /**
  74043. * Defines the maximum scale to use (2 by default)
  74044. */
  74045. maximumScale?: number,
  74046. /**
  74047. * Defines the step to use between two passes (0.5 by default)
  74048. */
  74049. step?: number);
  74050. /**
  74051. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74052. * @param scene defines the current scene where to apply this optimization
  74053. * @param optimizer defines the current optimizer
  74054. * @returns true if everything that can be done was applied
  74055. */
  74056. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74057. }
  74058. /**
  74059. * Defines an optimization used to remove shadows
  74060. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74061. */
  74062. export class ShadowsOptimization extends SceneOptimization {
  74063. /**
  74064. * Gets a string describing the action executed by the current optimization
  74065. * @return description string
  74066. */
  74067. getDescription(): string;
  74068. /**
  74069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74070. * @param scene defines the current scene where to apply this optimization
  74071. * @param optimizer defines the current optimizer
  74072. * @returns true if everything that can be done was applied
  74073. */
  74074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74075. }
  74076. /**
  74077. * Defines an optimization used to turn post-processes off
  74078. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74079. */
  74080. export class PostProcessesOptimization extends SceneOptimization {
  74081. /**
  74082. * Gets a string describing the action executed by the current optimization
  74083. * @return description string
  74084. */
  74085. getDescription(): string;
  74086. /**
  74087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74088. * @param scene defines the current scene where to apply this optimization
  74089. * @param optimizer defines the current optimizer
  74090. * @returns true if everything that can be done was applied
  74091. */
  74092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74093. }
  74094. /**
  74095. * Defines an optimization used to turn lens flares off
  74096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74097. */
  74098. export class LensFlaresOptimization extends SceneOptimization {
  74099. /**
  74100. * Gets a string describing the action executed by the current optimization
  74101. * @return description string
  74102. */
  74103. getDescription(): string;
  74104. /**
  74105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74106. * @param scene defines the current scene where to apply this optimization
  74107. * @param optimizer defines the current optimizer
  74108. * @returns true if everything that can be done was applied
  74109. */
  74110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74111. }
  74112. /**
  74113. * Defines an optimization based on user defined callback.
  74114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74115. */
  74116. export class CustomOptimization extends SceneOptimization {
  74117. /**
  74118. * Callback called to apply the custom optimization.
  74119. */
  74120. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74121. /**
  74122. * Callback called to get custom description
  74123. */
  74124. onGetDescription: () => string;
  74125. /**
  74126. * Gets a string describing the action executed by the current optimization
  74127. * @returns description string
  74128. */
  74129. getDescription(): string;
  74130. /**
  74131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74132. * @param scene defines the current scene where to apply this optimization
  74133. * @param optimizer defines the current optimizer
  74134. * @returns true if everything that can be done was applied
  74135. */
  74136. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74137. }
  74138. /**
  74139. * Defines an optimization used to turn particles off
  74140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74141. */
  74142. export class ParticlesOptimization extends SceneOptimization {
  74143. /**
  74144. * Gets a string describing the action executed by the current optimization
  74145. * @return description string
  74146. */
  74147. getDescription(): string;
  74148. /**
  74149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74150. * @param scene defines the current scene where to apply this optimization
  74151. * @param optimizer defines the current optimizer
  74152. * @returns true if everything that can be done was applied
  74153. */
  74154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74155. }
  74156. /**
  74157. * Defines an optimization used to turn render targets off
  74158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74159. */
  74160. export class RenderTargetsOptimization extends SceneOptimization {
  74161. /**
  74162. * Gets a string describing the action executed by the current optimization
  74163. * @return description string
  74164. */
  74165. getDescription(): string;
  74166. /**
  74167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74168. * @param scene defines the current scene where to apply this optimization
  74169. * @param optimizer defines the current optimizer
  74170. * @returns true if everything that can be done was applied
  74171. */
  74172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74173. }
  74174. /**
  74175. * Defines an optimization used to merge meshes with compatible materials
  74176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74177. */
  74178. export class MergeMeshesOptimization extends SceneOptimization {
  74179. private static _UpdateSelectionTree;
  74180. /**
  74181. * Gets or sets a boolean which defines if optimization octree has to be updated
  74182. */
  74183. static get UpdateSelectionTree(): boolean;
  74184. /**
  74185. * Gets or sets a boolean which defines if optimization octree has to be updated
  74186. */
  74187. static set UpdateSelectionTree(value: boolean);
  74188. /**
  74189. * Gets a string describing the action executed by the current optimization
  74190. * @return description string
  74191. */
  74192. getDescription(): string;
  74193. private _canBeMerged;
  74194. /**
  74195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74196. * @param scene defines the current scene where to apply this optimization
  74197. * @param optimizer defines the current optimizer
  74198. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74199. * @returns true if everything that can be done was applied
  74200. */
  74201. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74202. }
  74203. /**
  74204. * Defines a list of options used by SceneOptimizer
  74205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74206. */
  74207. export class SceneOptimizerOptions {
  74208. /**
  74209. * Defines the target frame rate to reach (60 by default)
  74210. */
  74211. targetFrameRate: number;
  74212. /**
  74213. * Defines the interval between two checkes (2000ms by default)
  74214. */
  74215. trackerDuration: number;
  74216. /**
  74217. * Gets the list of optimizations to apply
  74218. */
  74219. optimizations: SceneOptimization[];
  74220. /**
  74221. * Creates a new list of options used by SceneOptimizer
  74222. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74223. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74224. */
  74225. constructor(
  74226. /**
  74227. * Defines the target frame rate to reach (60 by default)
  74228. */
  74229. targetFrameRate?: number,
  74230. /**
  74231. * Defines the interval between two checkes (2000ms by default)
  74232. */
  74233. trackerDuration?: number);
  74234. /**
  74235. * Add a new optimization
  74236. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74237. * @returns the current SceneOptimizerOptions
  74238. */
  74239. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74240. /**
  74241. * Add a new custom optimization
  74242. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74243. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74244. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74245. * @returns the current SceneOptimizerOptions
  74246. */
  74247. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74248. /**
  74249. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74250. * @param targetFrameRate defines the target frame rate (60 by default)
  74251. * @returns a SceneOptimizerOptions object
  74252. */
  74253. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74254. /**
  74255. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74256. * @param targetFrameRate defines the target frame rate (60 by default)
  74257. * @returns a SceneOptimizerOptions object
  74258. */
  74259. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74260. /**
  74261. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74262. * @param targetFrameRate defines the target frame rate (60 by default)
  74263. * @returns a SceneOptimizerOptions object
  74264. */
  74265. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74266. }
  74267. /**
  74268. * Class used to run optimizations in order to reach a target frame rate
  74269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74270. */
  74271. export class SceneOptimizer implements IDisposable {
  74272. private _isRunning;
  74273. private _options;
  74274. private _scene;
  74275. private _currentPriorityLevel;
  74276. private _targetFrameRate;
  74277. private _trackerDuration;
  74278. private _currentFrameRate;
  74279. private _sceneDisposeObserver;
  74280. private _improvementMode;
  74281. /**
  74282. * Defines an observable called when the optimizer reaches the target frame rate
  74283. */
  74284. onSuccessObservable: Observable<SceneOptimizer>;
  74285. /**
  74286. * Defines an observable called when the optimizer enables an optimization
  74287. */
  74288. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74289. /**
  74290. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74291. */
  74292. onFailureObservable: Observable<SceneOptimizer>;
  74293. /**
  74294. * Gets a boolean indicating if the optimizer is in improvement mode
  74295. */
  74296. get isInImprovementMode(): boolean;
  74297. /**
  74298. * Gets the current priority level (0 at start)
  74299. */
  74300. get currentPriorityLevel(): number;
  74301. /**
  74302. * Gets the current frame rate checked by the SceneOptimizer
  74303. */
  74304. get currentFrameRate(): number;
  74305. /**
  74306. * Gets or sets the current target frame rate (60 by default)
  74307. */
  74308. get targetFrameRate(): number;
  74309. /**
  74310. * Gets or sets the current target frame rate (60 by default)
  74311. */
  74312. set targetFrameRate(value: number);
  74313. /**
  74314. * Gets or sets the current interval between two checks (every 2000ms by default)
  74315. */
  74316. get trackerDuration(): number;
  74317. /**
  74318. * Gets or sets the current interval between two checks (every 2000ms by default)
  74319. */
  74320. set trackerDuration(value: number);
  74321. /**
  74322. * Gets the list of active optimizations
  74323. */
  74324. get optimizations(): SceneOptimization[];
  74325. /**
  74326. * Creates a new SceneOptimizer
  74327. * @param scene defines the scene to work on
  74328. * @param options defines the options to use with the SceneOptimizer
  74329. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74330. * @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)
  74331. */
  74332. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74333. /**
  74334. * Stops the current optimizer
  74335. */
  74336. stop(): void;
  74337. /**
  74338. * Reset the optimizer to initial step (current priority level = 0)
  74339. */
  74340. reset(): void;
  74341. /**
  74342. * Start the optimizer. By default it will try to reach a specific framerate
  74343. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74344. */
  74345. start(): void;
  74346. private _checkCurrentState;
  74347. /**
  74348. * Release all resources
  74349. */
  74350. dispose(): void;
  74351. /**
  74352. * Helper function to create a SceneOptimizer with one single line of code
  74353. * @param scene defines the scene to work on
  74354. * @param options defines the options to use with the SceneOptimizer
  74355. * @param onSuccess defines a callback to call on success
  74356. * @param onFailure defines a callback to call on failure
  74357. * @returns the new SceneOptimizer object
  74358. */
  74359. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74360. }
  74361. }
  74362. declare module "babylonjs/Misc/sceneSerializer" {
  74363. import { Scene } from "babylonjs/scene";
  74364. /**
  74365. * Class used to serialize a scene into a string
  74366. */
  74367. export class SceneSerializer {
  74368. /**
  74369. * Clear cache used by a previous serialization
  74370. */
  74371. static ClearCache(): void;
  74372. /**
  74373. * Serialize a scene into a JSON compatible object
  74374. * @param scene defines the scene to serialize
  74375. * @returns a JSON compatible object
  74376. */
  74377. static Serialize(scene: Scene): any;
  74378. /**
  74379. * Serialize a mesh into a JSON compatible object
  74380. * @param toSerialize defines the mesh to serialize
  74381. * @param withParents defines if parents must be serialized as well
  74382. * @param withChildren defines if children must be serialized as well
  74383. * @returns a JSON compatible object
  74384. */
  74385. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74386. }
  74387. }
  74388. declare module "babylonjs/Misc/textureTools" {
  74389. import { Texture } from "babylonjs/Materials/Textures/texture";
  74390. /**
  74391. * Class used to host texture specific utilities
  74392. */
  74393. export class TextureTools {
  74394. /**
  74395. * Uses the GPU to create a copy texture rescaled at a given size
  74396. * @param texture Texture to copy from
  74397. * @param width defines the desired width
  74398. * @param height defines the desired height
  74399. * @param useBilinearMode defines if bilinear mode has to be used
  74400. * @return the generated texture
  74401. */
  74402. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74403. }
  74404. }
  74405. declare module "babylonjs/Misc/videoRecorder" {
  74406. import { Nullable } from "babylonjs/types";
  74407. import { Engine } from "babylonjs/Engines/engine";
  74408. /**
  74409. * This represents the different options available for the video capture.
  74410. */
  74411. export interface VideoRecorderOptions {
  74412. /** Defines the mime type of the video. */
  74413. mimeType: string;
  74414. /** Defines the FPS the video should be recorded at. */
  74415. fps: number;
  74416. /** Defines the chunk size for the recording data. */
  74417. recordChunckSize: number;
  74418. /** The audio tracks to attach to the recording. */
  74419. audioTracks?: MediaStreamTrack[];
  74420. }
  74421. /**
  74422. * This can help with recording videos from BabylonJS.
  74423. * This is based on the available WebRTC functionalities of the browser.
  74424. *
  74425. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  74426. */
  74427. export class VideoRecorder {
  74428. private static readonly _defaultOptions;
  74429. /**
  74430. * Returns whether or not the VideoRecorder is available in your browser.
  74431. * @param engine Defines the Babylon Engine.
  74432. * @returns true if supported otherwise false.
  74433. */
  74434. static IsSupported(engine: Engine): boolean;
  74435. private readonly _options;
  74436. private _canvas;
  74437. private _mediaRecorder;
  74438. private _recordedChunks;
  74439. private _fileName;
  74440. private _resolve;
  74441. private _reject;
  74442. /**
  74443. * True when a recording is already in progress.
  74444. */
  74445. get isRecording(): boolean;
  74446. /**
  74447. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74448. * @param engine Defines the BabylonJS Engine you wish to record.
  74449. * @param options Defines options that can be used to customize the capture.
  74450. */
  74451. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74452. /**
  74453. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74454. */
  74455. stopRecording(): void;
  74456. /**
  74457. * Starts recording the canvas for a max duration specified in parameters.
  74458. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74459. * If null no automatic download will start and you can rely on the promise to get the data back.
  74460. * @param maxDuration Defines the maximum recording time in seconds.
  74461. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74462. * @return A promise callback at the end of the recording with the video data in Blob.
  74463. */
  74464. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74465. /**
  74466. * Releases internal resources used during the recording.
  74467. */
  74468. dispose(): void;
  74469. private _handleDataAvailable;
  74470. private _handleError;
  74471. private _handleStop;
  74472. }
  74473. }
  74474. declare module "babylonjs/Misc/screenshotTools" {
  74475. import { Camera } from "babylonjs/Cameras/camera";
  74476. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  74477. import { Engine } from "babylonjs/Engines/engine";
  74478. /**
  74479. * Class containing a set of static utilities functions for screenshots
  74480. */
  74481. export class ScreenshotTools {
  74482. /**
  74483. * Captures a screenshot of the current rendering
  74484. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74485. * @param engine defines the rendering engine
  74486. * @param camera defines the source camera
  74487. * @param size This parameter can be set to a single number or to an object with the
  74488. * following (optional) properties: precision, width, height. If a single number is passed,
  74489. * it will be used for both width and height. If an object is passed, the screenshot size
  74490. * will be derived from the parameters. The precision property is a multiplier allowing
  74491. * rendering at a higher or lower resolution
  74492. * @param successCallback defines the callback receives a single parameter which contains the
  74493. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74494. * src parameter of an <img> to display it
  74495. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74496. * Check your browser for supported MIME types
  74497. */
  74498. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74499. /**
  74500. * Captures a screenshot of the current rendering
  74501. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74502. * @param engine defines the rendering engine
  74503. * @param camera defines the source camera
  74504. * @param size This parameter can be set to a single number or to an object with the
  74505. * following (optional) properties: precision, width, height. If a single number is passed,
  74506. * it will be used for both width and height. If an object is passed, the screenshot size
  74507. * will be derived from the parameters. The precision property is a multiplier allowing
  74508. * rendering at a higher or lower resolution
  74509. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74510. * Check your browser for supported MIME types
  74511. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74512. * to the src parameter of an <img> to display it
  74513. */
  74514. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74515. /**
  74516. * Generates an image screenshot from the specified camera.
  74517. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74518. * @param engine The engine to use for rendering
  74519. * @param camera The camera to use for rendering
  74520. * @param size This parameter can be set to a single number or to an object with the
  74521. * following (optional) properties: precision, width, height. If a single number is passed,
  74522. * it will be used for both width and height. If an object is passed, the screenshot size
  74523. * will be derived from the parameters. The precision property is a multiplier allowing
  74524. * rendering at a higher or lower resolution
  74525. * @param successCallback The callback receives a single parameter which contains the
  74526. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74527. * src parameter of an <img> to display it
  74528. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74529. * Check your browser for supported MIME types
  74530. * @param samples Texture samples (default: 1)
  74531. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74532. * @param fileName A name for for the downloaded file.
  74533. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74534. */
  74535. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  74536. /**
  74537. * Generates an image screenshot from the specified camera.
  74538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  74539. * @param engine The engine to use for rendering
  74540. * @param camera The camera to use for rendering
  74541. * @param size This parameter can be set to a single number or to an object with the
  74542. * following (optional) properties: precision, width, height. If a single number is passed,
  74543. * it will be used for both width and height. If an object is passed, the screenshot size
  74544. * will be derived from the parameters. The precision property is a multiplier allowing
  74545. * rendering at a higher or lower resolution
  74546. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74547. * Check your browser for supported MIME types
  74548. * @param samples Texture samples (default: 1)
  74549. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74550. * @param fileName A name for for the downloaded file.
  74551. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74552. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74553. * to the src parameter of an <img> to display it
  74554. */
  74555. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74556. /**
  74557. * Gets height and width for screenshot size
  74558. * @private
  74559. */
  74560. private static _getScreenshotSize;
  74561. }
  74562. }
  74563. declare module "babylonjs/Misc/dataReader" {
  74564. /**
  74565. * Interface for a data buffer
  74566. */
  74567. export interface IDataBuffer {
  74568. /**
  74569. * Reads bytes from the data buffer.
  74570. * @param byteOffset The byte offset to read
  74571. * @param byteLength The byte length to read
  74572. * @returns A promise that resolves when the bytes are read
  74573. */
  74574. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74575. /**
  74576. * The byte length of the buffer.
  74577. */
  74578. readonly byteLength: number;
  74579. }
  74580. /**
  74581. * Utility class for reading from a data buffer
  74582. */
  74583. export class DataReader {
  74584. /**
  74585. * The data buffer associated with this data reader.
  74586. */
  74587. readonly buffer: IDataBuffer;
  74588. /**
  74589. * The current byte offset from the beginning of the data buffer.
  74590. */
  74591. byteOffset: number;
  74592. private _dataView;
  74593. private _dataByteOffset;
  74594. /**
  74595. * Constructor
  74596. * @param buffer The buffer to read
  74597. */
  74598. constructor(buffer: IDataBuffer);
  74599. /**
  74600. * Loads the given byte length.
  74601. * @param byteLength The byte length to load
  74602. * @returns A promise that resolves when the load is complete
  74603. */
  74604. loadAsync(byteLength: number): Promise<void>;
  74605. /**
  74606. * Read a unsigned 32-bit integer from the currently loaded data range.
  74607. * @returns The 32-bit integer read
  74608. */
  74609. readUint32(): number;
  74610. /**
  74611. * Read a byte array from the currently loaded data range.
  74612. * @param byteLength The byte length to read
  74613. * @returns The byte array read
  74614. */
  74615. readUint8Array(byteLength: number): Uint8Array;
  74616. /**
  74617. * Read a string from the currently loaded data range.
  74618. * @param byteLength The byte length to read
  74619. * @returns The string read
  74620. */
  74621. readString(byteLength: number): string;
  74622. /**
  74623. * Skips the given byte length the currently loaded data range.
  74624. * @param byteLength The byte length to skip
  74625. */
  74626. skipBytes(byteLength: number): void;
  74627. }
  74628. }
  74629. declare module "babylonjs/Misc/dataStorage" {
  74630. /**
  74631. * Class for storing data to local storage if available or in-memory storage otherwise
  74632. */
  74633. export class DataStorage {
  74634. private static _Storage;
  74635. private static _GetStorage;
  74636. /**
  74637. * Reads a string from the data storage
  74638. * @param key The key to read
  74639. * @param defaultValue The value if the key doesn't exist
  74640. * @returns The string value
  74641. */
  74642. static ReadString(key: string, defaultValue: string): string;
  74643. /**
  74644. * Writes a string to the data storage
  74645. * @param key The key to write
  74646. * @param value The value to write
  74647. */
  74648. static WriteString(key: string, value: string): void;
  74649. /**
  74650. * Reads a boolean from the data storage
  74651. * @param key The key to read
  74652. * @param defaultValue The value if the key doesn't exist
  74653. * @returns The boolean value
  74654. */
  74655. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74656. /**
  74657. * Writes a boolean to the data storage
  74658. * @param key The key to write
  74659. * @param value The value to write
  74660. */
  74661. static WriteBoolean(key: string, value: boolean): void;
  74662. /**
  74663. * Reads a number from the data storage
  74664. * @param key The key to read
  74665. * @param defaultValue The value if the key doesn't exist
  74666. * @returns The number value
  74667. */
  74668. static ReadNumber(key: string, defaultValue: number): number;
  74669. /**
  74670. * Writes a number to the data storage
  74671. * @param key The key to write
  74672. * @param value The value to write
  74673. */
  74674. static WriteNumber(key: string, value: number): void;
  74675. }
  74676. }
  74677. declare module "babylonjs/Misc/index" {
  74678. export * from "babylonjs/Misc/andOrNotEvaluator";
  74679. export * from "babylonjs/Misc/assetsManager";
  74680. export * from "babylonjs/Misc/basis";
  74681. export * from "babylonjs/Misc/dds";
  74682. export * from "babylonjs/Misc/decorators";
  74683. export * from "babylonjs/Misc/deferred";
  74684. export * from "babylonjs/Misc/environmentTextureTools";
  74685. export * from "babylonjs/Misc/meshExploder";
  74686. export * from "babylonjs/Misc/filesInput";
  74687. export * from "babylonjs/Misc/HighDynamicRange/index";
  74688. export * from "babylonjs/Misc/khronosTextureContainer";
  74689. export * from "babylonjs/Misc/observable";
  74690. export * from "babylonjs/Misc/performanceMonitor";
  74691. export * from "babylonjs/Misc/promise";
  74692. export * from "babylonjs/Misc/sceneOptimizer";
  74693. export * from "babylonjs/Misc/sceneSerializer";
  74694. export * from "babylonjs/Misc/smartArray";
  74695. export * from "babylonjs/Misc/stringDictionary";
  74696. export * from "babylonjs/Misc/tags";
  74697. export * from "babylonjs/Misc/textureTools";
  74698. export * from "babylonjs/Misc/tga";
  74699. export * from "babylonjs/Misc/tools";
  74700. export * from "babylonjs/Misc/videoRecorder";
  74701. export * from "babylonjs/Misc/virtualJoystick";
  74702. export * from "babylonjs/Misc/workerPool";
  74703. export * from "babylonjs/Misc/logger";
  74704. export * from "babylonjs/Misc/typeStore";
  74705. export * from "babylonjs/Misc/filesInputStore";
  74706. export * from "babylonjs/Misc/deepCopier";
  74707. export * from "babylonjs/Misc/pivotTools";
  74708. export * from "babylonjs/Misc/precisionDate";
  74709. export * from "babylonjs/Misc/screenshotTools";
  74710. export * from "babylonjs/Misc/typeStore";
  74711. export * from "babylonjs/Misc/webRequest";
  74712. export * from "babylonjs/Misc/iInspectable";
  74713. export * from "babylonjs/Misc/brdfTextureTools";
  74714. export * from "babylonjs/Misc/rgbdTextureTools";
  74715. export * from "babylonjs/Misc/gradients";
  74716. export * from "babylonjs/Misc/perfCounter";
  74717. export * from "babylonjs/Misc/fileRequest";
  74718. export * from "babylonjs/Misc/customAnimationFrameRequester";
  74719. export * from "babylonjs/Misc/retryStrategy";
  74720. export * from "babylonjs/Misc/interfaces/screenshotSize";
  74721. export * from "babylonjs/Misc/canvasGenerator";
  74722. export * from "babylonjs/Misc/fileTools";
  74723. export * from "babylonjs/Misc/stringTools";
  74724. export * from "babylonjs/Misc/dataReader";
  74725. export * from "babylonjs/Misc/minMaxReducer";
  74726. export * from "babylonjs/Misc/depthReducer";
  74727. export * from "babylonjs/Misc/dataStorage";
  74728. }
  74729. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  74730. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74731. import { Observable } from "babylonjs/Misc/observable";
  74732. import { Matrix } from "babylonjs/Maths/math.vector";
  74733. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74734. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74735. /**
  74736. * Options used for hit testing
  74737. */
  74738. export interface IWebXRLegacyHitTestOptions {
  74739. /**
  74740. * Only test when user interacted with the scene. Default - hit test every frame
  74741. */
  74742. testOnPointerDownOnly?: boolean;
  74743. /**
  74744. * The node to use to transform the local results to world coordinates
  74745. */
  74746. worldParentNode?: TransformNode;
  74747. }
  74748. /**
  74749. * Interface defining the babylon result of raycasting/hit-test
  74750. */
  74751. export interface IWebXRLegacyHitResult {
  74752. /**
  74753. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74754. */
  74755. transformationMatrix: Matrix;
  74756. /**
  74757. * The native hit test result
  74758. */
  74759. xrHitResult: XRHitResult | XRHitTestResult;
  74760. }
  74761. /**
  74762. * The currently-working hit-test module.
  74763. * Hit test (or Ray-casting) is used to interact with the real world.
  74764. * For further information read here - https://github.com/immersive-web/hit-test
  74765. */
  74766. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  74767. /**
  74768. * options to use when constructing this feature
  74769. */
  74770. readonly options: IWebXRLegacyHitTestOptions;
  74771. private _direction;
  74772. private _mat;
  74773. private _onSelectEnabled;
  74774. private _origin;
  74775. /**
  74776. * The module's name
  74777. */
  74778. static readonly Name: string;
  74779. /**
  74780. * The (Babylon) version of this module.
  74781. * This is an integer representing the implementation version.
  74782. * This number does not correspond to the WebXR specs version
  74783. */
  74784. static readonly Version: number;
  74785. /**
  74786. * Populated with the last native XR Hit Results
  74787. */
  74788. lastNativeXRHitResults: XRHitResult[];
  74789. /**
  74790. * Triggered when new babylon (transformed) hit test results are available
  74791. */
  74792. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74793. /**
  74794. * Creates a new instance of the (legacy version) hit test feature
  74795. * @param _xrSessionManager an instance of WebXRSessionManager
  74796. * @param options options to use when constructing this feature
  74797. */
  74798. constructor(_xrSessionManager: WebXRSessionManager,
  74799. /**
  74800. * options to use when constructing this feature
  74801. */
  74802. options?: IWebXRLegacyHitTestOptions);
  74803. /**
  74804. * execute a hit test with an XR Ray
  74805. *
  74806. * @param xrSession a native xrSession that will execute this hit test
  74807. * @param xrRay the ray (position and direction) to use for ray-casting
  74808. * @param referenceSpace native XR reference space to use for the hit-test
  74809. * @param filter filter function that will filter the results
  74810. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74811. */
  74812. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74813. /**
  74814. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74815. * @param event the (select) event to use to select with
  74816. * @param referenceSpace the reference space to use for this hit test
  74817. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74818. */
  74819. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74820. /**
  74821. * attach this feature
  74822. * Will usually be called by the features manager
  74823. *
  74824. * @returns true if successful.
  74825. */
  74826. attach(): boolean;
  74827. /**
  74828. * detach this feature.
  74829. * Will usually be called by the features manager
  74830. *
  74831. * @returns true if successful.
  74832. */
  74833. detach(): boolean;
  74834. /**
  74835. * Dispose this feature and all of the resources attached
  74836. */
  74837. dispose(): void;
  74838. protected _onXRFrame(frame: XRFrame): void;
  74839. private _onHitTestResults;
  74840. private _onSelect;
  74841. }
  74842. }
  74843. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  74844. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74845. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74846. import { Observable } from "babylonjs/Misc/observable";
  74847. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  74848. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74849. /**
  74850. * Options used in the plane detector module
  74851. */
  74852. export interface IWebXRPlaneDetectorOptions {
  74853. /**
  74854. * The node to use to transform the local results to world coordinates
  74855. */
  74856. worldParentNode?: TransformNode;
  74857. }
  74858. /**
  74859. * A babylon interface for a WebXR plane.
  74860. * A Plane is actually a polygon, built from N points in space
  74861. *
  74862. * Supported in chrome 79, not supported in canary 81 ATM
  74863. */
  74864. export interface IWebXRPlane {
  74865. /**
  74866. * a babylon-assigned ID for this polygon
  74867. */
  74868. id: number;
  74869. /**
  74870. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74871. */
  74872. polygonDefinition: Array<Vector3>;
  74873. /**
  74874. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74875. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74876. */
  74877. transformationMatrix: Matrix;
  74878. /**
  74879. * the native xr-plane object
  74880. */
  74881. xrPlane: XRPlane;
  74882. }
  74883. /**
  74884. * The plane detector is used to detect planes in the real world when in AR
  74885. * For more information see https://github.com/immersive-web/real-world-geometry/
  74886. */
  74887. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74888. private _options;
  74889. private _detectedPlanes;
  74890. private _enabled;
  74891. private _lastFrameDetected;
  74892. /**
  74893. * The module's name
  74894. */
  74895. static readonly Name: string;
  74896. /**
  74897. * The (Babylon) version of this module.
  74898. * This is an integer representing the implementation version.
  74899. * This number does not correspond to the WebXR specs version
  74900. */
  74901. static readonly Version: number;
  74902. /**
  74903. * Observers registered here will be executed when a new plane was added to the session
  74904. */
  74905. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74906. /**
  74907. * Observers registered here will be executed when a plane is no longer detected in the session
  74908. */
  74909. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74910. /**
  74911. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74912. * This can execute N times every frame
  74913. */
  74914. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74915. /**
  74916. * construct a new Plane Detector
  74917. * @param _xrSessionManager an instance of xr Session manager
  74918. * @param _options configuration to use when constructing this feature
  74919. */
  74920. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74921. /**
  74922. * Dispose this feature and all of the resources attached
  74923. */
  74924. dispose(): void;
  74925. protected _onXRFrame(frame: XRFrame): void;
  74926. private _init;
  74927. private _updatePlaneWithXRPlane;
  74928. /**
  74929. * avoiding using Array.find for global support.
  74930. * @param xrPlane the plane to find in the array
  74931. */
  74932. private findIndexInPlaneArray;
  74933. }
  74934. }
  74935. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  74936. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  74937. import { Observable } from "babylonjs/Misc/observable";
  74938. import { Matrix } from "babylonjs/Maths/math.vector";
  74939. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74940. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  74941. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  74942. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  74943. /**
  74944. * Configuration options of the anchor system
  74945. */
  74946. export interface IWebXRAnchorSystemOptions {
  74947. /**
  74948. * Should a new anchor be added every time a select event is triggered
  74949. */
  74950. addAnchorOnSelect?: boolean;
  74951. /**
  74952. * should the anchor system use plane detection.
  74953. * If set to true, the plane-detection feature should be set using setPlaneDetector
  74954. */
  74955. usePlaneDetection?: boolean;
  74956. /**
  74957. * a node that will be used to convert local to world coordinates
  74958. */
  74959. worldParentNode?: TransformNode;
  74960. }
  74961. /**
  74962. * A babylon container for an XR Anchor
  74963. */
  74964. export interface IWebXRAnchor {
  74965. /**
  74966. * A babylon-assigned ID for this anchor
  74967. */
  74968. id: number;
  74969. /**
  74970. * Transformation matrix to apply to an object attached to this anchor
  74971. */
  74972. transformationMatrix: Matrix;
  74973. /**
  74974. * The native anchor object
  74975. */
  74976. xrAnchor: XRAnchor;
  74977. }
  74978. /**
  74979. * An implementation of the anchor system of WebXR.
  74980. * Note that the current documented implementation is not available in any browser. Future implementations
  74981. * will use the frame to create an anchor and not the session or a detected plane
  74982. * For further information see https://github.com/immersive-web/anchors/
  74983. */
  74984. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74985. private _options;
  74986. private _enabled;
  74987. private _hitTestModule;
  74988. private _lastFrameDetected;
  74989. private _onSelect;
  74990. private _planeDetector;
  74991. private _trackedAnchors;
  74992. /**
  74993. * The module's name
  74994. */
  74995. static readonly Name: string;
  74996. /**
  74997. * The (Babylon) version of this module.
  74998. * This is an integer representing the implementation version.
  74999. * This number does not correspond to the WebXR specs version
  75000. */
  75001. static readonly Version: number;
  75002. /**
  75003. * Observers registered here will be executed when a new anchor was added to the session
  75004. */
  75005. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75006. /**
  75007. * Observers registered here will be executed when an anchor was removed from the session
  75008. */
  75009. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75010. /**
  75011. * Observers registered here will be executed when an existing anchor updates
  75012. * This can execute N times every frame
  75013. */
  75014. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75015. /**
  75016. * constructs a new anchor system
  75017. * @param _xrSessionManager an instance of WebXRSessionManager
  75018. * @param _options configuration object for this feature
  75019. */
  75020. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75021. /**
  75022. * Add anchor at a specific XR point.
  75023. *
  75024. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  75025. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  75026. * @returns a promise the fulfills when the anchor was created
  75027. */
  75028. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  75029. /**
  75030. * attach this feature
  75031. * Will usually be called by the features manager
  75032. *
  75033. * @returns true if successful.
  75034. */
  75035. attach(): boolean;
  75036. /**
  75037. * detach this feature.
  75038. * Will usually be called by the features manager
  75039. *
  75040. * @returns true if successful.
  75041. */
  75042. detach(): boolean;
  75043. /**
  75044. * Dispose this feature and all of the resources attached
  75045. */
  75046. dispose(): void;
  75047. /**
  75048. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  75049. * @param hitTestModule the hit-test module to use.
  75050. */
  75051. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  75052. /**
  75053. * set the plane detector to use in order to create anchors from frames
  75054. * @param planeDetector the plane-detector module to use
  75055. * @param enable enable plane-anchors. default is true
  75056. */
  75057. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  75058. protected _onXRFrame(frame: XRFrame): void;
  75059. /**
  75060. * avoiding using Array.find for global support.
  75061. * @param xrAnchor the plane to find in the array
  75062. */
  75063. private _findIndexInAnchorArray;
  75064. private _updateAnchorWithXRFrame;
  75065. }
  75066. }
  75067. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  75068. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75070. import { Observable } from "babylonjs/Misc/observable";
  75071. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75072. /**
  75073. * Options interface for the background remover plugin
  75074. */
  75075. export interface IWebXRBackgroundRemoverOptions {
  75076. /**
  75077. * Further background meshes to disable when entering AR
  75078. */
  75079. backgroundMeshes?: AbstractMesh[];
  75080. /**
  75081. * flags to configure the removal of the environment helper.
  75082. * If not set, the entire background will be removed. If set, flags should be set as well.
  75083. */
  75084. environmentHelperRemovalFlags?: {
  75085. /**
  75086. * Should the skybox be removed (default false)
  75087. */
  75088. skyBox?: boolean;
  75089. /**
  75090. * Should the ground be removed (default false)
  75091. */
  75092. ground?: boolean;
  75093. };
  75094. /**
  75095. * don't disable the environment helper
  75096. */
  75097. ignoreEnvironmentHelper?: boolean;
  75098. }
  75099. /**
  75100. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75101. */
  75102. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75103. /**
  75104. * read-only options to be used in this module
  75105. */
  75106. readonly options: IWebXRBackgroundRemoverOptions;
  75107. /**
  75108. * The module's name
  75109. */
  75110. static readonly Name: string;
  75111. /**
  75112. * The (Babylon) version of this module.
  75113. * This is an integer representing the implementation version.
  75114. * This number does not correspond to the WebXR specs version
  75115. */
  75116. static readonly Version: number;
  75117. /**
  75118. * registered observers will be triggered when the background state changes
  75119. */
  75120. onBackgroundStateChangedObservable: Observable<boolean>;
  75121. /**
  75122. * constructs a new background remover module
  75123. * @param _xrSessionManager the session manager for this module
  75124. * @param options read-only options to be used in this module
  75125. */
  75126. constructor(_xrSessionManager: WebXRSessionManager,
  75127. /**
  75128. * read-only options to be used in this module
  75129. */
  75130. options?: IWebXRBackgroundRemoverOptions);
  75131. /**
  75132. * attach this feature
  75133. * Will usually be called by the features manager
  75134. *
  75135. * @returns true if successful.
  75136. */
  75137. attach(): boolean;
  75138. /**
  75139. * detach this feature.
  75140. * Will usually be called by the features manager
  75141. *
  75142. * @returns true if successful.
  75143. */
  75144. detach(): boolean;
  75145. /**
  75146. * Dispose this feature and all of the resources attached
  75147. */
  75148. dispose(): void;
  75149. protected _onXRFrame(_xrFrame: XRFrame): void;
  75150. private _setBackgroundState;
  75151. }
  75152. }
  75153. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  75154. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75155. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  75156. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  75157. import { WebXRInput } from "babylonjs/XR/webXRInput";
  75158. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75159. import { Nullable } from "babylonjs/types";
  75160. /**
  75161. * Options for the controller physics feature
  75162. */
  75163. export class IWebXRControllerPhysicsOptions {
  75164. /**
  75165. * Should the headset get its own impostor
  75166. */
  75167. enableHeadsetImpostor?: boolean;
  75168. /**
  75169. * Optional parameters for the headset impostor
  75170. */
  75171. headsetImpostorParams?: {
  75172. /**
  75173. * The type of impostor to create. Default is sphere
  75174. */
  75175. impostorType: number;
  75176. /**
  75177. * the size of the impostor. Defaults to 10cm
  75178. */
  75179. impostorSize?: number | {
  75180. width: number;
  75181. height: number;
  75182. depth: number;
  75183. };
  75184. /**
  75185. * Friction definitions
  75186. */
  75187. friction?: number;
  75188. /**
  75189. * Restitution
  75190. */
  75191. restitution?: number;
  75192. };
  75193. /**
  75194. * The physics properties of the future impostors
  75195. */
  75196. physicsProperties?: {
  75197. /**
  75198. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75199. * Note that this requires a physics engine that supports mesh impostors!
  75200. */
  75201. useControllerMesh?: boolean;
  75202. /**
  75203. * The type of impostor to create. Default is sphere
  75204. */
  75205. impostorType?: number;
  75206. /**
  75207. * the size of the impostor. Defaults to 10cm
  75208. */
  75209. impostorSize?: number | {
  75210. width: number;
  75211. height: number;
  75212. depth: number;
  75213. };
  75214. /**
  75215. * Friction definitions
  75216. */
  75217. friction?: number;
  75218. /**
  75219. * Restitution
  75220. */
  75221. restitution?: number;
  75222. };
  75223. /**
  75224. * the xr input to use with this pointer selection
  75225. */
  75226. xrInput: WebXRInput;
  75227. }
  75228. /**
  75229. * Add physics impostor to your webxr controllers,
  75230. * including naive calculation of their linear and angular velocity
  75231. */
  75232. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75233. private readonly _options;
  75234. private _attachController;
  75235. private _controllers;
  75236. private _debugMode;
  75237. private _delta;
  75238. private _headsetImpostor?;
  75239. private _headsetMesh?;
  75240. private _lastTimestamp;
  75241. private _tmpQuaternion;
  75242. private _tmpVector;
  75243. /**
  75244. * The module's name
  75245. */
  75246. static readonly Name: string;
  75247. /**
  75248. * The (Babylon) version of this module.
  75249. * This is an integer representing the implementation version.
  75250. * This number does not correspond to the webxr specs version
  75251. */
  75252. static readonly Version: number;
  75253. /**
  75254. * Construct a new Controller Physics Feature
  75255. * @param _xrSessionManager the corresponding xr session manager
  75256. * @param _options options to create this feature with
  75257. */
  75258. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75259. /**
  75260. * @hidden
  75261. * enable debugging - will show console outputs and the impostor mesh
  75262. */
  75263. _enablePhysicsDebug(): void;
  75264. /**
  75265. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75266. * @param xrController the controller to add
  75267. */
  75268. addController(xrController: WebXRInputSource): void;
  75269. /**
  75270. * attach this feature
  75271. * Will usually be called by the features manager
  75272. *
  75273. * @returns true if successful.
  75274. */
  75275. attach(): boolean;
  75276. /**
  75277. * detach this feature.
  75278. * Will usually be called by the features manager
  75279. *
  75280. * @returns true if successful.
  75281. */
  75282. detach(): boolean;
  75283. /**
  75284. * Get the headset impostor, if enabled
  75285. * @returns the impostor
  75286. */
  75287. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75288. /**
  75289. * Get the physics impostor of a specific controller.
  75290. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75291. * @param controller the controller or the controller id of which to get the impostor
  75292. * @returns the impostor or null
  75293. */
  75294. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75295. /**
  75296. * Update the physics properties provided in the constructor
  75297. * @param newProperties the new properties object
  75298. */
  75299. setPhysicsProperties(newProperties: {
  75300. impostorType?: number;
  75301. impostorSize?: number | {
  75302. width: number;
  75303. height: number;
  75304. depth: number;
  75305. };
  75306. friction?: number;
  75307. restitution?: number;
  75308. }): void;
  75309. protected _onXRFrame(_xrFrame: any): void;
  75310. private _detachController;
  75311. }
  75312. }
  75313. declare module "babylonjs/XR/features/WebXRHitTest" {
  75314. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  75315. import { Observable } from "babylonjs/Misc/observable";
  75316. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  75317. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  75318. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  75319. /**
  75320. * Options used for hit testing (version 2)
  75321. */
  75322. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75323. /**
  75324. * Do not create a permanent hit test. Will usually be used when only
  75325. * transient inputs are needed.
  75326. */
  75327. disablePermanentHitTest?: boolean;
  75328. /**
  75329. * Enable transient (for example touch-based) hit test inspections
  75330. */
  75331. enableTransientHitTest?: boolean;
  75332. /**
  75333. * Offset ray for the permanent hit test
  75334. */
  75335. offsetRay?: Vector3;
  75336. /**
  75337. * Offset ray for the transient hit test
  75338. */
  75339. transientOffsetRay?: Vector3;
  75340. /**
  75341. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75342. */
  75343. useReferenceSpace?: boolean;
  75344. }
  75345. /**
  75346. * Interface defining the babylon result of hit-test
  75347. */
  75348. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75349. /**
  75350. * The input source that generated this hit test (if transient)
  75351. */
  75352. inputSource?: XRInputSource;
  75353. /**
  75354. * Is this a transient hit test
  75355. */
  75356. isTransient?: boolean;
  75357. /**
  75358. * Position of the hit test result
  75359. */
  75360. position: Vector3;
  75361. /**
  75362. * Rotation of the hit test result
  75363. */
  75364. rotationQuaternion: Quaternion;
  75365. }
  75366. /**
  75367. * The currently-working hit-test module.
  75368. * Hit test (or Ray-casting) is used to interact with the real world.
  75369. * For further information read here - https://github.com/immersive-web/hit-test
  75370. *
  75371. * Tested on chrome (mobile) 80.
  75372. */
  75373. export class WebXRHitTest extends WebXRAbstractFeature {
  75374. /**
  75375. * options to use when constructing this feature
  75376. */
  75377. readonly options: IWebXRHitTestOptions;
  75378. private _tmpMat;
  75379. private _tmpPos;
  75380. private _tmpQuat;
  75381. private _transientXrHitTestSource;
  75382. private _xrHitTestSource;
  75383. private initHitTestSource;
  75384. /**
  75385. * The module's name
  75386. */
  75387. static readonly Name: string;
  75388. /**
  75389. * The (Babylon) version of this module.
  75390. * This is an integer representing the implementation version.
  75391. * This number does not correspond to the WebXR specs version
  75392. */
  75393. static readonly Version: number;
  75394. /**
  75395. * When set to true, each hit test will have its own position/rotation objects
  75396. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75397. * the developers will clone them or copy them as they see fit.
  75398. */
  75399. autoCloneTransformation: boolean;
  75400. /**
  75401. * Populated with the last native XR Hit Results
  75402. */
  75403. lastNativeXRHitResults: XRHitResult[];
  75404. /**
  75405. * Triggered when new babylon (transformed) hit test results are available
  75406. */
  75407. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75408. /**
  75409. * Use this to temporarily pause hit test checks.
  75410. */
  75411. paused: boolean;
  75412. /**
  75413. * Creates a new instance of the hit test feature
  75414. * @param _xrSessionManager an instance of WebXRSessionManager
  75415. * @param options options to use when constructing this feature
  75416. */
  75417. constructor(_xrSessionManager: WebXRSessionManager,
  75418. /**
  75419. * options to use when constructing this feature
  75420. */
  75421. options?: IWebXRHitTestOptions);
  75422. /**
  75423. * attach this feature
  75424. * Will usually be called by the features manager
  75425. *
  75426. * @returns true if successful.
  75427. */
  75428. attach(): boolean;
  75429. /**
  75430. * detach this feature.
  75431. * Will usually be called by the features manager
  75432. *
  75433. * @returns true if successful.
  75434. */
  75435. detach(): boolean;
  75436. /**
  75437. * Dispose this feature and all of the resources attached
  75438. */
  75439. dispose(): void;
  75440. protected _onXRFrame(frame: XRFrame): void;
  75441. private _processWebXRHitTestResult;
  75442. }
  75443. }
  75444. declare module "babylonjs/XR/features/index" {
  75445. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  75446. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  75447. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  75448. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  75449. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  75450. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  75451. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  75452. export * from "babylonjs/XR/features/WebXRHitTest";
  75453. }
  75454. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  75455. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75457. import { Scene } from "babylonjs/scene";
  75458. /**
  75459. * The motion controller class for all microsoft mixed reality controllers
  75460. */
  75461. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75462. protected readonly _mapping: {
  75463. defaultButton: {
  75464. valueNodeName: string;
  75465. unpressedNodeName: string;
  75466. pressedNodeName: string;
  75467. };
  75468. defaultAxis: {
  75469. valueNodeName: string;
  75470. minNodeName: string;
  75471. maxNodeName: string;
  75472. };
  75473. buttons: {
  75474. "xr-standard-trigger": {
  75475. rootNodeName: string;
  75476. componentProperty: string;
  75477. states: string[];
  75478. };
  75479. "xr-standard-squeeze": {
  75480. rootNodeName: string;
  75481. componentProperty: string;
  75482. states: string[];
  75483. };
  75484. "xr-standard-touchpad": {
  75485. rootNodeName: string;
  75486. labelAnchorNodeName: string;
  75487. touchPointNodeName: string;
  75488. };
  75489. "xr-standard-thumbstick": {
  75490. rootNodeName: string;
  75491. componentProperty: string;
  75492. states: string[];
  75493. };
  75494. };
  75495. axes: {
  75496. "xr-standard-touchpad": {
  75497. "x-axis": {
  75498. rootNodeName: string;
  75499. };
  75500. "y-axis": {
  75501. rootNodeName: string;
  75502. };
  75503. };
  75504. "xr-standard-thumbstick": {
  75505. "x-axis": {
  75506. rootNodeName: string;
  75507. };
  75508. "y-axis": {
  75509. rootNodeName: string;
  75510. };
  75511. };
  75512. };
  75513. };
  75514. /**
  75515. * The base url used to load the left and right controller models
  75516. */
  75517. static MODEL_BASE_URL: string;
  75518. /**
  75519. * The name of the left controller model file
  75520. */
  75521. static MODEL_LEFT_FILENAME: string;
  75522. /**
  75523. * The name of the right controller model file
  75524. */
  75525. static MODEL_RIGHT_FILENAME: string;
  75526. profileId: string;
  75527. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75528. protected _getFilenameAndPath(): {
  75529. filename: string;
  75530. path: string;
  75531. };
  75532. protected _getModelLoadingConstraints(): boolean;
  75533. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75534. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75535. protected _updateModel(): void;
  75536. }
  75537. }
  75538. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  75539. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75541. import { Scene } from "babylonjs/scene";
  75542. /**
  75543. * The motion controller class for oculus touch (quest, rift).
  75544. * This class supports legacy mapping as well the standard xr mapping
  75545. */
  75546. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75547. private _forceLegacyControllers;
  75548. private _modelRootNode;
  75549. /**
  75550. * The base url used to load the left and right controller models
  75551. */
  75552. static MODEL_BASE_URL: string;
  75553. /**
  75554. * The name of the left controller model file
  75555. */
  75556. static MODEL_LEFT_FILENAME: string;
  75557. /**
  75558. * The name of the right controller model file
  75559. */
  75560. static MODEL_RIGHT_FILENAME: string;
  75561. /**
  75562. * Base Url for the Quest controller model.
  75563. */
  75564. static QUEST_MODEL_BASE_URL: string;
  75565. profileId: string;
  75566. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75567. protected _getFilenameAndPath(): {
  75568. filename: string;
  75569. path: string;
  75570. };
  75571. protected _getModelLoadingConstraints(): boolean;
  75572. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75573. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75574. protected _updateModel(): void;
  75575. /**
  75576. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75577. * between the touch and touch 2.
  75578. */
  75579. private _isQuest;
  75580. }
  75581. }
  75582. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  75583. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75584. import { Scene } from "babylonjs/scene";
  75585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75586. /**
  75587. * The motion controller class for the standard HTC-Vive controllers
  75588. */
  75589. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75590. private _modelRootNode;
  75591. /**
  75592. * The base url used to load the left and right controller models
  75593. */
  75594. static MODEL_BASE_URL: string;
  75595. /**
  75596. * File name for the controller model.
  75597. */
  75598. static MODEL_FILENAME: string;
  75599. profileId: string;
  75600. /**
  75601. * Create a new Vive motion controller object
  75602. * @param scene the scene to use to create this controller
  75603. * @param gamepadObject the corresponding gamepad object
  75604. * @param handedness the handedness of the controller
  75605. */
  75606. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75607. protected _getFilenameAndPath(): {
  75608. filename: string;
  75609. path: string;
  75610. };
  75611. protected _getModelLoadingConstraints(): boolean;
  75612. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75613. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75614. protected _updateModel(): void;
  75615. }
  75616. }
  75617. declare module "babylonjs/XR/motionController/index" {
  75618. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  75619. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  75620. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  75621. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  75622. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  75623. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  75624. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  75625. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  75626. }
  75627. declare module "babylonjs/XR/index" {
  75628. export * from "babylonjs/XR/webXRCamera";
  75629. export * from "babylonjs/XR/webXREnterExitUI";
  75630. export * from "babylonjs/XR/webXRExperienceHelper";
  75631. export * from "babylonjs/XR/webXRInput";
  75632. export * from "babylonjs/XR/webXRInputSource";
  75633. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  75634. export * from "babylonjs/XR/webXRTypes";
  75635. export * from "babylonjs/XR/webXRSessionManager";
  75636. export * from "babylonjs/XR/webXRDefaultExperience";
  75637. export * from "babylonjs/XR/webXRFeaturesManager";
  75638. export * from "babylonjs/XR/features/index";
  75639. export * from "babylonjs/XR/motionController/index";
  75640. }
  75641. declare module "babylonjs/index" {
  75642. export * from "babylonjs/abstractScene";
  75643. export * from "babylonjs/Actions/index";
  75644. export * from "babylonjs/Animations/index";
  75645. export * from "babylonjs/assetContainer";
  75646. export * from "babylonjs/Audio/index";
  75647. export * from "babylonjs/Behaviors/index";
  75648. export * from "babylonjs/Bones/index";
  75649. export * from "babylonjs/Cameras/index";
  75650. export * from "babylonjs/Collisions/index";
  75651. export * from "babylonjs/Culling/index";
  75652. export * from "babylonjs/Debug/index";
  75653. export * from "babylonjs/DeviceInput/index";
  75654. export * from "babylonjs/Engines/index";
  75655. export * from "babylonjs/Events/index";
  75656. export * from "babylonjs/Gamepads/index";
  75657. export * from "babylonjs/Gizmos/index";
  75658. export * from "babylonjs/Helpers/index";
  75659. export * from "babylonjs/Instrumentation/index";
  75660. export * from "babylonjs/Layers/index";
  75661. export * from "babylonjs/LensFlares/index";
  75662. export * from "babylonjs/Lights/index";
  75663. export * from "babylonjs/Loading/index";
  75664. export * from "babylonjs/Materials/index";
  75665. export * from "babylonjs/Maths/index";
  75666. export * from "babylonjs/Meshes/index";
  75667. export * from "babylonjs/Morph/index";
  75668. export * from "babylonjs/Navigation/index";
  75669. export * from "babylonjs/node";
  75670. export * from "babylonjs/Offline/index";
  75671. export * from "babylonjs/Particles/index";
  75672. export * from "babylonjs/Physics/index";
  75673. export * from "babylonjs/PostProcesses/index";
  75674. export * from "babylonjs/Probes/index";
  75675. export * from "babylonjs/Rendering/index";
  75676. export * from "babylonjs/scene";
  75677. export * from "babylonjs/sceneComponent";
  75678. export * from "babylonjs/Sprites/index";
  75679. export * from "babylonjs/States/index";
  75680. export * from "babylonjs/Misc/index";
  75681. export * from "babylonjs/XR/index";
  75682. export * from "babylonjs/types";
  75683. }
  75684. declare module "babylonjs/Animations/pathCursor" {
  75685. import { Vector3 } from "babylonjs/Maths/math.vector";
  75686. import { Path2 } from "babylonjs/Maths/math.path";
  75687. /**
  75688. * A cursor which tracks a point on a path
  75689. */
  75690. export class PathCursor {
  75691. private path;
  75692. /**
  75693. * Stores path cursor callbacks for when an onchange event is triggered
  75694. */
  75695. private _onchange;
  75696. /**
  75697. * The value of the path cursor
  75698. */
  75699. value: number;
  75700. /**
  75701. * The animation array of the path cursor
  75702. */
  75703. animations: Animation[];
  75704. /**
  75705. * Initializes the path cursor
  75706. * @param path The path to track
  75707. */
  75708. constructor(path: Path2);
  75709. /**
  75710. * Gets the cursor point on the path
  75711. * @returns A point on the path cursor at the cursor location
  75712. */
  75713. getPoint(): Vector3;
  75714. /**
  75715. * Moves the cursor ahead by the step amount
  75716. * @param step The amount to move the cursor forward
  75717. * @returns This path cursor
  75718. */
  75719. moveAhead(step?: number): PathCursor;
  75720. /**
  75721. * Moves the cursor behind by the step amount
  75722. * @param step The amount to move the cursor back
  75723. * @returns This path cursor
  75724. */
  75725. moveBack(step?: number): PathCursor;
  75726. /**
  75727. * Moves the cursor by the step amount
  75728. * If the step amount is greater than one, an exception is thrown
  75729. * @param step The amount to move the cursor
  75730. * @returns This path cursor
  75731. */
  75732. move(step: number): PathCursor;
  75733. /**
  75734. * Ensures that the value is limited between zero and one
  75735. * @returns This path cursor
  75736. */
  75737. private ensureLimits;
  75738. /**
  75739. * Runs onchange callbacks on change (used by the animation engine)
  75740. * @returns This path cursor
  75741. */
  75742. private raiseOnChange;
  75743. /**
  75744. * Executes a function on change
  75745. * @param f A path cursor onchange callback
  75746. * @returns This path cursor
  75747. */
  75748. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75749. }
  75750. }
  75751. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  75752. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  75753. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  75754. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  75755. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  75756. }
  75757. declare module "babylonjs/Engines/Processors/Expressions/index" {
  75758. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  75759. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  75760. }
  75761. declare module "babylonjs/Engines/Processors/index" {
  75762. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  75763. export * from "babylonjs/Engines/Processors/Expressions/index";
  75764. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  75765. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  75766. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  75767. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  75768. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  75769. export * from "babylonjs/Engines/Processors/shaderProcessor";
  75770. }
  75771. declare module "babylonjs/Legacy/legacy" {
  75772. import * as Babylon from "babylonjs/index";
  75773. export * from "babylonjs/index";
  75774. }
  75775. declare module "babylonjs/Shaders/blur.fragment" {
  75776. /** @hidden */
  75777. export var blurPixelShader: {
  75778. name: string;
  75779. shader: string;
  75780. };
  75781. }
  75782. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  75783. /** @hidden */
  75784. export var pointCloudVertexDeclaration: {
  75785. name: string;
  75786. shader: string;
  75787. };
  75788. }
  75789. declare module "babylonjs" {
  75790. export * from "babylonjs/Legacy/legacy";
  75791. }
  75792. declare module BABYLON {
  75793. /** Alias type for value that can be null */
  75794. export type Nullable<T> = T | null;
  75795. /**
  75796. * Alias type for number that are floats
  75797. * @ignorenaming
  75798. */
  75799. export type float = number;
  75800. /**
  75801. * Alias type for number that are doubles.
  75802. * @ignorenaming
  75803. */
  75804. export type double = number;
  75805. /**
  75806. * Alias type for number that are integer
  75807. * @ignorenaming
  75808. */
  75809. export type int = number;
  75810. /** Alias type for number array or Float32Array */
  75811. export type FloatArray = number[] | Float32Array;
  75812. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  75813. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  75814. /**
  75815. * Alias for types that can be used by a Buffer or VertexBuffer.
  75816. */
  75817. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  75818. /**
  75819. * Alias type for primitive types
  75820. * @ignorenaming
  75821. */
  75822. type Primitive = undefined | null | boolean | string | number | Function;
  75823. /**
  75824. * Type modifier to make all the properties of an object Readonly
  75825. */
  75826. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  75827. /**
  75828. * Type modifier to make all the properties of an object Readonly recursively
  75829. */
  75830. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  75831. /**
  75832. * Type modifier to make object properties readonly.
  75833. */
  75834. export type DeepImmutableObject<T> = {
  75835. readonly [K in keyof T]: DeepImmutable<T[K]>;
  75836. };
  75837. /** @hidden */
  75838. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  75839. }
  75840. }
  75841. declare module BABYLON {
  75842. /**
  75843. * A class serves as a medium between the observable and its observers
  75844. */
  75845. export class EventState {
  75846. /**
  75847. * Create a new EventState
  75848. * @param mask defines the mask associated with this state
  75849. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  75850. * @param target defines the original target of the state
  75851. * @param currentTarget defines the current target of the state
  75852. */
  75853. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  75854. /**
  75855. * Initialize the current event state
  75856. * @param mask defines the mask associated with this state
  75857. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  75858. * @param target defines the original target of the state
  75859. * @param currentTarget defines the current target of the state
  75860. * @returns the current event state
  75861. */
  75862. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  75863. /**
  75864. * An Observer can set this property to true to prevent subsequent observers of being notified
  75865. */
  75866. skipNextObservers: boolean;
  75867. /**
  75868. * Get the mask value that were used to trigger the event corresponding to this EventState object
  75869. */
  75870. mask: number;
  75871. /**
  75872. * The object that originally notified the event
  75873. */
  75874. target?: any;
  75875. /**
  75876. * The current object in the bubbling phase
  75877. */
  75878. currentTarget?: any;
  75879. /**
  75880. * This will be populated with the return value of the last function that was executed.
  75881. * If it is the first function in the callback chain it will be the event data.
  75882. */
  75883. lastReturnValue?: any;
  75884. }
  75885. /**
  75886. * Represent an Observer registered to a given Observable object.
  75887. */
  75888. export class Observer<T> {
  75889. /**
  75890. * Defines the callback to call when the observer is notified
  75891. */
  75892. callback: (eventData: T, eventState: EventState) => void;
  75893. /**
  75894. * Defines the mask of the observer (used to filter notifications)
  75895. */
  75896. mask: number;
  75897. /**
  75898. * Defines the current scope used to restore the JS context
  75899. */
  75900. scope: any;
  75901. /** @hidden */
  75902. _willBeUnregistered: boolean;
  75903. /**
  75904. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  75905. */
  75906. unregisterOnNextCall: boolean;
  75907. /**
  75908. * Creates a new observer
  75909. * @param callback defines the callback to call when the observer is notified
  75910. * @param mask defines the mask of the observer (used to filter notifications)
  75911. * @param scope defines the current scope used to restore the JS context
  75912. */
  75913. constructor(
  75914. /**
  75915. * Defines the callback to call when the observer is notified
  75916. */
  75917. callback: (eventData: T, eventState: EventState) => void,
  75918. /**
  75919. * Defines the mask of the observer (used to filter notifications)
  75920. */
  75921. mask: number,
  75922. /**
  75923. * Defines the current scope used to restore the JS context
  75924. */
  75925. scope?: any);
  75926. }
  75927. /**
  75928. * Represent a list of observers registered to multiple Observables object.
  75929. */
  75930. export class MultiObserver<T> {
  75931. private _observers;
  75932. private _observables;
  75933. /**
  75934. * Release associated resources
  75935. */
  75936. dispose(): void;
  75937. /**
  75938. * Raise a callback when one of the observable will notify
  75939. * @param observables defines a list of observables to watch
  75940. * @param callback defines the callback to call on notification
  75941. * @param mask defines the mask used to filter notifications
  75942. * @param scope defines the current scope used to restore the JS context
  75943. * @returns the new MultiObserver
  75944. */
  75945. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  75946. }
  75947. /**
  75948. * The Observable class is a simple implementation of the Observable pattern.
  75949. *
  75950. * 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.
  75951. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  75952. * 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).
  75953. * 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.
  75954. */
  75955. export class Observable<T> {
  75956. private _observers;
  75957. private _eventState;
  75958. private _onObserverAdded;
  75959. /**
  75960. * Gets the list of observers
  75961. */
  75962. get observers(): Array<Observer<T>>;
  75963. /**
  75964. * Creates a new observable
  75965. * @param onObserverAdded defines a callback to call when a new observer is added
  75966. */
  75967. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  75968. /**
  75969. * Create a new Observer with the specified callback
  75970. * @param callback the callback that will be executed for that Observer
  75971. * @param mask the mask used to filter observers
  75972. * @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.
  75973. * @param scope optional scope for the callback to be called from
  75974. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  75975. * @returns the new observer created for the callback
  75976. */
  75977. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  75978. /**
  75979. * Create a new Observer with the specified callback and unregisters after the next notification
  75980. * @param callback the callback that will be executed for that Observer
  75981. * @returns the new observer created for the callback
  75982. */
  75983. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  75984. /**
  75985. * Remove an Observer from the Observable object
  75986. * @param observer the instance of the Observer to remove
  75987. * @returns false if it doesn't belong to this Observable
  75988. */
  75989. remove(observer: Nullable<Observer<T>>): boolean;
  75990. /**
  75991. * Remove a callback from the Observable object
  75992. * @param callback the callback to remove
  75993. * @param scope optional scope. If used only the callbacks with this scope will be removed
  75994. * @returns false if it doesn't belong to this Observable
  75995. */
  75996. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  75997. private _deferUnregister;
  75998. private _remove;
  75999. /**
  76000. * Moves the observable to the top of the observer list making it get called first when notified
  76001. * @param observer the observer to move
  76002. */
  76003. makeObserverTopPriority(observer: Observer<T>): void;
  76004. /**
  76005. * Moves the observable to the bottom of the observer list making it get called last when notified
  76006. * @param observer the observer to move
  76007. */
  76008. makeObserverBottomPriority(observer: Observer<T>): void;
  76009. /**
  76010. * Notify all Observers by calling their respective callback with the given data
  76011. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  76012. * @param eventData defines the data to send to all observers
  76013. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  76014. * @param target defines the original target of the state
  76015. * @param currentTarget defines the current target of the state
  76016. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  76017. */
  76018. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  76019. /**
  76020. * Calling this will execute each callback, expecting it to be a promise or return a value.
  76021. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  76022. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  76023. * and it is crucial that all callbacks will be executed.
  76024. * The order of the callbacks is kept, callbacks are not executed parallel.
  76025. *
  76026. * @param eventData The data to be sent to each callback
  76027. * @param mask is used to filter observers defaults to -1
  76028. * @param target defines the callback target (see EventState)
  76029. * @param currentTarget defines he current object in the bubbling phase
  76030. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  76031. */
  76032. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  76033. /**
  76034. * Notify a specific observer
  76035. * @param observer defines the observer to notify
  76036. * @param eventData defines the data to be sent to each callback
  76037. * @param mask is used to filter observers defaults to -1
  76038. */
  76039. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  76040. /**
  76041. * Gets a boolean indicating if the observable has at least one observer
  76042. * @returns true is the Observable has at least one Observer registered
  76043. */
  76044. hasObservers(): boolean;
  76045. /**
  76046. * Clear the list of observers
  76047. */
  76048. clear(): void;
  76049. /**
  76050. * Clone the current observable
  76051. * @returns a new observable
  76052. */
  76053. clone(): Observable<T>;
  76054. /**
  76055. * Does this observable handles observer registered with a given mask
  76056. * @param mask defines the mask to be tested
  76057. * @return whether or not one observer registered with the given mask is handeled
  76058. **/
  76059. hasSpecificMask(mask?: number): boolean;
  76060. }
  76061. }
  76062. declare module BABYLON {
  76063. /**
  76064. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  76065. * Babylon.js
  76066. */
  76067. export class DomManagement {
  76068. /**
  76069. * Checks if the window object exists
  76070. * @returns true if the window object exists
  76071. */
  76072. static IsWindowObjectExist(): boolean;
  76073. /**
  76074. * Checks if the navigator object exists
  76075. * @returns true if the navigator object exists
  76076. */
  76077. static IsNavigatorAvailable(): boolean;
  76078. /**
  76079. * Check if the document object exists
  76080. * @returns true if the document object exists
  76081. */
  76082. static IsDocumentAvailable(): boolean;
  76083. /**
  76084. * Extracts text content from a DOM element hierarchy
  76085. * @param element defines the root element
  76086. * @returns a string
  76087. */
  76088. static GetDOMTextContent(element: HTMLElement): string;
  76089. }
  76090. }
  76091. declare module BABYLON {
  76092. /**
  76093. * Logger used througouht the application to allow configuration of
  76094. * the log level required for the messages.
  76095. */
  76096. export class Logger {
  76097. /**
  76098. * No log
  76099. */
  76100. static readonly NoneLogLevel: number;
  76101. /**
  76102. * Only message logs
  76103. */
  76104. static readonly MessageLogLevel: number;
  76105. /**
  76106. * Only warning logs
  76107. */
  76108. static readonly WarningLogLevel: number;
  76109. /**
  76110. * Only error logs
  76111. */
  76112. static readonly ErrorLogLevel: number;
  76113. /**
  76114. * All logs
  76115. */
  76116. static readonly AllLogLevel: number;
  76117. private static _LogCache;
  76118. /**
  76119. * Gets a value indicating the number of loading errors
  76120. * @ignorenaming
  76121. */
  76122. static errorsCount: number;
  76123. /**
  76124. * Callback called when a new log is added
  76125. */
  76126. static OnNewCacheEntry: (entry: string) => void;
  76127. private static _AddLogEntry;
  76128. private static _FormatMessage;
  76129. private static _LogDisabled;
  76130. private static _LogEnabled;
  76131. private static _WarnDisabled;
  76132. private static _WarnEnabled;
  76133. private static _ErrorDisabled;
  76134. private static _ErrorEnabled;
  76135. /**
  76136. * Log a message to the console
  76137. */
  76138. static Log: (message: string) => void;
  76139. /**
  76140. * Write a warning message to the console
  76141. */
  76142. static Warn: (message: string) => void;
  76143. /**
  76144. * Write an error message to the console
  76145. */
  76146. static Error: (message: string) => void;
  76147. /**
  76148. * Gets current log cache (list of logs)
  76149. */
  76150. static get LogCache(): string;
  76151. /**
  76152. * Clears the log cache
  76153. */
  76154. static ClearLogCache(): void;
  76155. /**
  76156. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  76157. */
  76158. static set LogLevels(level: number);
  76159. }
  76160. }
  76161. declare module BABYLON {
  76162. /** @hidden */
  76163. export class _TypeStore {
  76164. /** @hidden */
  76165. static RegisteredTypes: {
  76166. [key: string]: Object;
  76167. };
  76168. /** @hidden */
  76169. static GetClass(fqdn: string): any;
  76170. }
  76171. }
  76172. declare module BABYLON {
  76173. /**
  76174. * Helper to manipulate strings
  76175. */
  76176. export class StringTools {
  76177. /**
  76178. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  76179. * @param str Source string
  76180. * @param suffix Suffix to search for in the source string
  76181. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76182. */
  76183. static EndsWith(str: string, suffix: string): boolean;
  76184. /**
  76185. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  76186. * @param str Source string
  76187. * @param suffix Suffix to search for in the source string
  76188. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  76189. */
  76190. static StartsWith(str: string, suffix: string): boolean;
  76191. /**
  76192. * Decodes a buffer into a string
  76193. * @param buffer The buffer to decode
  76194. * @returns The decoded string
  76195. */
  76196. static Decode(buffer: Uint8Array | Uint16Array): string;
  76197. /**
  76198. * Encode a buffer to a base64 string
  76199. * @param buffer defines the buffer to encode
  76200. * @returns the encoded string
  76201. */
  76202. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  76203. /**
  76204. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  76205. * @param num the number to convert and pad
  76206. * @param length the expected length of the string
  76207. * @returns the padded string
  76208. */
  76209. static PadNumber(num: number, length: number): string;
  76210. }
  76211. }
  76212. declare module BABYLON {
  76213. /**
  76214. * Class containing a set of static utilities functions for deep copy.
  76215. */
  76216. export class DeepCopier {
  76217. /**
  76218. * Tries to copy an object by duplicating every property
  76219. * @param source defines the source object
  76220. * @param destination defines the target object
  76221. * @param doNotCopyList defines a list of properties to avoid
  76222. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  76223. */
  76224. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  76225. }
  76226. }
  76227. declare module BABYLON {
  76228. /**
  76229. * Class containing a set of static utilities functions for precision date
  76230. */
  76231. export class PrecisionDate {
  76232. /**
  76233. * Gets either window.performance.now() if supported or Date.now() else
  76234. */
  76235. static get Now(): number;
  76236. }
  76237. }
  76238. declare module BABYLON {
  76239. /** @hidden */
  76240. export class _DevTools {
  76241. static WarnImport(name: string): string;
  76242. }
  76243. }
  76244. declare module BABYLON {
  76245. /**
  76246. * Interface used to define the mechanism to get data from the network
  76247. */
  76248. export interface IWebRequest {
  76249. /**
  76250. * Returns client's response url
  76251. */
  76252. responseURL: string;
  76253. /**
  76254. * Returns client's status
  76255. */
  76256. status: number;
  76257. /**
  76258. * Returns client's status as a text
  76259. */
  76260. statusText: string;
  76261. }
  76262. }
  76263. declare module BABYLON {
  76264. /**
  76265. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  76266. */
  76267. export class WebRequest implements IWebRequest {
  76268. private _xhr;
  76269. /**
  76270. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  76271. * i.e. when loading files, where the server/service expects an Authorization header
  76272. */
  76273. static CustomRequestHeaders: {
  76274. [key: string]: string;
  76275. };
  76276. /**
  76277. * Add callback functions in this array to update all the requests before they get sent to the network
  76278. */
  76279. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  76280. private _injectCustomRequestHeaders;
  76281. /**
  76282. * Gets or sets a function to be called when loading progress changes
  76283. */
  76284. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  76285. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  76286. /**
  76287. * Returns client's state
  76288. */
  76289. get readyState(): number;
  76290. /**
  76291. * Returns client's status
  76292. */
  76293. get status(): number;
  76294. /**
  76295. * Returns client's status as a text
  76296. */
  76297. get statusText(): string;
  76298. /**
  76299. * Returns client's response
  76300. */
  76301. get response(): any;
  76302. /**
  76303. * Returns client's response url
  76304. */
  76305. get responseURL(): string;
  76306. /**
  76307. * Returns client's response as text
  76308. */
  76309. get responseText(): string;
  76310. /**
  76311. * Gets or sets the expected response type
  76312. */
  76313. get responseType(): XMLHttpRequestResponseType;
  76314. set responseType(value: XMLHttpRequestResponseType);
  76315. /** @hidden */
  76316. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  76317. /** @hidden */
  76318. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  76319. /**
  76320. * Cancels any network activity
  76321. */
  76322. abort(): void;
  76323. /**
  76324. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  76325. * @param body defines an optional request body
  76326. */
  76327. send(body?: Document | BodyInit | null): void;
  76328. /**
  76329. * Sets the request method, request URL
  76330. * @param method defines the method to use (GET, POST, etc..)
  76331. * @param url defines the url to connect with
  76332. */
  76333. open(method: string, url: string): void;
  76334. /**
  76335. * Sets the value of a request header.
  76336. * @param name The name of the header whose value is to be set
  76337. * @param value The value to set as the body of the header
  76338. */
  76339. setRequestHeader(name: string, value: string): void;
  76340. /**
  76341. * Get the string containing the text of a particular header's value.
  76342. * @param name The name of the header
  76343. * @returns The string containing the text of the given header name
  76344. */
  76345. getResponseHeader(name: string): Nullable<string>;
  76346. }
  76347. }
  76348. declare module BABYLON {
  76349. /**
  76350. * File request interface
  76351. */
  76352. export interface IFileRequest {
  76353. /**
  76354. * Raised when the request is complete (success or error).
  76355. */
  76356. onCompleteObservable: Observable<IFileRequest>;
  76357. /**
  76358. * Aborts the request for a file.
  76359. */
  76360. abort: () => void;
  76361. }
  76362. }
  76363. declare module BABYLON {
  76364. /**
  76365. * Define options used to create a render target texture
  76366. */
  76367. export class RenderTargetCreationOptions {
  76368. /**
  76369. * Specifies is mipmaps must be generated
  76370. */
  76371. generateMipMaps?: boolean;
  76372. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  76373. generateDepthBuffer?: boolean;
  76374. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  76375. generateStencilBuffer?: boolean;
  76376. /** Defines texture type (int by default) */
  76377. type?: number;
  76378. /** Defines sampling mode (trilinear by default) */
  76379. samplingMode?: number;
  76380. /** Defines format (RGBA by default) */
  76381. format?: number;
  76382. }
  76383. }
  76384. declare module BABYLON {
  76385. /** Defines the cross module used constants to avoid circular dependncies */
  76386. export class Constants {
  76387. /** Defines that alpha blending is disabled */
  76388. static readonly ALPHA_DISABLE: number;
  76389. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  76390. static readonly ALPHA_ADD: number;
  76391. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  76392. static readonly ALPHA_COMBINE: number;
  76393. /** Defines that alpha blending is DEST - SRC * DEST */
  76394. static readonly ALPHA_SUBTRACT: number;
  76395. /** Defines that alpha blending is SRC * DEST */
  76396. static readonly ALPHA_MULTIPLY: number;
  76397. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  76398. static readonly ALPHA_MAXIMIZED: number;
  76399. /** Defines that alpha blending is SRC + DEST */
  76400. static readonly ALPHA_ONEONE: number;
  76401. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  76402. static readonly ALPHA_PREMULTIPLIED: number;
  76403. /**
  76404. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  76405. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  76406. */
  76407. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  76408. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  76409. static readonly ALPHA_INTERPOLATE: number;
  76410. /**
  76411. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  76412. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  76413. */
  76414. static readonly ALPHA_SCREENMODE: number;
  76415. /**
  76416. * Defines that alpha blending is SRC + DST
  76417. * Alpha will be set to SRC ALPHA + DST ALPHA
  76418. */
  76419. static readonly ALPHA_ONEONE_ONEONE: number;
  76420. /**
  76421. * Defines that alpha blending is SRC * DST ALPHA + DST
  76422. * Alpha will be set to 0
  76423. */
  76424. static readonly ALPHA_ALPHATOCOLOR: number;
  76425. /**
  76426. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76427. */
  76428. static readonly ALPHA_REVERSEONEMINUS: number;
  76429. /**
  76430. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  76431. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  76432. */
  76433. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  76434. /**
  76435. * Defines that alpha blending is SRC + DST
  76436. * Alpha will be set to SRC ALPHA
  76437. */
  76438. static readonly ALPHA_ONEONE_ONEZERO: number;
  76439. /**
  76440. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  76441. * Alpha will be set to DST ALPHA
  76442. */
  76443. static readonly ALPHA_EXCLUSION: number;
  76444. /** Defines that alpha blending equation a SUM */
  76445. static readonly ALPHA_EQUATION_ADD: number;
  76446. /** Defines that alpha blending equation a SUBSTRACTION */
  76447. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  76448. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  76449. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  76450. /** Defines that alpha blending equation a MAX operation */
  76451. static readonly ALPHA_EQUATION_MAX: number;
  76452. /** Defines that alpha blending equation a MIN operation */
  76453. static readonly ALPHA_EQUATION_MIN: number;
  76454. /**
  76455. * Defines that alpha blending equation a DARKEN operation:
  76456. * It takes the min of the src and sums the alpha channels.
  76457. */
  76458. static readonly ALPHA_EQUATION_DARKEN: number;
  76459. /** Defines that the ressource is not delayed*/
  76460. static readonly DELAYLOADSTATE_NONE: number;
  76461. /** Defines that the ressource was successfully delay loaded */
  76462. static readonly DELAYLOADSTATE_LOADED: number;
  76463. /** Defines that the ressource is currently delay loading */
  76464. static readonly DELAYLOADSTATE_LOADING: number;
  76465. /** Defines that the ressource is delayed and has not started loading */
  76466. static readonly DELAYLOADSTATE_NOTLOADED: number;
  76467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  76468. static readonly NEVER: number;
  76469. /** 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 */
  76470. static readonly ALWAYS: number;
  76471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  76472. static readonly LESS: number;
  76473. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  76474. static readonly EQUAL: number;
  76475. /** 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 */
  76476. static readonly LEQUAL: number;
  76477. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  76478. static readonly GREATER: number;
  76479. /** 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 */
  76480. static readonly GEQUAL: number;
  76481. /** 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 */
  76482. static readonly NOTEQUAL: number;
  76483. /** Passed to stencilOperation to specify that stencil value must be kept */
  76484. static readonly KEEP: number;
  76485. /** Passed to stencilOperation to specify that stencil value must be replaced */
  76486. static readonly REPLACE: number;
  76487. /** Passed to stencilOperation to specify that stencil value must be incremented */
  76488. static readonly INCR: number;
  76489. /** Passed to stencilOperation to specify that stencil value must be decremented */
  76490. static readonly DECR: number;
  76491. /** Passed to stencilOperation to specify that stencil value must be inverted */
  76492. static readonly INVERT: number;
  76493. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  76494. static readonly INCR_WRAP: number;
  76495. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  76496. static readonly DECR_WRAP: number;
  76497. /** Texture is not repeating outside of 0..1 UVs */
  76498. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  76499. /** Texture is repeating outside of 0..1 UVs */
  76500. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  76501. /** Texture is repeating and mirrored */
  76502. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  76503. /** ALPHA */
  76504. static readonly TEXTUREFORMAT_ALPHA: number;
  76505. /** LUMINANCE */
  76506. static readonly TEXTUREFORMAT_LUMINANCE: number;
  76507. /** LUMINANCE_ALPHA */
  76508. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  76509. /** RGB */
  76510. static readonly TEXTUREFORMAT_RGB: number;
  76511. /** RGBA */
  76512. static readonly TEXTUREFORMAT_RGBA: number;
  76513. /** RED */
  76514. static readonly TEXTUREFORMAT_RED: number;
  76515. /** RED (2nd reference) */
  76516. static readonly TEXTUREFORMAT_R: number;
  76517. /** RG */
  76518. static readonly TEXTUREFORMAT_RG: number;
  76519. /** RED_INTEGER */
  76520. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  76521. /** RED_INTEGER (2nd reference) */
  76522. static readonly TEXTUREFORMAT_R_INTEGER: number;
  76523. /** RG_INTEGER */
  76524. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  76525. /** RGB_INTEGER */
  76526. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  76527. /** RGBA_INTEGER */
  76528. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  76529. /** UNSIGNED_BYTE */
  76530. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  76531. /** UNSIGNED_BYTE (2nd reference) */
  76532. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  76533. /** FLOAT */
  76534. static readonly TEXTURETYPE_FLOAT: number;
  76535. /** HALF_FLOAT */
  76536. static readonly TEXTURETYPE_HALF_FLOAT: number;
  76537. /** BYTE */
  76538. static readonly TEXTURETYPE_BYTE: number;
  76539. /** SHORT */
  76540. static readonly TEXTURETYPE_SHORT: number;
  76541. /** UNSIGNED_SHORT */
  76542. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  76543. /** INT */
  76544. static readonly TEXTURETYPE_INT: number;
  76545. /** UNSIGNED_INT */
  76546. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  76547. /** UNSIGNED_SHORT_4_4_4_4 */
  76548. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  76549. /** UNSIGNED_SHORT_5_5_5_1 */
  76550. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  76551. /** UNSIGNED_SHORT_5_6_5 */
  76552. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  76553. /** UNSIGNED_INT_2_10_10_10_REV */
  76554. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  76555. /** UNSIGNED_INT_24_8 */
  76556. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  76557. /** UNSIGNED_INT_10F_11F_11F_REV */
  76558. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  76559. /** UNSIGNED_INT_5_9_9_9_REV */
  76560. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  76561. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  76562. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76563. /** nearest is mag = nearest and min = nearest and no mip */
  76564. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  76565. /** mag = nearest and min = nearest and mip = none */
  76566. static readonly TEXTURE_NEAREST_NEAREST: number;
  76567. /** Bilinear is mag = linear and min = linear and no mip */
  76568. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  76569. /** mag = linear and min = linear and mip = none */
  76570. static readonly TEXTURE_LINEAR_LINEAR: number;
  76571. /** Trilinear is mag = linear and min = linear and mip = linear */
  76572. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  76573. /** Trilinear is mag = linear and min = linear and mip = linear */
  76574. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  76575. /** mag = nearest and min = nearest and mip = nearest */
  76576. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  76577. /** mag = nearest and min = linear and mip = nearest */
  76578. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  76579. /** mag = nearest and min = linear and mip = linear */
  76580. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  76581. /** mag = nearest and min = linear and mip = none */
  76582. static readonly TEXTURE_NEAREST_LINEAR: number;
  76583. /** nearest is mag = nearest and min = nearest and mip = linear */
  76584. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  76585. /** mag = linear and min = nearest and mip = nearest */
  76586. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  76587. /** mag = linear and min = nearest and mip = linear */
  76588. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  76589. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76590. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  76591. /** mag = linear and min = nearest and mip = none */
  76592. static readonly TEXTURE_LINEAR_NEAREST: number;
  76593. /** Explicit coordinates mode */
  76594. static readonly TEXTURE_EXPLICIT_MODE: number;
  76595. /** Spherical coordinates mode */
  76596. static readonly TEXTURE_SPHERICAL_MODE: number;
  76597. /** Planar coordinates mode */
  76598. static readonly TEXTURE_PLANAR_MODE: number;
  76599. /** Cubic coordinates mode */
  76600. static readonly TEXTURE_CUBIC_MODE: number;
  76601. /** Projection coordinates mode */
  76602. static readonly TEXTURE_PROJECTION_MODE: number;
  76603. /** Skybox coordinates mode */
  76604. static readonly TEXTURE_SKYBOX_MODE: number;
  76605. /** Inverse Cubic coordinates mode */
  76606. static readonly TEXTURE_INVCUBIC_MODE: number;
  76607. /** Equirectangular coordinates mode */
  76608. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  76609. /** Equirectangular Fixed coordinates mode */
  76610. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  76611. /** Equirectangular Fixed Mirrored coordinates mode */
  76612. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76613. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  76614. static readonly SCALEMODE_FLOOR: number;
  76615. /** Defines that texture rescaling will look for the nearest power of 2 size */
  76616. static readonly SCALEMODE_NEAREST: number;
  76617. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  76618. static readonly SCALEMODE_CEILING: number;
  76619. /**
  76620. * The dirty texture flag value
  76621. */
  76622. static readonly MATERIAL_TextureDirtyFlag: number;
  76623. /**
  76624. * The dirty light flag value
  76625. */
  76626. static readonly MATERIAL_LightDirtyFlag: number;
  76627. /**
  76628. * The dirty fresnel flag value
  76629. */
  76630. static readonly MATERIAL_FresnelDirtyFlag: number;
  76631. /**
  76632. * The dirty attribute flag value
  76633. */
  76634. static readonly MATERIAL_AttributesDirtyFlag: number;
  76635. /**
  76636. * The dirty misc flag value
  76637. */
  76638. static readonly MATERIAL_MiscDirtyFlag: number;
  76639. /**
  76640. * The all dirty flag value
  76641. */
  76642. static readonly MATERIAL_AllDirtyFlag: number;
  76643. /**
  76644. * Returns the triangle fill mode
  76645. */
  76646. static readonly MATERIAL_TriangleFillMode: number;
  76647. /**
  76648. * Returns the wireframe mode
  76649. */
  76650. static readonly MATERIAL_WireFrameFillMode: number;
  76651. /**
  76652. * Returns the point fill mode
  76653. */
  76654. static readonly MATERIAL_PointFillMode: number;
  76655. /**
  76656. * Returns the point list draw mode
  76657. */
  76658. static readonly MATERIAL_PointListDrawMode: number;
  76659. /**
  76660. * Returns the line list draw mode
  76661. */
  76662. static readonly MATERIAL_LineListDrawMode: number;
  76663. /**
  76664. * Returns the line loop draw mode
  76665. */
  76666. static readonly MATERIAL_LineLoopDrawMode: number;
  76667. /**
  76668. * Returns the line strip draw mode
  76669. */
  76670. static readonly MATERIAL_LineStripDrawMode: number;
  76671. /**
  76672. * Returns the triangle strip draw mode
  76673. */
  76674. static readonly MATERIAL_TriangleStripDrawMode: number;
  76675. /**
  76676. * Returns the triangle fan draw mode
  76677. */
  76678. static readonly MATERIAL_TriangleFanDrawMode: number;
  76679. /**
  76680. * Stores the clock-wise side orientation
  76681. */
  76682. static readonly MATERIAL_ClockWiseSideOrientation: number;
  76683. /**
  76684. * Stores the counter clock-wise side orientation
  76685. */
  76686. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  76687. /**
  76688. * Nothing
  76689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76690. */
  76691. static readonly ACTION_NothingTrigger: number;
  76692. /**
  76693. * On pick
  76694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76695. */
  76696. static readonly ACTION_OnPickTrigger: number;
  76697. /**
  76698. * On left pick
  76699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76700. */
  76701. static readonly ACTION_OnLeftPickTrigger: number;
  76702. /**
  76703. * On right pick
  76704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76705. */
  76706. static readonly ACTION_OnRightPickTrigger: number;
  76707. /**
  76708. * On center pick
  76709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76710. */
  76711. static readonly ACTION_OnCenterPickTrigger: number;
  76712. /**
  76713. * On pick down
  76714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76715. */
  76716. static readonly ACTION_OnPickDownTrigger: number;
  76717. /**
  76718. * On double pick
  76719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76720. */
  76721. static readonly ACTION_OnDoublePickTrigger: number;
  76722. /**
  76723. * On pick up
  76724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76725. */
  76726. static readonly ACTION_OnPickUpTrigger: number;
  76727. /**
  76728. * On pick out.
  76729. * This trigger will only be raised if you also declared a OnPickDown
  76730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76731. */
  76732. static readonly ACTION_OnPickOutTrigger: number;
  76733. /**
  76734. * On long press
  76735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76736. */
  76737. static readonly ACTION_OnLongPressTrigger: number;
  76738. /**
  76739. * On pointer over
  76740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76741. */
  76742. static readonly ACTION_OnPointerOverTrigger: number;
  76743. /**
  76744. * On pointer out
  76745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76746. */
  76747. static readonly ACTION_OnPointerOutTrigger: number;
  76748. /**
  76749. * On every frame
  76750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76751. */
  76752. static readonly ACTION_OnEveryFrameTrigger: number;
  76753. /**
  76754. * On intersection enter
  76755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76756. */
  76757. static readonly ACTION_OnIntersectionEnterTrigger: number;
  76758. /**
  76759. * On intersection exit
  76760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76761. */
  76762. static readonly ACTION_OnIntersectionExitTrigger: number;
  76763. /**
  76764. * On key down
  76765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76766. */
  76767. static readonly ACTION_OnKeyDownTrigger: number;
  76768. /**
  76769. * On key up
  76770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76771. */
  76772. static readonly ACTION_OnKeyUpTrigger: number;
  76773. /**
  76774. * Billboard mode will only apply to Y axis
  76775. */
  76776. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  76777. /**
  76778. * Billboard mode will apply to all axes
  76779. */
  76780. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  76781. /**
  76782. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  76783. */
  76784. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  76785. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  76786. * Test order :
  76787. * Is the bounding sphere outside the frustum ?
  76788. * If not, are the bounding box vertices outside the frustum ?
  76789. * It not, then the cullable object is in the frustum.
  76790. */
  76791. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  76792. /** Culling strategy : Bounding Sphere Only.
  76793. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  76794. * It's also less accurate than the standard because some not visible objects can still be selected.
  76795. * Test : is the bounding sphere outside the frustum ?
  76796. * If not, then the cullable object is in the frustum.
  76797. */
  76798. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  76799. /** Culling strategy : Optimistic Inclusion.
  76800. * This in an inclusion test first, then the standard exclusion test.
  76801. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  76802. * 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.
  76803. * Anyway, it's as accurate as the standard strategy.
  76804. * Test :
  76805. * Is the cullable object bounding sphere center in the frustum ?
  76806. * If not, apply the default culling strategy.
  76807. */
  76808. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  76809. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  76810. * This in an inclusion test first, then the bounding sphere only exclusion test.
  76811. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  76812. * 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.
  76813. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  76814. * Test :
  76815. * Is the cullable object bounding sphere center in the frustum ?
  76816. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  76817. */
  76818. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  76819. /**
  76820. * No logging while loading
  76821. */
  76822. static readonly SCENELOADER_NO_LOGGING: number;
  76823. /**
  76824. * Minimal logging while loading
  76825. */
  76826. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  76827. /**
  76828. * Summary logging while loading
  76829. */
  76830. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  76831. /**
  76832. * Detailled logging while loading
  76833. */
  76834. static readonly SCENELOADER_DETAILED_LOGGING: number;
  76835. }
  76836. }
  76837. declare module BABYLON {
  76838. /**
  76839. * This represents the required contract to create a new type of texture loader.
  76840. */
  76841. export interface IInternalTextureLoader {
  76842. /**
  76843. * Defines wether the loader supports cascade loading the different faces.
  76844. */
  76845. supportCascades: boolean;
  76846. /**
  76847. * This returns if the loader support the current file information.
  76848. * @param extension defines the file extension of the file being loaded
  76849. * @returns true if the loader can load the specified file
  76850. */
  76851. canLoad(extension: string): boolean;
  76852. /**
  76853. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  76854. * @param data contains the texture data
  76855. * @param texture defines the BabylonJS internal texture
  76856. * @param createPolynomials will be true if polynomials have been requested
  76857. * @param onLoad defines the callback to trigger once the texture is ready
  76858. * @param onError defines the callback to trigger in case of error
  76859. */
  76860. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  76861. /**
  76862. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  76863. * @param data contains the texture data
  76864. * @param texture defines the BabylonJS internal texture
  76865. * @param callback defines the method to call once ready to upload
  76866. */
  76867. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  76868. }
  76869. }
  76870. declare module BABYLON {
  76871. /**
  76872. * Class used to store and describe the pipeline context associated with an effect
  76873. */
  76874. export interface IPipelineContext {
  76875. /**
  76876. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  76877. */
  76878. isAsync: boolean;
  76879. /**
  76880. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  76881. */
  76882. isReady: boolean;
  76883. /** @hidden */
  76884. _getVertexShaderCode(): string | null;
  76885. /** @hidden */
  76886. _getFragmentShaderCode(): string | null;
  76887. /** @hidden */
  76888. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  76889. }
  76890. }
  76891. declare module BABYLON {
  76892. /**
  76893. * Class used to store gfx data (like WebGLBuffer)
  76894. */
  76895. export class DataBuffer {
  76896. /**
  76897. * Gets or sets the number of objects referencing this buffer
  76898. */
  76899. references: number;
  76900. /** Gets or sets the size of the underlying buffer */
  76901. capacity: number;
  76902. /**
  76903. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  76904. */
  76905. is32Bits: boolean;
  76906. /**
  76907. * Gets the underlying buffer
  76908. */
  76909. get underlyingResource(): any;
  76910. }
  76911. }
  76912. declare module BABYLON {
  76913. /** @hidden */
  76914. export interface IShaderProcessor {
  76915. attributeProcessor?: (attribute: string) => string;
  76916. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  76917. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  76918. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  76919. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  76920. lineProcessor?: (line: string, isFragment: boolean) => string;
  76921. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  76922. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  76923. }
  76924. }
  76925. declare module BABYLON {
  76926. /** @hidden */
  76927. export interface ProcessingOptions {
  76928. defines: string[];
  76929. indexParameters: any;
  76930. isFragment: boolean;
  76931. shouldUseHighPrecisionShader: boolean;
  76932. supportsUniformBuffers: boolean;
  76933. shadersRepository: string;
  76934. includesShadersStore: {
  76935. [key: string]: string;
  76936. };
  76937. processor?: IShaderProcessor;
  76938. version: string;
  76939. platformName: string;
  76940. lookForClosingBracketForUniformBuffer?: boolean;
  76941. }
  76942. }
  76943. declare module BABYLON {
  76944. /** @hidden */
  76945. export class ShaderCodeNode {
  76946. line: string;
  76947. children: ShaderCodeNode[];
  76948. additionalDefineKey?: string;
  76949. additionalDefineValue?: string;
  76950. isValid(preprocessors: {
  76951. [key: string]: string;
  76952. }): boolean;
  76953. process(preprocessors: {
  76954. [key: string]: string;
  76955. }, options: ProcessingOptions): string;
  76956. }
  76957. }
  76958. declare module BABYLON {
  76959. /** @hidden */
  76960. export class ShaderCodeCursor {
  76961. private _lines;
  76962. lineIndex: number;
  76963. get currentLine(): string;
  76964. get canRead(): boolean;
  76965. set lines(value: string[]);
  76966. }
  76967. }
  76968. declare module BABYLON {
  76969. /** @hidden */
  76970. export class ShaderCodeConditionNode extends ShaderCodeNode {
  76971. process(preprocessors: {
  76972. [key: string]: string;
  76973. }, options: ProcessingOptions): string;
  76974. }
  76975. }
  76976. declare module BABYLON {
  76977. /** @hidden */
  76978. export class ShaderDefineExpression {
  76979. isTrue(preprocessors: {
  76980. [key: string]: string;
  76981. }): boolean;
  76982. private static _OperatorPriority;
  76983. private static _Stack;
  76984. static postfixToInfix(postfix: string[]): string;
  76985. static infixToPostfix(infix: string): string[];
  76986. }
  76987. }
  76988. declare module BABYLON {
  76989. /** @hidden */
  76990. export class ShaderCodeTestNode extends ShaderCodeNode {
  76991. testExpression: ShaderDefineExpression;
  76992. isValid(preprocessors: {
  76993. [key: string]: string;
  76994. }): boolean;
  76995. }
  76996. }
  76997. declare module BABYLON {
  76998. /** @hidden */
  76999. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  77000. define: string;
  77001. not: boolean;
  77002. constructor(define: string, not?: boolean);
  77003. isTrue(preprocessors: {
  77004. [key: string]: string;
  77005. }): boolean;
  77006. }
  77007. }
  77008. declare module BABYLON {
  77009. /** @hidden */
  77010. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  77011. leftOperand: ShaderDefineExpression;
  77012. rightOperand: ShaderDefineExpression;
  77013. isTrue(preprocessors: {
  77014. [key: string]: string;
  77015. }): boolean;
  77016. }
  77017. }
  77018. declare module BABYLON {
  77019. /** @hidden */
  77020. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  77021. leftOperand: ShaderDefineExpression;
  77022. rightOperand: ShaderDefineExpression;
  77023. isTrue(preprocessors: {
  77024. [key: string]: string;
  77025. }): boolean;
  77026. }
  77027. }
  77028. declare module BABYLON {
  77029. /** @hidden */
  77030. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  77031. define: string;
  77032. operand: string;
  77033. testValue: string;
  77034. constructor(define: string, operand: string, testValue: string);
  77035. isTrue(preprocessors: {
  77036. [key: string]: string;
  77037. }): boolean;
  77038. }
  77039. }
  77040. declare module BABYLON {
  77041. /**
  77042. * Class used to enable access to offline support
  77043. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  77044. */
  77045. export interface IOfflineProvider {
  77046. /**
  77047. * Gets a boolean indicating if scene must be saved in the database
  77048. */
  77049. enableSceneOffline: boolean;
  77050. /**
  77051. * Gets a boolean indicating if textures must be saved in the database
  77052. */
  77053. enableTexturesOffline: boolean;
  77054. /**
  77055. * Open the offline support and make it available
  77056. * @param successCallback defines the callback to call on success
  77057. * @param errorCallback defines the callback to call on error
  77058. */
  77059. open(successCallback: () => void, errorCallback: () => void): void;
  77060. /**
  77061. * Loads an image from the offline support
  77062. * @param url defines the url to load from
  77063. * @param image defines the target DOM image
  77064. */
  77065. loadImage(url: string, image: HTMLImageElement): void;
  77066. /**
  77067. * Loads a file from offline support
  77068. * @param url defines the URL to load from
  77069. * @param sceneLoaded defines a callback to call on success
  77070. * @param progressCallBack defines a callback to call when progress changed
  77071. * @param errorCallback defines a callback to call on error
  77072. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  77073. */
  77074. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  77075. }
  77076. }
  77077. declare module BABYLON {
  77078. /**
  77079. * Class used to help managing file picking and drag'n'drop
  77080. * File Storage
  77081. */
  77082. export class FilesInputStore {
  77083. /**
  77084. * List of files ready to be loaded
  77085. */
  77086. static FilesToLoad: {
  77087. [key: string]: File;
  77088. };
  77089. }
  77090. }
  77091. declare module BABYLON {
  77092. /**
  77093. * Class used to define a retry strategy when error happens while loading assets
  77094. */
  77095. export class RetryStrategy {
  77096. /**
  77097. * Function used to defines an exponential back off strategy
  77098. * @param maxRetries defines the maximum number of retries (3 by default)
  77099. * @param baseInterval defines the interval between retries
  77100. * @returns the strategy function to use
  77101. */
  77102. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  77103. }
  77104. }
  77105. declare module BABYLON {
  77106. /**
  77107. * @ignore
  77108. * Application error to support additional information when loading a file
  77109. */
  77110. export abstract class BaseError extends Error {
  77111. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  77112. }
  77113. }
  77114. declare module BABYLON {
  77115. /** @ignore */
  77116. export class LoadFileError extends BaseError {
  77117. request?: WebRequest;
  77118. file?: File;
  77119. /**
  77120. * Creates a new LoadFileError
  77121. * @param message defines the message of the error
  77122. * @param request defines the optional web request
  77123. * @param file defines the optional file
  77124. */
  77125. constructor(message: string, object?: WebRequest | File);
  77126. }
  77127. /** @ignore */
  77128. export class RequestFileError extends BaseError {
  77129. request: WebRequest;
  77130. /**
  77131. * Creates a new LoadFileError
  77132. * @param message defines the message of the error
  77133. * @param request defines the optional web request
  77134. */
  77135. constructor(message: string, request: WebRequest);
  77136. }
  77137. /** @ignore */
  77138. export class ReadFileError extends BaseError {
  77139. file: File;
  77140. /**
  77141. * Creates a new ReadFileError
  77142. * @param message defines the message of the error
  77143. * @param file defines the optional file
  77144. */
  77145. constructor(message: string, file: File);
  77146. }
  77147. /**
  77148. * @hidden
  77149. */
  77150. export class FileTools {
  77151. /**
  77152. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  77153. */
  77154. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  77155. /**
  77156. * Gets or sets the base URL to use to load assets
  77157. */
  77158. static BaseUrl: string;
  77159. /**
  77160. * Default behaviour for cors in the application.
  77161. * It can be a string if the expected behavior is identical in the entire app.
  77162. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  77163. */
  77164. static CorsBehavior: string | ((url: string | string[]) => string);
  77165. /**
  77166. * Gets or sets a function used to pre-process url before using them to load assets
  77167. */
  77168. static PreprocessUrl: (url: string) => string;
  77169. /**
  77170. * Removes unwanted characters from an url
  77171. * @param url defines the url to clean
  77172. * @returns the cleaned url
  77173. */
  77174. private static _CleanUrl;
  77175. /**
  77176. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  77177. * @param url define the url we are trying
  77178. * @param element define the dom element where to configure the cors policy
  77179. */
  77180. static SetCorsBehavior(url: string | string[], element: {
  77181. crossOrigin: string | null;
  77182. }): void;
  77183. /**
  77184. * Loads an image as an HTMLImageElement.
  77185. * @param input url string, ArrayBuffer, or Blob to load
  77186. * @param onLoad callback called when the image successfully loads
  77187. * @param onError callback called when the image fails to load
  77188. * @param offlineProvider offline provider for caching
  77189. * @param mimeType optional mime type
  77190. * @returns the HTMLImageElement of the loaded image
  77191. */
  77192. 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>;
  77193. /**
  77194. * Reads a file from a File object
  77195. * @param file defines the file to load
  77196. * @param onSuccess defines the callback to call when data is loaded
  77197. * @param onProgress defines the callback to call during loading process
  77198. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  77199. * @param onError defines the callback to call when an error occurs
  77200. * @returns a file request object
  77201. */
  77202. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  77203. /**
  77204. * Loads a file from a url
  77205. * @param url url to load
  77206. * @param onSuccess callback called when the file successfully loads
  77207. * @param onProgress callback called while file is loading (if the server supports this mode)
  77208. * @param offlineProvider defines the offline provider for caching
  77209. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77210. * @param onError callback called when the file fails to load
  77211. * @returns a file request object
  77212. */
  77213. 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;
  77214. /**
  77215. * Loads a file
  77216. * @param url url to load
  77217. * @param onSuccess callback called when the file successfully loads
  77218. * @param onProgress callback called while file is loading (if the server supports this mode)
  77219. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77220. * @param onError callback called when the file fails to load
  77221. * @param onOpened callback called when the web request is opened
  77222. * @returns a file request object
  77223. */
  77224. 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;
  77225. /**
  77226. * Checks if the loaded document was accessed via `file:`-Protocol.
  77227. * @returns boolean
  77228. */
  77229. static IsFileURL(): boolean;
  77230. }
  77231. }
  77232. declare module BABYLON {
  77233. /** @hidden */
  77234. export class ShaderProcessor {
  77235. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  77236. private static _ProcessPrecision;
  77237. private static _ExtractOperation;
  77238. private static _BuildSubExpression;
  77239. private static _BuildExpression;
  77240. private static _MoveCursorWithinIf;
  77241. private static _MoveCursor;
  77242. private static _EvaluatePreProcessors;
  77243. private static _PreparePreProcessors;
  77244. private static _ProcessShaderConversion;
  77245. private static _ProcessIncludes;
  77246. /**
  77247. * Loads a file from a url
  77248. * @param url url to load
  77249. * @param onSuccess callback called when the file successfully loads
  77250. * @param onProgress callback called while file is loading (if the server supports this mode)
  77251. * @param offlineProvider defines the offline provider for caching
  77252. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  77253. * @param onError callback called when the file fails to load
  77254. * @returns a file request object
  77255. * @hidden
  77256. */
  77257. 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;
  77258. }
  77259. }
  77260. declare module BABYLON {
  77261. /**
  77262. * @hidden
  77263. */
  77264. export interface IColor4Like {
  77265. r: float;
  77266. g: float;
  77267. b: float;
  77268. a: float;
  77269. }
  77270. /**
  77271. * @hidden
  77272. */
  77273. export interface IColor3Like {
  77274. r: float;
  77275. g: float;
  77276. b: float;
  77277. }
  77278. /**
  77279. * @hidden
  77280. */
  77281. export interface IVector4Like {
  77282. x: float;
  77283. y: float;
  77284. z: float;
  77285. w: float;
  77286. }
  77287. /**
  77288. * @hidden
  77289. */
  77290. export interface IVector3Like {
  77291. x: float;
  77292. y: float;
  77293. z: float;
  77294. }
  77295. /**
  77296. * @hidden
  77297. */
  77298. export interface IVector2Like {
  77299. x: float;
  77300. y: float;
  77301. }
  77302. /**
  77303. * @hidden
  77304. */
  77305. export interface IMatrixLike {
  77306. toArray(): DeepImmutable<Float32Array>;
  77307. updateFlag: int;
  77308. }
  77309. /**
  77310. * @hidden
  77311. */
  77312. export interface IViewportLike {
  77313. x: float;
  77314. y: float;
  77315. width: float;
  77316. height: float;
  77317. }
  77318. /**
  77319. * @hidden
  77320. */
  77321. export interface IPlaneLike {
  77322. normal: IVector3Like;
  77323. d: float;
  77324. normalize(): void;
  77325. }
  77326. }
  77327. declare module BABYLON {
  77328. /**
  77329. * Interface used to define common properties for effect fallbacks
  77330. */
  77331. export interface IEffectFallbacks {
  77332. /**
  77333. * Removes the defines that should be removed when falling back.
  77334. * @param currentDefines defines the current define statements for the shader.
  77335. * @param effect defines the current effect we try to compile
  77336. * @returns The resulting defines with defines of the current rank removed.
  77337. */
  77338. reduce(currentDefines: string, effect: Effect): string;
  77339. /**
  77340. * Removes the fallback from the bound mesh.
  77341. */
  77342. unBindMesh(): void;
  77343. /**
  77344. * Checks to see if more fallbacks are still availible.
  77345. */
  77346. hasMoreFallbacks: boolean;
  77347. }
  77348. }
  77349. declare module BABYLON {
  77350. /**
  77351. * Class used to evalaute queries containing `and` and `or` operators
  77352. */
  77353. export class AndOrNotEvaluator {
  77354. /**
  77355. * Evaluate a query
  77356. * @param query defines the query to evaluate
  77357. * @param evaluateCallback defines the callback used to filter result
  77358. * @returns true if the query matches
  77359. */
  77360. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  77361. private static _HandleParenthesisContent;
  77362. private static _SimplifyNegation;
  77363. }
  77364. }
  77365. declare module BABYLON {
  77366. /**
  77367. * Class used to store custom tags
  77368. */
  77369. export class Tags {
  77370. /**
  77371. * Adds support for tags on the given object
  77372. * @param obj defines the object to use
  77373. */
  77374. static EnableFor(obj: any): void;
  77375. /**
  77376. * Removes tags support
  77377. * @param obj defines the object to use
  77378. */
  77379. static DisableFor(obj: any): void;
  77380. /**
  77381. * Gets a boolean indicating if the given object has tags
  77382. * @param obj defines the object to use
  77383. * @returns a boolean
  77384. */
  77385. static HasTags(obj: any): boolean;
  77386. /**
  77387. * Gets the tags available on a given object
  77388. * @param obj defines the object to use
  77389. * @param asString defines if the tags must be returned as a string instead of an array of strings
  77390. * @returns the tags
  77391. */
  77392. static GetTags(obj: any, asString?: boolean): any;
  77393. /**
  77394. * Adds tags to an object
  77395. * @param obj defines the object to use
  77396. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  77397. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  77398. */
  77399. static AddTagsTo(obj: any, tagsString: string): void;
  77400. /**
  77401. * @hidden
  77402. */
  77403. static _AddTagTo(obj: any, tag: string): void;
  77404. /**
  77405. * Removes specific tags from a specific object
  77406. * @param obj defines the object to use
  77407. * @param tagsString defines the tags to remove
  77408. */
  77409. static RemoveTagsFrom(obj: any, tagsString: string): void;
  77410. /**
  77411. * @hidden
  77412. */
  77413. static _RemoveTagFrom(obj: any, tag: string): void;
  77414. /**
  77415. * Defines if tags hosted on an object match a given query
  77416. * @param obj defines the object to use
  77417. * @param tagsQuery defines the tag query
  77418. * @returns a boolean
  77419. */
  77420. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  77421. }
  77422. }
  77423. declare module BABYLON {
  77424. /**
  77425. * Scalar computation library
  77426. */
  77427. export class Scalar {
  77428. /**
  77429. * Two pi constants convenient for computation.
  77430. */
  77431. static TwoPi: number;
  77432. /**
  77433. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77434. * @param a number
  77435. * @param b number
  77436. * @param epsilon (default = 1.401298E-45)
  77437. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  77438. */
  77439. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  77440. /**
  77441. * Returns a string : the upper case translation of the number i to hexadecimal.
  77442. * @param i number
  77443. * @returns the upper case translation of the number i to hexadecimal.
  77444. */
  77445. static ToHex(i: number): string;
  77446. /**
  77447. * Returns -1 if value is negative and +1 is value is positive.
  77448. * @param value the value
  77449. * @returns the value itself if it's equal to zero.
  77450. */
  77451. static Sign(value: number): number;
  77452. /**
  77453. * Returns the value itself if it's between min and max.
  77454. * Returns min if the value is lower than min.
  77455. * Returns max if the value is greater than max.
  77456. * @param value the value to clmap
  77457. * @param min the min value to clamp to (default: 0)
  77458. * @param max the max value to clamp to (default: 1)
  77459. * @returns the clamped value
  77460. */
  77461. static Clamp(value: number, min?: number, max?: number): number;
  77462. /**
  77463. * the log2 of value.
  77464. * @param value the value to compute log2 of
  77465. * @returns the log2 of value.
  77466. */
  77467. static Log2(value: number): number;
  77468. /**
  77469. * Loops the value, so that it is never larger than length and never smaller than 0.
  77470. *
  77471. * This is similar to the modulo operator but it works with floating point numbers.
  77472. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  77473. * With t = 5 and length = 2.5, the result would be 0.0.
  77474. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  77475. * @param value the value
  77476. * @param length the length
  77477. * @returns the looped value
  77478. */
  77479. static Repeat(value: number, length: number): number;
  77480. /**
  77481. * Normalize the value between 0.0 and 1.0 using min and max values
  77482. * @param value value to normalize
  77483. * @param min max to normalize between
  77484. * @param max min to normalize between
  77485. * @returns the normalized value
  77486. */
  77487. static Normalize(value: number, min: number, max: number): number;
  77488. /**
  77489. * Denormalize the value from 0.0 and 1.0 using min and max values
  77490. * @param normalized value to denormalize
  77491. * @param min max to denormalize between
  77492. * @param max min to denormalize between
  77493. * @returns the denormalized value
  77494. */
  77495. static Denormalize(normalized: number, min: number, max: number): number;
  77496. /**
  77497. * Calculates the shortest difference between two given angles given in degrees.
  77498. * @param current current angle in degrees
  77499. * @param target target angle in degrees
  77500. * @returns the delta
  77501. */
  77502. static DeltaAngle(current: number, target: number): number;
  77503. /**
  77504. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  77505. * @param tx value
  77506. * @param length length
  77507. * @returns The returned value will move back and forth between 0 and length
  77508. */
  77509. static PingPong(tx: number, length: number): number;
  77510. /**
  77511. * Interpolates between min and max with smoothing at the limits.
  77512. *
  77513. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  77514. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  77515. * @param from from
  77516. * @param to to
  77517. * @param tx value
  77518. * @returns the smooth stepped value
  77519. */
  77520. static SmoothStep(from: number, to: number, tx: number): number;
  77521. /**
  77522. * Moves a value current towards target.
  77523. *
  77524. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  77525. * Negative values of maxDelta pushes the value away from target.
  77526. * @param current current value
  77527. * @param target target value
  77528. * @param maxDelta max distance to move
  77529. * @returns resulting value
  77530. */
  77531. static MoveTowards(current: number, target: number, maxDelta: number): number;
  77532. /**
  77533. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77534. *
  77535. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  77536. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  77537. * @param current current value
  77538. * @param target target value
  77539. * @param maxDelta max distance to move
  77540. * @returns resulting angle
  77541. */
  77542. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  77543. /**
  77544. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  77545. * @param start start value
  77546. * @param end target value
  77547. * @param amount amount to lerp between
  77548. * @returns the lerped value
  77549. */
  77550. static Lerp(start: number, end: number, amount: number): number;
  77551. /**
  77552. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  77553. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  77554. * @param start start value
  77555. * @param end target value
  77556. * @param amount amount to lerp between
  77557. * @returns the lerped value
  77558. */
  77559. static LerpAngle(start: number, end: number, amount: number): number;
  77560. /**
  77561. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  77562. * @param a start value
  77563. * @param b target value
  77564. * @param value value between a and b
  77565. * @returns the inverseLerp value
  77566. */
  77567. static InverseLerp(a: number, b: number, value: number): number;
  77568. /**
  77569. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  77570. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  77571. * @param value1 spline value
  77572. * @param tangent1 spline value
  77573. * @param value2 spline value
  77574. * @param tangent2 spline value
  77575. * @param amount input value
  77576. * @returns hermite result
  77577. */
  77578. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  77579. /**
  77580. * Returns a random float number between and min and max values
  77581. * @param min min value of random
  77582. * @param max max value of random
  77583. * @returns random value
  77584. */
  77585. static RandomRange(min: number, max: number): number;
  77586. /**
  77587. * This function returns percentage of a number in a given range.
  77588. *
  77589. * RangeToPercent(40,20,60) will return 0.5 (50%)
  77590. * RangeToPercent(34,0,100) will return 0.34 (34%)
  77591. * @param number to convert to percentage
  77592. * @param min min range
  77593. * @param max max range
  77594. * @returns the percentage
  77595. */
  77596. static RangeToPercent(number: number, min: number, max: number): number;
  77597. /**
  77598. * This function returns number that corresponds to the percentage in a given range.
  77599. *
  77600. * PercentToRange(0.34,0,100) will return 34.
  77601. * @param percent to convert to number
  77602. * @param min min range
  77603. * @param max max range
  77604. * @returns the number
  77605. */
  77606. static PercentToRange(percent: number, min: number, max: number): number;
  77607. /**
  77608. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  77609. * @param angle The angle to normalize in radian.
  77610. * @return The converted angle.
  77611. */
  77612. static NormalizeRadians(angle: number): number;
  77613. }
  77614. }
  77615. declare module BABYLON {
  77616. /**
  77617. * Constant used to convert a value to gamma space
  77618. * @ignorenaming
  77619. */
  77620. export const ToGammaSpace: number;
  77621. /**
  77622. * Constant used to convert a value to linear space
  77623. * @ignorenaming
  77624. */
  77625. export const ToLinearSpace = 2.2;
  77626. /**
  77627. * Constant used to define the minimal number value in Babylon.js
  77628. * @ignorenaming
  77629. */
  77630. let Epsilon: number;
  77631. }
  77632. declare module BABYLON {
  77633. /**
  77634. * Class used to represent a viewport on screen
  77635. */
  77636. export class Viewport {
  77637. /** viewport left coordinate */
  77638. x: number;
  77639. /** viewport top coordinate */
  77640. y: number;
  77641. /**viewport width */
  77642. width: number;
  77643. /** viewport height */
  77644. height: number;
  77645. /**
  77646. * Creates a Viewport object located at (x, y) and sized (width, height)
  77647. * @param x defines viewport left coordinate
  77648. * @param y defines viewport top coordinate
  77649. * @param width defines the viewport width
  77650. * @param height defines the viewport height
  77651. */
  77652. constructor(
  77653. /** viewport left coordinate */
  77654. x: number,
  77655. /** viewport top coordinate */
  77656. y: number,
  77657. /**viewport width */
  77658. width: number,
  77659. /** viewport height */
  77660. height: number);
  77661. /**
  77662. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  77663. * @param renderWidth defines the rendering width
  77664. * @param renderHeight defines the rendering height
  77665. * @returns a new Viewport
  77666. */
  77667. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  77668. /**
  77669. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  77670. * @param renderWidth defines the rendering width
  77671. * @param renderHeight defines the rendering height
  77672. * @param ref defines the target viewport
  77673. * @returns the current viewport
  77674. */
  77675. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  77676. /**
  77677. * Returns a new Viewport copied from the current one
  77678. * @returns a new Viewport
  77679. */
  77680. clone(): Viewport;
  77681. }
  77682. }
  77683. declare module BABYLON {
  77684. /**
  77685. * Class containing a set of static utilities functions for arrays.
  77686. */
  77687. export class ArrayTools {
  77688. /**
  77689. * Returns an array of the given size filled with element built from the given constructor and the paramters
  77690. * @param size the number of element to construct and put in the array
  77691. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  77692. * @returns a new array filled with new objects
  77693. */
  77694. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  77695. }
  77696. }
  77697. declare module BABYLON {
  77698. /**
  77699. * Represens a plane by the equation ax + by + cz + d = 0
  77700. */
  77701. export class Plane {
  77702. private static _TmpMatrix;
  77703. /**
  77704. * Normal of the plane (a,b,c)
  77705. */
  77706. normal: Vector3;
  77707. /**
  77708. * d component of the plane
  77709. */
  77710. d: number;
  77711. /**
  77712. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77713. * @param a a component of the plane
  77714. * @param b b component of the plane
  77715. * @param c c component of the plane
  77716. * @param d d component of the plane
  77717. */
  77718. constructor(a: number, b: number, c: number, d: number);
  77719. /**
  77720. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77721. */
  77722. asArray(): number[];
  77723. /**
  77724. * @returns a new plane copied from the current Plane.
  77725. */
  77726. clone(): Plane;
  77727. /**
  77728. * @returns the string "Plane".
  77729. */
  77730. getClassName(): string;
  77731. /**
  77732. * @returns the Plane hash code.
  77733. */
  77734. getHashCode(): number;
  77735. /**
  77736. * Normalize the current Plane in place.
  77737. * @returns the updated Plane.
  77738. */
  77739. normalize(): Plane;
  77740. /**
  77741. * Applies a transformation the plane and returns the result
  77742. * @param transformation the transformation matrix to be applied to the plane
  77743. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77744. */
  77745. transform(transformation: DeepImmutable<Matrix>): Plane;
  77746. /**
  77747. * Compute the dot product between the point and the plane normal
  77748. * @param point point to calculate the dot product with
  77749. * @returns the dot product (float) of the point coordinates and the plane normal.
  77750. */
  77751. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77752. /**
  77753. * Updates the current Plane from the plane defined by the three given points.
  77754. * @param point1 one of the points used to contruct the plane
  77755. * @param point2 one of the points used to contruct the plane
  77756. * @param point3 one of the points used to contruct the plane
  77757. * @returns the updated Plane.
  77758. */
  77759. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77760. /**
  77761. * Checks if the plane is facing a given direction
  77762. * @param direction the direction to check if the plane is facing
  77763. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77764. * @returns True is the vector "direction" is the same side than the plane normal.
  77765. */
  77766. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77767. /**
  77768. * Calculates the distance to a point
  77769. * @param point point to calculate distance to
  77770. * @returns the signed distance (float) from the given point to the Plane.
  77771. */
  77772. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77773. /**
  77774. * Creates a plane from an array
  77775. * @param array the array to create a plane from
  77776. * @returns a new Plane from the given array.
  77777. */
  77778. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77779. /**
  77780. * Creates a plane from three points
  77781. * @param point1 point used to create the plane
  77782. * @param point2 point used to create the plane
  77783. * @param point3 point used to create the plane
  77784. * @returns a new Plane defined by the three given points.
  77785. */
  77786. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77787. /**
  77788. * Creates a plane from an origin point and a normal
  77789. * @param origin origin of the plane to be constructed
  77790. * @param normal normal of the plane to be constructed
  77791. * @returns a new Plane the normal vector to this plane at the given origin point.
  77792. * Note : the vector "normal" is updated because normalized.
  77793. */
  77794. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77795. /**
  77796. * Calculates the distance from a plane and a point
  77797. * @param origin origin of the plane to be constructed
  77798. * @param normal normal of the plane to be constructed
  77799. * @param point point to calculate distance to
  77800. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77801. */
  77802. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77803. }
  77804. }
  77805. declare module BABYLON {
  77806. /**
  77807. * Class representing a vector containing 2 coordinates
  77808. */
  77809. export class Vector2 {
  77810. /** defines the first coordinate */
  77811. x: number;
  77812. /** defines the second coordinate */
  77813. y: number;
  77814. /**
  77815. * Creates a new Vector2 from the given x and y coordinates
  77816. * @param x defines the first coordinate
  77817. * @param y defines the second coordinate
  77818. */
  77819. constructor(
  77820. /** defines the first coordinate */
  77821. x?: number,
  77822. /** defines the second coordinate */
  77823. y?: number);
  77824. /**
  77825. * Gets a string with the Vector2 coordinates
  77826. * @returns a string with the Vector2 coordinates
  77827. */
  77828. toString(): string;
  77829. /**
  77830. * Gets class name
  77831. * @returns the string "Vector2"
  77832. */
  77833. getClassName(): string;
  77834. /**
  77835. * Gets current vector hash code
  77836. * @returns the Vector2 hash code as a number
  77837. */
  77838. getHashCode(): number;
  77839. /**
  77840. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  77841. * @param array defines the source array
  77842. * @param index defines the offset in source array
  77843. * @returns the current Vector2
  77844. */
  77845. toArray(array: FloatArray, index?: number): Vector2;
  77846. /**
  77847. * Copy the current vector to an array
  77848. * @returns a new array with 2 elements: the Vector2 coordinates.
  77849. */
  77850. asArray(): number[];
  77851. /**
  77852. * Sets the Vector2 coordinates with the given Vector2 coordinates
  77853. * @param source defines the source Vector2
  77854. * @returns the current updated Vector2
  77855. */
  77856. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  77857. /**
  77858. * Sets the Vector2 coordinates with the given floats
  77859. * @param x defines the first coordinate
  77860. * @param y defines the second coordinate
  77861. * @returns the current updated Vector2
  77862. */
  77863. copyFromFloats(x: number, y: number): Vector2;
  77864. /**
  77865. * Sets the Vector2 coordinates with the given floats
  77866. * @param x defines the first coordinate
  77867. * @param y defines the second coordinate
  77868. * @returns the current updated Vector2
  77869. */
  77870. set(x: number, y: number): Vector2;
  77871. /**
  77872. * Add another vector with the current one
  77873. * @param otherVector defines the other vector
  77874. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  77875. */
  77876. add(otherVector: DeepImmutable<Vector2>): Vector2;
  77877. /**
  77878. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  77879. * @param otherVector defines the other vector
  77880. * @param result defines the target vector
  77881. * @returns the unmodified current Vector2
  77882. */
  77883. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77884. /**
  77885. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  77886. * @param otherVector defines the other vector
  77887. * @returns the current updated Vector2
  77888. */
  77889. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77890. /**
  77891. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  77892. * @param otherVector defines the other vector
  77893. * @returns a new Vector2
  77894. */
  77895. addVector3(otherVector: Vector3): Vector2;
  77896. /**
  77897. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  77898. * @param otherVector defines the other vector
  77899. * @returns a new Vector2
  77900. */
  77901. subtract(otherVector: Vector2): Vector2;
  77902. /**
  77903. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  77904. * @param otherVector defines the other vector
  77905. * @param result defines the target vector
  77906. * @returns the unmodified current Vector2
  77907. */
  77908. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77909. /**
  77910. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  77911. * @param otherVector defines the other vector
  77912. * @returns the current updated Vector2
  77913. */
  77914. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77915. /**
  77916. * Multiplies in place the current Vector2 coordinates by the given ones
  77917. * @param otherVector defines the other vector
  77918. * @returns the current updated Vector2
  77919. */
  77920. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77921. /**
  77922. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  77923. * @param otherVector defines the other vector
  77924. * @returns a new Vector2
  77925. */
  77926. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  77927. /**
  77928. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  77929. * @param otherVector defines the other vector
  77930. * @param result defines the target vector
  77931. * @returns the unmodified current Vector2
  77932. */
  77933. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77934. /**
  77935. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  77936. * @param x defines the first coordinate
  77937. * @param y defines the second coordinate
  77938. * @returns a new Vector2
  77939. */
  77940. multiplyByFloats(x: number, y: number): Vector2;
  77941. /**
  77942. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  77943. * @param otherVector defines the other vector
  77944. * @returns a new Vector2
  77945. */
  77946. divide(otherVector: Vector2): Vector2;
  77947. /**
  77948. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  77949. * @param otherVector defines the other vector
  77950. * @param result defines the target vector
  77951. * @returns the unmodified current Vector2
  77952. */
  77953. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  77954. /**
  77955. * Divides the current Vector2 coordinates by the given ones
  77956. * @param otherVector defines the other vector
  77957. * @returns the current updated Vector2
  77958. */
  77959. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  77960. /**
  77961. * Gets a new Vector2 with current Vector2 negated coordinates
  77962. * @returns a new Vector2
  77963. */
  77964. negate(): Vector2;
  77965. /**
  77966. * Negate this vector in place
  77967. * @returns this
  77968. */
  77969. negateInPlace(): Vector2;
  77970. /**
  77971. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  77972. * @param result defines the Vector3 object where to store the result
  77973. * @returns the current Vector2
  77974. */
  77975. negateToRef(result: Vector2): Vector2;
  77976. /**
  77977. * Multiply the Vector2 coordinates by scale
  77978. * @param scale defines the scaling factor
  77979. * @returns the current updated Vector2
  77980. */
  77981. scaleInPlace(scale: number): Vector2;
  77982. /**
  77983. * Returns a new Vector2 scaled by "scale" from the current Vector2
  77984. * @param scale defines the scaling factor
  77985. * @returns a new Vector2
  77986. */
  77987. scale(scale: number): Vector2;
  77988. /**
  77989. * Scale the current Vector2 values by a factor to a given Vector2
  77990. * @param scale defines the scale factor
  77991. * @param result defines the Vector2 object where to store the result
  77992. * @returns the unmodified current Vector2
  77993. */
  77994. scaleToRef(scale: number, result: Vector2): Vector2;
  77995. /**
  77996. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  77997. * @param scale defines the scale factor
  77998. * @param result defines the Vector2 object where to store the result
  77999. * @returns the unmodified current Vector2
  78000. */
  78001. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  78002. /**
  78003. * Gets a boolean if two vectors are equals
  78004. * @param otherVector defines the other vector
  78005. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  78006. */
  78007. equals(otherVector: DeepImmutable<Vector2>): boolean;
  78008. /**
  78009. * Gets a boolean if two vectors are equals (using an epsilon value)
  78010. * @param otherVector defines the other vector
  78011. * @param epsilon defines the minimal distance to consider equality
  78012. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  78013. */
  78014. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  78015. /**
  78016. * Gets a new Vector2 from current Vector2 floored values
  78017. * @returns a new Vector2
  78018. */
  78019. floor(): Vector2;
  78020. /**
  78021. * Gets a new Vector2 from current Vector2 floored values
  78022. * @returns a new Vector2
  78023. */
  78024. fract(): Vector2;
  78025. /**
  78026. * Gets the length of the vector
  78027. * @returns the vector length (float)
  78028. */
  78029. length(): number;
  78030. /**
  78031. * Gets the vector squared length
  78032. * @returns the vector squared length (float)
  78033. */
  78034. lengthSquared(): number;
  78035. /**
  78036. * Normalize the vector
  78037. * @returns the current updated Vector2
  78038. */
  78039. normalize(): Vector2;
  78040. /**
  78041. * Gets a new Vector2 copied from the Vector2
  78042. * @returns a new Vector2
  78043. */
  78044. clone(): Vector2;
  78045. /**
  78046. * Gets a new Vector2(0, 0)
  78047. * @returns a new Vector2
  78048. */
  78049. static Zero(): Vector2;
  78050. /**
  78051. * Gets a new Vector2(1, 1)
  78052. * @returns a new Vector2
  78053. */
  78054. static One(): Vector2;
  78055. /**
  78056. * Gets a new Vector2 set from the given index element of the given array
  78057. * @param array defines the data source
  78058. * @param offset defines the offset in the data source
  78059. * @returns a new Vector2
  78060. */
  78061. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  78062. /**
  78063. * Sets "result" from the given index element of the given array
  78064. * @param array defines the data source
  78065. * @param offset defines the offset in the data source
  78066. * @param result defines the target vector
  78067. */
  78068. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  78069. /**
  78070. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  78071. * @param value1 defines 1st point of control
  78072. * @param value2 defines 2nd point of control
  78073. * @param value3 defines 3rd point of control
  78074. * @param value4 defines 4th point of control
  78075. * @param amount defines the interpolation factor
  78076. * @returns a new Vector2
  78077. */
  78078. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  78079. /**
  78080. * 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".
  78081. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  78082. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  78083. * @param value defines the value to clamp
  78084. * @param min defines the lower limit
  78085. * @param max defines the upper limit
  78086. * @returns a new Vector2
  78087. */
  78088. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  78089. /**
  78090. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  78091. * @param value1 defines the 1st control point
  78092. * @param tangent1 defines the outgoing tangent
  78093. * @param value2 defines the 2nd control point
  78094. * @param tangent2 defines the incoming tangent
  78095. * @param amount defines the interpolation factor
  78096. * @returns a new Vector2
  78097. */
  78098. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  78099. /**
  78100. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  78101. * @param start defines the start vector
  78102. * @param end defines the end vector
  78103. * @param amount defines the interpolation factor
  78104. * @returns a new Vector2
  78105. */
  78106. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  78107. /**
  78108. * Gets the dot product of the vector "left" and the vector "right"
  78109. * @param left defines first vector
  78110. * @param right defines second vector
  78111. * @returns the dot product (float)
  78112. */
  78113. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  78114. /**
  78115. * Returns a new Vector2 equal to the normalized given vector
  78116. * @param vector defines the vector to normalize
  78117. * @returns a new Vector2
  78118. */
  78119. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  78120. /**
  78121. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  78122. * @param left defines 1st vector
  78123. * @param right defines 2nd vector
  78124. * @returns a new Vector2
  78125. */
  78126. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78127. /**
  78128. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  78129. * @param left defines 1st vector
  78130. * @param right defines 2nd vector
  78131. * @returns a new Vector2
  78132. */
  78133. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  78134. /**
  78135. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  78136. * @param vector defines the vector to transform
  78137. * @param transformation defines the matrix to apply
  78138. * @returns a new Vector2
  78139. */
  78140. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  78141. /**
  78142. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  78143. * @param vector defines the vector to transform
  78144. * @param transformation defines the matrix to apply
  78145. * @param result defines the target vector
  78146. */
  78147. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  78148. /**
  78149. * Determines if a given vector is included in a triangle
  78150. * @param p defines the vector to test
  78151. * @param p0 defines 1st triangle point
  78152. * @param p1 defines 2nd triangle point
  78153. * @param p2 defines 3rd triangle point
  78154. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  78155. */
  78156. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  78157. /**
  78158. * Gets the distance between the vectors "value1" and "value2"
  78159. * @param value1 defines first vector
  78160. * @param value2 defines second vector
  78161. * @returns the distance between vectors
  78162. */
  78163. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78164. /**
  78165. * Returns the squared distance between the vectors "value1" and "value2"
  78166. * @param value1 defines first vector
  78167. * @param value2 defines second vector
  78168. * @returns the squared distance between vectors
  78169. */
  78170. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  78171. /**
  78172. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  78173. * @param value1 defines first vector
  78174. * @param value2 defines second vector
  78175. * @returns a new Vector2
  78176. */
  78177. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  78178. /**
  78179. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  78180. * @param p defines the middle point
  78181. * @param segA defines one point of the segment
  78182. * @param segB defines the other point of the segment
  78183. * @returns the shortest distance
  78184. */
  78185. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  78186. }
  78187. /**
  78188. * Class used to store (x,y,z) vector representation
  78189. * A Vector3 is the main object used in 3D geometry
  78190. * It can represent etiher the coordinates of a point the space, either a direction
  78191. * Reminder: js uses a left handed forward facing system
  78192. */
  78193. export class Vector3 {
  78194. /**
  78195. * Defines the first coordinates (on X axis)
  78196. */
  78197. x: number;
  78198. /**
  78199. * Defines the second coordinates (on Y axis)
  78200. */
  78201. y: number;
  78202. /**
  78203. * Defines the third coordinates (on Z axis)
  78204. */
  78205. z: number;
  78206. private static _UpReadOnly;
  78207. private static _ZeroReadOnly;
  78208. /**
  78209. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  78210. * @param x defines the first coordinates (on X axis)
  78211. * @param y defines the second coordinates (on Y axis)
  78212. * @param z defines the third coordinates (on Z axis)
  78213. */
  78214. constructor(
  78215. /**
  78216. * Defines the first coordinates (on X axis)
  78217. */
  78218. x?: number,
  78219. /**
  78220. * Defines the second coordinates (on Y axis)
  78221. */
  78222. y?: number,
  78223. /**
  78224. * Defines the third coordinates (on Z axis)
  78225. */
  78226. z?: number);
  78227. /**
  78228. * Creates a string representation of the Vector3
  78229. * @returns a string with the Vector3 coordinates.
  78230. */
  78231. toString(): string;
  78232. /**
  78233. * Gets the class name
  78234. * @returns the string "Vector3"
  78235. */
  78236. getClassName(): string;
  78237. /**
  78238. * Creates the Vector3 hash code
  78239. * @returns a number which tends to be unique between Vector3 instances
  78240. */
  78241. getHashCode(): number;
  78242. /**
  78243. * Creates an array containing three elements : the coordinates of the Vector3
  78244. * @returns a new array of numbers
  78245. */
  78246. asArray(): number[];
  78247. /**
  78248. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  78249. * @param array defines the destination array
  78250. * @param index defines the offset in the destination array
  78251. * @returns the current Vector3
  78252. */
  78253. toArray(array: FloatArray, index?: number): Vector3;
  78254. /**
  78255. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  78256. * @returns a new Quaternion object, computed from the Vector3 coordinates
  78257. */
  78258. toQuaternion(): Quaternion;
  78259. /**
  78260. * Adds the given vector to the current Vector3
  78261. * @param otherVector defines the second operand
  78262. * @returns the current updated Vector3
  78263. */
  78264. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78265. /**
  78266. * Adds the given coordinates to the current Vector3
  78267. * @param x defines the x coordinate of the operand
  78268. * @param y defines the y coordinate of the operand
  78269. * @param z defines the z coordinate of the operand
  78270. * @returns the current updated Vector3
  78271. */
  78272. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78273. /**
  78274. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  78275. * @param otherVector defines the second operand
  78276. * @returns the resulting Vector3
  78277. */
  78278. add(otherVector: DeepImmutable<Vector3>): Vector3;
  78279. /**
  78280. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  78281. * @param otherVector defines the second operand
  78282. * @param result defines the Vector3 object where to store the result
  78283. * @returns the current Vector3
  78284. */
  78285. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78286. /**
  78287. * Subtract the given vector from the current Vector3
  78288. * @param otherVector defines the second operand
  78289. * @returns the current updated Vector3
  78290. */
  78291. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78292. /**
  78293. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  78294. * @param otherVector defines the second operand
  78295. * @returns the resulting Vector3
  78296. */
  78297. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  78298. /**
  78299. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  78300. * @param otherVector defines the second operand
  78301. * @param result defines the Vector3 object where to store the result
  78302. * @returns the current Vector3
  78303. */
  78304. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78305. /**
  78306. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  78307. * @param x defines the x coordinate of the operand
  78308. * @param y defines the y coordinate of the operand
  78309. * @param z defines the z coordinate of the operand
  78310. * @returns the resulting Vector3
  78311. */
  78312. subtractFromFloats(x: number, y: number, z: number): Vector3;
  78313. /**
  78314. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  78315. * @param x defines the x coordinate of the operand
  78316. * @param y defines the y coordinate of the operand
  78317. * @param z defines the z coordinate of the operand
  78318. * @param result defines the Vector3 object where to store the result
  78319. * @returns the current Vector3
  78320. */
  78321. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  78322. /**
  78323. * Gets a new Vector3 set with the current Vector3 negated coordinates
  78324. * @returns a new Vector3
  78325. */
  78326. negate(): Vector3;
  78327. /**
  78328. * Negate this vector in place
  78329. * @returns this
  78330. */
  78331. negateInPlace(): Vector3;
  78332. /**
  78333. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  78334. * @param result defines the Vector3 object where to store the result
  78335. * @returns the current Vector3
  78336. */
  78337. negateToRef(result: Vector3): Vector3;
  78338. /**
  78339. * Multiplies the Vector3 coordinates by the float "scale"
  78340. * @param scale defines the multiplier factor
  78341. * @returns the current updated Vector3
  78342. */
  78343. scaleInPlace(scale: number): Vector3;
  78344. /**
  78345. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  78346. * @param scale defines the multiplier factor
  78347. * @returns a new Vector3
  78348. */
  78349. scale(scale: number): Vector3;
  78350. /**
  78351. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  78352. * @param scale defines the multiplier factor
  78353. * @param result defines the Vector3 object where to store the result
  78354. * @returns the current Vector3
  78355. */
  78356. scaleToRef(scale: number, result: Vector3): Vector3;
  78357. /**
  78358. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  78359. * @param scale defines the scale factor
  78360. * @param result defines the Vector3 object where to store the result
  78361. * @returns the unmodified current Vector3
  78362. */
  78363. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  78364. /**
  78365. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78366. * @param origin defines the origin of the projection ray
  78367. * @param plane defines the plane to project to
  78368. * @returns the projected vector3
  78369. */
  78370. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  78371. /**
  78372. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  78373. * @param origin defines the origin of the projection ray
  78374. * @param plane defines the plane to project to
  78375. * @param result defines the Vector3 where to store the result
  78376. */
  78377. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  78378. /**
  78379. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  78380. * @param otherVector defines the second operand
  78381. * @returns true if both vectors are equals
  78382. */
  78383. equals(otherVector: DeepImmutable<Vector3>): boolean;
  78384. /**
  78385. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  78386. * @param otherVector defines the second operand
  78387. * @param epsilon defines the minimal distance to define values as equals
  78388. * @returns true if both vectors are distant less than epsilon
  78389. */
  78390. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  78391. /**
  78392. * Returns true if the current Vector3 coordinates equals the given floats
  78393. * @param x defines the x coordinate of the operand
  78394. * @param y defines the y coordinate of the operand
  78395. * @param z defines the z coordinate of the operand
  78396. * @returns true if both vectors are equals
  78397. */
  78398. equalsToFloats(x: number, y: number, z: number): boolean;
  78399. /**
  78400. * Multiplies the current Vector3 coordinates by the given ones
  78401. * @param otherVector defines the second operand
  78402. * @returns the current updated Vector3
  78403. */
  78404. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  78405. /**
  78406. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  78407. * @param otherVector defines the second operand
  78408. * @returns the new Vector3
  78409. */
  78410. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  78411. /**
  78412. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  78413. * @param otherVector defines the second operand
  78414. * @param result defines the Vector3 object where to store the result
  78415. * @returns the current Vector3
  78416. */
  78417. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78418. /**
  78419. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  78420. * @param x defines the x coordinate of the operand
  78421. * @param y defines the y coordinate of the operand
  78422. * @param z defines the z coordinate of the operand
  78423. * @returns the new Vector3
  78424. */
  78425. multiplyByFloats(x: number, y: number, z: number): Vector3;
  78426. /**
  78427. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  78428. * @param otherVector defines the second operand
  78429. * @returns the new Vector3
  78430. */
  78431. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  78432. /**
  78433. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  78434. * @param otherVector defines the second operand
  78435. * @param result defines the Vector3 object where to store the result
  78436. * @returns the current Vector3
  78437. */
  78438. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  78439. /**
  78440. * Divides the current Vector3 coordinates by the given ones.
  78441. * @param otherVector defines the second operand
  78442. * @returns the current updated Vector3
  78443. */
  78444. divideInPlace(otherVector: Vector3): Vector3;
  78445. /**
  78446. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  78447. * @param other defines the second operand
  78448. * @returns the current updated Vector3
  78449. */
  78450. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78451. /**
  78452. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  78453. * @param other defines the second operand
  78454. * @returns the current updated Vector3
  78455. */
  78456. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  78457. /**
  78458. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  78459. * @param x defines the x coordinate of the operand
  78460. * @param y defines the y coordinate of the operand
  78461. * @param z defines the z coordinate of the operand
  78462. * @returns the current updated Vector3
  78463. */
  78464. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78465. /**
  78466. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  78467. * @param x defines the x coordinate of the operand
  78468. * @param y defines the y coordinate of the operand
  78469. * @param z defines the z coordinate of the operand
  78470. * @returns the current updated Vector3
  78471. */
  78472. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  78473. /**
  78474. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  78475. * Check if is non uniform within a certain amount of decimal places to account for this
  78476. * @param epsilon the amount the values can differ
  78477. * @returns if the the vector is non uniform to a certain number of decimal places
  78478. */
  78479. isNonUniformWithinEpsilon(epsilon: number): boolean;
  78480. /**
  78481. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  78482. */
  78483. get isNonUniform(): boolean;
  78484. /**
  78485. * Gets a new Vector3 from current Vector3 floored values
  78486. * @returns a new Vector3
  78487. */
  78488. floor(): Vector3;
  78489. /**
  78490. * Gets a new Vector3 from current Vector3 floored values
  78491. * @returns a new Vector3
  78492. */
  78493. fract(): Vector3;
  78494. /**
  78495. * Gets the length of the Vector3
  78496. * @returns the length of the Vector3
  78497. */
  78498. length(): number;
  78499. /**
  78500. * Gets the squared length of the Vector3
  78501. * @returns squared length of the Vector3
  78502. */
  78503. lengthSquared(): number;
  78504. /**
  78505. * Normalize the current Vector3.
  78506. * Please note that this is an in place operation.
  78507. * @returns the current updated Vector3
  78508. */
  78509. normalize(): Vector3;
  78510. /**
  78511. * Reorders the x y z properties of the vector in place
  78512. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  78513. * @returns the current updated vector
  78514. */
  78515. reorderInPlace(order: string): this;
  78516. /**
  78517. * Rotates the vector around 0,0,0 by a quaternion
  78518. * @param quaternion the rotation quaternion
  78519. * @param result vector to store the result
  78520. * @returns the resulting vector
  78521. */
  78522. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  78523. /**
  78524. * Rotates a vector around a given point
  78525. * @param quaternion the rotation quaternion
  78526. * @param point the point to rotate around
  78527. * @param result vector to store the result
  78528. * @returns the resulting vector
  78529. */
  78530. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  78531. /**
  78532. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  78533. * The cross product is then orthogonal to both current and "other"
  78534. * @param other defines the right operand
  78535. * @returns the cross product
  78536. */
  78537. cross(other: Vector3): Vector3;
  78538. /**
  78539. * Normalize the current Vector3 with the given input length.
  78540. * Please note that this is an in place operation.
  78541. * @param len the length of the vector
  78542. * @returns the current updated Vector3
  78543. */
  78544. normalizeFromLength(len: number): Vector3;
  78545. /**
  78546. * Normalize the current Vector3 to a new vector
  78547. * @returns the new Vector3
  78548. */
  78549. normalizeToNew(): Vector3;
  78550. /**
  78551. * Normalize the current Vector3 to the reference
  78552. * @param reference define the Vector3 to update
  78553. * @returns the updated Vector3
  78554. */
  78555. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  78556. /**
  78557. * Creates a new Vector3 copied from the current Vector3
  78558. * @returns the new Vector3
  78559. */
  78560. clone(): Vector3;
  78561. /**
  78562. * Copies the given vector coordinates to the current Vector3 ones
  78563. * @param source defines the source Vector3
  78564. * @returns the current updated Vector3
  78565. */
  78566. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  78567. /**
  78568. * Copies the given floats to the current Vector3 coordinates
  78569. * @param x defines the x coordinate of the operand
  78570. * @param y defines the y coordinate of the operand
  78571. * @param z defines the z coordinate of the operand
  78572. * @returns the current updated Vector3
  78573. */
  78574. copyFromFloats(x: number, y: number, z: number): Vector3;
  78575. /**
  78576. * Copies the given floats to the current Vector3 coordinates
  78577. * @param x defines the x coordinate of the operand
  78578. * @param y defines the y coordinate of the operand
  78579. * @param z defines the z coordinate of the operand
  78580. * @returns the current updated Vector3
  78581. */
  78582. set(x: number, y: number, z: number): Vector3;
  78583. /**
  78584. * Copies the given float to the current Vector3 coordinates
  78585. * @param v defines the x, y and z coordinates of the operand
  78586. * @returns the current updated Vector3
  78587. */
  78588. setAll(v: number): Vector3;
  78589. /**
  78590. * Get the clip factor between two vectors
  78591. * @param vector0 defines the first operand
  78592. * @param vector1 defines the second operand
  78593. * @param axis defines the axis to use
  78594. * @param size defines the size along the axis
  78595. * @returns the clip factor
  78596. */
  78597. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  78598. /**
  78599. * Get angle between two vectors
  78600. * @param vector0 angle between vector0 and vector1
  78601. * @param vector1 angle between vector0 and vector1
  78602. * @param normal direction of the normal
  78603. * @return the angle between vector0 and vector1
  78604. */
  78605. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  78606. /**
  78607. * Returns a new Vector3 set from the index "offset" of the given array
  78608. * @param array defines the source array
  78609. * @param offset defines the offset in the source array
  78610. * @returns the new Vector3
  78611. */
  78612. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  78613. /**
  78614. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  78615. * @param array defines the source array
  78616. * @param offset defines the offset in the source array
  78617. * @returns the new Vector3
  78618. * @deprecated Please use FromArray instead.
  78619. */
  78620. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  78621. /**
  78622. * Sets the given vector "result" with the element values from the index "offset" of the given array
  78623. * @param array defines the source array
  78624. * @param offset defines the offset in the source array
  78625. * @param result defines the Vector3 where to store the result
  78626. */
  78627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  78628. /**
  78629. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  78630. * @param array defines the source array
  78631. * @param offset defines the offset in the source array
  78632. * @param result defines the Vector3 where to store the result
  78633. * @deprecated Please use FromArrayToRef instead.
  78634. */
  78635. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  78636. /**
  78637. * Sets the given vector "result" with the given floats.
  78638. * @param x defines the x coordinate of the source
  78639. * @param y defines the y coordinate of the source
  78640. * @param z defines the z coordinate of the source
  78641. * @param result defines the Vector3 where to store the result
  78642. */
  78643. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  78644. /**
  78645. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  78646. * @returns a new empty Vector3
  78647. */
  78648. static Zero(): Vector3;
  78649. /**
  78650. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  78651. * @returns a new unit Vector3
  78652. */
  78653. static One(): Vector3;
  78654. /**
  78655. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  78656. * @returns a new up Vector3
  78657. */
  78658. static Up(): Vector3;
  78659. /**
  78660. * Gets a up Vector3 that must not be updated
  78661. */
  78662. static get UpReadOnly(): DeepImmutable<Vector3>;
  78663. /**
  78664. * Gets a zero Vector3 that must not be updated
  78665. */
  78666. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  78667. /**
  78668. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  78669. * @returns a new down Vector3
  78670. */
  78671. static Down(): Vector3;
  78672. /**
  78673. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  78674. * @param rightHandedSystem is the scene right-handed (negative z)
  78675. * @returns a new forward Vector3
  78676. */
  78677. static Forward(rightHandedSystem?: boolean): Vector3;
  78678. /**
  78679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  78680. * @param rightHandedSystem is the scene right-handed (negative-z)
  78681. * @returns a new forward Vector3
  78682. */
  78683. static Backward(rightHandedSystem?: boolean): Vector3;
  78684. /**
  78685. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  78686. * @returns a new right Vector3
  78687. */
  78688. static Right(): Vector3;
  78689. /**
  78690. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  78691. * @returns a new left Vector3
  78692. */
  78693. static Left(): Vector3;
  78694. /**
  78695. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  78696. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78697. * @param vector defines the Vector3 to transform
  78698. * @param transformation defines the transformation matrix
  78699. * @returns the transformed Vector3
  78700. */
  78701. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78702. /**
  78703. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  78704. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  78705. * @param vector defines the Vector3 to transform
  78706. * @param transformation defines the transformation matrix
  78707. * @param result defines the Vector3 where to store the result
  78708. */
  78709. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78710. /**
  78711. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  78712. * This method computes tranformed coordinates only, not transformed direction vectors
  78713. * @param x define the x coordinate of the source vector
  78714. * @param y define the y coordinate of the source vector
  78715. * @param z define the z coordinate of the source vector
  78716. * @param transformation defines the transformation matrix
  78717. * @param result defines the Vector3 where to store the result
  78718. */
  78719. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78720. /**
  78721. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  78722. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78723. * @param vector defines the Vector3 to transform
  78724. * @param transformation defines the transformation matrix
  78725. * @returns the new Vector3
  78726. */
  78727. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  78728. /**
  78729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  78730. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78731. * @param vector defines the Vector3 to transform
  78732. * @param transformation defines the transformation matrix
  78733. * @param result defines the Vector3 where to store the result
  78734. */
  78735. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78736. /**
  78737. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  78738. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  78739. * @param x define the x coordinate of the source vector
  78740. * @param y define the y coordinate of the source vector
  78741. * @param z define the z coordinate of the source vector
  78742. * @param transformation defines the transformation matrix
  78743. * @param result defines the Vector3 where to store the result
  78744. */
  78745. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  78746. /**
  78747. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  78748. * @param value1 defines the first control point
  78749. * @param value2 defines the second control point
  78750. * @param value3 defines the third control point
  78751. * @param value4 defines the fourth control point
  78752. * @param amount defines the amount on the spline to use
  78753. * @returns the new Vector3
  78754. */
  78755. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  78756. /**
  78757. * 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"
  78758. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78759. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78760. * @param value defines the current value
  78761. * @param min defines the lower range value
  78762. * @param max defines the upper range value
  78763. * @returns the new Vector3
  78764. */
  78765. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  78766. /**
  78767. * 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"
  78768. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  78769. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  78770. * @param value defines the current value
  78771. * @param min defines the lower range value
  78772. * @param max defines the upper range value
  78773. * @param result defines the Vector3 where to store the result
  78774. */
  78775. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  78776. /**
  78777. * Checks if a given vector is inside a specific range
  78778. * @param v defines the vector to test
  78779. * @param min defines the minimum range
  78780. * @param max defines the maximum range
  78781. */
  78782. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  78783. /**
  78784. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  78785. * @param value1 defines the first control point
  78786. * @param tangent1 defines the first tangent vector
  78787. * @param value2 defines the second control point
  78788. * @param tangent2 defines the second tangent vector
  78789. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  78790. * @returns the new Vector3
  78791. */
  78792. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  78793. /**
  78794. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  78795. * @param start defines the start value
  78796. * @param end defines the end value
  78797. * @param amount max defines amount between both (between 0 and 1)
  78798. * @returns the new Vector3
  78799. */
  78800. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  78801. /**
  78802. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  78803. * @param start defines the start value
  78804. * @param end defines the end value
  78805. * @param amount max defines amount between both (between 0 and 1)
  78806. * @param result defines the Vector3 where to store the result
  78807. */
  78808. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  78809. /**
  78810. * Returns the dot product (float) between the vectors "left" and "right"
  78811. * @param left defines the left operand
  78812. * @param right defines the right operand
  78813. * @returns the dot product
  78814. */
  78815. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  78816. /**
  78817. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  78818. * The cross product is then orthogonal to both "left" and "right"
  78819. * @param left defines the left operand
  78820. * @param right defines the right operand
  78821. * @returns the cross product
  78822. */
  78823. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  78824. /**
  78825. * Sets the given vector "result" with the cross product of "left" and "right"
  78826. * The cross product is then orthogonal to both "left" and "right"
  78827. * @param left defines the left operand
  78828. * @param right defines the right operand
  78829. * @param result defines the Vector3 where to store the result
  78830. */
  78831. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  78832. /**
  78833. * Returns a new Vector3 as the normalization of the given vector
  78834. * @param vector defines the Vector3 to normalize
  78835. * @returns the new Vector3
  78836. */
  78837. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  78838. /**
  78839. * Sets the given vector "result" with the normalization of the given first vector
  78840. * @param vector defines the Vector3 to normalize
  78841. * @param result defines the Vector3 where to store the result
  78842. */
  78843. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  78844. /**
  78845. * Project a Vector3 onto screen space
  78846. * @param vector defines the Vector3 to project
  78847. * @param world defines the world matrix to use
  78848. * @param transform defines the transform (view x projection) matrix to use
  78849. * @param viewport defines the screen viewport to use
  78850. * @returns the new Vector3
  78851. */
  78852. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  78853. /** @hidden */
  78854. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  78855. /**
  78856. * Unproject from screen space to object space
  78857. * @param source defines the screen space Vector3 to use
  78858. * @param viewportWidth defines the current width of the viewport
  78859. * @param viewportHeight defines the current height of the viewport
  78860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78861. * @param transform defines the transform (view x projection) matrix to use
  78862. * @returns the new Vector3
  78863. */
  78864. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  78865. /**
  78866. * Unproject from screen space to object space
  78867. * @param source defines the screen space Vector3 to use
  78868. * @param viewportWidth defines the current width of the viewport
  78869. * @param viewportHeight defines the current height of the viewport
  78870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78871. * @param view defines the view matrix to use
  78872. * @param projection defines the projection matrix to use
  78873. * @returns the new Vector3
  78874. */
  78875. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  78876. /**
  78877. * Unproject from screen space to object space
  78878. * @param source defines the screen space Vector3 to use
  78879. * @param viewportWidth defines the current width of the viewport
  78880. * @param viewportHeight defines the current height of the viewport
  78881. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78882. * @param view defines the view matrix to use
  78883. * @param projection defines the projection matrix to use
  78884. * @param result defines the Vector3 where to store the result
  78885. */
  78886. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  78887. /**
  78888. * Unproject from screen space to object space
  78889. * @param sourceX defines the screen space x coordinate to use
  78890. * @param sourceY defines the screen space y coordinate to use
  78891. * @param sourceZ defines the screen space z coordinate to use
  78892. * @param viewportWidth defines the current width of the viewport
  78893. * @param viewportHeight defines the current height of the viewport
  78894. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78895. * @param view defines the view matrix to use
  78896. * @param projection defines the projection matrix to use
  78897. * @param result defines the Vector3 where to store the result
  78898. */
  78899. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  78900. /**
  78901. * Gets the minimal coordinate values between two Vector3
  78902. * @param left defines the first operand
  78903. * @param right defines the second operand
  78904. * @returns the new Vector3
  78905. */
  78906. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  78907. /**
  78908. * Gets the maximal coordinate values between two Vector3
  78909. * @param left defines the first operand
  78910. * @param right defines the second operand
  78911. * @returns the new Vector3
  78912. */
  78913. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  78914. /**
  78915. * Returns the distance between the vectors "value1" and "value2"
  78916. * @param value1 defines the first operand
  78917. * @param value2 defines the second operand
  78918. * @returns the distance
  78919. */
  78920. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  78921. /**
  78922. * Returns the squared distance between the vectors "value1" and "value2"
  78923. * @param value1 defines the first operand
  78924. * @param value2 defines the second operand
  78925. * @returns the squared distance
  78926. */
  78927. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  78928. /**
  78929. * Returns a new Vector3 located at the center between "value1" and "value2"
  78930. * @param value1 defines the first operand
  78931. * @param value2 defines the second operand
  78932. * @returns the new Vector3
  78933. */
  78934. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  78935. /**
  78936. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  78937. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  78938. * to something in order to rotate it from its local system to the given target system
  78939. * Note: axis1, axis2 and axis3 are normalized during this operation
  78940. * @param axis1 defines the first axis
  78941. * @param axis2 defines the second axis
  78942. * @param axis3 defines the third axis
  78943. * @returns a new Vector3
  78944. */
  78945. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  78946. /**
  78947. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  78948. * @param axis1 defines the first axis
  78949. * @param axis2 defines the second axis
  78950. * @param axis3 defines the third axis
  78951. * @param ref defines the Vector3 where to store the result
  78952. */
  78953. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  78954. }
  78955. /**
  78956. * Vector4 class created for EulerAngle class conversion to Quaternion
  78957. */
  78958. export class Vector4 {
  78959. /** x value of the vector */
  78960. x: number;
  78961. /** y value of the vector */
  78962. y: number;
  78963. /** z value of the vector */
  78964. z: number;
  78965. /** w value of the vector */
  78966. w: number;
  78967. /**
  78968. * Creates a Vector4 object from the given floats.
  78969. * @param x x value of the vector
  78970. * @param y y value of the vector
  78971. * @param z z value of the vector
  78972. * @param w w value of the vector
  78973. */
  78974. constructor(
  78975. /** x value of the vector */
  78976. x: number,
  78977. /** y value of the vector */
  78978. y: number,
  78979. /** z value of the vector */
  78980. z: number,
  78981. /** w value of the vector */
  78982. w: number);
  78983. /**
  78984. * Returns the string with the Vector4 coordinates.
  78985. * @returns a string containing all the vector values
  78986. */
  78987. toString(): string;
  78988. /**
  78989. * Returns the string "Vector4".
  78990. * @returns "Vector4"
  78991. */
  78992. getClassName(): string;
  78993. /**
  78994. * Returns the Vector4 hash code.
  78995. * @returns a unique hash code
  78996. */
  78997. getHashCode(): number;
  78998. /**
  78999. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  79000. * @returns the resulting array
  79001. */
  79002. asArray(): number[];
  79003. /**
  79004. * Populates the given array from the given index with the Vector4 coordinates.
  79005. * @param array array to populate
  79006. * @param index index of the array to start at (default: 0)
  79007. * @returns the Vector4.
  79008. */
  79009. toArray(array: FloatArray, index?: number): Vector4;
  79010. /**
  79011. * Adds the given vector to the current Vector4.
  79012. * @param otherVector the vector to add
  79013. * @returns the updated Vector4.
  79014. */
  79015. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79016. /**
  79017. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  79018. * @param otherVector the vector to add
  79019. * @returns the resulting vector
  79020. */
  79021. add(otherVector: DeepImmutable<Vector4>): Vector4;
  79022. /**
  79023. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  79024. * @param otherVector the vector to add
  79025. * @param result the vector to store the result
  79026. * @returns the current Vector4.
  79027. */
  79028. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79029. /**
  79030. * Subtract in place the given vector from the current Vector4.
  79031. * @param otherVector the vector to subtract
  79032. * @returns the updated Vector4.
  79033. */
  79034. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79035. /**
  79036. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  79037. * @param otherVector the vector to add
  79038. * @returns the new vector with the result
  79039. */
  79040. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  79041. /**
  79042. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  79043. * @param otherVector the vector to subtract
  79044. * @param result the vector to store the result
  79045. * @returns the current Vector4.
  79046. */
  79047. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79048. /**
  79049. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79050. */
  79051. /**
  79052. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79053. * @param x value to subtract
  79054. * @param y value to subtract
  79055. * @param z value to subtract
  79056. * @param w value to subtract
  79057. * @returns new vector containing the result
  79058. */
  79059. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79060. /**
  79061. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  79062. * @param x value to subtract
  79063. * @param y value to subtract
  79064. * @param z value to subtract
  79065. * @param w value to subtract
  79066. * @param result the vector to store the result in
  79067. * @returns the current Vector4.
  79068. */
  79069. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  79070. /**
  79071. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  79072. * @returns a new vector with the negated values
  79073. */
  79074. negate(): Vector4;
  79075. /**
  79076. * Negate this vector in place
  79077. * @returns this
  79078. */
  79079. negateInPlace(): Vector4;
  79080. /**
  79081. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  79082. * @param result defines the Vector3 object where to store the result
  79083. * @returns the current Vector4
  79084. */
  79085. negateToRef(result: Vector4): Vector4;
  79086. /**
  79087. * Multiplies the current Vector4 coordinates by scale (float).
  79088. * @param scale the number to scale with
  79089. * @returns the updated Vector4.
  79090. */
  79091. scaleInPlace(scale: number): Vector4;
  79092. /**
  79093. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  79094. * @param scale the number to scale with
  79095. * @returns a new vector with the result
  79096. */
  79097. scale(scale: number): Vector4;
  79098. /**
  79099. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  79100. * @param scale the number to scale with
  79101. * @param result a vector to store the result in
  79102. * @returns the current Vector4.
  79103. */
  79104. scaleToRef(scale: number, result: Vector4): Vector4;
  79105. /**
  79106. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  79107. * @param scale defines the scale factor
  79108. * @param result defines the Vector4 object where to store the result
  79109. * @returns the unmodified current Vector4
  79110. */
  79111. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  79112. /**
  79113. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  79114. * @param otherVector the vector to compare against
  79115. * @returns true if they are equal
  79116. */
  79117. equals(otherVector: DeepImmutable<Vector4>): boolean;
  79118. /**
  79119. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  79120. * @param otherVector vector to compare against
  79121. * @param epsilon (Default: very small number)
  79122. * @returns true if they are equal
  79123. */
  79124. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  79125. /**
  79126. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  79127. * @param x x value to compare against
  79128. * @param y y value to compare against
  79129. * @param z z value to compare against
  79130. * @param w w value to compare against
  79131. * @returns true if equal
  79132. */
  79133. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  79134. /**
  79135. * Multiplies in place the current Vector4 by the given one.
  79136. * @param otherVector vector to multiple with
  79137. * @returns the updated Vector4.
  79138. */
  79139. multiplyInPlace(otherVector: Vector4): Vector4;
  79140. /**
  79141. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  79142. * @param otherVector vector to multiple with
  79143. * @returns resulting new vector
  79144. */
  79145. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  79146. /**
  79147. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  79148. * @param otherVector vector to multiple with
  79149. * @param result vector to store the result
  79150. * @returns the current Vector4.
  79151. */
  79152. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79153. /**
  79154. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  79155. * @param x x value multiply with
  79156. * @param y y value multiply with
  79157. * @param z z value multiply with
  79158. * @param w w value multiply with
  79159. * @returns resulting new vector
  79160. */
  79161. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  79162. /**
  79163. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  79164. * @param otherVector vector to devide with
  79165. * @returns resulting new vector
  79166. */
  79167. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  79168. /**
  79169. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  79170. * @param otherVector vector to devide with
  79171. * @param result vector to store the result
  79172. * @returns the current Vector4.
  79173. */
  79174. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  79175. /**
  79176. * Divides the current Vector3 coordinates by the given ones.
  79177. * @param otherVector vector to devide with
  79178. * @returns the updated Vector3.
  79179. */
  79180. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  79181. /**
  79182. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  79183. * @param other defines the second operand
  79184. * @returns the current updated Vector4
  79185. */
  79186. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79187. /**
  79188. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  79189. * @param other defines the second operand
  79190. * @returns the current updated Vector4
  79191. */
  79192. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  79193. /**
  79194. * Gets a new Vector4 from current Vector4 floored values
  79195. * @returns a new Vector4
  79196. */
  79197. floor(): Vector4;
  79198. /**
  79199. * Gets a new Vector4 from current Vector3 floored values
  79200. * @returns a new Vector4
  79201. */
  79202. fract(): Vector4;
  79203. /**
  79204. * Returns the Vector4 length (float).
  79205. * @returns the length
  79206. */
  79207. length(): number;
  79208. /**
  79209. * Returns the Vector4 squared length (float).
  79210. * @returns the length squared
  79211. */
  79212. lengthSquared(): number;
  79213. /**
  79214. * Normalizes in place the Vector4.
  79215. * @returns the updated Vector4.
  79216. */
  79217. normalize(): Vector4;
  79218. /**
  79219. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  79220. * @returns this converted to a new vector3
  79221. */
  79222. toVector3(): Vector3;
  79223. /**
  79224. * Returns a new Vector4 copied from the current one.
  79225. * @returns the new cloned vector
  79226. */
  79227. clone(): Vector4;
  79228. /**
  79229. * Updates the current Vector4 with the given one coordinates.
  79230. * @param source the source vector to copy from
  79231. * @returns the updated Vector4.
  79232. */
  79233. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  79234. /**
  79235. * Updates the current Vector4 coordinates with the given floats.
  79236. * @param x float to copy from
  79237. * @param y float to copy from
  79238. * @param z float to copy from
  79239. * @param w float to copy from
  79240. * @returns the updated Vector4.
  79241. */
  79242. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  79243. /**
  79244. * Updates the current Vector4 coordinates with the given floats.
  79245. * @param x float to set from
  79246. * @param y float to set from
  79247. * @param z float to set from
  79248. * @param w float to set from
  79249. * @returns the updated Vector4.
  79250. */
  79251. set(x: number, y: number, z: number, w: number): Vector4;
  79252. /**
  79253. * Copies the given float to the current Vector3 coordinates
  79254. * @param v defines the x, y, z and w coordinates of the operand
  79255. * @returns the current updated Vector3
  79256. */
  79257. setAll(v: number): Vector4;
  79258. /**
  79259. * Returns a new Vector4 set from the starting index of the given array.
  79260. * @param array the array to pull values from
  79261. * @param offset the offset into the array to start at
  79262. * @returns the new vector
  79263. */
  79264. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  79265. /**
  79266. * Updates the given vector "result" from the starting index of the given array.
  79267. * @param array the array to pull values from
  79268. * @param offset the offset into the array to start at
  79269. * @param result the vector to store the result in
  79270. */
  79271. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  79272. /**
  79273. * Updates the given vector "result" from the starting index of the given Float32Array.
  79274. * @param array the array to pull values from
  79275. * @param offset the offset into the array to start at
  79276. * @param result the vector to store the result in
  79277. */
  79278. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  79279. /**
  79280. * Updates the given vector "result" coordinates from the given floats.
  79281. * @param x float to set from
  79282. * @param y float to set from
  79283. * @param z float to set from
  79284. * @param w float to set from
  79285. * @param result the vector to the floats in
  79286. */
  79287. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  79288. /**
  79289. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  79290. * @returns the new vector
  79291. */
  79292. static Zero(): Vector4;
  79293. /**
  79294. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  79295. * @returns the new vector
  79296. */
  79297. static One(): Vector4;
  79298. /**
  79299. * Returns a new normalized Vector4 from the given one.
  79300. * @param vector the vector to normalize
  79301. * @returns the vector
  79302. */
  79303. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  79304. /**
  79305. * Updates the given vector "result" from the normalization of the given one.
  79306. * @param vector the vector to normalize
  79307. * @param result the vector to store the result in
  79308. */
  79309. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  79310. /**
  79311. * Returns a vector with the minimum values from the left and right vectors
  79312. * @param left left vector to minimize
  79313. * @param right right vector to minimize
  79314. * @returns a new vector with the minimum of the left and right vector values
  79315. */
  79316. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79317. /**
  79318. * Returns a vector with the maximum values from the left and right vectors
  79319. * @param left left vector to maximize
  79320. * @param right right vector to maximize
  79321. * @returns a new vector with the maximum of the left and right vector values
  79322. */
  79323. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  79324. /**
  79325. * Returns the distance (float) between the vectors "value1" and "value2".
  79326. * @param value1 value to calulate the distance between
  79327. * @param value2 value to calulate the distance between
  79328. * @return the distance between the two vectors
  79329. */
  79330. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79331. /**
  79332. * Returns the squared distance (float) between the vectors "value1" and "value2".
  79333. * @param value1 value to calulate the distance between
  79334. * @param value2 value to calulate the distance between
  79335. * @return the distance between the two vectors squared
  79336. */
  79337. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  79338. /**
  79339. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  79340. * @param value1 value to calulate the center between
  79341. * @param value2 value to calulate the center between
  79342. * @return the center between the two vectors
  79343. */
  79344. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  79345. /**
  79346. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  79347. * This methods computes transformed normalized direction vectors only.
  79348. * @param vector the vector to transform
  79349. * @param transformation the transformation matrix to apply
  79350. * @returns the new vector
  79351. */
  79352. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  79353. /**
  79354. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  79355. * This methods computes transformed normalized direction vectors only.
  79356. * @param vector the vector to transform
  79357. * @param transformation the transformation matrix to apply
  79358. * @param result the vector to store the result in
  79359. */
  79360. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79361. /**
  79362. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  79363. * This methods computes transformed normalized direction vectors only.
  79364. * @param x value to transform
  79365. * @param y value to transform
  79366. * @param z value to transform
  79367. * @param w value to transform
  79368. * @param transformation the transformation matrix to apply
  79369. * @param result the vector to store the results in
  79370. */
  79371. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  79372. /**
  79373. * Creates a new Vector4 from a Vector3
  79374. * @param source defines the source data
  79375. * @param w defines the 4th component (default is 0)
  79376. * @returns a new Vector4
  79377. */
  79378. static FromVector3(source: Vector3, w?: number): Vector4;
  79379. }
  79380. /**
  79381. * Class used to store quaternion data
  79382. * @see https://en.wikipedia.org/wiki/Quaternion
  79383. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  79384. */
  79385. export class Quaternion {
  79386. /** defines the first component (0 by default) */
  79387. x: number;
  79388. /** defines the second component (0 by default) */
  79389. y: number;
  79390. /** defines the third component (0 by default) */
  79391. z: number;
  79392. /** defines the fourth component (1.0 by default) */
  79393. w: number;
  79394. /**
  79395. * Creates a new Quaternion from the given floats
  79396. * @param x defines the first component (0 by default)
  79397. * @param y defines the second component (0 by default)
  79398. * @param z defines the third component (0 by default)
  79399. * @param w defines the fourth component (1.0 by default)
  79400. */
  79401. constructor(
  79402. /** defines the first component (0 by default) */
  79403. x?: number,
  79404. /** defines the second component (0 by default) */
  79405. y?: number,
  79406. /** defines the third component (0 by default) */
  79407. z?: number,
  79408. /** defines the fourth component (1.0 by default) */
  79409. w?: number);
  79410. /**
  79411. * Gets a string representation for the current quaternion
  79412. * @returns a string with the Quaternion coordinates
  79413. */
  79414. toString(): string;
  79415. /**
  79416. * Gets the class name of the quaternion
  79417. * @returns the string "Quaternion"
  79418. */
  79419. getClassName(): string;
  79420. /**
  79421. * Gets a hash code for this quaternion
  79422. * @returns the quaternion hash code
  79423. */
  79424. getHashCode(): number;
  79425. /**
  79426. * Copy the quaternion to an array
  79427. * @returns a new array populated with 4 elements from the quaternion coordinates
  79428. */
  79429. asArray(): number[];
  79430. /**
  79431. * Check if two quaternions are equals
  79432. * @param otherQuaternion defines the second operand
  79433. * @return true if the current quaternion and the given one coordinates are strictly equals
  79434. */
  79435. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  79436. /**
  79437. * Gets a boolean if two quaternions are equals (using an epsilon value)
  79438. * @param otherQuaternion defines the other quaternion
  79439. * @param epsilon defines the minimal distance to consider equality
  79440. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  79441. */
  79442. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  79443. /**
  79444. * Clone the current quaternion
  79445. * @returns a new quaternion copied from the current one
  79446. */
  79447. clone(): Quaternion;
  79448. /**
  79449. * Copy a quaternion to the current one
  79450. * @param other defines the other quaternion
  79451. * @returns the updated current quaternion
  79452. */
  79453. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  79454. /**
  79455. * Updates the current quaternion with the given float coordinates
  79456. * @param x defines the x coordinate
  79457. * @param y defines the y coordinate
  79458. * @param z defines the z coordinate
  79459. * @param w defines the w coordinate
  79460. * @returns the updated current quaternion
  79461. */
  79462. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  79463. /**
  79464. * Updates the current quaternion from the given float coordinates
  79465. * @param x defines the x coordinate
  79466. * @param y defines the y coordinate
  79467. * @param z defines the z coordinate
  79468. * @param w defines the w coordinate
  79469. * @returns the updated current quaternion
  79470. */
  79471. set(x: number, y: number, z: number, w: number): Quaternion;
  79472. /**
  79473. * Adds two quaternions
  79474. * @param other defines the second operand
  79475. * @returns a new quaternion as the addition result of the given one and the current quaternion
  79476. */
  79477. add(other: DeepImmutable<Quaternion>): Quaternion;
  79478. /**
  79479. * Add a quaternion to the current one
  79480. * @param other defines the quaternion to add
  79481. * @returns the current quaternion
  79482. */
  79483. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  79484. /**
  79485. * Subtract two quaternions
  79486. * @param other defines the second operand
  79487. * @returns a new quaternion as the subtraction result of the given one from the current one
  79488. */
  79489. subtract(other: Quaternion): Quaternion;
  79490. /**
  79491. * Multiplies the current quaternion by a scale factor
  79492. * @param value defines the scale factor
  79493. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  79494. */
  79495. scale(value: number): Quaternion;
  79496. /**
  79497. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  79498. * @param scale defines the scale factor
  79499. * @param result defines the Quaternion object where to store the result
  79500. * @returns the unmodified current quaternion
  79501. */
  79502. scaleToRef(scale: number, result: Quaternion): Quaternion;
  79503. /**
  79504. * Multiplies in place the current quaternion by a scale factor
  79505. * @param value defines the scale factor
  79506. * @returns the current modified quaternion
  79507. */
  79508. scaleInPlace(value: number): Quaternion;
  79509. /**
  79510. * Scale the current quaternion values by a factor and add the result to a given quaternion
  79511. * @param scale defines the scale factor
  79512. * @param result defines the Quaternion object where to store the result
  79513. * @returns the unmodified current quaternion
  79514. */
  79515. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  79516. /**
  79517. * Multiplies two quaternions
  79518. * @param q1 defines the second operand
  79519. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  79520. */
  79521. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  79522. /**
  79523. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  79524. * @param q1 defines the second operand
  79525. * @param result defines the target quaternion
  79526. * @returns the current quaternion
  79527. */
  79528. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  79529. /**
  79530. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  79531. * @param q1 defines the second operand
  79532. * @returns the currentupdated quaternion
  79533. */
  79534. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  79535. /**
  79536. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  79537. * @param ref defines the target quaternion
  79538. * @returns the current quaternion
  79539. */
  79540. conjugateToRef(ref: Quaternion): Quaternion;
  79541. /**
  79542. * Conjugates in place (1-q) the current quaternion
  79543. * @returns the current updated quaternion
  79544. */
  79545. conjugateInPlace(): Quaternion;
  79546. /**
  79547. * Conjugates in place (1-q) the current quaternion
  79548. * @returns a new quaternion
  79549. */
  79550. conjugate(): Quaternion;
  79551. /**
  79552. * Gets length of current quaternion
  79553. * @returns the quaternion length (float)
  79554. */
  79555. length(): number;
  79556. /**
  79557. * Normalize in place the current quaternion
  79558. * @returns the current updated quaternion
  79559. */
  79560. normalize(): Quaternion;
  79561. /**
  79562. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  79563. * @param order is a reserved parameter and is ignore for now
  79564. * @returns a new Vector3 containing the Euler angles
  79565. */
  79566. toEulerAngles(order?: string): Vector3;
  79567. /**
  79568. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  79569. * @param result defines the vector which will be filled with the Euler angles
  79570. * @param order is a reserved parameter and is ignore for now
  79571. * @returns the current unchanged quaternion
  79572. */
  79573. toEulerAnglesToRef(result: Vector3): Quaternion;
  79574. /**
  79575. * Updates the given rotation matrix with the current quaternion values
  79576. * @param result defines the target matrix
  79577. * @returns the current unchanged quaternion
  79578. */
  79579. toRotationMatrix(result: Matrix): Quaternion;
  79580. /**
  79581. * Updates the current quaternion from the given rotation matrix values
  79582. * @param matrix defines the source matrix
  79583. * @returns the current updated quaternion
  79584. */
  79585. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79586. /**
  79587. * Creates a new quaternion from a rotation matrix
  79588. * @param matrix defines the source matrix
  79589. * @returns a new quaternion created from the given rotation matrix values
  79590. */
  79591. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  79592. /**
  79593. * Updates the given quaternion with the given rotation matrix values
  79594. * @param matrix defines the source matrix
  79595. * @param result defines the target quaternion
  79596. */
  79597. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  79598. /**
  79599. * Returns the dot product (float) between the quaternions "left" and "right"
  79600. * @param left defines the left operand
  79601. * @param right defines the right operand
  79602. * @returns the dot product
  79603. */
  79604. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  79605. /**
  79606. * Checks if the two quaternions are close to each other
  79607. * @param quat0 defines the first quaternion to check
  79608. * @param quat1 defines the second quaternion to check
  79609. * @returns true if the two quaternions are close to each other
  79610. */
  79611. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  79612. /**
  79613. * Creates an empty quaternion
  79614. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  79615. */
  79616. static Zero(): Quaternion;
  79617. /**
  79618. * Inverse a given quaternion
  79619. * @param q defines the source quaternion
  79620. * @returns a new quaternion as the inverted current quaternion
  79621. */
  79622. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  79623. /**
  79624. * Inverse a given quaternion
  79625. * @param q defines the source quaternion
  79626. * @param result the quaternion the result will be stored in
  79627. * @returns the result quaternion
  79628. */
  79629. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  79630. /**
  79631. * Creates an identity quaternion
  79632. * @returns the identity quaternion
  79633. */
  79634. static Identity(): Quaternion;
  79635. /**
  79636. * Gets a boolean indicating if the given quaternion is identity
  79637. * @param quaternion defines the quaternion to check
  79638. * @returns true if the quaternion is identity
  79639. */
  79640. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  79641. /**
  79642. * Creates a quaternion from a rotation around an axis
  79643. * @param axis defines the axis to use
  79644. * @param angle defines the angle to use
  79645. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  79646. */
  79647. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  79648. /**
  79649. * Creates a rotation around an axis and stores it into the given quaternion
  79650. * @param axis defines the axis to use
  79651. * @param angle defines the angle to use
  79652. * @param result defines the target quaternion
  79653. * @returns the target quaternion
  79654. */
  79655. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  79656. /**
  79657. * Creates a new quaternion from data stored into an array
  79658. * @param array defines the data source
  79659. * @param offset defines the offset in the source array where the data starts
  79660. * @returns a new quaternion
  79661. */
  79662. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  79663. /**
  79664. * Updates the given quaternion "result" from the starting index of the given array.
  79665. * @param array the array to pull values from
  79666. * @param offset the offset into the array to start at
  79667. * @param result the quaternion to store the result in
  79668. */
  79669. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  79670. /**
  79671. * Create a quaternion from Euler rotation angles
  79672. * @param x Pitch
  79673. * @param y Yaw
  79674. * @param z Roll
  79675. * @returns the new Quaternion
  79676. */
  79677. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  79678. /**
  79679. * Updates a quaternion from Euler rotation angles
  79680. * @param x Pitch
  79681. * @param y Yaw
  79682. * @param z Roll
  79683. * @param result the quaternion to store the result
  79684. * @returns the updated quaternion
  79685. */
  79686. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  79687. /**
  79688. * Create a quaternion from Euler rotation vector
  79689. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79690. * @returns the new Quaternion
  79691. */
  79692. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  79693. /**
  79694. * Updates a quaternion from Euler rotation vector
  79695. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  79696. * @param result the quaternion to store the result
  79697. * @returns the updated quaternion
  79698. */
  79699. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  79700. /**
  79701. * Creates a new quaternion from the given Euler float angles (y, x, z)
  79702. * @param yaw defines the rotation around Y axis
  79703. * @param pitch defines the rotation around X axis
  79704. * @param roll defines the rotation around Z axis
  79705. * @returns the new quaternion
  79706. */
  79707. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  79708. /**
  79709. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  79710. * @param yaw defines the rotation around Y axis
  79711. * @param pitch defines the rotation around X axis
  79712. * @param roll defines the rotation around Z axis
  79713. * @param result defines the target quaternion
  79714. */
  79715. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  79716. /**
  79717. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  79718. * @param alpha defines the rotation around first axis
  79719. * @param beta defines the rotation around second axis
  79720. * @param gamma defines the rotation around third axis
  79721. * @returns the new quaternion
  79722. */
  79723. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  79724. /**
  79725. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  79726. * @param alpha defines the rotation around first axis
  79727. * @param beta defines the rotation around second axis
  79728. * @param gamma defines the rotation around third axis
  79729. * @param result defines the target quaternion
  79730. */
  79731. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  79732. /**
  79733. * 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)
  79734. * @param axis1 defines the first axis
  79735. * @param axis2 defines the second axis
  79736. * @param axis3 defines the third axis
  79737. * @returns the new quaternion
  79738. */
  79739. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  79740. /**
  79741. * 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
  79742. * @param axis1 defines the first axis
  79743. * @param axis2 defines the second axis
  79744. * @param axis3 defines the third axis
  79745. * @param ref defines the target quaternion
  79746. */
  79747. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  79748. /**
  79749. * Interpolates between two quaternions
  79750. * @param left defines first quaternion
  79751. * @param right defines second quaternion
  79752. * @param amount defines the gradient to use
  79753. * @returns the new interpolated quaternion
  79754. */
  79755. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79756. /**
  79757. * Interpolates between two quaternions and stores it into a target quaternion
  79758. * @param left defines first quaternion
  79759. * @param right defines second quaternion
  79760. * @param amount defines the gradient to use
  79761. * @param result defines the target quaternion
  79762. */
  79763. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  79764. /**
  79765. * Interpolate between two quaternions using Hermite interpolation
  79766. * @param value1 defines first quaternion
  79767. * @param tangent1 defines the incoming tangent
  79768. * @param value2 defines second quaternion
  79769. * @param tangent2 defines the outgoing tangent
  79770. * @param amount defines the target quaternion
  79771. * @returns the new interpolated quaternion
  79772. */
  79773. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  79774. }
  79775. /**
  79776. * Class used to store matrix data (4x4)
  79777. */
  79778. export class Matrix {
  79779. private static _updateFlagSeed;
  79780. private static _identityReadOnly;
  79781. private _isIdentity;
  79782. private _isIdentityDirty;
  79783. private _isIdentity3x2;
  79784. private _isIdentity3x2Dirty;
  79785. /**
  79786. * Gets the update flag of the matrix which is an unique number for the matrix.
  79787. * It will be incremented every time the matrix data change.
  79788. * You can use it to speed the comparison between two versions of the same matrix.
  79789. */
  79790. updateFlag: number;
  79791. private readonly _m;
  79792. /**
  79793. * Gets the internal data of the matrix
  79794. */
  79795. get m(): DeepImmutable<Float32Array>;
  79796. /** @hidden */
  79797. _markAsUpdated(): void;
  79798. /** @hidden */
  79799. private _updateIdentityStatus;
  79800. /**
  79801. * Creates an empty matrix (filled with zeros)
  79802. */
  79803. constructor();
  79804. /**
  79805. * Check if the current matrix is identity
  79806. * @returns true is the matrix is the identity matrix
  79807. */
  79808. isIdentity(): boolean;
  79809. /**
  79810. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  79811. * @returns true is the matrix is the identity matrix
  79812. */
  79813. isIdentityAs3x2(): boolean;
  79814. /**
  79815. * Gets the determinant of the matrix
  79816. * @returns the matrix determinant
  79817. */
  79818. determinant(): number;
  79819. /**
  79820. * Returns the matrix as a Float32Array
  79821. * @returns the matrix underlying array
  79822. */
  79823. toArray(): DeepImmutable<Float32Array>;
  79824. /**
  79825. * Returns the matrix as a Float32Array
  79826. * @returns the matrix underlying array.
  79827. */
  79828. asArray(): DeepImmutable<Float32Array>;
  79829. /**
  79830. * Inverts the current matrix in place
  79831. * @returns the current inverted matrix
  79832. */
  79833. invert(): Matrix;
  79834. /**
  79835. * Sets all the matrix elements to zero
  79836. * @returns the current matrix
  79837. */
  79838. reset(): Matrix;
  79839. /**
  79840. * Adds the current matrix with a second one
  79841. * @param other defines the matrix to add
  79842. * @returns a new matrix as the addition of the current matrix and the given one
  79843. */
  79844. add(other: DeepImmutable<Matrix>): Matrix;
  79845. /**
  79846. * Sets the given matrix "result" to the addition of the current matrix and the given one
  79847. * @param other defines the matrix to add
  79848. * @param result defines the target matrix
  79849. * @returns the current matrix
  79850. */
  79851. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  79852. /**
  79853. * Adds in place the given matrix to the current matrix
  79854. * @param other defines the second operand
  79855. * @returns the current updated matrix
  79856. */
  79857. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  79858. /**
  79859. * Sets the given matrix to the current inverted Matrix
  79860. * @param other defines the target matrix
  79861. * @returns the unmodified current matrix
  79862. */
  79863. invertToRef(other: Matrix): Matrix;
  79864. /**
  79865. * add a value at the specified position in the current Matrix
  79866. * @param index the index of the value within the matrix. between 0 and 15.
  79867. * @param value the value to be added
  79868. * @returns the current updated matrix
  79869. */
  79870. addAtIndex(index: number, value: number): Matrix;
  79871. /**
  79872. * mutiply the specified position in the current Matrix by a value
  79873. * @param index the index of the value within the matrix. between 0 and 15.
  79874. * @param value the value to be added
  79875. * @returns the current updated matrix
  79876. */
  79877. multiplyAtIndex(index: number, value: number): Matrix;
  79878. /**
  79879. * Inserts the translation vector (using 3 floats) in the current matrix
  79880. * @param x defines the 1st component of the translation
  79881. * @param y defines the 2nd component of the translation
  79882. * @param z defines the 3rd component of the translation
  79883. * @returns the current updated matrix
  79884. */
  79885. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  79886. /**
  79887. * Adds the translation vector (using 3 floats) in the current matrix
  79888. * @param x defines the 1st component of the translation
  79889. * @param y defines the 2nd component of the translation
  79890. * @param z defines the 3rd component of the translation
  79891. * @returns the current updated matrix
  79892. */
  79893. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  79894. /**
  79895. * Inserts the translation vector in the current matrix
  79896. * @param vector3 defines the translation to insert
  79897. * @returns the current updated matrix
  79898. */
  79899. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  79900. /**
  79901. * Gets the translation value of the current matrix
  79902. * @returns a new Vector3 as the extracted translation from the matrix
  79903. */
  79904. getTranslation(): Vector3;
  79905. /**
  79906. * Fill a Vector3 with the extracted translation from the matrix
  79907. * @param result defines the Vector3 where to store the translation
  79908. * @returns the current matrix
  79909. */
  79910. getTranslationToRef(result: Vector3): Matrix;
  79911. /**
  79912. * Remove rotation and scaling part from the matrix
  79913. * @returns the updated matrix
  79914. */
  79915. removeRotationAndScaling(): Matrix;
  79916. /**
  79917. * Multiply two matrices
  79918. * @param other defines the second operand
  79919. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  79920. */
  79921. multiply(other: DeepImmutable<Matrix>): Matrix;
  79922. /**
  79923. * Copy the current matrix from the given one
  79924. * @param other defines the source matrix
  79925. * @returns the current updated matrix
  79926. */
  79927. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  79928. /**
  79929. * Populates the given array from the starting index with the current matrix values
  79930. * @param array defines the target array
  79931. * @param offset defines the offset in the target array where to start storing values
  79932. * @returns the current matrix
  79933. */
  79934. copyToArray(array: Float32Array, offset?: number): Matrix;
  79935. /**
  79936. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  79937. * @param other defines the second operand
  79938. * @param result defines the matrix where to store the multiplication
  79939. * @returns the current matrix
  79940. */
  79941. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  79942. /**
  79943. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  79944. * @param other defines the second operand
  79945. * @param result defines the array where to store the multiplication
  79946. * @param offset defines the offset in the target array where to start storing values
  79947. * @returns the current matrix
  79948. */
  79949. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  79950. /**
  79951. * Check equality between this matrix and a second one
  79952. * @param value defines the second matrix to compare
  79953. * @returns true is the current matrix and the given one values are strictly equal
  79954. */
  79955. equals(value: DeepImmutable<Matrix>): boolean;
  79956. /**
  79957. * Clone the current matrix
  79958. * @returns a new matrix from the current matrix
  79959. */
  79960. clone(): Matrix;
  79961. /**
  79962. * Returns the name of the current matrix class
  79963. * @returns the string "Matrix"
  79964. */
  79965. getClassName(): string;
  79966. /**
  79967. * Gets the hash code of the current matrix
  79968. * @returns the hash code
  79969. */
  79970. getHashCode(): number;
  79971. /**
  79972. * Decomposes the current Matrix into a translation, rotation and scaling components
  79973. * @param scale defines the scale vector3 given as a reference to update
  79974. * @param rotation defines the rotation quaternion given as a reference to update
  79975. * @param translation defines the translation vector3 given as a reference to update
  79976. * @returns true if operation was successful
  79977. */
  79978. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  79979. /**
  79980. * Gets specific row of the matrix
  79981. * @param index defines the number of the row to get
  79982. * @returns the index-th row of the current matrix as a new Vector4
  79983. */
  79984. getRow(index: number): Nullable<Vector4>;
  79985. /**
  79986. * Sets the index-th row of the current matrix to the vector4 values
  79987. * @param index defines the number of the row to set
  79988. * @param row defines the target vector4
  79989. * @returns the updated current matrix
  79990. */
  79991. setRow(index: number, row: Vector4): Matrix;
  79992. /**
  79993. * Compute the transpose of the matrix
  79994. * @returns the new transposed matrix
  79995. */
  79996. transpose(): Matrix;
  79997. /**
  79998. * Compute the transpose of the matrix and store it in a given matrix
  79999. * @param result defines the target matrix
  80000. * @returns the current matrix
  80001. */
  80002. transposeToRef(result: Matrix): Matrix;
  80003. /**
  80004. * Sets the index-th row of the current matrix with the given 4 x float values
  80005. * @param index defines the row index
  80006. * @param x defines the x component to set
  80007. * @param y defines the y component to set
  80008. * @param z defines the z component to set
  80009. * @param w defines the w component to set
  80010. * @returns the updated current matrix
  80011. */
  80012. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  80013. /**
  80014. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  80015. * @param scale defines the scale factor
  80016. * @returns a new matrix
  80017. */
  80018. scale(scale: number): Matrix;
  80019. /**
  80020. * Scale the current matrix values by a factor to a given result matrix
  80021. * @param scale defines the scale factor
  80022. * @param result defines the matrix to store the result
  80023. * @returns the current matrix
  80024. */
  80025. scaleToRef(scale: number, result: Matrix): Matrix;
  80026. /**
  80027. * Scale the current matrix values by a factor and add the result to a given matrix
  80028. * @param scale defines the scale factor
  80029. * @param result defines the Matrix to store the result
  80030. * @returns the current matrix
  80031. */
  80032. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  80033. /**
  80034. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  80035. * @param ref matrix to store the result
  80036. */
  80037. toNormalMatrix(ref: Matrix): void;
  80038. /**
  80039. * Gets only rotation part of the current matrix
  80040. * @returns a new matrix sets to the extracted rotation matrix from the current one
  80041. */
  80042. getRotationMatrix(): Matrix;
  80043. /**
  80044. * Extracts the rotation matrix from the current one and sets it as the given "result"
  80045. * @param result defines the target matrix to store data to
  80046. * @returns the current matrix
  80047. */
  80048. getRotationMatrixToRef(result: Matrix): Matrix;
  80049. /**
  80050. * Toggles model matrix from being right handed to left handed in place and vice versa
  80051. */
  80052. toggleModelMatrixHandInPlace(): void;
  80053. /**
  80054. * Toggles projection matrix from being right handed to left handed in place and vice versa
  80055. */
  80056. toggleProjectionMatrixHandInPlace(): void;
  80057. /**
  80058. * Creates a matrix from an array
  80059. * @param array defines the source array
  80060. * @param offset defines an offset in the source array
  80061. * @returns a new Matrix set from the starting index of the given array
  80062. */
  80063. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  80064. /**
  80065. * Copy the content of an array into a given matrix
  80066. * @param array defines the source array
  80067. * @param offset defines an offset in the source array
  80068. * @param result defines the target matrix
  80069. */
  80070. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  80071. /**
  80072. * Stores an array into a matrix after having multiplied each component by a given factor
  80073. * @param array defines the source array
  80074. * @param offset defines the offset in the source array
  80075. * @param scale defines the scaling factor
  80076. * @param result defines the target matrix
  80077. */
  80078. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  80079. /**
  80080. * Gets an identity matrix that must not be updated
  80081. */
  80082. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  80083. /**
  80084. * Stores a list of values (16) inside a given matrix
  80085. * @param initialM11 defines 1st value of 1st row
  80086. * @param initialM12 defines 2nd value of 1st row
  80087. * @param initialM13 defines 3rd value of 1st row
  80088. * @param initialM14 defines 4th value of 1st row
  80089. * @param initialM21 defines 1st value of 2nd row
  80090. * @param initialM22 defines 2nd value of 2nd row
  80091. * @param initialM23 defines 3rd value of 2nd row
  80092. * @param initialM24 defines 4th value of 2nd row
  80093. * @param initialM31 defines 1st value of 3rd row
  80094. * @param initialM32 defines 2nd value of 3rd row
  80095. * @param initialM33 defines 3rd value of 3rd row
  80096. * @param initialM34 defines 4th value of 3rd row
  80097. * @param initialM41 defines 1st value of 4th row
  80098. * @param initialM42 defines 2nd value of 4th row
  80099. * @param initialM43 defines 3rd value of 4th row
  80100. * @param initialM44 defines 4th value of 4th row
  80101. * @param result defines the target matrix
  80102. */
  80103. 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;
  80104. /**
  80105. * Creates new matrix from a list of values (16)
  80106. * @param initialM11 defines 1st value of 1st row
  80107. * @param initialM12 defines 2nd value of 1st row
  80108. * @param initialM13 defines 3rd value of 1st row
  80109. * @param initialM14 defines 4th value of 1st row
  80110. * @param initialM21 defines 1st value of 2nd row
  80111. * @param initialM22 defines 2nd value of 2nd row
  80112. * @param initialM23 defines 3rd value of 2nd row
  80113. * @param initialM24 defines 4th value of 2nd row
  80114. * @param initialM31 defines 1st value of 3rd row
  80115. * @param initialM32 defines 2nd value of 3rd row
  80116. * @param initialM33 defines 3rd value of 3rd row
  80117. * @param initialM34 defines 4th value of 3rd row
  80118. * @param initialM41 defines 1st value of 4th row
  80119. * @param initialM42 defines 2nd value of 4th row
  80120. * @param initialM43 defines 3rd value of 4th row
  80121. * @param initialM44 defines 4th value of 4th row
  80122. * @returns the new matrix
  80123. */
  80124. 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;
  80125. /**
  80126. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80127. * @param scale defines the scale vector3
  80128. * @param rotation defines the rotation quaternion
  80129. * @param translation defines the translation vector3
  80130. * @returns a new matrix
  80131. */
  80132. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  80133. /**
  80134. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  80135. * @param scale defines the scale vector3
  80136. * @param rotation defines the rotation quaternion
  80137. * @param translation defines the translation vector3
  80138. * @param result defines the target matrix
  80139. */
  80140. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  80141. /**
  80142. * Creates a new identity matrix
  80143. * @returns a new identity matrix
  80144. */
  80145. static Identity(): Matrix;
  80146. /**
  80147. * Creates a new identity matrix and stores the result in a given matrix
  80148. * @param result defines the target matrix
  80149. */
  80150. static IdentityToRef(result: Matrix): void;
  80151. /**
  80152. * Creates a new zero matrix
  80153. * @returns a new zero matrix
  80154. */
  80155. static Zero(): Matrix;
  80156. /**
  80157. * Creates a new rotation matrix for "angle" radians around the X axis
  80158. * @param angle defines the angle (in radians) to use
  80159. * @return the new matrix
  80160. */
  80161. static RotationX(angle: number): Matrix;
  80162. /**
  80163. * Creates a new matrix as the invert of a given matrix
  80164. * @param source defines the source matrix
  80165. * @returns the new matrix
  80166. */
  80167. static Invert(source: DeepImmutable<Matrix>): Matrix;
  80168. /**
  80169. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  80170. * @param angle defines the angle (in radians) to use
  80171. * @param result defines the target matrix
  80172. */
  80173. static RotationXToRef(angle: number, result: Matrix): void;
  80174. /**
  80175. * Creates a new rotation matrix for "angle" radians around the Y axis
  80176. * @param angle defines the angle (in radians) to use
  80177. * @return the new matrix
  80178. */
  80179. static RotationY(angle: number): Matrix;
  80180. /**
  80181. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  80182. * @param angle defines the angle (in radians) to use
  80183. * @param result defines the target matrix
  80184. */
  80185. static RotationYToRef(angle: number, result: Matrix): void;
  80186. /**
  80187. * Creates a new rotation matrix for "angle" radians around the Z axis
  80188. * @param angle defines the angle (in radians) to use
  80189. * @return the new matrix
  80190. */
  80191. static RotationZ(angle: number): Matrix;
  80192. /**
  80193. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  80194. * @param angle defines the angle (in radians) to use
  80195. * @param result defines the target matrix
  80196. */
  80197. static RotationZToRef(angle: number, result: Matrix): void;
  80198. /**
  80199. * Creates a new rotation matrix for "angle" radians around the given axis
  80200. * @param axis defines the axis to use
  80201. * @param angle defines the angle (in radians) to use
  80202. * @return the new matrix
  80203. */
  80204. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  80205. /**
  80206. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  80207. * @param axis defines the axis to use
  80208. * @param angle defines the angle (in radians) to use
  80209. * @param result defines the target matrix
  80210. */
  80211. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  80212. /**
  80213. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  80214. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  80215. * @param from defines the vector to align
  80216. * @param to defines the vector to align to
  80217. * @param result defines the target matrix
  80218. */
  80219. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  80220. /**
  80221. * Creates a rotation matrix
  80222. * @param yaw defines the yaw angle in radians (Y axis)
  80223. * @param pitch defines the pitch angle in radians (X axis)
  80224. * @param roll defines the roll angle in radians (X axis)
  80225. * @returns the new rotation matrix
  80226. */
  80227. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  80228. /**
  80229. * Creates a rotation matrix and stores it in a given matrix
  80230. * @param yaw defines the yaw angle in radians (Y axis)
  80231. * @param pitch defines the pitch angle in radians (X axis)
  80232. * @param roll defines the roll angle in radians (X axis)
  80233. * @param result defines the target matrix
  80234. */
  80235. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  80236. /**
  80237. * Creates a scaling matrix
  80238. * @param x defines the scale factor on X axis
  80239. * @param y defines the scale factor on Y axis
  80240. * @param z defines the scale factor on Z axis
  80241. * @returns the new matrix
  80242. */
  80243. static Scaling(x: number, y: number, z: number): Matrix;
  80244. /**
  80245. * Creates a scaling matrix and stores it in a given matrix
  80246. * @param x defines the scale factor on X axis
  80247. * @param y defines the scale factor on Y axis
  80248. * @param z defines the scale factor on Z axis
  80249. * @param result defines the target matrix
  80250. */
  80251. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  80252. /**
  80253. * Creates a translation matrix
  80254. * @param x defines the translation on X axis
  80255. * @param y defines the translation on Y axis
  80256. * @param z defines the translationon Z axis
  80257. * @returns the new matrix
  80258. */
  80259. static Translation(x: number, y: number, z: number): Matrix;
  80260. /**
  80261. * Creates a translation matrix and stores it in a given matrix
  80262. * @param x defines the translation on X axis
  80263. * @param y defines the translation on Y axis
  80264. * @param z defines the translationon Z axis
  80265. * @param result defines the target matrix
  80266. */
  80267. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  80268. /**
  80269. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80270. * @param startValue defines the start value
  80271. * @param endValue defines the end value
  80272. * @param gradient defines the gradient factor
  80273. * @returns the new matrix
  80274. */
  80275. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80276. /**
  80277. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  80278. * @param startValue defines the start value
  80279. * @param endValue defines the end value
  80280. * @param gradient defines the gradient factor
  80281. * @param result defines the Matrix object where to store data
  80282. */
  80283. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80284. /**
  80285. * Builds a new matrix whose values are computed by:
  80286. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80287. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80288. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80289. * @param startValue defines the first matrix
  80290. * @param endValue defines the second matrix
  80291. * @param gradient defines the gradient between the two matrices
  80292. * @returns the new matrix
  80293. */
  80294. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  80295. /**
  80296. * Update a matrix to values which are computed by:
  80297. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  80298. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  80299. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  80300. * @param startValue defines the first matrix
  80301. * @param endValue defines the second matrix
  80302. * @param gradient defines the gradient between the two matrices
  80303. * @param result defines the target matrix
  80304. */
  80305. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  80306. /**
  80307. * 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"
  80308. * This function works in left handed mode
  80309. * @param eye defines the final position of the entity
  80310. * @param target defines where the entity should look at
  80311. * @param up defines the up vector for the entity
  80312. * @returns the new matrix
  80313. */
  80314. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80315. /**
  80316. * 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".
  80317. * This function works in left handed mode
  80318. * @param eye defines the final position of the entity
  80319. * @param target defines where the entity should look at
  80320. * @param up defines the up vector for the entity
  80321. * @param result defines the target matrix
  80322. */
  80323. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80324. /**
  80325. * 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"
  80326. * This function works in right handed mode
  80327. * @param eye defines the final position of the entity
  80328. * @param target defines where the entity should look at
  80329. * @param up defines the up vector for the entity
  80330. * @returns the new matrix
  80331. */
  80332. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  80333. /**
  80334. * 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".
  80335. * This function works in right handed mode
  80336. * @param eye defines the final position of the entity
  80337. * @param target defines where the entity should look at
  80338. * @param up defines the up vector for the entity
  80339. * @param result defines the target matrix
  80340. */
  80341. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  80342. /**
  80343. * Create a left-handed orthographic projection matrix
  80344. * @param width defines the viewport width
  80345. * @param height defines the viewport height
  80346. * @param znear defines the near clip plane
  80347. * @param zfar defines the far clip plane
  80348. * @returns a new matrix as a left-handed orthographic projection matrix
  80349. */
  80350. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80351. /**
  80352. * Store a left-handed orthographic projection to a given matrix
  80353. * @param width defines the viewport width
  80354. * @param height defines the viewport height
  80355. * @param znear defines the near clip plane
  80356. * @param zfar defines the far clip plane
  80357. * @param result defines the target matrix
  80358. */
  80359. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  80360. /**
  80361. * Create a left-handed orthographic projection matrix
  80362. * @param left defines the viewport left coordinate
  80363. * @param right defines the viewport right coordinate
  80364. * @param bottom defines the viewport bottom coordinate
  80365. * @param top defines the viewport top coordinate
  80366. * @param znear defines the near clip plane
  80367. * @param zfar defines the far clip plane
  80368. * @returns a new matrix as a left-handed orthographic projection matrix
  80369. */
  80370. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80371. /**
  80372. * Stores a left-handed orthographic projection into a given matrix
  80373. * @param left defines the viewport left coordinate
  80374. * @param right defines the viewport right coordinate
  80375. * @param bottom defines the viewport bottom coordinate
  80376. * @param top defines the viewport top coordinate
  80377. * @param znear defines the near clip plane
  80378. * @param zfar defines the far clip plane
  80379. * @param result defines the target matrix
  80380. */
  80381. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80382. /**
  80383. * Creates a right-handed orthographic projection matrix
  80384. * @param left defines the viewport left coordinate
  80385. * @param right defines the viewport right coordinate
  80386. * @param bottom defines the viewport bottom coordinate
  80387. * @param top defines the viewport top coordinate
  80388. * @param znear defines the near clip plane
  80389. * @param zfar defines the far clip plane
  80390. * @returns a new matrix as a right-handed orthographic projection matrix
  80391. */
  80392. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  80393. /**
  80394. * Stores a right-handed orthographic projection into a given matrix
  80395. * @param left defines the viewport left coordinate
  80396. * @param right defines the viewport right coordinate
  80397. * @param bottom defines the viewport bottom coordinate
  80398. * @param top defines the viewport top coordinate
  80399. * @param znear defines the near clip plane
  80400. * @param zfar defines the far clip plane
  80401. * @param result defines the target matrix
  80402. */
  80403. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  80404. /**
  80405. * Creates a left-handed perspective projection matrix
  80406. * @param width defines the viewport width
  80407. * @param height defines the viewport height
  80408. * @param znear defines the near clip plane
  80409. * @param zfar defines the far clip plane
  80410. * @returns a new matrix as a left-handed perspective projection matrix
  80411. */
  80412. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  80413. /**
  80414. * Creates a left-handed perspective projection matrix
  80415. * @param fov defines the horizontal field of view
  80416. * @param aspect defines the aspect ratio
  80417. * @param znear defines the near clip plane
  80418. * @param zfar defines the far clip plane
  80419. * @returns a new matrix as a left-handed perspective projection matrix
  80420. */
  80421. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80422. /**
  80423. * Stores a left-handed perspective projection into a given matrix
  80424. * @param fov defines the horizontal field of view
  80425. * @param aspect defines the aspect ratio
  80426. * @param znear defines the near clip plane
  80427. * @param zfar defines the far clip plane
  80428. * @param result defines the target matrix
  80429. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80430. */
  80431. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80432. /**
  80433. * Stores a left-handed perspective projection into a given matrix with depth reversed
  80434. * @param fov defines the horizontal field of view
  80435. * @param aspect defines the aspect ratio
  80436. * @param znear defines the near clip plane
  80437. * @param zfar not used as infinity is used as far clip
  80438. * @param result defines the target matrix
  80439. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80440. */
  80441. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80442. /**
  80443. * Creates a right-handed perspective projection matrix
  80444. * @param fov defines the horizontal field of view
  80445. * @param aspect defines the aspect ratio
  80446. * @param znear defines the near clip plane
  80447. * @param zfar defines the far clip plane
  80448. * @returns a new matrix as a right-handed perspective projection matrix
  80449. */
  80450. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  80451. /**
  80452. * Stores a right-handed perspective projection into a given matrix
  80453. * @param fov defines the horizontal field of view
  80454. * @param aspect defines the aspect ratio
  80455. * @param znear defines the near clip plane
  80456. * @param zfar defines the far clip plane
  80457. * @param result defines the target matrix
  80458. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80459. */
  80460. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80461. /**
  80462. * Stores a right-handed perspective projection into a given matrix
  80463. * @param fov defines the horizontal field of view
  80464. * @param aspect defines the aspect ratio
  80465. * @param znear defines the near clip plane
  80466. * @param zfar not used as infinity is used as far clip
  80467. * @param result defines the target matrix
  80468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  80469. */
  80470. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  80471. /**
  80472. * Stores a perspective projection for WebVR info a given matrix
  80473. * @param fov defines the field of view
  80474. * @param znear defines the near clip plane
  80475. * @param zfar defines the far clip plane
  80476. * @param result defines the target matrix
  80477. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  80478. */
  80479. static PerspectiveFovWebVRToRef(fov: {
  80480. upDegrees: number;
  80481. downDegrees: number;
  80482. leftDegrees: number;
  80483. rightDegrees: number;
  80484. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  80485. /**
  80486. * Computes a complete transformation matrix
  80487. * @param viewport defines the viewport to use
  80488. * @param world defines the world matrix
  80489. * @param view defines the view matrix
  80490. * @param projection defines the projection matrix
  80491. * @param zmin defines the near clip plane
  80492. * @param zmax defines the far clip plane
  80493. * @returns the transformation matrix
  80494. */
  80495. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  80496. /**
  80497. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  80498. * @param matrix defines the matrix to use
  80499. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  80500. */
  80501. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  80502. /**
  80503. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  80504. * @param matrix defines the matrix to use
  80505. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  80506. */
  80507. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  80508. /**
  80509. * Compute the transpose of a given matrix
  80510. * @param matrix defines the matrix to transpose
  80511. * @returns the new matrix
  80512. */
  80513. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  80514. /**
  80515. * Compute the transpose of a matrix and store it in a target matrix
  80516. * @param matrix defines the matrix to transpose
  80517. * @param result defines the target matrix
  80518. */
  80519. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  80520. /**
  80521. * Computes a reflection matrix from a plane
  80522. * @param plane defines the reflection plane
  80523. * @returns a new matrix
  80524. */
  80525. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  80526. /**
  80527. * Computes a reflection matrix from a plane
  80528. * @param plane defines the reflection plane
  80529. * @param result defines the target matrix
  80530. */
  80531. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  80532. /**
  80533. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  80534. * @param xaxis defines the value of the 1st axis
  80535. * @param yaxis defines the value of the 2nd axis
  80536. * @param zaxis defines the value of the 3rd axis
  80537. * @param result defines the target matrix
  80538. */
  80539. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  80540. /**
  80541. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  80542. * @param quat defines the quaternion to use
  80543. * @param result defines the target matrix
  80544. */
  80545. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  80546. }
  80547. /**
  80548. * @hidden
  80549. */
  80550. export class TmpVectors {
  80551. static Vector2: Vector2[];
  80552. static Vector3: Vector3[];
  80553. static Vector4: Vector4[];
  80554. static Quaternion: Quaternion[];
  80555. static Matrix: Matrix[];
  80556. }
  80557. }
  80558. declare module BABYLON {
  80559. /**
  80560. * Defines potential orientation for back face culling
  80561. */
  80562. export enum Orientation {
  80563. /**
  80564. * Clockwise
  80565. */
  80566. CW = 0,
  80567. /** Counter clockwise */
  80568. CCW = 1
  80569. }
  80570. /** Class used to represent a Bezier curve */
  80571. export class BezierCurve {
  80572. /**
  80573. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  80574. * @param t defines the time
  80575. * @param x1 defines the left coordinate on X axis
  80576. * @param y1 defines the left coordinate on Y axis
  80577. * @param x2 defines the right coordinate on X axis
  80578. * @param y2 defines the right coordinate on Y axis
  80579. * @returns the interpolated value
  80580. */
  80581. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  80582. }
  80583. /**
  80584. * Defines angle representation
  80585. */
  80586. export class Angle {
  80587. private _radians;
  80588. /**
  80589. * Creates an Angle object of "radians" radians (float).
  80590. * @param radians the angle in radians
  80591. */
  80592. constructor(radians: number);
  80593. /**
  80594. * Get value in degrees
  80595. * @returns the Angle value in degrees (float)
  80596. */
  80597. degrees(): number;
  80598. /**
  80599. * Get value in radians
  80600. * @returns the Angle value in radians (float)
  80601. */
  80602. radians(): number;
  80603. /**
  80604. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  80605. * @param a defines first vector
  80606. * @param b defines second vector
  80607. * @returns a new Angle
  80608. */
  80609. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  80610. /**
  80611. * Gets a new Angle object from the given float in radians
  80612. * @param radians defines the angle value in radians
  80613. * @returns a new Angle
  80614. */
  80615. static FromRadians(radians: number): Angle;
  80616. /**
  80617. * Gets a new Angle object from the given float in degrees
  80618. * @param degrees defines the angle value in degrees
  80619. * @returns a new Angle
  80620. */
  80621. static FromDegrees(degrees: number): Angle;
  80622. }
  80623. /**
  80624. * This represents an arc in a 2d space.
  80625. */
  80626. export class Arc2 {
  80627. /** Defines the start point of the arc */
  80628. startPoint: Vector2;
  80629. /** Defines the mid point of the arc */
  80630. midPoint: Vector2;
  80631. /** Defines the end point of the arc */
  80632. endPoint: Vector2;
  80633. /**
  80634. * Defines the center point of the arc.
  80635. */
  80636. centerPoint: Vector2;
  80637. /**
  80638. * Defines the radius of the arc.
  80639. */
  80640. radius: number;
  80641. /**
  80642. * Defines the angle of the arc (from mid point to end point).
  80643. */
  80644. angle: Angle;
  80645. /**
  80646. * Defines the start angle of the arc (from start point to middle point).
  80647. */
  80648. startAngle: Angle;
  80649. /**
  80650. * Defines the orientation of the arc (clock wise/counter clock wise).
  80651. */
  80652. orientation: Orientation;
  80653. /**
  80654. * Creates an Arc object from the three given points : start, middle and end.
  80655. * @param startPoint Defines the start point of the arc
  80656. * @param midPoint Defines the midlle point of the arc
  80657. * @param endPoint Defines the end point of the arc
  80658. */
  80659. constructor(
  80660. /** Defines the start point of the arc */
  80661. startPoint: Vector2,
  80662. /** Defines the mid point of the arc */
  80663. midPoint: Vector2,
  80664. /** Defines the end point of the arc */
  80665. endPoint: Vector2);
  80666. }
  80667. /**
  80668. * Represents a 2D path made up of multiple 2D points
  80669. */
  80670. export class Path2 {
  80671. private _points;
  80672. private _length;
  80673. /**
  80674. * If the path start and end point are the same
  80675. */
  80676. closed: boolean;
  80677. /**
  80678. * Creates a Path2 object from the starting 2D coordinates x and y.
  80679. * @param x the starting points x value
  80680. * @param y the starting points y value
  80681. */
  80682. constructor(x: number, y: number);
  80683. /**
  80684. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  80685. * @param x the added points x value
  80686. * @param y the added points y value
  80687. * @returns the updated Path2.
  80688. */
  80689. addLineTo(x: number, y: number): Path2;
  80690. /**
  80691. * 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.
  80692. * @param midX middle point x value
  80693. * @param midY middle point y value
  80694. * @param endX end point x value
  80695. * @param endY end point y value
  80696. * @param numberOfSegments (default: 36)
  80697. * @returns the updated Path2.
  80698. */
  80699. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  80700. /**
  80701. * Closes the Path2.
  80702. * @returns the Path2.
  80703. */
  80704. close(): Path2;
  80705. /**
  80706. * Gets the sum of the distance between each sequential point in the path
  80707. * @returns the Path2 total length (float).
  80708. */
  80709. length(): number;
  80710. /**
  80711. * Gets the points which construct the path
  80712. * @returns the Path2 internal array of points.
  80713. */
  80714. getPoints(): Vector2[];
  80715. /**
  80716. * Retreives the point at the distance aways from the starting point
  80717. * @param normalizedLengthPosition the length along the path to retreive the point from
  80718. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  80719. */
  80720. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  80721. /**
  80722. * Creates a new path starting from an x and y position
  80723. * @param x starting x value
  80724. * @param y starting y value
  80725. * @returns a new Path2 starting at the coordinates (x, y).
  80726. */
  80727. static StartingAt(x: number, y: number): Path2;
  80728. }
  80729. /**
  80730. * Represents a 3D path made up of multiple 3D points
  80731. */
  80732. export class Path3D {
  80733. /**
  80734. * an array of Vector3, the curve axis of the Path3D
  80735. */
  80736. path: Vector3[];
  80737. private _curve;
  80738. private _distances;
  80739. private _tangents;
  80740. private _normals;
  80741. private _binormals;
  80742. private _raw;
  80743. private _alignTangentsWithPath;
  80744. private readonly _pointAtData;
  80745. /**
  80746. * new Path3D(path, normal, raw)
  80747. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  80748. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  80749. * @param path an array of Vector3, the curve axis of the Path3D
  80750. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  80751. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  80752. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  80753. */
  80754. constructor(
  80755. /**
  80756. * an array of Vector3, the curve axis of the Path3D
  80757. */
  80758. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  80759. /**
  80760. * Returns the Path3D array of successive Vector3 designing its curve.
  80761. * @returns the Path3D array of successive Vector3 designing its curve.
  80762. */
  80763. getCurve(): Vector3[];
  80764. /**
  80765. * Returns the Path3D array of successive Vector3 designing its curve.
  80766. * @returns the Path3D array of successive Vector3 designing its curve.
  80767. */
  80768. getPoints(): Vector3[];
  80769. /**
  80770. * @returns the computed length (float) of the path.
  80771. */
  80772. length(): number;
  80773. /**
  80774. * Returns an array populated with tangent vectors on each Path3D curve point.
  80775. * @returns an array populated with tangent vectors on each Path3D curve point.
  80776. */
  80777. getTangents(): Vector3[];
  80778. /**
  80779. * Returns an array populated with normal vectors on each Path3D curve point.
  80780. * @returns an array populated with normal vectors on each Path3D curve point.
  80781. */
  80782. getNormals(): Vector3[];
  80783. /**
  80784. * Returns an array populated with binormal vectors on each Path3D curve point.
  80785. * @returns an array populated with binormal vectors on each Path3D curve point.
  80786. */
  80787. getBinormals(): Vector3[];
  80788. /**
  80789. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  80790. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  80791. */
  80792. getDistances(): number[];
  80793. /**
  80794. * Returns an interpolated point along this path
  80795. * @param position the position of the point along this path, from 0.0 to 1.0
  80796. * @returns a new Vector3 as the point
  80797. */
  80798. getPointAt(position: number): Vector3;
  80799. /**
  80800. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80801. * @param position the position of the point along this path, from 0.0 to 1.0
  80802. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  80803. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  80804. */
  80805. getTangentAt(position: number, interpolated?: boolean): Vector3;
  80806. /**
  80807. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  80808. * @param position the position of the point along this path, from 0.0 to 1.0
  80809. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  80810. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  80811. */
  80812. getNormalAt(position: number, interpolated?: boolean): Vector3;
  80813. /**
  80814. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  80815. * @param position the position of the point along this path, from 0.0 to 1.0
  80816. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  80817. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  80818. */
  80819. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  80820. /**
  80821. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  80822. * @param position the position of the point along this path, from 0.0 to 1.0
  80823. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  80824. */
  80825. getDistanceAt(position: number): number;
  80826. /**
  80827. * Returns the array index of the previous point of an interpolated point along this path
  80828. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  80829. * @returns the array index
  80830. */
  80831. getPreviousPointIndexAt(position: number): number;
  80832. /**
  80833. * 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)
  80834. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  80835. * @returns the sub position
  80836. */
  80837. getSubPositionAt(position: number): number;
  80838. /**
  80839. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  80840. * @param target the vector of which to get the closest position to
  80841. * @returns the position of the closest virtual point on this path to the target vector
  80842. */
  80843. getClosestPositionTo(target: Vector3): number;
  80844. /**
  80845. * Returns a sub path (slice) of this path
  80846. * @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
  80847. * @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
  80848. * @returns a sub path (slice) of this path
  80849. */
  80850. slice(start?: number, end?: number): Path3D;
  80851. /**
  80852. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  80853. * @param path path which all values are copied into the curves points
  80854. * @param firstNormal which should be projected onto the curve
  80855. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  80856. * @returns the same object updated.
  80857. */
  80858. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  80859. private _compute;
  80860. private _getFirstNonNullVector;
  80861. private _getLastNonNullVector;
  80862. private _normalVector;
  80863. /**
  80864. * Updates the point at data for an interpolated point along this curve
  80865. * @param position the position of the point along this curve, from 0.0 to 1.0
  80866. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  80867. * @returns the (updated) point at data
  80868. */
  80869. private _updatePointAtData;
  80870. /**
  80871. * Updates the point at data from the specified parameters
  80872. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  80873. * @param point the interpolated point
  80874. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  80875. */
  80876. private _setPointAtData;
  80877. /**
  80878. * Updates the point at interpolation matrix for the tangents, normals and binormals
  80879. */
  80880. private _updateInterpolationMatrix;
  80881. }
  80882. /**
  80883. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  80884. * A Curve3 is designed from a series of successive Vector3.
  80885. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  80886. */
  80887. export class Curve3 {
  80888. private _points;
  80889. private _length;
  80890. /**
  80891. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  80892. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  80893. * @param v1 (Vector3) the control point
  80894. * @param v2 (Vector3) the end point of the Quadratic Bezier
  80895. * @param nbPoints (integer) the wanted number of points in the curve
  80896. * @returns the created Curve3
  80897. */
  80898. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  80899. /**
  80900. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  80901. * @param v0 (Vector3) the origin point of the Cubic Bezier
  80902. * @param v1 (Vector3) the first control point
  80903. * @param v2 (Vector3) the second control point
  80904. * @param v3 (Vector3) the end point of the Cubic Bezier
  80905. * @param nbPoints (integer) the wanted number of points in the curve
  80906. * @returns the created Curve3
  80907. */
  80908. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  80909. /**
  80910. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  80911. * @param p1 (Vector3) the origin point of the Hermite Spline
  80912. * @param t1 (Vector3) the tangent vector at the origin point
  80913. * @param p2 (Vector3) the end point of the Hermite Spline
  80914. * @param t2 (Vector3) the tangent vector at the end point
  80915. * @param nbPoints (integer) the wanted number of points in the curve
  80916. * @returns the created Curve3
  80917. */
  80918. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  80919. /**
  80920. * Returns a Curve3 object along a CatmullRom Spline curve :
  80921. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  80922. * @param nbPoints (integer) the wanted number of points between each curve control points
  80923. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  80924. * @returns the created Curve3
  80925. */
  80926. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  80927. /**
  80928. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  80929. * A Curve3 is designed from a series of successive Vector3.
  80930. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  80931. * @param points points which make up the curve
  80932. */
  80933. constructor(points: Vector3[]);
  80934. /**
  80935. * @returns the Curve3 stored array of successive Vector3
  80936. */
  80937. getPoints(): Vector3[];
  80938. /**
  80939. * @returns the computed length (float) of the curve.
  80940. */
  80941. length(): number;
  80942. /**
  80943. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  80944. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  80945. * curveA and curveB keep unchanged.
  80946. * @param curve the curve to continue from this curve
  80947. * @returns the newly constructed curve
  80948. */
  80949. continue(curve: DeepImmutable<Curve3>): Curve3;
  80950. private _computeLength;
  80951. }
  80952. }
  80953. declare module BABYLON {
  80954. /**
  80955. * This represents the main contract an easing function should follow.
  80956. * Easing functions are used throughout the animation system.
  80957. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80958. */
  80959. export interface IEasingFunction {
  80960. /**
  80961. * Given an input gradient between 0 and 1, this returns the corrseponding value
  80962. * of the easing function.
  80963. * The link below provides some of the most common examples of easing functions.
  80964. * @see https://easings.net/
  80965. * @param gradient Defines the value between 0 and 1 we want the easing value for
  80966. * @returns the corresponding value on the curve defined by the easing function
  80967. */
  80968. ease(gradient: number): number;
  80969. }
  80970. /**
  80971. * Base class used for every default easing function.
  80972. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  80973. */
  80974. export class EasingFunction implements IEasingFunction {
  80975. /**
  80976. * Interpolation follows the mathematical formula associated with the easing function.
  80977. */
  80978. static readonly EASINGMODE_EASEIN: number;
  80979. /**
  80980. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  80981. */
  80982. static readonly EASINGMODE_EASEOUT: number;
  80983. /**
  80984. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  80985. */
  80986. static readonly EASINGMODE_EASEINOUT: number;
  80987. private _easingMode;
  80988. /**
  80989. * Sets the easing mode of the current function.
  80990. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  80991. */
  80992. setEasingMode(easingMode: number): void;
  80993. /**
  80994. * Gets the current easing mode.
  80995. * @returns the easing mode
  80996. */
  80997. getEasingMode(): number;
  80998. /**
  80999. * @hidden
  81000. */
  81001. easeInCore(gradient: number): number;
  81002. /**
  81003. * Given an input gradient between 0 and 1, this returns the corresponding value
  81004. * of the easing function.
  81005. * @param gradient Defines the value between 0 and 1 we want the easing value for
  81006. * @returns the corresponding value on the curve defined by the easing function
  81007. */
  81008. ease(gradient: number): number;
  81009. }
  81010. /**
  81011. * Easing function with a circle shape (see link below).
  81012. * @see https://easings.net/#easeInCirc
  81013. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81014. */
  81015. export class CircleEase extends EasingFunction implements IEasingFunction {
  81016. /** @hidden */
  81017. easeInCore(gradient: number): number;
  81018. }
  81019. /**
  81020. * Easing function with a ease back shape (see link below).
  81021. * @see https://easings.net/#easeInBack
  81022. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81023. */
  81024. export class BackEase extends EasingFunction implements IEasingFunction {
  81025. /** Defines the amplitude of the function */
  81026. amplitude: number;
  81027. /**
  81028. * Instantiates a back ease easing
  81029. * @see https://easings.net/#easeInBack
  81030. * @param amplitude Defines the amplitude of the function
  81031. */
  81032. constructor(
  81033. /** Defines the amplitude of the function */
  81034. amplitude?: number);
  81035. /** @hidden */
  81036. easeInCore(gradient: number): number;
  81037. }
  81038. /**
  81039. * Easing function with a bouncing shape (see link below).
  81040. * @see https://easings.net/#easeInBounce
  81041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81042. */
  81043. export class BounceEase extends EasingFunction implements IEasingFunction {
  81044. /** Defines the number of bounces */
  81045. bounces: number;
  81046. /** Defines the amplitude of the bounce */
  81047. bounciness: number;
  81048. /**
  81049. * Instantiates a bounce easing
  81050. * @see https://easings.net/#easeInBounce
  81051. * @param bounces Defines the number of bounces
  81052. * @param bounciness Defines the amplitude of the bounce
  81053. */
  81054. constructor(
  81055. /** Defines the number of bounces */
  81056. bounces?: number,
  81057. /** Defines the amplitude of the bounce */
  81058. bounciness?: number);
  81059. /** @hidden */
  81060. easeInCore(gradient: number): number;
  81061. }
  81062. /**
  81063. * Easing function with a power of 3 shape (see link below).
  81064. * @see https://easings.net/#easeInCubic
  81065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81066. */
  81067. export class CubicEase extends EasingFunction implements IEasingFunction {
  81068. /** @hidden */
  81069. easeInCore(gradient: number): number;
  81070. }
  81071. /**
  81072. * Easing function with an elastic shape (see link below).
  81073. * @see https://easings.net/#easeInElastic
  81074. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81075. */
  81076. export class ElasticEase extends EasingFunction implements IEasingFunction {
  81077. /** Defines the number of oscillations*/
  81078. oscillations: number;
  81079. /** Defines the amplitude of the oscillations*/
  81080. springiness: number;
  81081. /**
  81082. * Instantiates an elastic easing function
  81083. * @see https://easings.net/#easeInElastic
  81084. * @param oscillations Defines the number of oscillations
  81085. * @param springiness Defines the amplitude of the oscillations
  81086. */
  81087. constructor(
  81088. /** Defines the number of oscillations*/
  81089. oscillations?: number,
  81090. /** Defines the amplitude of the oscillations*/
  81091. springiness?: number);
  81092. /** @hidden */
  81093. easeInCore(gradient: number): number;
  81094. }
  81095. /**
  81096. * Easing function with an exponential shape (see link below).
  81097. * @see https://easings.net/#easeInExpo
  81098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81099. */
  81100. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  81101. /** Defines the exponent of the function */
  81102. exponent: number;
  81103. /**
  81104. * Instantiates an exponential easing function
  81105. * @see https://easings.net/#easeInExpo
  81106. * @param exponent Defines the exponent of the function
  81107. */
  81108. constructor(
  81109. /** Defines the exponent of the function */
  81110. exponent?: number);
  81111. /** @hidden */
  81112. easeInCore(gradient: number): number;
  81113. }
  81114. /**
  81115. * Easing function with a power shape (see link below).
  81116. * @see https://easings.net/#easeInQuad
  81117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81118. */
  81119. export class PowerEase extends EasingFunction implements IEasingFunction {
  81120. /** Defines the power of the function */
  81121. power: number;
  81122. /**
  81123. * Instantiates an power base easing function
  81124. * @see https://easings.net/#easeInQuad
  81125. * @param power Defines the power of the function
  81126. */
  81127. constructor(
  81128. /** Defines the power of the function */
  81129. power?: number);
  81130. /** @hidden */
  81131. easeInCore(gradient: number): number;
  81132. }
  81133. /**
  81134. * Easing function with a power of 2 shape (see link below).
  81135. * @see https://easings.net/#easeInQuad
  81136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81137. */
  81138. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  81139. /** @hidden */
  81140. easeInCore(gradient: number): number;
  81141. }
  81142. /**
  81143. * Easing function with a power of 4 shape (see link below).
  81144. * @see https://easings.net/#easeInQuart
  81145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81146. */
  81147. export class QuarticEase extends EasingFunction implements IEasingFunction {
  81148. /** @hidden */
  81149. easeInCore(gradient: number): number;
  81150. }
  81151. /**
  81152. * Easing function with a power of 5 shape (see link below).
  81153. * @see https://easings.net/#easeInQuint
  81154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81155. */
  81156. export class QuinticEase extends EasingFunction implements IEasingFunction {
  81157. /** @hidden */
  81158. easeInCore(gradient: number): number;
  81159. }
  81160. /**
  81161. * Easing function with a sin shape (see link below).
  81162. * @see https://easings.net/#easeInSine
  81163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81164. */
  81165. export class SineEase extends EasingFunction implements IEasingFunction {
  81166. /** @hidden */
  81167. easeInCore(gradient: number): number;
  81168. }
  81169. /**
  81170. * Easing function with a bezier shape (see link below).
  81171. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  81173. */
  81174. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  81175. /** Defines the x component of the start tangent in the bezier curve */
  81176. x1: number;
  81177. /** Defines the y component of the start tangent in the bezier curve */
  81178. y1: number;
  81179. /** Defines the x component of the end tangent in the bezier curve */
  81180. x2: number;
  81181. /** Defines the y component of the end tangent in the bezier curve */
  81182. y2: number;
  81183. /**
  81184. * Instantiates a bezier function
  81185. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  81186. * @param x1 Defines the x component of the start tangent in the bezier curve
  81187. * @param y1 Defines the y component of the start tangent in the bezier curve
  81188. * @param x2 Defines the x component of the end tangent in the bezier curve
  81189. * @param y2 Defines the y component of the end tangent in the bezier curve
  81190. */
  81191. constructor(
  81192. /** Defines the x component of the start tangent in the bezier curve */
  81193. x1?: number,
  81194. /** Defines the y component of the start tangent in the bezier curve */
  81195. y1?: number,
  81196. /** Defines the x component of the end tangent in the bezier curve */
  81197. x2?: number,
  81198. /** Defines the y component of the end tangent in the bezier curve */
  81199. y2?: number);
  81200. /** @hidden */
  81201. easeInCore(gradient: number): number;
  81202. }
  81203. }
  81204. declare module BABYLON {
  81205. /**
  81206. * Class used to hold a RBG color
  81207. */
  81208. export class Color3 {
  81209. /**
  81210. * Defines the red component (between 0 and 1, default is 0)
  81211. */
  81212. r: number;
  81213. /**
  81214. * Defines the green component (between 0 and 1, default is 0)
  81215. */
  81216. g: number;
  81217. /**
  81218. * Defines the blue component (between 0 and 1, default is 0)
  81219. */
  81220. b: number;
  81221. /**
  81222. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  81223. * @param r defines the red component (between 0 and 1, default is 0)
  81224. * @param g defines the green component (between 0 and 1, default is 0)
  81225. * @param b defines the blue component (between 0 and 1, default is 0)
  81226. */
  81227. constructor(
  81228. /**
  81229. * Defines the red component (between 0 and 1, default is 0)
  81230. */
  81231. r?: number,
  81232. /**
  81233. * Defines the green component (between 0 and 1, default is 0)
  81234. */
  81235. g?: number,
  81236. /**
  81237. * Defines the blue component (between 0 and 1, default is 0)
  81238. */
  81239. b?: number);
  81240. /**
  81241. * Creates a string with the Color3 current values
  81242. * @returns the string representation of the Color3 object
  81243. */
  81244. toString(): string;
  81245. /**
  81246. * Returns the string "Color3"
  81247. * @returns "Color3"
  81248. */
  81249. getClassName(): string;
  81250. /**
  81251. * Compute the Color3 hash code
  81252. * @returns an unique number that can be used to hash Color3 objects
  81253. */
  81254. getHashCode(): number;
  81255. /**
  81256. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  81257. * @param array defines the array where to store the r,g,b components
  81258. * @param index defines an optional index in the target array to define where to start storing values
  81259. * @returns the current Color3 object
  81260. */
  81261. toArray(array: FloatArray, index?: number): Color3;
  81262. /**
  81263. * Returns a new Color4 object from the current Color3 and the given alpha
  81264. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  81265. * @returns a new Color4 object
  81266. */
  81267. toColor4(alpha?: number): Color4;
  81268. /**
  81269. * Returns a new array populated with 3 numeric elements : red, green and blue values
  81270. * @returns the new array
  81271. */
  81272. asArray(): number[];
  81273. /**
  81274. * Returns the luminance value
  81275. * @returns a float value
  81276. */
  81277. toLuminance(): number;
  81278. /**
  81279. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  81280. * @param otherColor defines the second operand
  81281. * @returns the new Color3 object
  81282. */
  81283. multiply(otherColor: DeepImmutable<Color3>): Color3;
  81284. /**
  81285. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  81286. * @param otherColor defines the second operand
  81287. * @param result defines the Color3 object where to store the result
  81288. * @returns the current Color3
  81289. */
  81290. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81291. /**
  81292. * Determines equality between Color3 objects
  81293. * @param otherColor defines the second operand
  81294. * @returns true if the rgb values are equal to the given ones
  81295. */
  81296. equals(otherColor: DeepImmutable<Color3>): boolean;
  81297. /**
  81298. * Determines equality between the current Color3 object and a set of r,b,g values
  81299. * @param r defines the red component to check
  81300. * @param g defines the green component to check
  81301. * @param b defines the blue component to check
  81302. * @returns true if the rgb values are equal to the given ones
  81303. */
  81304. equalsFloats(r: number, g: number, b: number): boolean;
  81305. /**
  81306. * Multiplies in place each rgb value by scale
  81307. * @param scale defines the scaling factor
  81308. * @returns the updated Color3
  81309. */
  81310. scale(scale: number): Color3;
  81311. /**
  81312. * Multiplies the rgb values by scale and stores the result into "result"
  81313. * @param scale defines the scaling factor
  81314. * @param result defines the Color3 object where to store the result
  81315. * @returns the unmodified current Color3
  81316. */
  81317. scaleToRef(scale: number, result: Color3): Color3;
  81318. /**
  81319. * Scale the current Color3 values by a factor and add the result to a given Color3
  81320. * @param scale defines the scale factor
  81321. * @param result defines color to store the result into
  81322. * @returns the unmodified current Color3
  81323. */
  81324. scaleAndAddToRef(scale: number, result: Color3): Color3;
  81325. /**
  81326. * Clamps the rgb values by the min and max values and stores the result into "result"
  81327. * @param min defines minimum clamping value (default is 0)
  81328. * @param max defines maximum clamping value (default is 1)
  81329. * @param result defines color to store the result into
  81330. * @returns the original Color3
  81331. */
  81332. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  81333. /**
  81334. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  81335. * @param otherColor defines the second operand
  81336. * @returns the new Color3
  81337. */
  81338. add(otherColor: DeepImmutable<Color3>): Color3;
  81339. /**
  81340. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  81341. * @param otherColor defines the second operand
  81342. * @param result defines Color3 object to store the result into
  81343. * @returns the unmodified current Color3
  81344. */
  81345. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81346. /**
  81347. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  81348. * @param otherColor defines the second operand
  81349. * @returns the new Color3
  81350. */
  81351. subtract(otherColor: DeepImmutable<Color3>): Color3;
  81352. /**
  81353. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  81354. * @param otherColor defines the second operand
  81355. * @param result defines Color3 object to store the result into
  81356. * @returns the unmodified current Color3
  81357. */
  81358. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  81359. /**
  81360. * Copy the current object
  81361. * @returns a new Color3 copied the current one
  81362. */
  81363. clone(): Color3;
  81364. /**
  81365. * Copies the rgb values from the source in the current Color3
  81366. * @param source defines the source Color3 object
  81367. * @returns the updated Color3 object
  81368. */
  81369. copyFrom(source: DeepImmutable<Color3>): Color3;
  81370. /**
  81371. * Updates the Color3 rgb values from the given floats
  81372. * @param r defines the red component to read from
  81373. * @param g defines the green component to read from
  81374. * @param b defines the blue component to read from
  81375. * @returns the current Color3 object
  81376. */
  81377. copyFromFloats(r: number, g: number, b: number): Color3;
  81378. /**
  81379. * Updates the Color3 rgb values from the given floats
  81380. * @param r defines the red component to read from
  81381. * @param g defines the green component to read from
  81382. * @param b defines the blue component to read from
  81383. * @returns the current Color3 object
  81384. */
  81385. set(r: number, g: number, b: number): Color3;
  81386. /**
  81387. * Compute the Color3 hexadecimal code as a string
  81388. * @returns a string containing the hexadecimal representation of the Color3 object
  81389. */
  81390. toHexString(): string;
  81391. /**
  81392. * Computes a new Color3 converted from the current one to linear space
  81393. * @returns a new Color3 object
  81394. */
  81395. toLinearSpace(): Color3;
  81396. /**
  81397. * Converts current color in rgb space to HSV values
  81398. * @returns a new color3 representing the HSV values
  81399. */
  81400. toHSV(): Color3;
  81401. /**
  81402. * Converts current color in rgb space to HSV values
  81403. * @param result defines the Color3 where to store the HSV values
  81404. */
  81405. toHSVToRef(result: Color3): void;
  81406. /**
  81407. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  81408. * @param convertedColor defines the Color3 object where to store the linear space version
  81409. * @returns the unmodified Color3
  81410. */
  81411. toLinearSpaceToRef(convertedColor: Color3): Color3;
  81412. /**
  81413. * Computes a new Color3 converted from the current one to gamma space
  81414. * @returns a new Color3 object
  81415. */
  81416. toGammaSpace(): Color3;
  81417. /**
  81418. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  81419. * @param convertedColor defines the Color3 object where to store the gamma space version
  81420. * @returns the unmodified Color3
  81421. */
  81422. toGammaSpaceToRef(convertedColor: Color3): Color3;
  81423. private static _BlackReadOnly;
  81424. /**
  81425. * Convert Hue, saturation and value to a Color3 (RGB)
  81426. * @param hue defines the hue
  81427. * @param saturation defines the saturation
  81428. * @param value defines the value
  81429. * @param result defines the Color3 where to store the RGB values
  81430. */
  81431. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  81432. /**
  81433. * Creates a new Color3 from the string containing valid hexadecimal values
  81434. * @param hex defines a string containing valid hexadecimal values
  81435. * @returns a new Color3 object
  81436. */
  81437. static FromHexString(hex: string): Color3;
  81438. /**
  81439. * Creates a new Color3 from the starting index of the given array
  81440. * @param array defines the source array
  81441. * @param offset defines an offset in the source array
  81442. * @returns a new Color3 object
  81443. */
  81444. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  81445. /**
  81446. * Creates a new Color3 from integer values (< 256)
  81447. * @param r defines the red component to read from (value between 0 and 255)
  81448. * @param g defines the green component to read from (value between 0 and 255)
  81449. * @param b defines the blue component to read from (value between 0 and 255)
  81450. * @returns a new Color3 object
  81451. */
  81452. static FromInts(r: number, g: number, b: number): Color3;
  81453. /**
  81454. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81455. * @param start defines the start Color3 value
  81456. * @param end defines the end Color3 value
  81457. * @param amount defines the gradient value between start and end
  81458. * @returns a new Color3 object
  81459. */
  81460. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  81461. /**
  81462. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  81463. * @param left defines the start value
  81464. * @param right defines the end value
  81465. * @param amount defines the gradient factor
  81466. * @param result defines the Color3 object where to store the result
  81467. */
  81468. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  81469. /**
  81470. * Returns a Color3 value containing a red color
  81471. * @returns a new Color3 object
  81472. */
  81473. static Red(): Color3;
  81474. /**
  81475. * Returns a Color3 value containing a green color
  81476. * @returns a new Color3 object
  81477. */
  81478. static Green(): Color3;
  81479. /**
  81480. * Returns a Color3 value containing a blue color
  81481. * @returns a new Color3 object
  81482. */
  81483. static Blue(): Color3;
  81484. /**
  81485. * Returns a Color3 value containing a black color
  81486. * @returns a new Color3 object
  81487. */
  81488. static Black(): Color3;
  81489. /**
  81490. * Gets a Color3 value containing a black color that must not be updated
  81491. */
  81492. static get BlackReadOnly(): DeepImmutable<Color3>;
  81493. /**
  81494. * Returns a Color3 value containing a white color
  81495. * @returns a new Color3 object
  81496. */
  81497. static White(): Color3;
  81498. /**
  81499. * Returns a Color3 value containing a purple color
  81500. * @returns a new Color3 object
  81501. */
  81502. static Purple(): Color3;
  81503. /**
  81504. * Returns a Color3 value containing a magenta color
  81505. * @returns a new Color3 object
  81506. */
  81507. static Magenta(): Color3;
  81508. /**
  81509. * Returns a Color3 value containing a yellow color
  81510. * @returns a new Color3 object
  81511. */
  81512. static Yellow(): Color3;
  81513. /**
  81514. * Returns a Color3 value containing a gray color
  81515. * @returns a new Color3 object
  81516. */
  81517. static Gray(): Color3;
  81518. /**
  81519. * Returns a Color3 value containing a teal color
  81520. * @returns a new Color3 object
  81521. */
  81522. static Teal(): Color3;
  81523. /**
  81524. * Returns a Color3 value containing a random color
  81525. * @returns a new Color3 object
  81526. */
  81527. static Random(): Color3;
  81528. }
  81529. /**
  81530. * Class used to hold a RBGA color
  81531. */
  81532. export class Color4 {
  81533. /**
  81534. * Defines the red component (between 0 and 1, default is 0)
  81535. */
  81536. r: number;
  81537. /**
  81538. * Defines the green component (between 0 and 1, default is 0)
  81539. */
  81540. g: number;
  81541. /**
  81542. * Defines the blue component (between 0 and 1, default is 0)
  81543. */
  81544. b: number;
  81545. /**
  81546. * Defines the alpha component (between 0 and 1, default is 1)
  81547. */
  81548. a: number;
  81549. /**
  81550. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  81551. * @param r defines the red component (between 0 and 1, default is 0)
  81552. * @param g defines the green component (between 0 and 1, default is 0)
  81553. * @param b defines the blue component (between 0 and 1, default is 0)
  81554. * @param a defines the alpha component (between 0 and 1, default is 1)
  81555. */
  81556. constructor(
  81557. /**
  81558. * Defines the red component (between 0 and 1, default is 0)
  81559. */
  81560. r?: number,
  81561. /**
  81562. * Defines the green component (between 0 and 1, default is 0)
  81563. */
  81564. g?: number,
  81565. /**
  81566. * Defines the blue component (between 0 and 1, default is 0)
  81567. */
  81568. b?: number,
  81569. /**
  81570. * Defines the alpha component (between 0 and 1, default is 1)
  81571. */
  81572. a?: number);
  81573. /**
  81574. * Adds in place the given Color4 values to the current Color4 object
  81575. * @param right defines the second operand
  81576. * @returns the current updated Color4 object
  81577. */
  81578. addInPlace(right: DeepImmutable<Color4>): Color4;
  81579. /**
  81580. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  81581. * @returns the new array
  81582. */
  81583. asArray(): number[];
  81584. /**
  81585. * Stores from the starting index in the given array the Color4 successive values
  81586. * @param array defines the array where to store the r,g,b components
  81587. * @param index defines an optional index in the target array to define where to start storing values
  81588. * @returns the current Color4 object
  81589. */
  81590. toArray(array: number[], index?: number): Color4;
  81591. /**
  81592. * Determines equality between Color4 objects
  81593. * @param otherColor defines the second operand
  81594. * @returns true if the rgba values are equal to the given ones
  81595. */
  81596. equals(otherColor: DeepImmutable<Color4>): boolean;
  81597. /**
  81598. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  81599. * @param right defines the second operand
  81600. * @returns a new Color4 object
  81601. */
  81602. add(right: DeepImmutable<Color4>): Color4;
  81603. /**
  81604. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  81605. * @param right defines the second operand
  81606. * @returns a new Color4 object
  81607. */
  81608. subtract(right: DeepImmutable<Color4>): Color4;
  81609. /**
  81610. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  81611. * @param right defines the second operand
  81612. * @param result defines the Color4 object where to store the result
  81613. * @returns the current Color4 object
  81614. */
  81615. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  81616. /**
  81617. * Creates a new Color4 with the current Color4 values multiplied by scale
  81618. * @param scale defines the scaling factor to apply
  81619. * @returns a new Color4 object
  81620. */
  81621. scale(scale: number): Color4;
  81622. /**
  81623. * Multiplies the current Color4 values by scale and stores the result in "result"
  81624. * @param scale defines the scaling factor to apply
  81625. * @param result defines the Color4 object where to store the result
  81626. * @returns the current unmodified Color4
  81627. */
  81628. scaleToRef(scale: number, result: Color4): Color4;
  81629. /**
  81630. * Scale the current Color4 values by a factor and add the result to a given Color4
  81631. * @param scale defines the scale factor
  81632. * @param result defines the Color4 object where to store the result
  81633. * @returns the unmodified current Color4
  81634. */
  81635. scaleAndAddToRef(scale: number, result: Color4): Color4;
  81636. /**
  81637. * Clamps the rgb values by the min and max values and stores the result into "result"
  81638. * @param min defines minimum clamping value (default is 0)
  81639. * @param max defines maximum clamping value (default is 1)
  81640. * @param result defines color to store the result into.
  81641. * @returns the cuurent Color4
  81642. */
  81643. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  81644. /**
  81645. * Multipy an Color4 value by another and return a new Color4 object
  81646. * @param color defines the Color4 value to multiply by
  81647. * @returns a new Color4 object
  81648. */
  81649. multiply(color: Color4): Color4;
  81650. /**
  81651. * Multipy a Color4 value by another and push the result in a reference value
  81652. * @param color defines the Color4 value to multiply by
  81653. * @param result defines the Color4 to fill the result in
  81654. * @returns the result Color4
  81655. */
  81656. multiplyToRef(color: Color4, result: Color4): Color4;
  81657. /**
  81658. * Creates a string with the Color4 current values
  81659. * @returns the string representation of the Color4 object
  81660. */
  81661. toString(): string;
  81662. /**
  81663. * Returns the string "Color4"
  81664. * @returns "Color4"
  81665. */
  81666. getClassName(): string;
  81667. /**
  81668. * Compute the Color4 hash code
  81669. * @returns an unique number that can be used to hash Color4 objects
  81670. */
  81671. getHashCode(): number;
  81672. /**
  81673. * Creates a new Color4 copied from the current one
  81674. * @returns a new Color4 object
  81675. */
  81676. clone(): Color4;
  81677. /**
  81678. * Copies the given Color4 values into the current one
  81679. * @param source defines the source Color4 object
  81680. * @returns the current updated Color4 object
  81681. */
  81682. copyFrom(source: Color4): Color4;
  81683. /**
  81684. * Copies the given float values into the current one
  81685. * @param r defines the red component to read from
  81686. * @param g defines the green component to read from
  81687. * @param b defines the blue component to read from
  81688. * @param a defines the alpha component to read from
  81689. * @returns the current updated Color4 object
  81690. */
  81691. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  81692. /**
  81693. * Copies the given float values into the current one
  81694. * @param r defines the red component to read from
  81695. * @param g defines the green component to read from
  81696. * @param b defines the blue component to read from
  81697. * @param a defines the alpha component to read from
  81698. * @returns the current updated Color4 object
  81699. */
  81700. set(r: number, g: number, b: number, a: number): Color4;
  81701. /**
  81702. * Compute the Color4 hexadecimal code as a string
  81703. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  81704. * @returns a string containing the hexadecimal representation of the Color4 object
  81705. */
  81706. toHexString(returnAsColor3?: boolean): string;
  81707. /**
  81708. * Computes a new Color4 converted from the current one to linear space
  81709. * @returns a new Color4 object
  81710. */
  81711. toLinearSpace(): Color4;
  81712. /**
  81713. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  81714. * @param convertedColor defines the Color4 object where to store the linear space version
  81715. * @returns the unmodified Color4
  81716. */
  81717. toLinearSpaceToRef(convertedColor: Color4): Color4;
  81718. /**
  81719. * Computes a new Color4 converted from the current one to gamma space
  81720. * @returns a new Color4 object
  81721. */
  81722. toGammaSpace(): Color4;
  81723. /**
  81724. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  81725. * @param convertedColor defines the Color4 object where to store the gamma space version
  81726. * @returns the unmodified Color4
  81727. */
  81728. toGammaSpaceToRef(convertedColor: Color4): Color4;
  81729. /**
  81730. * Creates a new Color4 from the string containing valid hexadecimal values
  81731. * @param hex defines a string containing valid hexadecimal values
  81732. * @returns a new Color4 object
  81733. */
  81734. static FromHexString(hex: string): Color4;
  81735. /**
  81736. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81737. * @param left defines the start value
  81738. * @param right defines the end value
  81739. * @param amount defines the gradient factor
  81740. * @returns a new Color4 object
  81741. */
  81742. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  81743. /**
  81744. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  81745. * @param left defines the start value
  81746. * @param right defines the end value
  81747. * @param amount defines the gradient factor
  81748. * @param result defines the Color4 object where to store data
  81749. */
  81750. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  81751. /**
  81752. * Creates a new Color4 from a Color3 and an alpha value
  81753. * @param color3 defines the source Color3 to read from
  81754. * @param alpha defines the alpha component (1.0 by default)
  81755. * @returns a new Color4 object
  81756. */
  81757. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  81758. /**
  81759. * Creates a new Color4 from the starting index element of the given array
  81760. * @param array defines the source array to read from
  81761. * @param offset defines the offset in the source array
  81762. * @returns a new Color4 object
  81763. */
  81764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  81765. /**
  81766. * Creates a new Color3 from integer values (< 256)
  81767. * @param r defines the red component to read from (value between 0 and 255)
  81768. * @param g defines the green component to read from (value between 0 and 255)
  81769. * @param b defines the blue component to read from (value between 0 and 255)
  81770. * @param a defines the alpha component to read from (value between 0 and 255)
  81771. * @returns a new Color3 object
  81772. */
  81773. static FromInts(r: number, g: number, b: number, a: number): Color4;
  81774. /**
  81775. * Check the content of a given array and convert it to an array containing RGBA data
  81776. * If the original array was already containing count * 4 values then it is returned directly
  81777. * @param colors defines the array to check
  81778. * @param count defines the number of RGBA data to expect
  81779. * @returns an array containing count * 4 values (RGBA)
  81780. */
  81781. static CheckColors4(colors: number[], count: number): number[];
  81782. }
  81783. /**
  81784. * @hidden
  81785. */
  81786. export class TmpColors {
  81787. static Color3: Color3[];
  81788. static Color4: Color4[];
  81789. }
  81790. }
  81791. declare module BABYLON {
  81792. /**
  81793. * Defines an interface which represents an animation key frame
  81794. */
  81795. export interface IAnimationKey {
  81796. /**
  81797. * Frame of the key frame
  81798. */
  81799. frame: number;
  81800. /**
  81801. * Value at the specifies key frame
  81802. */
  81803. value: any;
  81804. /**
  81805. * The input tangent for the cubic hermite spline
  81806. */
  81807. inTangent?: any;
  81808. /**
  81809. * The output tangent for the cubic hermite spline
  81810. */
  81811. outTangent?: any;
  81812. /**
  81813. * The animation interpolation type
  81814. */
  81815. interpolation?: AnimationKeyInterpolation;
  81816. }
  81817. /**
  81818. * Enum for the animation key frame interpolation type
  81819. */
  81820. export enum AnimationKeyInterpolation {
  81821. /**
  81822. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  81823. */
  81824. STEP = 1
  81825. }
  81826. }
  81827. declare module BABYLON {
  81828. /**
  81829. * Represents the range of an animation
  81830. */
  81831. export class AnimationRange {
  81832. /**The name of the animation range**/
  81833. name: string;
  81834. /**The starting frame of the animation */
  81835. from: number;
  81836. /**The ending frame of the animation*/
  81837. to: number;
  81838. /**
  81839. * Initializes the range of an animation
  81840. * @param name The name of the animation range
  81841. * @param from The starting frame of the animation
  81842. * @param to The ending frame of the animation
  81843. */
  81844. constructor(
  81845. /**The name of the animation range**/
  81846. name: string,
  81847. /**The starting frame of the animation */
  81848. from: number,
  81849. /**The ending frame of the animation*/
  81850. to: number);
  81851. /**
  81852. * Makes a copy of the animation range
  81853. * @returns A copy of the animation range
  81854. */
  81855. clone(): AnimationRange;
  81856. }
  81857. }
  81858. declare module BABYLON {
  81859. /**
  81860. * Composed of a frame, and an action function
  81861. */
  81862. export class AnimationEvent {
  81863. /** The frame for which the event is triggered **/
  81864. frame: number;
  81865. /** The event to perform when triggered **/
  81866. action: (currentFrame: number) => void;
  81867. /** Specifies if the event should be triggered only once**/
  81868. onlyOnce?: boolean | undefined;
  81869. /**
  81870. * Specifies if the animation event is done
  81871. */
  81872. isDone: boolean;
  81873. /**
  81874. * Initializes the animation event
  81875. * @param frame The frame for which the event is triggered
  81876. * @param action The event to perform when triggered
  81877. * @param onlyOnce Specifies if the event should be triggered only once
  81878. */
  81879. constructor(
  81880. /** The frame for which the event is triggered **/
  81881. frame: number,
  81882. /** The event to perform when triggered **/
  81883. action: (currentFrame: number) => void,
  81884. /** Specifies if the event should be triggered only once**/
  81885. onlyOnce?: boolean | undefined);
  81886. /** @hidden */
  81887. _clone(): AnimationEvent;
  81888. }
  81889. }
  81890. declare module BABYLON {
  81891. /**
  81892. * Interface used to define a behavior
  81893. */
  81894. export interface Behavior<T> {
  81895. /** gets or sets behavior's name */
  81896. name: string;
  81897. /**
  81898. * Function called when the behavior needs to be initialized (after attaching it to a target)
  81899. */
  81900. init(): void;
  81901. /**
  81902. * Called when the behavior is attached to a target
  81903. * @param target defines the target where the behavior is attached to
  81904. */
  81905. attach(target: T): void;
  81906. /**
  81907. * Called when the behavior is detached from its target
  81908. */
  81909. detach(): void;
  81910. }
  81911. /**
  81912. * Interface implemented by classes supporting behaviors
  81913. */
  81914. export interface IBehaviorAware<T> {
  81915. /**
  81916. * Attach a behavior
  81917. * @param behavior defines the behavior to attach
  81918. * @returns the current host
  81919. */
  81920. addBehavior(behavior: Behavior<T>): T;
  81921. /**
  81922. * Remove a behavior from the current object
  81923. * @param behavior defines the behavior to detach
  81924. * @returns the current host
  81925. */
  81926. removeBehavior(behavior: Behavior<T>): T;
  81927. /**
  81928. * Gets a behavior using its name to search
  81929. * @param name defines the name to search
  81930. * @returns the behavior or null if not found
  81931. */
  81932. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  81933. }
  81934. }
  81935. declare module BABYLON {
  81936. /**
  81937. * Defines an array and its length.
  81938. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  81939. */
  81940. export interface ISmartArrayLike<T> {
  81941. /**
  81942. * The data of the array.
  81943. */
  81944. data: Array<T>;
  81945. /**
  81946. * The active length of the array.
  81947. */
  81948. length: number;
  81949. }
  81950. /**
  81951. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  81952. */
  81953. export class SmartArray<T> implements ISmartArrayLike<T> {
  81954. /**
  81955. * The full set of data from the array.
  81956. */
  81957. data: Array<T>;
  81958. /**
  81959. * The active length of the array.
  81960. */
  81961. length: number;
  81962. protected _id: number;
  81963. /**
  81964. * Instantiates a Smart Array.
  81965. * @param capacity defines the default capacity of the array.
  81966. */
  81967. constructor(capacity: number);
  81968. /**
  81969. * Pushes a value at the end of the active data.
  81970. * @param value defines the object to push in the array.
  81971. */
  81972. push(value: T): void;
  81973. /**
  81974. * Iterates over the active data and apply the lambda to them.
  81975. * @param func defines the action to apply on each value.
  81976. */
  81977. forEach(func: (content: T) => void): void;
  81978. /**
  81979. * Sorts the full sets of data.
  81980. * @param compareFn defines the comparison function to apply.
  81981. */
  81982. sort(compareFn: (a: T, b: T) => number): void;
  81983. /**
  81984. * Resets the active data to an empty array.
  81985. */
  81986. reset(): void;
  81987. /**
  81988. * Releases all the data from the array as well as the array.
  81989. */
  81990. dispose(): void;
  81991. /**
  81992. * Concats the active data with a given array.
  81993. * @param array defines the data to concatenate with.
  81994. */
  81995. concat(array: any): void;
  81996. /**
  81997. * Returns the position of a value in the active data.
  81998. * @param value defines the value to find the index for
  81999. * @returns the index if found in the active data otherwise -1
  82000. */
  82001. indexOf(value: T): number;
  82002. /**
  82003. * Returns whether an element is part of the active data.
  82004. * @param value defines the value to look for
  82005. * @returns true if found in the active data otherwise false
  82006. */
  82007. contains(value: T): boolean;
  82008. private static _GlobalId;
  82009. }
  82010. /**
  82011. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  82012. * The data in this array can only be present once
  82013. */
  82014. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  82015. private _duplicateId;
  82016. /**
  82017. * Pushes a value at the end of the active data.
  82018. * THIS DOES NOT PREVENT DUPPLICATE DATA
  82019. * @param value defines the object to push in the array.
  82020. */
  82021. push(value: T): void;
  82022. /**
  82023. * Pushes a value at the end of the active data.
  82024. * If the data is already present, it won t be added again
  82025. * @param value defines the object to push in the array.
  82026. * @returns true if added false if it was already present
  82027. */
  82028. pushNoDuplicate(value: T): boolean;
  82029. /**
  82030. * Resets the active data to an empty array.
  82031. */
  82032. reset(): void;
  82033. /**
  82034. * Concats the active data with a given array.
  82035. * This ensures no dupplicate will be present in the result.
  82036. * @param array defines the data to concatenate with.
  82037. */
  82038. concatWithNoDuplicate(array: any): void;
  82039. }
  82040. }
  82041. declare module BABYLON {
  82042. /**
  82043. * @ignore
  82044. * This is a list of all the different input types that are available in the application.
  82045. * Fo instance: ArcRotateCameraGamepadInput...
  82046. */
  82047. export var CameraInputTypes: {};
  82048. /**
  82049. * This is the contract to implement in order to create a new input class.
  82050. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  82051. */
  82052. export interface ICameraInput<TCamera extends Camera> {
  82053. /**
  82054. * Defines the camera the input is attached to.
  82055. */
  82056. camera: Nullable<TCamera>;
  82057. /**
  82058. * Gets the class name of the current intput.
  82059. * @returns the class name
  82060. */
  82061. getClassName(): string;
  82062. /**
  82063. * Get the friendly name associated with the input class.
  82064. * @returns the input friendly name
  82065. */
  82066. getSimpleName(): string;
  82067. /**
  82068. * Attach the input controls to a specific dom element to get the input from.
  82069. * @param element Defines the element the controls should be listened from
  82070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82071. */
  82072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82073. /**
  82074. * Detach the current controls from the specified dom element.
  82075. * @param element Defines the element to stop listening the inputs from
  82076. */
  82077. detachControl(element: Nullable<HTMLElement>): void;
  82078. /**
  82079. * Update the current camera state depending on the inputs that have been used this frame.
  82080. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82081. */
  82082. checkInputs?: () => void;
  82083. }
  82084. /**
  82085. * Represents a map of input types to input instance or input index to input instance.
  82086. */
  82087. export interface CameraInputsMap<TCamera extends Camera> {
  82088. /**
  82089. * Accessor to the input by input type.
  82090. */
  82091. [name: string]: ICameraInput<TCamera>;
  82092. /**
  82093. * Accessor to the input by input index.
  82094. */
  82095. [idx: number]: ICameraInput<TCamera>;
  82096. }
  82097. /**
  82098. * This represents the input manager used within a camera.
  82099. * It helps dealing with all the different kind of input attached to a camera.
  82100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82101. */
  82102. export class CameraInputsManager<TCamera extends Camera> {
  82103. /**
  82104. * Defines the list of inputs attahed to the camera.
  82105. */
  82106. attached: CameraInputsMap<TCamera>;
  82107. /**
  82108. * Defines the dom element the camera is collecting inputs from.
  82109. * This is null if the controls have not been attached.
  82110. */
  82111. attachedElement: Nullable<HTMLElement>;
  82112. /**
  82113. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82114. */
  82115. noPreventDefault: boolean;
  82116. /**
  82117. * Defined the camera the input manager belongs to.
  82118. */
  82119. camera: TCamera;
  82120. /**
  82121. * Update the current camera state depending on the inputs that have been used this frame.
  82122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82123. */
  82124. checkInputs: () => void;
  82125. /**
  82126. * Instantiate a new Camera Input Manager.
  82127. * @param camera Defines the camera the input manager blongs to
  82128. */
  82129. constructor(camera: TCamera);
  82130. /**
  82131. * Add an input method to a camera
  82132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82133. * @param input camera input method
  82134. */
  82135. add(input: ICameraInput<TCamera>): void;
  82136. /**
  82137. * Remove a specific input method from a camera
  82138. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  82139. * @param inputToRemove camera input method
  82140. */
  82141. remove(inputToRemove: ICameraInput<TCamera>): void;
  82142. /**
  82143. * Remove a specific input type from a camera
  82144. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  82145. * @param inputType the type of the input to remove
  82146. */
  82147. removeByType(inputType: string): void;
  82148. private _addCheckInputs;
  82149. /**
  82150. * Attach the input controls to the currently attached dom element to listen the events from.
  82151. * @param input Defines the input to attach
  82152. */
  82153. attachInput(input: ICameraInput<TCamera>): void;
  82154. /**
  82155. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  82156. * @param element Defines the dom element to collect the events from
  82157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82158. */
  82159. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  82160. /**
  82161. * Detach the current manager inputs controls from a specific dom element.
  82162. * @param element Defines the dom element to collect the events from
  82163. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  82164. */
  82165. detachElement(element: HTMLElement, disconnect?: boolean): void;
  82166. /**
  82167. * Rebuild the dynamic inputCheck function from the current list of
  82168. * defined inputs in the manager.
  82169. */
  82170. rebuildInputCheck(): void;
  82171. /**
  82172. * Remove all attached input methods from a camera
  82173. */
  82174. clear(): void;
  82175. /**
  82176. * Serialize the current input manager attached to a camera.
  82177. * This ensures than once parsed,
  82178. * the input associated to the camera will be identical to the current ones
  82179. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  82180. */
  82181. serialize(serializedCamera: any): void;
  82182. /**
  82183. * Parses an input manager serialized JSON to restore the previous list of inputs
  82184. * and states associated to a camera.
  82185. * @param parsedCamera Defines the JSON to parse
  82186. */
  82187. parse(parsedCamera: any): void;
  82188. }
  82189. }
  82190. declare module BABYLON {
  82191. /**
  82192. * Class used to store data that will be store in GPU memory
  82193. */
  82194. export class Buffer {
  82195. private _engine;
  82196. private _buffer;
  82197. /** @hidden */
  82198. _data: Nullable<DataArray>;
  82199. private _updatable;
  82200. private _instanced;
  82201. private _divisor;
  82202. /**
  82203. * Gets the byte stride.
  82204. */
  82205. readonly byteStride: number;
  82206. /**
  82207. * Constructor
  82208. * @param engine the engine
  82209. * @param data the data to use for this buffer
  82210. * @param updatable whether the data is updatable
  82211. * @param stride the stride (optional)
  82212. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82213. * @param instanced whether the buffer is instanced (optional)
  82214. * @param useBytes set to true if the stride in in bytes (optional)
  82215. * @param divisor sets an optional divisor for instances (1 by default)
  82216. */
  82217. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  82218. /**
  82219. * Create a new VertexBuffer based on the current buffer
  82220. * @param kind defines the vertex buffer kind (position, normal, etc.)
  82221. * @param offset defines offset in the buffer (0 by default)
  82222. * @param size defines the size in floats of attributes (position is 3 for instance)
  82223. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  82224. * @param instanced defines if the vertex buffer contains indexed data
  82225. * @param useBytes defines if the offset and stride are in bytes *
  82226. * @param divisor sets an optional divisor for instances (1 by default)
  82227. * @returns the new vertex buffer
  82228. */
  82229. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  82230. /**
  82231. * Gets a boolean indicating if the Buffer is updatable?
  82232. * @returns true if the buffer is updatable
  82233. */
  82234. isUpdatable(): boolean;
  82235. /**
  82236. * Gets current buffer's data
  82237. * @returns a DataArray or null
  82238. */
  82239. getData(): Nullable<DataArray>;
  82240. /**
  82241. * Gets underlying native buffer
  82242. * @returns underlying native buffer
  82243. */
  82244. getBuffer(): Nullable<DataBuffer>;
  82245. /**
  82246. * Gets the stride in float32 units (i.e. byte stride / 4).
  82247. * May not be an integer if the byte stride is not divisible by 4.
  82248. * @returns the stride in float32 units
  82249. * @deprecated Please use byteStride instead.
  82250. */
  82251. getStrideSize(): number;
  82252. /**
  82253. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82254. * @param data defines the data to store
  82255. */
  82256. create(data?: Nullable<DataArray>): void;
  82257. /** @hidden */
  82258. _rebuild(): void;
  82259. /**
  82260. * Update current buffer data
  82261. * @param data defines the data to store
  82262. */
  82263. update(data: DataArray): void;
  82264. /**
  82265. * Updates the data directly.
  82266. * @param data the new data
  82267. * @param offset the new offset
  82268. * @param vertexCount the vertex count (optional)
  82269. * @param useBytes set to true if the offset is in bytes
  82270. */
  82271. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  82272. /**
  82273. * Release all resources
  82274. */
  82275. dispose(): void;
  82276. }
  82277. /**
  82278. * Specialized buffer used to store vertex data
  82279. */
  82280. export class VertexBuffer {
  82281. /** @hidden */
  82282. _buffer: Buffer;
  82283. private _kind;
  82284. private _size;
  82285. private _ownsBuffer;
  82286. private _instanced;
  82287. private _instanceDivisor;
  82288. /**
  82289. * The byte type.
  82290. */
  82291. static readonly BYTE: number;
  82292. /**
  82293. * The unsigned byte type.
  82294. */
  82295. static readonly UNSIGNED_BYTE: number;
  82296. /**
  82297. * The short type.
  82298. */
  82299. static readonly SHORT: number;
  82300. /**
  82301. * The unsigned short type.
  82302. */
  82303. static readonly UNSIGNED_SHORT: number;
  82304. /**
  82305. * The integer type.
  82306. */
  82307. static readonly INT: number;
  82308. /**
  82309. * The unsigned integer type.
  82310. */
  82311. static readonly UNSIGNED_INT: number;
  82312. /**
  82313. * The float type.
  82314. */
  82315. static readonly FLOAT: number;
  82316. /**
  82317. * Gets or sets the instance divisor when in instanced mode
  82318. */
  82319. get instanceDivisor(): number;
  82320. set instanceDivisor(value: number);
  82321. /**
  82322. * Gets the byte stride.
  82323. */
  82324. readonly byteStride: number;
  82325. /**
  82326. * Gets the byte offset.
  82327. */
  82328. readonly byteOffset: number;
  82329. /**
  82330. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  82331. */
  82332. readonly normalized: boolean;
  82333. /**
  82334. * Gets the data type of each component in the array.
  82335. */
  82336. readonly type: number;
  82337. /**
  82338. * Constructor
  82339. * @param engine the engine
  82340. * @param data the data to use for this vertex buffer
  82341. * @param kind the vertex buffer kind
  82342. * @param updatable whether the data is updatable
  82343. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  82344. * @param stride the stride (optional)
  82345. * @param instanced whether the buffer is instanced (optional)
  82346. * @param offset the offset of the data (optional)
  82347. * @param size the number of components (optional)
  82348. * @param type the type of the component (optional)
  82349. * @param normalized whether the data contains normalized data (optional)
  82350. * @param useBytes set to true if stride and offset are in bytes (optional)
  82351. * @param divisor defines the instance divisor to use (1 by default)
  82352. */
  82353. 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);
  82354. /** @hidden */
  82355. _rebuild(): void;
  82356. /**
  82357. * Returns the kind of the VertexBuffer (string)
  82358. * @returns a string
  82359. */
  82360. getKind(): string;
  82361. /**
  82362. * Gets a boolean indicating if the VertexBuffer is updatable?
  82363. * @returns true if the buffer is updatable
  82364. */
  82365. isUpdatable(): boolean;
  82366. /**
  82367. * Gets current buffer's data
  82368. * @returns a DataArray or null
  82369. */
  82370. getData(): Nullable<DataArray>;
  82371. /**
  82372. * Gets underlying native buffer
  82373. * @returns underlying native buffer
  82374. */
  82375. getBuffer(): Nullable<DataBuffer>;
  82376. /**
  82377. * Gets the stride in float32 units (i.e. byte stride / 4).
  82378. * May not be an integer if the byte stride is not divisible by 4.
  82379. * @returns the stride in float32 units
  82380. * @deprecated Please use byteStride instead.
  82381. */
  82382. getStrideSize(): number;
  82383. /**
  82384. * Returns the offset as a multiple of the type byte length.
  82385. * @returns the offset in bytes
  82386. * @deprecated Please use byteOffset instead.
  82387. */
  82388. getOffset(): number;
  82389. /**
  82390. * Returns the number of components per vertex attribute (integer)
  82391. * @returns the size in float
  82392. */
  82393. getSize(): number;
  82394. /**
  82395. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  82396. * @returns true if this buffer is instanced
  82397. */
  82398. getIsInstanced(): boolean;
  82399. /**
  82400. * Returns the instancing divisor, zero for non-instanced (integer).
  82401. * @returns a number
  82402. */
  82403. getInstanceDivisor(): number;
  82404. /**
  82405. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  82406. * @param data defines the data to store
  82407. */
  82408. create(data?: DataArray): void;
  82409. /**
  82410. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  82411. * This function will create a new buffer if the current one is not updatable
  82412. * @param data defines the data to store
  82413. */
  82414. update(data: DataArray): void;
  82415. /**
  82416. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  82417. * Returns the directly updated WebGLBuffer.
  82418. * @param data the new data
  82419. * @param offset the new offset
  82420. * @param useBytes set to true if the offset is in bytes
  82421. */
  82422. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  82423. /**
  82424. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  82425. */
  82426. dispose(): void;
  82427. /**
  82428. * Enumerates each value of this vertex buffer as numbers.
  82429. * @param count the number of values to enumerate
  82430. * @param callback the callback function called for each value
  82431. */
  82432. forEach(count: number, callback: (value: number, index: number) => void): void;
  82433. /**
  82434. * Positions
  82435. */
  82436. static readonly PositionKind: string;
  82437. /**
  82438. * Normals
  82439. */
  82440. static readonly NormalKind: string;
  82441. /**
  82442. * Tangents
  82443. */
  82444. static readonly TangentKind: string;
  82445. /**
  82446. * Texture coordinates
  82447. */
  82448. static readonly UVKind: string;
  82449. /**
  82450. * Texture coordinates 2
  82451. */
  82452. static readonly UV2Kind: string;
  82453. /**
  82454. * Texture coordinates 3
  82455. */
  82456. static readonly UV3Kind: string;
  82457. /**
  82458. * Texture coordinates 4
  82459. */
  82460. static readonly UV4Kind: string;
  82461. /**
  82462. * Texture coordinates 5
  82463. */
  82464. static readonly UV5Kind: string;
  82465. /**
  82466. * Texture coordinates 6
  82467. */
  82468. static readonly UV6Kind: string;
  82469. /**
  82470. * Colors
  82471. */
  82472. static readonly ColorKind: string;
  82473. /**
  82474. * Matrix indices (for bones)
  82475. */
  82476. static readonly MatricesIndicesKind: string;
  82477. /**
  82478. * Matrix weights (for bones)
  82479. */
  82480. static readonly MatricesWeightsKind: string;
  82481. /**
  82482. * Additional matrix indices (for bones)
  82483. */
  82484. static readonly MatricesIndicesExtraKind: string;
  82485. /**
  82486. * Additional matrix weights (for bones)
  82487. */
  82488. static readonly MatricesWeightsExtraKind: string;
  82489. /**
  82490. * Deduces the stride given a kind.
  82491. * @param kind The kind string to deduce
  82492. * @returns The deduced stride
  82493. */
  82494. static DeduceStride(kind: string): number;
  82495. /**
  82496. * Gets the byte length of the given type.
  82497. * @param type the type
  82498. * @returns the number of bytes
  82499. */
  82500. static GetTypeByteLength(type: number): number;
  82501. /**
  82502. * Enumerates each value of the given parameters as numbers.
  82503. * @param data the data to enumerate
  82504. * @param byteOffset the byte offset of the data
  82505. * @param byteStride the byte stride of the data
  82506. * @param componentCount the number of components per element
  82507. * @param componentType the type of the component
  82508. * @param count the number of values to enumerate
  82509. * @param normalized whether the data is normalized
  82510. * @param callback the callback function called for each value
  82511. */
  82512. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  82513. private static _GetFloatValue;
  82514. }
  82515. }
  82516. declare module BABYLON {
  82517. /**
  82518. * @hidden
  82519. */
  82520. export class IntersectionInfo {
  82521. bu: Nullable<number>;
  82522. bv: Nullable<number>;
  82523. distance: number;
  82524. faceId: number;
  82525. subMeshId: number;
  82526. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  82527. }
  82528. }
  82529. declare module BABYLON {
  82530. /**
  82531. * Class used to store bounding sphere information
  82532. */
  82533. export class BoundingSphere {
  82534. /**
  82535. * Gets the center of the bounding sphere in local space
  82536. */
  82537. readonly center: Vector3;
  82538. /**
  82539. * Radius of the bounding sphere in local space
  82540. */
  82541. radius: number;
  82542. /**
  82543. * Gets the center of the bounding sphere in world space
  82544. */
  82545. readonly centerWorld: Vector3;
  82546. /**
  82547. * Radius of the bounding sphere in world space
  82548. */
  82549. radiusWorld: number;
  82550. /**
  82551. * Gets the minimum vector in local space
  82552. */
  82553. readonly minimum: Vector3;
  82554. /**
  82555. * Gets the maximum vector in local space
  82556. */
  82557. readonly maximum: Vector3;
  82558. private _worldMatrix;
  82559. private static readonly TmpVector3;
  82560. /**
  82561. * Creates a new bounding sphere
  82562. * @param min defines the minimum vector (in local space)
  82563. * @param max defines the maximum vector (in local space)
  82564. * @param worldMatrix defines the new world matrix
  82565. */
  82566. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82567. /**
  82568. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  82569. * @param min defines the new minimum vector (in local space)
  82570. * @param max defines the new maximum vector (in local space)
  82571. * @param worldMatrix defines the new world matrix
  82572. */
  82573. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82574. /**
  82575. * Scale the current bounding sphere by applying a scale factor
  82576. * @param factor defines the scale factor to apply
  82577. * @returns the current bounding box
  82578. */
  82579. scale(factor: number): BoundingSphere;
  82580. /**
  82581. * Gets the world matrix of the bounding box
  82582. * @returns a matrix
  82583. */
  82584. getWorldMatrix(): DeepImmutable<Matrix>;
  82585. /** @hidden */
  82586. _update(worldMatrix: DeepImmutable<Matrix>): void;
  82587. /**
  82588. * Tests if the bounding sphere is intersecting the frustum planes
  82589. * @param frustumPlanes defines the frustum planes to test
  82590. * @returns true if there is an intersection
  82591. */
  82592. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82593. /**
  82594. * Tests if the bounding sphere center is in between the frustum planes.
  82595. * Used for optimistic fast inclusion.
  82596. * @param frustumPlanes defines the frustum planes to test
  82597. * @returns true if the sphere center is in between the frustum planes
  82598. */
  82599. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82600. /**
  82601. * Tests if a point is inside the bounding sphere
  82602. * @param point defines the point to test
  82603. * @returns true if the point is inside the bounding sphere
  82604. */
  82605. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82606. /**
  82607. * Checks if two sphere intersct
  82608. * @param sphere0 sphere 0
  82609. * @param sphere1 sphere 1
  82610. * @returns true if the speres intersect
  82611. */
  82612. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  82613. }
  82614. }
  82615. declare module BABYLON {
  82616. /**
  82617. * Class used to store bounding box information
  82618. */
  82619. export class BoundingBox implements ICullable {
  82620. /**
  82621. * Gets the 8 vectors representing the bounding box in local space
  82622. */
  82623. readonly vectors: Vector3[];
  82624. /**
  82625. * Gets the center of the bounding box in local space
  82626. */
  82627. readonly center: Vector3;
  82628. /**
  82629. * Gets the center of the bounding box in world space
  82630. */
  82631. readonly centerWorld: Vector3;
  82632. /**
  82633. * Gets the extend size in local space
  82634. */
  82635. readonly extendSize: Vector3;
  82636. /**
  82637. * Gets the extend size in world space
  82638. */
  82639. readonly extendSizeWorld: Vector3;
  82640. /**
  82641. * Gets the OBB (object bounding box) directions
  82642. */
  82643. readonly directions: Vector3[];
  82644. /**
  82645. * Gets the 8 vectors representing the bounding box in world space
  82646. */
  82647. readonly vectorsWorld: Vector3[];
  82648. /**
  82649. * Gets the minimum vector in world space
  82650. */
  82651. readonly minimumWorld: Vector3;
  82652. /**
  82653. * Gets the maximum vector in world space
  82654. */
  82655. readonly maximumWorld: Vector3;
  82656. /**
  82657. * Gets the minimum vector in local space
  82658. */
  82659. readonly minimum: Vector3;
  82660. /**
  82661. * Gets the maximum vector in local space
  82662. */
  82663. readonly maximum: Vector3;
  82664. private _worldMatrix;
  82665. private static readonly TmpVector3;
  82666. /**
  82667. * @hidden
  82668. */
  82669. _tag: number;
  82670. /**
  82671. * Creates a new bounding box
  82672. * @param min defines the minimum vector (in local space)
  82673. * @param max defines the maximum vector (in local space)
  82674. * @param worldMatrix defines the new world matrix
  82675. */
  82676. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82677. /**
  82678. * Recreates the entire bounding box from scratch as if we call the constructor in place
  82679. * @param min defines the new minimum vector (in local space)
  82680. * @param max defines the new maximum vector (in local space)
  82681. * @param worldMatrix defines the new world matrix
  82682. */
  82683. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82684. /**
  82685. * Scale the current bounding box by applying a scale factor
  82686. * @param factor defines the scale factor to apply
  82687. * @returns the current bounding box
  82688. */
  82689. scale(factor: number): BoundingBox;
  82690. /**
  82691. * Gets the world matrix of the bounding box
  82692. * @returns a matrix
  82693. */
  82694. getWorldMatrix(): DeepImmutable<Matrix>;
  82695. /** @hidden */
  82696. _update(world: DeepImmutable<Matrix>): void;
  82697. /**
  82698. * Tests if the bounding box is intersecting the frustum planes
  82699. * @param frustumPlanes defines the frustum planes to test
  82700. * @returns true if there is an intersection
  82701. */
  82702. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82703. /**
  82704. * Tests if the bounding box is entirely inside the frustum planes
  82705. * @param frustumPlanes defines the frustum planes to test
  82706. * @returns true if there is an inclusion
  82707. */
  82708. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82709. /**
  82710. * Tests if a point is inside the bounding box
  82711. * @param point defines the point to test
  82712. * @returns true if the point is inside the bounding box
  82713. */
  82714. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82715. /**
  82716. * Tests if the bounding box intersects with a bounding sphere
  82717. * @param sphere defines the sphere to test
  82718. * @returns true if there is an intersection
  82719. */
  82720. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  82721. /**
  82722. * Tests if the bounding box intersects with a box defined by a min and max vectors
  82723. * @param min defines the min vector to use
  82724. * @param max defines the max vector to use
  82725. * @returns true if there is an intersection
  82726. */
  82727. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  82728. /**
  82729. * Tests if two bounding boxes are intersections
  82730. * @param box0 defines the first box to test
  82731. * @param box1 defines the second box to test
  82732. * @returns true if there is an intersection
  82733. */
  82734. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  82735. /**
  82736. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  82737. * @param minPoint defines the minimum vector of the bounding box
  82738. * @param maxPoint defines the maximum vector of the bounding box
  82739. * @param sphereCenter defines the sphere center
  82740. * @param sphereRadius defines the sphere radius
  82741. * @returns true if there is an intersection
  82742. */
  82743. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  82744. /**
  82745. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  82746. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82747. * @param frustumPlanes defines the frustum planes to test
  82748. * @return true if there is an inclusion
  82749. */
  82750. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82751. /**
  82752. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  82753. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  82754. * @param frustumPlanes defines the frustum planes to test
  82755. * @return true if there is an intersection
  82756. */
  82757. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82758. }
  82759. }
  82760. declare module BABYLON {
  82761. /** @hidden */
  82762. export class Collider {
  82763. /** Define if a collision was found */
  82764. collisionFound: boolean;
  82765. /**
  82766. * Define last intersection point in local space
  82767. */
  82768. intersectionPoint: Vector3;
  82769. /**
  82770. * Define last collided mesh
  82771. */
  82772. collidedMesh: Nullable<AbstractMesh>;
  82773. private _collisionPoint;
  82774. private _planeIntersectionPoint;
  82775. private _tempVector;
  82776. private _tempVector2;
  82777. private _tempVector3;
  82778. private _tempVector4;
  82779. private _edge;
  82780. private _baseToVertex;
  82781. private _destinationPoint;
  82782. private _slidePlaneNormal;
  82783. private _displacementVector;
  82784. /** @hidden */
  82785. _radius: Vector3;
  82786. /** @hidden */
  82787. _retry: number;
  82788. private _velocity;
  82789. private _basePoint;
  82790. private _epsilon;
  82791. /** @hidden */
  82792. _velocityWorldLength: number;
  82793. /** @hidden */
  82794. _basePointWorld: Vector3;
  82795. private _velocityWorld;
  82796. private _normalizedVelocity;
  82797. /** @hidden */
  82798. _initialVelocity: Vector3;
  82799. /** @hidden */
  82800. _initialPosition: Vector3;
  82801. private _nearestDistance;
  82802. private _collisionMask;
  82803. get collisionMask(): number;
  82804. set collisionMask(mask: number);
  82805. /**
  82806. * Gets the plane normal used to compute the sliding response (in local space)
  82807. */
  82808. get slidePlaneNormal(): Vector3;
  82809. /** @hidden */
  82810. _initialize(source: Vector3, dir: Vector3, e: number): void;
  82811. /** @hidden */
  82812. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  82813. /** @hidden */
  82814. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  82815. /** @hidden */
  82816. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  82817. /** @hidden */
  82818. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  82819. /** @hidden */
  82820. _getResponse(pos: Vector3, vel: Vector3): void;
  82821. }
  82822. }
  82823. declare module BABYLON {
  82824. /**
  82825. * Interface for cullable objects
  82826. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  82827. */
  82828. export interface ICullable {
  82829. /**
  82830. * Checks if the object or part of the object is in the frustum
  82831. * @param frustumPlanes Camera near/planes
  82832. * @returns true if the object is in frustum otherwise false
  82833. */
  82834. isInFrustum(frustumPlanes: Plane[]): boolean;
  82835. /**
  82836. * Checks if a cullable object (mesh...) is in the camera frustum
  82837. * Unlike isInFrustum this cheks the full bounding box
  82838. * @param frustumPlanes Camera near/planes
  82839. * @returns true if the object is in frustum otherwise false
  82840. */
  82841. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82842. }
  82843. /**
  82844. * Info for a bounding data of a mesh
  82845. */
  82846. export class BoundingInfo implements ICullable {
  82847. /**
  82848. * Bounding box for the mesh
  82849. */
  82850. readonly boundingBox: BoundingBox;
  82851. /**
  82852. * Bounding sphere for the mesh
  82853. */
  82854. readonly boundingSphere: BoundingSphere;
  82855. private _isLocked;
  82856. private static readonly TmpVector3;
  82857. /**
  82858. * Constructs bounding info
  82859. * @param minimum min vector of the bounding box/sphere
  82860. * @param maximum max vector of the bounding box/sphere
  82861. * @param worldMatrix defines the new world matrix
  82862. */
  82863. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  82864. /**
  82865. * Recreates the entire bounding info from scratch as if we call the constructor in place
  82866. * @param min defines the new minimum vector (in local space)
  82867. * @param max defines the new maximum vector (in local space)
  82868. * @param worldMatrix defines the new world matrix
  82869. */
  82870. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  82871. /**
  82872. * min vector of the bounding box/sphere
  82873. */
  82874. get minimum(): Vector3;
  82875. /**
  82876. * max vector of the bounding box/sphere
  82877. */
  82878. get maximum(): Vector3;
  82879. /**
  82880. * If the info is locked and won't be updated to avoid perf overhead
  82881. */
  82882. get isLocked(): boolean;
  82883. set isLocked(value: boolean);
  82884. /**
  82885. * Updates the bounding sphere and box
  82886. * @param world world matrix to be used to update
  82887. */
  82888. update(world: DeepImmutable<Matrix>): void;
  82889. /**
  82890. * Recreate the bounding info to be centered around a specific point given a specific extend.
  82891. * @param center New center of the bounding info
  82892. * @param extend New extend of the bounding info
  82893. * @returns the current bounding info
  82894. */
  82895. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  82896. /**
  82897. * Scale the current bounding info by applying a scale factor
  82898. * @param factor defines the scale factor to apply
  82899. * @returns the current bounding info
  82900. */
  82901. scale(factor: number): BoundingInfo;
  82902. /**
  82903. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  82904. * @param frustumPlanes defines the frustum to test
  82905. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  82906. * @returns true if the bounding info is in the frustum planes
  82907. */
  82908. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  82909. /**
  82910. * Gets the world distance between the min and max points of the bounding box
  82911. */
  82912. get diagonalLength(): number;
  82913. /**
  82914. * Checks if a cullable object (mesh...) is in the camera frustum
  82915. * Unlike isInFrustum this cheks the full bounding box
  82916. * @param frustumPlanes Camera near/planes
  82917. * @returns true if the object is in frustum otherwise false
  82918. */
  82919. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  82920. /** @hidden */
  82921. _checkCollision(collider: Collider): boolean;
  82922. /**
  82923. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  82924. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82925. * @param point the point to check intersection with
  82926. * @returns if the point intersects
  82927. */
  82928. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  82929. /**
  82930. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  82931. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82932. * @param boundingInfo the bounding info to check intersection with
  82933. * @param precise if the intersection should be done using OBB
  82934. * @returns if the bounding info intersects
  82935. */
  82936. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  82937. }
  82938. }
  82939. declare module BABYLON {
  82940. /**
  82941. * Extracts minimum and maximum values from a list of indexed positions
  82942. * @param positions defines the positions to use
  82943. * @param indices defines the indices to the positions
  82944. * @param indexStart defines the start index
  82945. * @param indexCount defines the end index
  82946. * @param bias defines bias value to add to the result
  82947. * @return minimum and maximum values
  82948. */
  82949. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  82950. minimum: Vector3;
  82951. maximum: Vector3;
  82952. };
  82953. /**
  82954. * Extracts minimum and maximum values from a list of positions
  82955. * @param positions defines the positions to use
  82956. * @param start defines the start index in the positions array
  82957. * @param count defines the number of positions to handle
  82958. * @param bias defines bias value to add to the result
  82959. * @param stride defines the stride size to use (distance between two positions in the positions array)
  82960. * @return minimum and maximum values
  82961. */
  82962. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  82963. minimum: Vector3;
  82964. maximum: Vector3;
  82965. };
  82966. }
  82967. declare module BABYLON {
  82968. /** @hidden */
  82969. export class WebGLDataBuffer extends DataBuffer {
  82970. private _buffer;
  82971. constructor(resource: WebGLBuffer);
  82972. get underlyingResource(): any;
  82973. }
  82974. }
  82975. declare module BABYLON {
  82976. /** @hidden */
  82977. export class WebGLPipelineContext implements IPipelineContext {
  82978. engine: ThinEngine;
  82979. program: Nullable<WebGLProgram>;
  82980. context?: WebGLRenderingContext;
  82981. vertexShader?: WebGLShader;
  82982. fragmentShader?: WebGLShader;
  82983. isParallelCompiled: boolean;
  82984. onCompiled?: () => void;
  82985. transformFeedback?: WebGLTransformFeedback | null;
  82986. vertexCompilationError: Nullable<string>;
  82987. fragmentCompilationError: Nullable<string>;
  82988. programLinkError: Nullable<string>;
  82989. programValidationError: Nullable<string>;
  82990. get isAsync(): boolean;
  82991. get isReady(): boolean;
  82992. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  82993. _getVertexShaderCode(): string | null;
  82994. _getFragmentShaderCode(): string | null;
  82995. }
  82996. }
  82997. declare module BABYLON {
  82998. interface ThinEngine {
  82999. /**
  83000. * Create an uniform buffer
  83001. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83002. * @param elements defines the content of the uniform buffer
  83003. * @returns the webGL uniform buffer
  83004. */
  83005. createUniformBuffer(elements: FloatArray): DataBuffer;
  83006. /**
  83007. * Create a dynamic uniform buffer
  83008. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83009. * @param elements defines the content of the uniform buffer
  83010. * @returns the webGL uniform buffer
  83011. */
  83012. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  83013. /**
  83014. * Update an existing uniform buffer
  83015. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83016. * @param uniformBuffer defines the target uniform buffer
  83017. * @param elements defines the content to update
  83018. * @param offset defines the offset in the uniform buffer where update should start
  83019. * @param count defines the size of the data to update
  83020. */
  83021. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83022. /**
  83023. * Bind an uniform buffer to the current webGL context
  83024. * @param buffer defines the buffer to bind
  83025. */
  83026. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  83027. /**
  83028. * Bind a buffer to the current webGL context at a given location
  83029. * @param buffer defines the buffer to bind
  83030. * @param location defines the index where to bind the buffer
  83031. */
  83032. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  83033. /**
  83034. * Bind a specific block at a given index in a specific shader program
  83035. * @param pipelineContext defines the pipeline context to use
  83036. * @param blockName defines the block name
  83037. * @param index defines the index where to bind the block
  83038. */
  83039. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  83040. }
  83041. }
  83042. declare module BABYLON {
  83043. /**
  83044. * Uniform buffer objects.
  83045. *
  83046. * Handles blocks of uniform on the GPU.
  83047. *
  83048. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83049. *
  83050. * For more information, please refer to :
  83051. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83052. */
  83053. export class UniformBuffer {
  83054. private _engine;
  83055. private _buffer;
  83056. private _data;
  83057. private _bufferData;
  83058. private _dynamic?;
  83059. private _uniformLocations;
  83060. private _uniformSizes;
  83061. private _uniformLocationPointer;
  83062. private _needSync;
  83063. private _noUBO;
  83064. private _currentEffect;
  83065. /** @hidden */
  83066. _alreadyBound: boolean;
  83067. private static _MAX_UNIFORM_SIZE;
  83068. private static _tempBuffer;
  83069. /**
  83070. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83071. * This is dynamic to allow compat with webgl 1 and 2.
  83072. * You will need to pass the name of the uniform as well as the value.
  83073. */
  83074. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83075. /**
  83076. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83077. * This is dynamic to allow compat with webgl 1 and 2.
  83078. * You will need to pass the name of the uniform as well as the value.
  83079. */
  83080. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83081. /**
  83082. * Lambda to Update a single float in a uniform buffer.
  83083. * This is dynamic to allow compat with webgl 1 and 2.
  83084. * You will need to pass the name of the uniform as well as the value.
  83085. */
  83086. updateFloat: (name: string, x: number) => void;
  83087. /**
  83088. * Lambda to Update a vec2 of float in a uniform buffer.
  83089. * This is dynamic to allow compat with webgl 1 and 2.
  83090. * You will need to pass the name of the uniform as well as the value.
  83091. */
  83092. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  83093. /**
  83094. * Lambda to Update a vec3 of float in a uniform buffer.
  83095. * This is dynamic to allow compat with webgl 1 and 2.
  83096. * You will need to pass the name of the uniform as well as the value.
  83097. */
  83098. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  83099. /**
  83100. * Lambda to Update a vec4 of float in a uniform buffer.
  83101. * This is dynamic to allow compat with webgl 1 and 2.
  83102. * You will need to pass the name of the uniform as well as the value.
  83103. */
  83104. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  83105. /**
  83106. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  83107. * This is dynamic to allow compat with webgl 1 and 2.
  83108. * You will need to pass the name of the uniform as well as the value.
  83109. */
  83110. updateMatrix: (name: string, mat: Matrix) => void;
  83111. /**
  83112. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  83113. * This is dynamic to allow compat with webgl 1 and 2.
  83114. * You will need to pass the name of the uniform as well as the value.
  83115. */
  83116. updateVector3: (name: string, vector: Vector3) => void;
  83117. /**
  83118. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  83119. * This is dynamic to allow compat with webgl 1 and 2.
  83120. * You will need to pass the name of the uniform as well as the value.
  83121. */
  83122. updateVector4: (name: string, vector: Vector4) => void;
  83123. /**
  83124. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  83125. * This is dynamic to allow compat with webgl 1 and 2.
  83126. * You will need to pass the name of the uniform as well as the value.
  83127. */
  83128. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  83129. /**
  83130. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  83131. * This is dynamic to allow compat with webgl 1 and 2.
  83132. * You will need to pass the name of the uniform as well as the value.
  83133. */
  83134. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  83135. /**
  83136. * Instantiates a new Uniform buffer objects.
  83137. *
  83138. * Handles blocks of uniform on the GPU.
  83139. *
  83140. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83141. *
  83142. * For more information, please refer to :
  83143. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83144. * @param engine Define the engine the buffer is associated with
  83145. * @param data Define the data contained in the buffer
  83146. * @param dynamic Define if the buffer is updatable
  83147. */
  83148. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  83149. /**
  83150. * Indicates if the buffer is using the WebGL2 UBO implementation,
  83151. * or just falling back on setUniformXXX calls.
  83152. */
  83153. get useUbo(): boolean;
  83154. /**
  83155. * Indicates if the WebGL underlying uniform buffer is in sync
  83156. * with the javascript cache data.
  83157. */
  83158. get isSync(): boolean;
  83159. /**
  83160. * Indicates if the WebGL underlying uniform buffer is dynamic.
  83161. * Also, a dynamic UniformBuffer will disable cache verification and always
  83162. * update the underlying WebGL uniform buffer to the GPU.
  83163. * @returns if Dynamic, otherwise false
  83164. */
  83165. isDynamic(): boolean;
  83166. /**
  83167. * The data cache on JS side.
  83168. * @returns the underlying data as a float array
  83169. */
  83170. getData(): Float32Array;
  83171. /**
  83172. * The underlying WebGL Uniform buffer.
  83173. * @returns the webgl buffer
  83174. */
  83175. getBuffer(): Nullable<DataBuffer>;
  83176. /**
  83177. * std140 layout specifies how to align data within an UBO structure.
  83178. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83179. * for specs.
  83180. */
  83181. private _fillAlignment;
  83182. /**
  83183. * Adds an uniform in the buffer.
  83184. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83185. * for the layout to be correct !
  83186. * @param name Name of the uniform, as used in the uniform block in the shader.
  83187. * @param size Data size, or data directly.
  83188. */
  83189. addUniform(name: string, size: number | number[]): void;
  83190. /**
  83191. * Adds a Matrix 4x4 to the uniform buffer.
  83192. * @param name Name of the uniform, as used in the uniform block in the shader.
  83193. * @param mat A 4x4 matrix.
  83194. */
  83195. addMatrix(name: string, mat: Matrix): void;
  83196. /**
  83197. * Adds a vec2 to the uniform buffer.
  83198. * @param name Name of the uniform, as used in the uniform block in the shader.
  83199. * @param x Define the x component value of the vec2
  83200. * @param y Define the y component value of the vec2
  83201. */
  83202. addFloat2(name: string, x: number, y: number): void;
  83203. /**
  83204. * Adds a vec3 to the uniform buffer.
  83205. * @param name Name of the uniform, as used in the uniform block in the shader.
  83206. * @param x Define the x component value of the vec3
  83207. * @param y Define the y component value of the vec3
  83208. * @param z Define the z component value of the vec3
  83209. */
  83210. addFloat3(name: string, x: number, y: number, z: number): void;
  83211. /**
  83212. * Adds a vec3 to the uniform buffer.
  83213. * @param name Name of the uniform, as used in the uniform block in the shader.
  83214. * @param color Define the vec3 from a Color
  83215. */
  83216. addColor3(name: string, color: Color3): void;
  83217. /**
  83218. * Adds a vec4 to the uniform buffer.
  83219. * @param name Name of the uniform, as used in the uniform block in the shader.
  83220. * @param color Define the rgb components from a Color
  83221. * @param alpha Define the a component of the vec4
  83222. */
  83223. addColor4(name: string, color: Color3, alpha: number): void;
  83224. /**
  83225. * Adds a vec3 to the uniform buffer.
  83226. * @param name Name of the uniform, as used in the uniform block in the shader.
  83227. * @param vector Define the vec3 components from a Vector
  83228. */
  83229. addVector3(name: string, vector: Vector3): void;
  83230. /**
  83231. * Adds a Matrix 3x3 to the uniform buffer.
  83232. * @param name Name of the uniform, as used in the uniform block in the shader.
  83233. */
  83234. addMatrix3x3(name: string): void;
  83235. /**
  83236. * Adds a Matrix 2x2 to the uniform buffer.
  83237. * @param name Name of the uniform, as used in the uniform block in the shader.
  83238. */
  83239. addMatrix2x2(name: string): void;
  83240. /**
  83241. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83242. */
  83243. create(): void;
  83244. /** @hidden */
  83245. _rebuild(): void;
  83246. /**
  83247. * Updates the WebGL Uniform Buffer on the GPU.
  83248. * If the `dynamic` flag is set to true, no cache comparison is done.
  83249. * Otherwise, the buffer will be updated only if the cache differs.
  83250. */
  83251. update(): void;
  83252. /**
  83253. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83254. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83255. * @param data Define the flattened data
  83256. * @param size Define the size of the data.
  83257. */
  83258. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83259. private _valueCache;
  83260. private _cacheMatrix;
  83261. private _updateMatrix3x3ForUniform;
  83262. private _updateMatrix3x3ForEffect;
  83263. private _updateMatrix2x2ForEffect;
  83264. private _updateMatrix2x2ForUniform;
  83265. private _updateFloatForEffect;
  83266. private _updateFloatForUniform;
  83267. private _updateFloat2ForEffect;
  83268. private _updateFloat2ForUniform;
  83269. private _updateFloat3ForEffect;
  83270. private _updateFloat3ForUniform;
  83271. private _updateFloat4ForEffect;
  83272. private _updateFloat4ForUniform;
  83273. private _updateMatrixForEffect;
  83274. private _updateMatrixForUniform;
  83275. private _updateVector3ForEffect;
  83276. private _updateVector3ForUniform;
  83277. private _updateVector4ForEffect;
  83278. private _updateVector4ForUniform;
  83279. private _updateColor3ForEffect;
  83280. private _updateColor3ForUniform;
  83281. private _updateColor4ForEffect;
  83282. private _updateColor4ForUniform;
  83283. /**
  83284. * Sets a sampler uniform on the effect.
  83285. * @param name Define the name of the sampler.
  83286. * @param texture Define the texture to set in the sampler
  83287. */
  83288. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83289. /**
  83290. * Directly updates the value of the uniform in the cache AND on the GPU.
  83291. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83292. * @param data Define the flattened data
  83293. */
  83294. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83295. /**
  83296. * Binds this uniform buffer to an effect.
  83297. * @param effect Define the effect to bind the buffer to
  83298. * @param name Name of the uniform block in the shader.
  83299. */
  83300. bindToEffect(effect: Effect, name: string): void;
  83301. /**
  83302. * Disposes the uniform buffer.
  83303. */
  83304. dispose(): void;
  83305. }
  83306. }
  83307. declare module BABYLON {
  83308. /**
  83309. * Enum that determines the text-wrapping mode to use.
  83310. */
  83311. export enum InspectableType {
  83312. /**
  83313. * Checkbox for booleans
  83314. */
  83315. Checkbox = 0,
  83316. /**
  83317. * Sliders for numbers
  83318. */
  83319. Slider = 1,
  83320. /**
  83321. * Vector3
  83322. */
  83323. Vector3 = 2,
  83324. /**
  83325. * Quaternions
  83326. */
  83327. Quaternion = 3,
  83328. /**
  83329. * Color3
  83330. */
  83331. Color3 = 4,
  83332. /**
  83333. * String
  83334. */
  83335. String = 5
  83336. }
  83337. /**
  83338. * Interface used to define custom inspectable properties.
  83339. * This interface is used by the inspector to display custom property grids
  83340. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83341. */
  83342. export interface IInspectable {
  83343. /**
  83344. * Gets the label to display
  83345. */
  83346. label: string;
  83347. /**
  83348. * Gets the name of the property to edit
  83349. */
  83350. propertyName: string;
  83351. /**
  83352. * Gets the type of the editor to use
  83353. */
  83354. type: InspectableType;
  83355. /**
  83356. * Gets the minimum value of the property when using in "slider" mode
  83357. */
  83358. min?: number;
  83359. /**
  83360. * Gets the maximum value of the property when using in "slider" mode
  83361. */
  83362. max?: number;
  83363. /**
  83364. * Gets the setp to use when using in "slider" mode
  83365. */
  83366. step?: number;
  83367. }
  83368. }
  83369. declare module BABYLON {
  83370. /**
  83371. * Class used to provide helper for timing
  83372. */
  83373. export class TimingTools {
  83374. /**
  83375. * Polyfill for setImmediate
  83376. * @param action defines the action to execute after the current execution block
  83377. */
  83378. static SetImmediate(action: () => void): void;
  83379. }
  83380. }
  83381. declare module BABYLON {
  83382. /**
  83383. * Class used to enable instatition of objects by class name
  83384. */
  83385. export class InstantiationTools {
  83386. /**
  83387. * Use this object to register external classes like custom textures or material
  83388. * to allow the laoders to instantiate them
  83389. */
  83390. static RegisteredExternalClasses: {
  83391. [key: string]: Object;
  83392. };
  83393. /**
  83394. * Tries to instantiate a new object from a given class name
  83395. * @param className defines the class name to instantiate
  83396. * @returns the new object or null if the system was not able to do the instantiation
  83397. */
  83398. static Instantiate(className: string): any;
  83399. }
  83400. }
  83401. declare module BABYLON {
  83402. /**
  83403. * Define options used to create a depth texture
  83404. */
  83405. export class DepthTextureCreationOptions {
  83406. /** Specifies whether or not a stencil should be allocated in the texture */
  83407. generateStencil?: boolean;
  83408. /** Specifies whether or not bilinear filtering is enable on the texture */
  83409. bilinearFiltering?: boolean;
  83410. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83411. comparisonFunction?: number;
  83412. /** Specifies if the created texture is a cube texture */
  83413. isCube?: boolean;
  83414. }
  83415. }
  83416. declare module BABYLON {
  83417. interface ThinEngine {
  83418. /**
  83419. * Creates a depth stencil cube texture.
  83420. * This is only available in WebGL 2.
  83421. * @param size The size of face edge in the cube texture.
  83422. * @param options The options defining the cube texture.
  83423. * @returns The cube texture
  83424. */
  83425. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  83426. /**
  83427. * Creates a cube texture
  83428. * @param rootUrl defines the url where the files to load is located
  83429. * @param scene defines the current scene
  83430. * @param files defines the list of files to load (1 per face)
  83431. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83432. * @param onLoad defines an optional callback raised when the texture is loaded
  83433. * @param onError defines an optional callback raised if there is an issue to load the texture
  83434. * @param format defines the format of the data
  83435. * @param forcedExtension defines the extension to use to pick the right loader
  83436. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83437. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83438. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83439. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  83440. * @returns the cube texture as an InternalTexture
  83441. */
  83442. 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;
  83443. /**
  83444. * Creates a cube texture
  83445. * @param rootUrl defines the url where the files to load is located
  83446. * @param scene defines the current scene
  83447. * @param files defines the list of files to load (1 per face)
  83448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83449. * @param onLoad defines an optional callback raised when the texture is loaded
  83450. * @param onError defines an optional callback raised if there is an issue to load the texture
  83451. * @param format defines the format of the data
  83452. * @param forcedExtension defines the extension to use to pick the right loader
  83453. * @returns the cube texture as an InternalTexture
  83454. */
  83455. 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;
  83456. /**
  83457. * Creates a cube texture
  83458. * @param rootUrl defines the url where the files to load is located
  83459. * @param scene defines the current scene
  83460. * @param files defines the list of files to load (1 per face)
  83461. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  83462. * @param onLoad defines an optional callback raised when the texture is loaded
  83463. * @param onError defines an optional callback raised if there is an issue to load the texture
  83464. * @param format defines the format of the data
  83465. * @param forcedExtension defines the extension to use to pick the right loader
  83466. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  83467. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83468. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83469. * @returns the cube texture as an InternalTexture
  83470. */
  83471. 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;
  83472. /** @hidden */
  83473. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  83474. /** @hidden */
  83475. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  83476. /** @hidden */
  83477. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83478. /** @hidden */
  83479. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  83480. /**
  83481. * @hidden
  83482. */
  83483. _setCubeMapTextureParams(loadMipmap: boolean): void;
  83484. }
  83485. }
  83486. declare module BABYLON {
  83487. /**
  83488. * Class for creating a cube texture
  83489. */
  83490. export class CubeTexture extends BaseTexture {
  83491. private _delayedOnLoad;
  83492. /**
  83493. * Observable triggered once the texture has been loaded.
  83494. */
  83495. onLoadObservable: Observable<CubeTexture>;
  83496. /**
  83497. * The url of the texture
  83498. */
  83499. url: string;
  83500. /**
  83501. * Gets or sets the center of the bounding box associated with the cube texture.
  83502. * It must define where the camera used to render the texture was set
  83503. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83504. */
  83505. boundingBoxPosition: Vector3;
  83506. private _boundingBoxSize;
  83507. /**
  83508. * Gets or sets the size of the bounding box associated with the cube texture
  83509. * When defined, the cubemap will switch to local mode
  83510. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83511. * @example https://www.babylonjs-playground.com/#RNASML
  83512. */
  83513. set boundingBoxSize(value: Vector3);
  83514. /**
  83515. * Returns the bounding box size
  83516. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  83517. */
  83518. get boundingBoxSize(): Vector3;
  83519. protected _rotationY: number;
  83520. /**
  83521. * Sets texture matrix rotation angle around Y axis in radians.
  83522. */
  83523. set rotationY(value: number);
  83524. /**
  83525. * Gets texture matrix rotation angle around Y axis radians.
  83526. */
  83527. get rotationY(): number;
  83528. /**
  83529. * Are mip maps generated for this texture or not.
  83530. */
  83531. get noMipmap(): boolean;
  83532. private _noMipmap;
  83533. private _files;
  83534. protected _forcedExtension: Nullable<string>;
  83535. private _extensions;
  83536. private _textureMatrix;
  83537. private _format;
  83538. private _createPolynomials;
  83539. /** @hidden */
  83540. _prefiltered: boolean;
  83541. /**
  83542. * Creates a cube texture from an array of image urls
  83543. * @param files defines an array of image urls
  83544. * @param scene defines the hosting scene
  83545. * @param noMipmap specifies if mip maps are not used
  83546. * @returns a cube texture
  83547. */
  83548. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  83549. /**
  83550. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  83551. * @param url defines the url of the prefiltered texture
  83552. * @param scene defines the scene the texture is attached to
  83553. * @param forcedExtension defines the extension of the file if different from the url
  83554. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83555. * @return the prefiltered texture
  83556. */
  83557. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  83558. /**
  83559. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  83560. * as prefiltered data.
  83561. * @param rootUrl defines the url of the texture or the root name of the six images
  83562. * @param scene defines the scene the texture is attached to
  83563. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  83564. * @param noMipmap defines if mipmaps should be created or not
  83565. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  83566. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  83567. * @param onError defines a callback triggered in case of error during load
  83568. * @param format defines the internal format to use for the texture once loaded
  83569. * @param prefiltered defines whether or not the texture is created from prefiltered data
  83570. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  83571. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  83572. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  83573. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  83574. * @return the cube texture
  83575. */
  83576. 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);
  83577. /**
  83578. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  83579. */
  83580. get isPrefiltered(): boolean;
  83581. /**
  83582. * Get the current class name of the texture useful for serialization or dynamic coding.
  83583. * @returns "CubeTexture"
  83584. */
  83585. getClassName(): string;
  83586. /**
  83587. * Update the url (and optional buffer) of this texture if url was null during construction.
  83588. * @param url the url of the texture
  83589. * @param forcedExtension defines the extension to use
  83590. * @param onLoad callback called when the texture is loaded (defaults to null)
  83591. * @param prefiltered Defines whether the updated texture is prefiltered or not
  83592. */
  83593. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  83594. /**
  83595. * Delays loading of the cube texture
  83596. * @param forcedExtension defines the extension to use
  83597. */
  83598. delayLoad(forcedExtension?: string): void;
  83599. /**
  83600. * Returns the reflection texture matrix
  83601. * @returns the reflection texture matrix
  83602. */
  83603. getReflectionTextureMatrix(): Matrix;
  83604. /**
  83605. * Sets the reflection texture matrix
  83606. * @param value Reflection texture matrix
  83607. */
  83608. setReflectionTextureMatrix(value: Matrix): void;
  83609. /**
  83610. * Parses text to create a cube texture
  83611. * @param parsedTexture define the serialized text to read from
  83612. * @param scene defines the hosting scene
  83613. * @param rootUrl defines the root url of the cube texture
  83614. * @returns a cube texture
  83615. */
  83616. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  83617. /**
  83618. * Makes a clone, or deep copy, of the cube texture
  83619. * @returns a new cube texture
  83620. */
  83621. clone(): CubeTexture;
  83622. }
  83623. }
  83624. declare module BABYLON {
  83625. /**
  83626. * Manages the defines for the Material
  83627. */
  83628. export class MaterialDefines {
  83629. /** @hidden */
  83630. protected _keys: string[];
  83631. private _isDirty;
  83632. /** @hidden */
  83633. _renderId: number;
  83634. /** @hidden */
  83635. _areLightsDirty: boolean;
  83636. /** @hidden */
  83637. _areLightsDisposed: boolean;
  83638. /** @hidden */
  83639. _areAttributesDirty: boolean;
  83640. /** @hidden */
  83641. _areTexturesDirty: boolean;
  83642. /** @hidden */
  83643. _areFresnelDirty: boolean;
  83644. /** @hidden */
  83645. _areMiscDirty: boolean;
  83646. /** @hidden */
  83647. _areImageProcessingDirty: boolean;
  83648. /** @hidden */
  83649. _normals: boolean;
  83650. /** @hidden */
  83651. _uvs: boolean;
  83652. /** @hidden */
  83653. _needNormals: boolean;
  83654. /** @hidden */
  83655. _needUVs: boolean;
  83656. [id: string]: any;
  83657. /**
  83658. * Specifies if the material needs to be re-calculated
  83659. */
  83660. get isDirty(): boolean;
  83661. /**
  83662. * Marks the material to indicate that it has been re-calculated
  83663. */
  83664. markAsProcessed(): void;
  83665. /**
  83666. * Marks the material to indicate that it needs to be re-calculated
  83667. */
  83668. markAsUnprocessed(): void;
  83669. /**
  83670. * Marks the material to indicate all of its defines need to be re-calculated
  83671. */
  83672. markAllAsDirty(): void;
  83673. /**
  83674. * Marks the material to indicate that image processing needs to be re-calculated
  83675. */
  83676. markAsImageProcessingDirty(): void;
  83677. /**
  83678. * Marks the material to indicate the lights need to be re-calculated
  83679. * @param disposed Defines whether the light is dirty due to dispose or not
  83680. */
  83681. markAsLightDirty(disposed?: boolean): void;
  83682. /**
  83683. * Marks the attribute state as changed
  83684. */
  83685. markAsAttributesDirty(): void;
  83686. /**
  83687. * Marks the texture state as changed
  83688. */
  83689. markAsTexturesDirty(): void;
  83690. /**
  83691. * Marks the fresnel state as changed
  83692. */
  83693. markAsFresnelDirty(): void;
  83694. /**
  83695. * Marks the misc state as changed
  83696. */
  83697. markAsMiscDirty(): void;
  83698. /**
  83699. * Rebuilds the material defines
  83700. */
  83701. rebuild(): void;
  83702. /**
  83703. * Specifies if two material defines are equal
  83704. * @param other - A material define instance to compare to
  83705. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  83706. */
  83707. isEqual(other: MaterialDefines): boolean;
  83708. /**
  83709. * Clones this instance's defines to another instance
  83710. * @param other - material defines to clone values to
  83711. */
  83712. cloneTo(other: MaterialDefines): void;
  83713. /**
  83714. * Resets the material define values
  83715. */
  83716. reset(): void;
  83717. /**
  83718. * Converts the material define values to a string
  83719. * @returns - String of material define information
  83720. */
  83721. toString(): string;
  83722. }
  83723. }
  83724. declare module BABYLON {
  83725. /**
  83726. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  83727. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  83728. * 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;
  83729. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  83730. */
  83731. export class ColorCurves {
  83732. private _dirty;
  83733. private _tempColor;
  83734. private _globalCurve;
  83735. private _highlightsCurve;
  83736. private _midtonesCurve;
  83737. private _shadowsCurve;
  83738. private _positiveCurve;
  83739. private _negativeCurve;
  83740. private _globalHue;
  83741. private _globalDensity;
  83742. private _globalSaturation;
  83743. private _globalExposure;
  83744. /**
  83745. * Gets the global Hue value.
  83746. * 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).
  83747. */
  83748. get globalHue(): number;
  83749. /**
  83750. * Sets the global Hue value.
  83751. * 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).
  83752. */
  83753. set globalHue(value: number);
  83754. /**
  83755. * Gets the global Density value.
  83756. * 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.
  83757. * Values less than zero provide a filter of opposite hue.
  83758. */
  83759. get globalDensity(): number;
  83760. /**
  83761. * Sets the global Density value.
  83762. * 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.
  83763. * Values less than zero provide a filter of opposite hue.
  83764. */
  83765. set globalDensity(value: number);
  83766. /**
  83767. * Gets the global Saturation value.
  83768. * 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.
  83769. */
  83770. get globalSaturation(): number;
  83771. /**
  83772. * Sets the global Saturation value.
  83773. * 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.
  83774. */
  83775. set globalSaturation(value: number);
  83776. /**
  83777. * Gets the global Exposure value.
  83778. * 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.
  83779. */
  83780. get globalExposure(): number;
  83781. /**
  83782. * Sets the global Exposure value.
  83783. * 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.
  83784. */
  83785. set globalExposure(value: number);
  83786. private _highlightsHue;
  83787. private _highlightsDensity;
  83788. private _highlightsSaturation;
  83789. private _highlightsExposure;
  83790. /**
  83791. * Gets the highlights Hue value.
  83792. * 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).
  83793. */
  83794. get highlightsHue(): number;
  83795. /**
  83796. * Sets the highlights Hue value.
  83797. * 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).
  83798. */
  83799. set highlightsHue(value: number);
  83800. /**
  83801. * Gets the highlights Density value.
  83802. * 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.
  83803. * Values less than zero provide a filter of opposite hue.
  83804. */
  83805. get highlightsDensity(): number;
  83806. /**
  83807. * Sets the highlights Density value.
  83808. * 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.
  83809. * Values less than zero provide a filter of opposite hue.
  83810. */
  83811. set highlightsDensity(value: number);
  83812. /**
  83813. * Gets the highlights Saturation value.
  83814. * 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.
  83815. */
  83816. get highlightsSaturation(): number;
  83817. /**
  83818. * Sets the highlights Saturation value.
  83819. * 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.
  83820. */
  83821. set highlightsSaturation(value: number);
  83822. /**
  83823. * Gets the highlights Exposure value.
  83824. * 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.
  83825. */
  83826. get highlightsExposure(): number;
  83827. /**
  83828. * Sets the highlights Exposure value.
  83829. * 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.
  83830. */
  83831. set highlightsExposure(value: number);
  83832. private _midtonesHue;
  83833. private _midtonesDensity;
  83834. private _midtonesSaturation;
  83835. private _midtonesExposure;
  83836. /**
  83837. * Gets the midtones Hue value.
  83838. * 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).
  83839. */
  83840. get midtonesHue(): number;
  83841. /**
  83842. * Sets the midtones Hue value.
  83843. * 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).
  83844. */
  83845. set midtonesHue(value: number);
  83846. /**
  83847. * Gets the midtones Density value.
  83848. * 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.
  83849. * Values less than zero provide a filter of opposite hue.
  83850. */
  83851. get midtonesDensity(): number;
  83852. /**
  83853. * Sets the midtones Density value.
  83854. * 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.
  83855. * Values less than zero provide a filter of opposite hue.
  83856. */
  83857. set midtonesDensity(value: number);
  83858. /**
  83859. * Gets the midtones Saturation value.
  83860. * 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.
  83861. */
  83862. get midtonesSaturation(): number;
  83863. /**
  83864. * Sets the midtones Saturation value.
  83865. * 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.
  83866. */
  83867. set midtonesSaturation(value: number);
  83868. /**
  83869. * Gets the midtones Exposure value.
  83870. * 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.
  83871. */
  83872. get midtonesExposure(): number;
  83873. /**
  83874. * Sets the midtones Exposure value.
  83875. * 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.
  83876. */
  83877. set midtonesExposure(value: number);
  83878. private _shadowsHue;
  83879. private _shadowsDensity;
  83880. private _shadowsSaturation;
  83881. private _shadowsExposure;
  83882. /**
  83883. * Gets the shadows Hue value.
  83884. * 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).
  83885. */
  83886. get shadowsHue(): number;
  83887. /**
  83888. * Sets the shadows Hue value.
  83889. * 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).
  83890. */
  83891. set shadowsHue(value: number);
  83892. /**
  83893. * Gets the shadows Density value.
  83894. * 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.
  83895. * Values less than zero provide a filter of opposite hue.
  83896. */
  83897. get shadowsDensity(): number;
  83898. /**
  83899. * Sets the shadows Density value.
  83900. * 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.
  83901. * Values less than zero provide a filter of opposite hue.
  83902. */
  83903. set shadowsDensity(value: number);
  83904. /**
  83905. * Gets the shadows Saturation value.
  83906. * 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.
  83907. */
  83908. get shadowsSaturation(): number;
  83909. /**
  83910. * Sets the shadows Saturation value.
  83911. * 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.
  83912. */
  83913. set shadowsSaturation(value: number);
  83914. /**
  83915. * Gets the shadows Exposure value.
  83916. * 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.
  83917. */
  83918. get shadowsExposure(): number;
  83919. /**
  83920. * Sets the shadows Exposure value.
  83921. * 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.
  83922. */
  83923. set shadowsExposure(value: number);
  83924. /**
  83925. * Returns the class name
  83926. * @returns The class name
  83927. */
  83928. getClassName(): string;
  83929. /**
  83930. * Binds the color curves to the shader.
  83931. * @param colorCurves The color curve to bind
  83932. * @param effect The effect to bind to
  83933. * @param positiveUniform The positive uniform shader parameter
  83934. * @param neutralUniform The neutral uniform shader parameter
  83935. * @param negativeUniform The negative uniform shader parameter
  83936. */
  83937. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  83938. /**
  83939. * Prepare the list of uniforms associated with the ColorCurves effects.
  83940. * @param uniformsList The list of uniforms used in the effect
  83941. */
  83942. static PrepareUniforms(uniformsList: string[]): void;
  83943. /**
  83944. * Returns color grading data based on a hue, density, saturation and exposure value.
  83945. * @param filterHue The hue of the color filter.
  83946. * @param filterDensity The density of the color filter.
  83947. * @param saturation The saturation.
  83948. * @param exposure The exposure.
  83949. * @param result The result data container.
  83950. */
  83951. private getColorGradingDataToRef;
  83952. /**
  83953. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  83954. * @param value The input slider value in range [-100,100].
  83955. * @returns Adjusted value.
  83956. */
  83957. private static applyColorGradingSliderNonlinear;
  83958. /**
  83959. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  83960. * @param hue The hue (H) input.
  83961. * @param saturation The saturation (S) input.
  83962. * @param brightness The brightness (B) input.
  83963. * @result An RGBA color represented as Vector4.
  83964. */
  83965. private static fromHSBToRef;
  83966. /**
  83967. * Returns a value clamped between min and max
  83968. * @param value The value to clamp
  83969. * @param min The minimum of value
  83970. * @param max The maximum of value
  83971. * @returns The clamped value.
  83972. */
  83973. private static clamp;
  83974. /**
  83975. * Clones the current color curve instance.
  83976. * @return The cloned curves
  83977. */
  83978. clone(): ColorCurves;
  83979. /**
  83980. * Serializes the current color curve instance to a json representation.
  83981. * @return a JSON representation
  83982. */
  83983. serialize(): any;
  83984. /**
  83985. * Parses the color curve from a json representation.
  83986. * @param source the JSON source to parse
  83987. * @return The parsed curves
  83988. */
  83989. static Parse(source: any): ColorCurves;
  83990. }
  83991. }
  83992. declare module BABYLON {
  83993. /**
  83994. * Interface to follow in your material defines to integrate easily the
  83995. * Image proccessing functions.
  83996. * @hidden
  83997. */
  83998. export interface IImageProcessingConfigurationDefines {
  83999. IMAGEPROCESSING: boolean;
  84000. VIGNETTE: boolean;
  84001. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84002. VIGNETTEBLENDMODEOPAQUE: boolean;
  84003. TONEMAPPING: boolean;
  84004. TONEMAPPING_ACES: boolean;
  84005. CONTRAST: boolean;
  84006. EXPOSURE: boolean;
  84007. COLORCURVES: boolean;
  84008. COLORGRADING: boolean;
  84009. COLORGRADING3D: boolean;
  84010. SAMPLER3DGREENDEPTH: boolean;
  84011. SAMPLER3DBGRMAP: boolean;
  84012. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84013. }
  84014. /**
  84015. * @hidden
  84016. */
  84017. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  84018. IMAGEPROCESSING: boolean;
  84019. VIGNETTE: boolean;
  84020. VIGNETTEBLENDMODEMULTIPLY: boolean;
  84021. VIGNETTEBLENDMODEOPAQUE: boolean;
  84022. TONEMAPPING: boolean;
  84023. TONEMAPPING_ACES: boolean;
  84024. CONTRAST: boolean;
  84025. COLORCURVES: boolean;
  84026. COLORGRADING: boolean;
  84027. COLORGRADING3D: boolean;
  84028. SAMPLER3DGREENDEPTH: boolean;
  84029. SAMPLER3DBGRMAP: boolean;
  84030. IMAGEPROCESSINGPOSTPROCESS: boolean;
  84031. EXPOSURE: boolean;
  84032. constructor();
  84033. }
  84034. /**
  84035. * This groups together the common properties used for image processing either in direct forward pass
  84036. * or through post processing effect depending on the use of the image processing pipeline in your scene
  84037. * or not.
  84038. */
  84039. export class ImageProcessingConfiguration {
  84040. /**
  84041. * Default tone mapping applied in BabylonJS.
  84042. */
  84043. static readonly TONEMAPPING_STANDARD: number;
  84044. /**
  84045. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  84046. * to other engines rendering to increase portability.
  84047. */
  84048. static readonly TONEMAPPING_ACES: number;
  84049. /**
  84050. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  84051. */
  84052. colorCurves: Nullable<ColorCurves>;
  84053. private _colorCurvesEnabled;
  84054. /**
  84055. * Gets wether the color curves effect is enabled.
  84056. */
  84057. get colorCurvesEnabled(): boolean;
  84058. /**
  84059. * Sets wether the color curves effect is enabled.
  84060. */
  84061. set colorCurvesEnabled(value: boolean);
  84062. private _colorGradingTexture;
  84063. /**
  84064. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84065. */
  84066. get colorGradingTexture(): Nullable<BaseTexture>;
  84067. /**
  84068. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  84069. */
  84070. set colorGradingTexture(value: Nullable<BaseTexture>);
  84071. private _colorGradingEnabled;
  84072. /**
  84073. * Gets wether the color grading effect is enabled.
  84074. */
  84075. get colorGradingEnabled(): boolean;
  84076. /**
  84077. * Sets wether the color grading effect is enabled.
  84078. */
  84079. set colorGradingEnabled(value: boolean);
  84080. private _colorGradingWithGreenDepth;
  84081. /**
  84082. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  84083. */
  84084. get colorGradingWithGreenDepth(): boolean;
  84085. /**
  84086. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  84087. */
  84088. set colorGradingWithGreenDepth(value: boolean);
  84089. private _colorGradingBGR;
  84090. /**
  84091. * Gets wether the color grading texture contains BGR values.
  84092. */
  84093. get colorGradingBGR(): boolean;
  84094. /**
  84095. * Sets wether the color grading texture contains BGR values.
  84096. */
  84097. set colorGradingBGR(value: boolean);
  84098. /** @hidden */
  84099. _exposure: number;
  84100. /**
  84101. * Gets the Exposure used in the effect.
  84102. */
  84103. get exposure(): number;
  84104. /**
  84105. * Sets the Exposure used in the effect.
  84106. */
  84107. set exposure(value: number);
  84108. private _toneMappingEnabled;
  84109. /**
  84110. * Gets wether the tone mapping effect is enabled.
  84111. */
  84112. get toneMappingEnabled(): boolean;
  84113. /**
  84114. * Sets wether the tone mapping effect is enabled.
  84115. */
  84116. set toneMappingEnabled(value: boolean);
  84117. private _toneMappingType;
  84118. /**
  84119. * Gets the type of tone mapping effect.
  84120. */
  84121. get toneMappingType(): number;
  84122. /**
  84123. * Sets the type of tone mapping effect used in BabylonJS.
  84124. */
  84125. set toneMappingType(value: number);
  84126. protected _contrast: number;
  84127. /**
  84128. * Gets the contrast used in the effect.
  84129. */
  84130. get contrast(): number;
  84131. /**
  84132. * Sets the contrast used in the effect.
  84133. */
  84134. set contrast(value: number);
  84135. /**
  84136. * Vignette stretch size.
  84137. */
  84138. vignetteStretch: number;
  84139. /**
  84140. * Vignette centre X Offset.
  84141. */
  84142. vignetteCentreX: number;
  84143. /**
  84144. * Vignette centre Y Offset.
  84145. */
  84146. vignetteCentreY: number;
  84147. /**
  84148. * Vignette weight or intensity of the vignette effect.
  84149. */
  84150. vignetteWeight: number;
  84151. /**
  84152. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  84153. * if vignetteEnabled is set to true.
  84154. */
  84155. vignetteColor: Color4;
  84156. /**
  84157. * Camera field of view used by the Vignette effect.
  84158. */
  84159. vignetteCameraFov: number;
  84160. private _vignetteBlendMode;
  84161. /**
  84162. * Gets the vignette blend mode allowing different kind of effect.
  84163. */
  84164. get vignetteBlendMode(): number;
  84165. /**
  84166. * Sets the vignette blend mode allowing different kind of effect.
  84167. */
  84168. set vignetteBlendMode(value: number);
  84169. private _vignetteEnabled;
  84170. /**
  84171. * Gets wether the vignette effect is enabled.
  84172. */
  84173. get vignetteEnabled(): boolean;
  84174. /**
  84175. * Sets wether the vignette effect is enabled.
  84176. */
  84177. set vignetteEnabled(value: boolean);
  84178. private _applyByPostProcess;
  84179. /**
  84180. * Gets wether the image processing is applied through a post process or not.
  84181. */
  84182. get applyByPostProcess(): boolean;
  84183. /**
  84184. * Sets wether the image processing is applied through a post process or not.
  84185. */
  84186. set applyByPostProcess(value: boolean);
  84187. private _isEnabled;
  84188. /**
  84189. * Gets wether the image processing is enabled or not.
  84190. */
  84191. get isEnabled(): boolean;
  84192. /**
  84193. * Sets wether the image processing is enabled or not.
  84194. */
  84195. set isEnabled(value: boolean);
  84196. /**
  84197. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  84198. */
  84199. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  84200. /**
  84201. * Method called each time the image processing information changes requires to recompile the effect.
  84202. */
  84203. protected _updateParameters(): void;
  84204. /**
  84205. * Gets the current class name.
  84206. * @return "ImageProcessingConfiguration"
  84207. */
  84208. getClassName(): string;
  84209. /**
  84210. * Prepare the list of uniforms associated with the Image Processing effects.
  84211. * @param uniforms The list of uniforms used in the effect
  84212. * @param defines the list of defines currently in use
  84213. */
  84214. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  84215. /**
  84216. * Prepare the list of samplers associated with the Image Processing effects.
  84217. * @param samplersList The list of uniforms used in the effect
  84218. * @param defines the list of defines currently in use
  84219. */
  84220. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  84221. /**
  84222. * Prepare the list of defines associated to the shader.
  84223. * @param defines the list of defines to complete
  84224. * @param forPostProcess Define if we are currently in post process mode or not
  84225. */
  84226. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  84227. /**
  84228. * Returns true if all the image processing information are ready.
  84229. * @returns True if ready, otherwise, false
  84230. */
  84231. isReady(): boolean;
  84232. /**
  84233. * Binds the image processing to the shader.
  84234. * @param effect The effect to bind to
  84235. * @param overrideAspectRatio Override the aspect ratio of the effect
  84236. */
  84237. bind(effect: Effect, overrideAspectRatio?: number): void;
  84238. /**
  84239. * Clones the current image processing instance.
  84240. * @return The cloned image processing
  84241. */
  84242. clone(): ImageProcessingConfiguration;
  84243. /**
  84244. * Serializes the current image processing instance to a json representation.
  84245. * @return a JSON representation
  84246. */
  84247. serialize(): any;
  84248. /**
  84249. * Parses the image processing from a json representation.
  84250. * @param source the JSON source to parse
  84251. * @return The parsed image processing
  84252. */
  84253. static Parse(source: any): ImageProcessingConfiguration;
  84254. private static _VIGNETTEMODE_MULTIPLY;
  84255. private static _VIGNETTEMODE_OPAQUE;
  84256. /**
  84257. * Used to apply the vignette as a mix with the pixel color.
  84258. */
  84259. static get VIGNETTEMODE_MULTIPLY(): number;
  84260. /**
  84261. * Used to apply the vignette as a replacement of the pixel color.
  84262. */
  84263. static get VIGNETTEMODE_OPAQUE(): number;
  84264. }
  84265. }
  84266. declare module BABYLON {
  84267. /** @hidden */
  84268. export var postprocessVertexShader: {
  84269. name: string;
  84270. shader: string;
  84271. };
  84272. }
  84273. declare module BABYLON {
  84274. interface ThinEngine {
  84275. /**
  84276. * Creates a new render target texture
  84277. * @param size defines the size of the texture
  84278. * @param options defines the options used to create the texture
  84279. * @returns a new render target texture stored in an InternalTexture
  84280. */
  84281. createRenderTargetTexture(size: number | {
  84282. width: number;
  84283. height: number;
  84284. layers?: number;
  84285. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84286. /**
  84287. * Creates a depth stencil texture.
  84288. * This is only available in WebGL 2 or with the depth texture extension available.
  84289. * @param size The size of face edge in the texture.
  84290. * @param options The options defining the texture.
  84291. * @returns The texture
  84292. */
  84293. createDepthStencilTexture(size: number | {
  84294. width: number;
  84295. height: number;
  84296. layers?: number;
  84297. }, options: DepthTextureCreationOptions): InternalTexture;
  84298. /** @hidden */
  84299. _createDepthStencilTexture(size: number | {
  84300. width: number;
  84301. height: number;
  84302. layers?: number;
  84303. }, options: DepthTextureCreationOptions): InternalTexture;
  84304. }
  84305. }
  84306. declare module BABYLON {
  84307. /** Defines supported spaces */
  84308. export enum Space {
  84309. /** Local (object) space */
  84310. LOCAL = 0,
  84311. /** World space */
  84312. WORLD = 1,
  84313. /** Bone space */
  84314. BONE = 2
  84315. }
  84316. /** Defines the 3 main axes */
  84317. export class Axis {
  84318. /** X axis */
  84319. static X: Vector3;
  84320. /** Y axis */
  84321. static Y: Vector3;
  84322. /** Z axis */
  84323. static Z: Vector3;
  84324. }
  84325. }
  84326. declare module BABYLON {
  84327. /**
  84328. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  84329. * This is the base of the follow, arc rotate cameras and Free camera
  84330. * @see http://doc.babylonjs.com/features/cameras
  84331. */
  84332. export class TargetCamera extends Camera {
  84333. private static _RigCamTransformMatrix;
  84334. private static _TargetTransformMatrix;
  84335. private static _TargetFocalPoint;
  84336. /**
  84337. * Define the current direction the camera is moving to
  84338. */
  84339. cameraDirection: Vector3;
  84340. /**
  84341. * Define the current rotation the camera is rotating to
  84342. */
  84343. cameraRotation: Vector2;
  84344. /**
  84345. * When set, the up vector of the camera will be updated by the rotation of the camera
  84346. */
  84347. updateUpVectorFromRotation: boolean;
  84348. private _tmpQuaternion;
  84349. /**
  84350. * Define the current rotation of the camera
  84351. */
  84352. rotation: Vector3;
  84353. /**
  84354. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  84355. */
  84356. rotationQuaternion: Quaternion;
  84357. /**
  84358. * Define the current speed of the camera
  84359. */
  84360. speed: number;
  84361. /**
  84362. * Add constraint to the camera to prevent it to move freely in all directions and
  84363. * around all axis.
  84364. */
  84365. noRotationConstraint: boolean;
  84366. /**
  84367. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  84368. * panning
  84369. */
  84370. invertRotation: boolean;
  84371. /**
  84372. * Speed multiplier for inverse camera panning
  84373. */
  84374. inverseRotationSpeed: number;
  84375. /**
  84376. * Define the current target of the camera as an object or a position.
  84377. */
  84378. lockedTarget: any;
  84379. /** @hidden */
  84380. _currentTarget: Vector3;
  84381. /** @hidden */
  84382. _initialFocalDistance: number;
  84383. /** @hidden */
  84384. _viewMatrix: Matrix;
  84385. /** @hidden */
  84386. _camMatrix: Matrix;
  84387. /** @hidden */
  84388. _cameraTransformMatrix: Matrix;
  84389. /** @hidden */
  84390. _cameraRotationMatrix: Matrix;
  84391. /** @hidden */
  84392. _referencePoint: Vector3;
  84393. /** @hidden */
  84394. _transformedReferencePoint: Vector3;
  84395. protected _globalCurrentTarget: Vector3;
  84396. protected _globalCurrentUpVector: Vector3;
  84397. /** @hidden */
  84398. _reset: () => void;
  84399. private _defaultUp;
  84400. /**
  84401. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  84402. * This is the base of the follow, arc rotate cameras and Free camera
  84403. * @see http://doc.babylonjs.com/features/cameras
  84404. * @param name Defines the name of the camera in the scene
  84405. * @param position Defines the start position of the camera in the scene
  84406. * @param scene Defines the scene the camera belongs to
  84407. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  84408. */
  84409. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  84410. /**
  84411. * Gets the position in front of the camera at a given distance.
  84412. * @param distance The distance from the camera we want the position to be
  84413. * @returns the position
  84414. */
  84415. getFrontPosition(distance: number): Vector3;
  84416. /** @hidden */
  84417. _getLockedTargetPosition(): Nullable<Vector3>;
  84418. private _storedPosition;
  84419. private _storedRotation;
  84420. private _storedRotationQuaternion;
  84421. /**
  84422. * Store current camera state of the camera (fov, position, rotation, etc..)
  84423. * @returns the camera
  84424. */
  84425. storeState(): Camera;
  84426. /**
  84427. * Restored camera state. You must call storeState() first
  84428. * @returns whether it was successful or not
  84429. * @hidden
  84430. */
  84431. _restoreStateValues(): boolean;
  84432. /** @hidden */
  84433. _initCache(): void;
  84434. /** @hidden */
  84435. _updateCache(ignoreParentClass?: boolean): void;
  84436. /** @hidden */
  84437. _isSynchronizedViewMatrix(): boolean;
  84438. /** @hidden */
  84439. _computeLocalCameraSpeed(): number;
  84440. /**
  84441. * Defines the target the camera should look at.
  84442. * @param target Defines the new target as a Vector or a mesh
  84443. */
  84444. setTarget(target: Vector3): void;
  84445. /**
  84446. * Return the current target position of the camera. This value is expressed in local space.
  84447. * @returns the target position
  84448. */
  84449. getTarget(): Vector3;
  84450. /** @hidden */
  84451. _decideIfNeedsToMove(): boolean;
  84452. /** @hidden */
  84453. _updatePosition(): void;
  84454. /** @hidden */
  84455. _checkInputs(): void;
  84456. protected _updateCameraRotationMatrix(): void;
  84457. /**
  84458. * 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)
  84459. * @returns the current camera
  84460. */
  84461. private _rotateUpVectorWithCameraRotationMatrix;
  84462. private _cachedRotationZ;
  84463. private _cachedQuaternionRotationZ;
  84464. /** @hidden */
  84465. _getViewMatrix(): Matrix;
  84466. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  84467. /**
  84468. * @hidden
  84469. */
  84470. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  84471. /**
  84472. * @hidden
  84473. */
  84474. _updateRigCameras(): void;
  84475. private _getRigCamPositionAndTarget;
  84476. /**
  84477. * Gets the current object class name.
  84478. * @return the class name
  84479. */
  84480. getClassName(): string;
  84481. }
  84482. }
  84483. declare module BABYLON {
  84484. /**
  84485. * Gather the list of keyboard event types as constants.
  84486. */
  84487. export class KeyboardEventTypes {
  84488. /**
  84489. * The keydown event is fired when a key becomes active (pressed).
  84490. */
  84491. static readonly KEYDOWN: number;
  84492. /**
  84493. * The keyup event is fired when a key has been released.
  84494. */
  84495. static readonly KEYUP: number;
  84496. }
  84497. /**
  84498. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84499. */
  84500. export class KeyboardInfo {
  84501. /**
  84502. * Defines the type of event (KeyboardEventTypes)
  84503. */
  84504. type: number;
  84505. /**
  84506. * Defines the related dom event
  84507. */
  84508. event: KeyboardEvent;
  84509. /**
  84510. * Instantiates a new keyboard info.
  84511. * This class is used to store keyboard related info for the onKeyboardObservable event.
  84512. * @param type Defines the type of event (KeyboardEventTypes)
  84513. * @param event Defines the related dom event
  84514. */
  84515. constructor(
  84516. /**
  84517. * Defines the type of event (KeyboardEventTypes)
  84518. */
  84519. type: number,
  84520. /**
  84521. * Defines the related dom event
  84522. */
  84523. event: KeyboardEvent);
  84524. }
  84525. /**
  84526. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84527. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  84528. */
  84529. export class KeyboardInfoPre extends KeyboardInfo {
  84530. /**
  84531. * Defines the type of event (KeyboardEventTypes)
  84532. */
  84533. type: number;
  84534. /**
  84535. * Defines the related dom event
  84536. */
  84537. event: KeyboardEvent;
  84538. /**
  84539. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  84540. */
  84541. skipOnPointerObservable: boolean;
  84542. /**
  84543. * Instantiates a new keyboard pre info.
  84544. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  84545. * @param type Defines the type of event (KeyboardEventTypes)
  84546. * @param event Defines the related dom event
  84547. */
  84548. constructor(
  84549. /**
  84550. * Defines the type of event (KeyboardEventTypes)
  84551. */
  84552. type: number,
  84553. /**
  84554. * Defines the related dom event
  84555. */
  84556. event: KeyboardEvent);
  84557. }
  84558. }
  84559. declare module BABYLON {
  84560. /**
  84561. * Manage the keyboard inputs to control the movement of a free camera.
  84562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84563. */
  84564. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  84565. /**
  84566. * Defines the camera the input is attached to.
  84567. */
  84568. camera: FreeCamera;
  84569. /**
  84570. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  84571. */
  84572. keysUp: number[];
  84573. /**
  84574. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  84575. */
  84576. keysUpward: number[];
  84577. /**
  84578. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  84579. */
  84580. keysDown: number[];
  84581. /**
  84582. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  84583. */
  84584. keysDownward: number[];
  84585. /**
  84586. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  84587. */
  84588. keysLeft: number[];
  84589. /**
  84590. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  84591. */
  84592. keysRight: number[];
  84593. private _keys;
  84594. private _onCanvasBlurObserver;
  84595. private _onKeyboardObserver;
  84596. private _engine;
  84597. private _scene;
  84598. /**
  84599. * Attach the input controls to a specific dom element to get the input from.
  84600. * @param element Defines the element the controls should be listened from
  84601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84602. */
  84603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84604. /**
  84605. * Detach the current controls from the specified dom element.
  84606. * @param element Defines the element to stop listening the inputs from
  84607. */
  84608. detachControl(element: Nullable<HTMLElement>): void;
  84609. /**
  84610. * Update the current camera state depending on the inputs that have been used this frame.
  84611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84612. */
  84613. checkInputs(): void;
  84614. /**
  84615. * Gets the class name of the current intput.
  84616. * @returns the class name
  84617. */
  84618. getClassName(): string;
  84619. /** @hidden */
  84620. _onLostFocus(): void;
  84621. /**
  84622. * Get the friendly name associated with the input class.
  84623. * @returns the input friendly name
  84624. */
  84625. getSimpleName(): string;
  84626. }
  84627. }
  84628. declare module BABYLON {
  84629. /**
  84630. * Interface describing all the common properties and methods a shadow light needs to implement.
  84631. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  84632. * as well as binding the different shadow properties to the effects.
  84633. */
  84634. export interface IShadowLight extends Light {
  84635. /**
  84636. * The light id in the scene (used in scene.findLighById for instance)
  84637. */
  84638. id: string;
  84639. /**
  84640. * The position the shdow will be casted from.
  84641. */
  84642. position: Vector3;
  84643. /**
  84644. * In 2d mode (needCube being false), the direction used to cast the shadow.
  84645. */
  84646. direction: Vector3;
  84647. /**
  84648. * The transformed position. Position of the light in world space taking parenting in account.
  84649. */
  84650. transformedPosition: Vector3;
  84651. /**
  84652. * The transformed direction. Direction of the light in world space taking parenting in account.
  84653. */
  84654. transformedDirection: Vector3;
  84655. /**
  84656. * The friendly name of the light in the scene.
  84657. */
  84658. name: string;
  84659. /**
  84660. * Defines the shadow projection clipping minimum z value.
  84661. */
  84662. shadowMinZ: number;
  84663. /**
  84664. * Defines the shadow projection clipping maximum z value.
  84665. */
  84666. shadowMaxZ: number;
  84667. /**
  84668. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84669. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84670. */
  84671. computeTransformedInformation(): boolean;
  84672. /**
  84673. * Gets the scene the light belongs to.
  84674. * @returns The scene
  84675. */
  84676. getScene(): Scene;
  84677. /**
  84678. * Callback defining a custom Projection Matrix Builder.
  84679. * This can be used to override the default projection matrix computation.
  84680. */
  84681. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84682. /**
  84683. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84684. * @param matrix The materix to updated with the projection information
  84685. * @param viewMatrix The transform matrix of the light
  84686. * @param renderList The list of mesh to render in the map
  84687. * @returns The current light
  84688. */
  84689. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84690. /**
  84691. * Gets the current depth scale used in ESM.
  84692. * @returns The scale
  84693. */
  84694. getDepthScale(): number;
  84695. /**
  84696. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84697. * @returns true if a cube texture needs to be use
  84698. */
  84699. needCube(): boolean;
  84700. /**
  84701. * Detects if the projection matrix requires to be recomputed this frame.
  84702. * @returns true if it requires to be recomputed otherwise, false.
  84703. */
  84704. needProjectionMatrixCompute(): boolean;
  84705. /**
  84706. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84707. */
  84708. forceProjectionMatrixCompute(): void;
  84709. /**
  84710. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84711. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84712. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84713. */
  84714. getShadowDirection(faceIndex?: number): Vector3;
  84715. /**
  84716. * Gets the minZ used for shadow according to both the scene and the light.
  84717. * @param activeCamera The camera we are returning the min for
  84718. * @returns the depth min z
  84719. */
  84720. getDepthMinZ(activeCamera: Camera): number;
  84721. /**
  84722. * Gets the maxZ used for shadow according to both the scene and the light.
  84723. * @param activeCamera The camera we are returning the max for
  84724. * @returns the depth max z
  84725. */
  84726. getDepthMaxZ(activeCamera: Camera): number;
  84727. }
  84728. /**
  84729. * Base implementation IShadowLight
  84730. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  84731. */
  84732. export abstract class ShadowLight extends Light implements IShadowLight {
  84733. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  84734. protected _position: Vector3;
  84735. protected _setPosition(value: Vector3): void;
  84736. /**
  84737. * Sets the position the shadow will be casted from. Also use as the light position for both
  84738. * point and spot lights.
  84739. */
  84740. get position(): Vector3;
  84741. /**
  84742. * Sets the position the shadow will be casted from. Also use as the light position for both
  84743. * point and spot lights.
  84744. */
  84745. set position(value: Vector3);
  84746. protected _direction: Vector3;
  84747. protected _setDirection(value: Vector3): void;
  84748. /**
  84749. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  84750. * Also use as the light direction on spot and directional lights.
  84751. */
  84752. get direction(): Vector3;
  84753. /**
  84754. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  84755. * Also use as the light direction on spot and directional lights.
  84756. */
  84757. set direction(value: Vector3);
  84758. protected _shadowMinZ: number;
  84759. /**
  84760. * Gets the shadow projection clipping minimum z value.
  84761. */
  84762. get shadowMinZ(): number;
  84763. /**
  84764. * Sets the shadow projection clipping minimum z value.
  84765. */
  84766. set shadowMinZ(value: number);
  84767. protected _shadowMaxZ: number;
  84768. /**
  84769. * Sets the shadow projection clipping maximum z value.
  84770. */
  84771. get shadowMaxZ(): number;
  84772. /**
  84773. * Gets the shadow projection clipping maximum z value.
  84774. */
  84775. set shadowMaxZ(value: number);
  84776. /**
  84777. * Callback defining a custom Projection Matrix Builder.
  84778. * This can be used to override the default projection matrix computation.
  84779. */
  84780. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  84781. /**
  84782. * The transformed position. Position of the light in world space taking parenting in account.
  84783. */
  84784. transformedPosition: Vector3;
  84785. /**
  84786. * The transformed direction. Direction of the light in world space taking parenting in account.
  84787. */
  84788. transformedDirection: Vector3;
  84789. private _needProjectionMatrixCompute;
  84790. /**
  84791. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  84792. * @returns true if the information has been computed, false if it does not need to (no parenting)
  84793. */
  84794. computeTransformedInformation(): boolean;
  84795. /**
  84796. * Return the depth scale used for the shadow map.
  84797. * @returns the depth scale.
  84798. */
  84799. getDepthScale(): number;
  84800. /**
  84801. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  84802. * @param faceIndex The index of the face we are computed the direction to generate shadow
  84803. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  84804. */
  84805. getShadowDirection(faceIndex?: number): Vector3;
  84806. /**
  84807. * Returns the ShadowLight absolute position in the World.
  84808. * @returns the position vector in world space
  84809. */
  84810. getAbsolutePosition(): Vector3;
  84811. /**
  84812. * Sets the ShadowLight direction toward the passed target.
  84813. * @param target The point to target in local space
  84814. * @returns the updated ShadowLight direction
  84815. */
  84816. setDirectionToTarget(target: Vector3): Vector3;
  84817. /**
  84818. * Returns the light rotation in euler definition.
  84819. * @returns the x y z rotation in local space.
  84820. */
  84821. getRotation(): Vector3;
  84822. /**
  84823. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  84824. * @returns true if a cube texture needs to be use
  84825. */
  84826. needCube(): boolean;
  84827. /**
  84828. * Detects if the projection matrix requires to be recomputed this frame.
  84829. * @returns true if it requires to be recomputed otherwise, false.
  84830. */
  84831. needProjectionMatrixCompute(): boolean;
  84832. /**
  84833. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  84834. */
  84835. forceProjectionMatrixCompute(): void;
  84836. /** @hidden */
  84837. _initCache(): void;
  84838. /** @hidden */
  84839. _isSynchronized(): boolean;
  84840. /**
  84841. * Computes the world matrix of the node
  84842. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84843. * @returns the world matrix
  84844. */
  84845. computeWorldMatrix(force?: boolean): Matrix;
  84846. /**
  84847. * Gets the minZ used for shadow according to both the scene and the light.
  84848. * @param activeCamera The camera we are returning the min for
  84849. * @returns the depth min z
  84850. */
  84851. getDepthMinZ(activeCamera: Camera): number;
  84852. /**
  84853. * Gets the maxZ used for shadow according to both the scene and the light.
  84854. * @param activeCamera The camera we are returning the max for
  84855. * @returns the depth max z
  84856. */
  84857. getDepthMaxZ(activeCamera: Camera): number;
  84858. /**
  84859. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  84860. * @param matrix The materix to updated with the projection information
  84861. * @param viewMatrix The transform matrix of the light
  84862. * @param renderList The list of mesh to render in the map
  84863. * @returns The current light
  84864. */
  84865. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  84866. }
  84867. }
  84868. declare module BABYLON {
  84869. /**
  84870. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84871. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84872. */
  84873. export class EffectFallbacks implements IEffectFallbacks {
  84874. private _defines;
  84875. private _currentRank;
  84876. private _maxRank;
  84877. private _mesh;
  84878. /**
  84879. * Removes the fallback from the bound mesh.
  84880. */
  84881. unBindMesh(): void;
  84882. /**
  84883. * Adds a fallback on the specified property.
  84884. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84885. * @param define The name of the define in the shader
  84886. */
  84887. addFallback(rank: number, define: string): void;
  84888. /**
  84889. * Sets the mesh to use CPU skinning when needing to fallback.
  84890. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84891. * @param mesh The mesh to use the fallbacks.
  84892. */
  84893. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84894. /**
  84895. * Checks to see if more fallbacks are still availible.
  84896. */
  84897. get hasMoreFallbacks(): boolean;
  84898. /**
  84899. * Removes the defines that should be removed when falling back.
  84900. * @param currentDefines defines the current define statements for the shader.
  84901. * @param effect defines the current effect we try to compile
  84902. * @returns The resulting defines with defines of the current rank removed.
  84903. */
  84904. reduce(currentDefines: string, effect: Effect): string;
  84905. }
  84906. }
  84907. declare module BABYLON {
  84908. /**
  84909. * "Static Class" containing the most commonly used helper while dealing with material for
  84910. * rendering purpose.
  84911. *
  84912. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  84913. *
  84914. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  84915. */
  84916. export class MaterialHelper {
  84917. /**
  84918. * Bind the current view position to an effect.
  84919. * @param effect The effect to be bound
  84920. * @param scene The scene the eyes position is used from
  84921. * @param variableName name of the shader variable that will hold the eye position
  84922. */
  84923. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  84924. /**
  84925. * Helps preparing the defines values about the UVs in used in the effect.
  84926. * UVs are shared as much as we can accross channels in the shaders.
  84927. * @param texture The texture we are preparing the UVs for
  84928. * @param defines The defines to update
  84929. * @param key The channel key "diffuse", "specular"... used in the shader
  84930. */
  84931. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  84932. /**
  84933. * Binds a texture matrix value to its corrsponding uniform
  84934. * @param texture The texture to bind the matrix for
  84935. * @param uniformBuffer The uniform buffer receivin the data
  84936. * @param key The channel key "diffuse", "specular"... used in the shader
  84937. */
  84938. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  84939. /**
  84940. * Gets the current status of the fog (should it be enabled?)
  84941. * @param mesh defines the mesh to evaluate for fog support
  84942. * @param scene defines the hosting scene
  84943. * @returns true if fog must be enabled
  84944. */
  84945. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  84946. /**
  84947. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  84948. * @param mesh defines the current mesh
  84949. * @param scene defines the current scene
  84950. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  84951. * @param pointsCloud defines if point cloud rendering has to be turned on
  84952. * @param fogEnabled defines if fog has to be turned on
  84953. * @param alphaTest defines if alpha testing has to be turned on
  84954. * @param defines defines the current list of defines
  84955. */
  84956. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  84957. /**
  84958. * Helper used to prepare the list of defines associated with frame values for shader compilation
  84959. * @param scene defines the current scene
  84960. * @param engine defines the current engine
  84961. * @param defines specifies the list of active defines
  84962. * @param useInstances defines if instances have to be turned on
  84963. * @param useClipPlane defines if clip plane have to be turned on
  84964. */
  84965. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  84966. /**
  84967. * Prepares the defines for bones
  84968. * @param mesh The mesh containing the geometry data we will draw
  84969. * @param defines The defines to update
  84970. */
  84971. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  84972. /**
  84973. * Prepares the defines for morph targets
  84974. * @param mesh The mesh containing the geometry data we will draw
  84975. * @param defines The defines to update
  84976. */
  84977. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  84978. /**
  84979. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  84980. * @param mesh The mesh containing the geometry data we will draw
  84981. * @param defines The defines to update
  84982. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  84983. * @param useBones Precise whether bones should be used or not (override mesh info)
  84984. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  84985. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  84986. * @returns false if defines are considered not dirty and have not been checked
  84987. */
  84988. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  84989. /**
  84990. * Prepares the defines related to multiview
  84991. * @param scene The scene we are intending to draw
  84992. * @param defines The defines to update
  84993. */
  84994. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  84995. /**
  84996. * Prepares the defines related to the light information passed in parameter
  84997. * @param scene The scene we are intending to draw
  84998. * @param mesh The mesh the effect is compiling for
  84999. * @param light The light the effect is compiling for
  85000. * @param lightIndex The index of the light
  85001. * @param defines The defines to update
  85002. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85003. * @param state Defines the current state regarding what is needed (normals, etc...)
  85004. */
  85005. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  85006. needNormals: boolean;
  85007. needRebuild: boolean;
  85008. shadowEnabled: boolean;
  85009. specularEnabled: boolean;
  85010. lightmapMode: boolean;
  85011. }): void;
  85012. /**
  85013. * Prepares the defines related to the light information passed in parameter
  85014. * @param scene The scene we are intending to draw
  85015. * @param mesh The mesh the effect is compiling for
  85016. * @param defines The defines to update
  85017. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  85018. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  85019. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  85020. * @returns true if normals will be required for the rest of the effect
  85021. */
  85022. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  85023. /**
  85024. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  85025. * @param lightIndex defines the light index
  85026. * @param uniformsList The uniform list
  85027. * @param samplersList The sampler list
  85028. * @param projectedLightTexture defines if projected texture must be used
  85029. * @param uniformBuffersList defines an optional list of uniform buffers
  85030. */
  85031. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  85032. /**
  85033. * Prepares the uniforms and samplers list to be used in the effect
  85034. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  85035. * @param samplersList The sampler list
  85036. * @param defines The defines helping in the list generation
  85037. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  85038. */
  85039. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  85040. /**
  85041. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  85042. * @param defines The defines to update while falling back
  85043. * @param fallbacks The authorized effect fallbacks
  85044. * @param maxSimultaneousLights The maximum number of lights allowed
  85045. * @param rank the current rank of the Effect
  85046. * @returns The newly affected rank
  85047. */
  85048. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  85049. private static _TmpMorphInfluencers;
  85050. /**
  85051. * Prepares the list of attributes required for morph targets according to the effect defines.
  85052. * @param attribs The current list of supported attribs
  85053. * @param mesh The mesh to prepare the morph targets attributes for
  85054. * @param influencers The number of influencers
  85055. */
  85056. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  85057. /**
  85058. * Prepares the list of attributes required for morph targets according to the effect defines.
  85059. * @param attribs The current list of supported attribs
  85060. * @param mesh The mesh to prepare the morph targets attributes for
  85061. * @param defines The current Defines of the effect
  85062. */
  85063. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  85064. /**
  85065. * Prepares the list of attributes required for bones according to the effect defines.
  85066. * @param attribs The current list of supported attribs
  85067. * @param mesh The mesh to prepare the bones attributes for
  85068. * @param defines The current Defines of the effect
  85069. * @param fallbacks The current efffect fallback strategy
  85070. */
  85071. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  85072. /**
  85073. * Check and prepare the list of attributes required for instances according to the effect defines.
  85074. * @param attribs The current list of supported attribs
  85075. * @param defines The current MaterialDefines of the effect
  85076. */
  85077. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  85078. /**
  85079. * Add the list of attributes required for instances to the attribs array.
  85080. * @param attribs The current list of supported attribs
  85081. */
  85082. static PushAttributesForInstances(attribs: string[]): void;
  85083. /**
  85084. * Binds the light information to the effect.
  85085. * @param light The light containing the generator
  85086. * @param effect The effect we are binding the data to
  85087. * @param lightIndex The light index in the effect used to render
  85088. */
  85089. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  85090. /**
  85091. * Binds the lights information from the scene to the effect for the given mesh.
  85092. * @param light Light to bind
  85093. * @param lightIndex Light index
  85094. * @param scene The scene where the light belongs to
  85095. * @param effect The effect we are binding the data to
  85096. * @param useSpecular Defines if specular is supported
  85097. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85098. */
  85099. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  85100. /**
  85101. * Binds the lights information from the scene to the effect for the given mesh.
  85102. * @param scene The scene the lights belongs to
  85103. * @param mesh The mesh we are binding the information to render
  85104. * @param effect The effect we are binding the data to
  85105. * @param defines The generated defines for the effect
  85106. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  85107. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  85108. */
  85109. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  85110. private static _tempFogColor;
  85111. /**
  85112. * Binds the fog information from the scene to the effect for the given mesh.
  85113. * @param scene The scene the lights belongs to
  85114. * @param mesh The mesh we are binding the information to render
  85115. * @param effect The effect we are binding the data to
  85116. * @param linearSpace Defines if the fog effect is applied in linear space
  85117. */
  85118. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  85119. /**
  85120. * Binds the bones information from the mesh to the effect.
  85121. * @param mesh The mesh we are binding the information to render
  85122. * @param effect The effect we are binding the data to
  85123. */
  85124. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  85125. /**
  85126. * Binds the morph targets information from the mesh to the effect.
  85127. * @param abstractMesh The mesh we are binding the information to render
  85128. * @param effect The effect we are binding the data to
  85129. */
  85130. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  85131. /**
  85132. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  85133. * @param defines The generated defines used in the effect
  85134. * @param effect The effect we are binding the data to
  85135. * @param scene The scene we are willing to render with logarithmic scale for
  85136. */
  85137. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  85138. /**
  85139. * Binds the clip plane information from the scene to the effect.
  85140. * @param scene The scene the clip plane information are extracted from
  85141. * @param effect The effect we are binding the data to
  85142. */
  85143. static BindClipPlane(effect: Effect, scene: Scene): void;
  85144. }
  85145. }
  85146. declare module BABYLON {
  85147. /** @hidden */
  85148. export var packingFunctions: {
  85149. name: string;
  85150. shader: string;
  85151. };
  85152. }
  85153. declare module BABYLON {
  85154. /** @hidden */
  85155. export var shadowMapFragmentDeclaration: {
  85156. name: string;
  85157. shader: string;
  85158. };
  85159. }
  85160. declare module BABYLON {
  85161. /** @hidden */
  85162. export var clipPlaneFragmentDeclaration: {
  85163. name: string;
  85164. shader: string;
  85165. };
  85166. }
  85167. declare module BABYLON {
  85168. /** @hidden */
  85169. export var clipPlaneFragment: {
  85170. name: string;
  85171. shader: string;
  85172. };
  85173. }
  85174. declare module BABYLON {
  85175. /** @hidden */
  85176. export var shadowMapFragment: {
  85177. name: string;
  85178. shader: string;
  85179. };
  85180. }
  85181. declare module BABYLON {
  85182. /** @hidden */
  85183. export var shadowMapPixelShader: {
  85184. name: string;
  85185. shader: string;
  85186. };
  85187. }
  85188. declare module BABYLON {
  85189. /** @hidden */
  85190. export var bonesDeclaration: {
  85191. name: string;
  85192. shader: string;
  85193. };
  85194. }
  85195. declare module BABYLON {
  85196. /** @hidden */
  85197. export var morphTargetsVertexGlobalDeclaration: {
  85198. name: string;
  85199. shader: string;
  85200. };
  85201. }
  85202. declare module BABYLON {
  85203. /** @hidden */
  85204. export var morphTargetsVertexDeclaration: {
  85205. name: string;
  85206. shader: string;
  85207. };
  85208. }
  85209. declare module BABYLON {
  85210. /** @hidden */
  85211. export var instancesDeclaration: {
  85212. name: string;
  85213. shader: string;
  85214. };
  85215. }
  85216. declare module BABYLON {
  85217. /** @hidden */
  85218. export var helperFunctions: {
  85219. name: string;
  85220. shader: string;
  85221. };
  85222. }
  85223. declare module BABYLON {
  85224. /** @hidden */
  85225. export var shadowMapVertexDeclaration: {
  85226. name: string;
  85227. shader: string;
  85228. };
  85229. }
  85230. declare module BABYLON {
  85231. /** @hidden */
  85232. export var clipPlaneVertexDeclaration: {
  85233. name: string;
  85234. shader: string;
  85235. };
  85236. }
  85237. declare module BABYLON {
  85238. /** @hidden */
  85239. export var morphTargetsVertex: {
  85240. name: string;
  85241. shader: string;
  85242. };
  85243. }
  85244. declare module BABYLON {
  85245. /** @hidden */
  85246. export var instancesVertex: {
  85247. name: string;
  85248. shader: string;
  85249. };
  85250. }
  85251. declare module BABYLON {
  85252. /** @hidden */
  85253. export var bonesVertex: {
  85254. name: string;
  85255. shader: string;
  85256. };
  85257. }
  85258. declare module BABYLON {
  85259. /** @hidden */
  85260. export var shadowMapVertexNormalBias: {
  85261. name: string;
  85262. shader: string;
  85263. };
  85264. }
  85265. declare module BABYLON {
  85266. /** @hidden */
  85267. export var shadowMapVertexMetric: {
  85268. name: string;
  85269. shader: string;
  85270. };
  85271. }
  85272. declare module BABYLON {
  85273. /** @hidden */
  85274. export var clipPlaneVertex: {
  85275. name: string;
  85276. shader: string;
  85277. };
  85278. }
  85279. declare module BABYLON {
  85280. /** @hidden */
  85281. export var shadowMapVertexShader: {
  85282. name: string;
  85283. shader: string;
  85284. };
  85285. }
  85286. declare module BABYLON {
  85287. /** @hidden */
  85288. export var depthBoxBlurPixelShader: {
  85289. name: string;
  85290. shader: string;
  85291. };
  85292. }
  85293. declare module BABYLON {
  85294. /**
  85295. * Class representing a ray with position and direction
  85296. */
  85297. export class Ray {
  85298. /** origin point */
  85299. origin: Vector3;
  85300. /** direction */
  85301. direction: Vector3;
  85302. /** length of the ray */
  85303. length: number;
  85304. private static readonly TmpVector3;
  85305. private _tmpRay;
  85306. /**
  85307. * Creates a new ray
  85308. * @param origin origin point
  85309. * @param direction direction
  85310. * @param length length of the ray
  85311. */
  85312. constructor(
  85313. /** origin point */
  85314. origin: Vector3,
  85315. /** direction */
  85316. direction: Vector3,
  85317. /** length of the ray */
  85318. length?: number);
  85319. /**
  85320. * Checks if the ray intersects a box
  85321. * This does not account for the ray lenght by design to improve perfs.
  85322. * @param minimum bound of the box
  85323. * @param maximum bound of the box
  85324. * @param intersectionTreshold extra extend to be added to the box in all direction
  85325. * @returns if the box was hit
  85326. */
  85327. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  85328. /**
  85329. * Checks if the ray intersects a box
  85330. * This does not account for the ray lenght by design to improve perfs.
  85331. * @param box the bounding box to check
  85332. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  85333. * @returns if the box was hit
  85334. */
  85335. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  85336. /**
  85337. * If the ray hits a sphere
  85338. * @param sphere the bounding sphere to check
  85339. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  85340. * @returns true if it hits the sphere
  85341. */
  85342. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  85343. /**
  85344. * If the ray hits a triange
  85345. * @param vertex0 triangle vertex
  85346. * @param vertex1 triangle vertex
  85347. * @param vertex2 triangle vertex
  85348. * @returns intersection information if hit
  85349. */
  85350. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  85351. /**
  85352. * Checks if ray intersects a plane
  85353. * @param plane the plane to check
  85354. * @returns the distance away it was hit
  85355. */
  85356. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  85357. /**
  85358. * Calculate the intercept of a ray on a given axis
  85359. * @param axis to check 'x' | 'y' | 'z'
  85360. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  85361. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  85362. */
  85363. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  85364. /**
  85365. * Checks if ray intersects a mesh
  85366. * @param mesh the mesh to check
  85367. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85368. * @returns picking info of the intersecton
  85369. */
  85370. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  85371. /**
  85372. * Checks if ray intersects a mesh
  85373. * @param meshes the meshes to check
  85374. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85375. * @param results array to store result in
  85376. * @returns Array of picking infos
  85377. */
  85378. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  85379. private _comparePickingInfo;
  85380. private static smallnum;
  85381. private static rayl;
  85382. /**
  85383. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  85384. * @param sega the first point of the segment to test the intersection against
  85385. * @param segb the second point of the segment to test the intersection against
  85386. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  85387. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  85388. */
  85389. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  85390. /**
  85391. * Update the ray from viewport position
  85392. * @param x position
  85393. * @param y y position
  85394. * @param viewportWidth viewport width
  85395. * @param viewportHeight viewport height
  85396. * @param world world matrix
  85397. * @param view view matrix
  85398. * @param projection projection matrix
  85399. * @returns this ray updated
  85400. */
  85401. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85402. /**
  85403. * Creates a ray with origin and direction of 0,0,0
  85404. * @returns the new ray
  85405. */
  85406. static Zero(): Ray;
  85407. /**
  85408. * Creates a new ray from screen space and viewport
  85409. * @param x position
  85410. * @param y y position
  85411. * @param viewportWidth viewport width
  85412. * @param viewportHeight viewport height
  85413. * @param world world matrix
  85414. * @param view view matrix
  85415. * @param projection projection matrix
  85416. * @returns new ray
  85417. */
  85418. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  85419. /**
  85420. * 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
  85421. * transformed to the given world matrix.
  85422. * @param origin The origin point
  85423. * @param end The end point
  85424. * @param world a matrix to transform the ray to. Default is the identity matrix.
  85425. * @returns the new ray
  85426. */
  85427. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  85428. /**
  85429. * Transforms a ray by a matrix
  85430. * @param ray ray to transform
  85431. * @param matrix matrix to apply
  85432. * @returns the resulting new ray
  85433. */
  85434. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  85435. /**
  85436. * Transforms a ray by a matrix
  85437. * @param ray ray to transform
  85438. * @param matrix matrix to apply
  85439. * @param result ray to store result in
  85440. */
  85441. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  85442. /**
  85443. * Unproject a ray from screen space to object space
  85444. * @param sourceX defines the screen space x coordinate to use
  85445. * @param sourceY defines the screen space y coordinate to use
  85446. * @param viewportWidth defines the current width of the viewport
  85447. * @param viewportHeight defines the current height of the viewport
  85448. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85449. * @param view defines the view matrix to use
  85450. * @param projection defines the projection matrix to use
  85451. */
  85452. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  85453. }
  85454. /**
  85455. * Type used to define predicate used to select faces when a mesh intersection is detected
  85456. */
  85457. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  85458. interface Scene {
  85459. /** @hidden */
  85460. _tempPickingRay: Nullable<Ray>;
  85461. /** @hidden */
  85462. _cachedRayForTransform: Ray;
  85463. /** @hidden */
  85464. _pickWithRayInverseMatrix: Matrix;
  85465. /** @hidden */
  85466. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  85467. /** @hidden */
  85468. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  85469. }
  85470. }
  85471. declare module BABYLON {
  85472. /**
  85473. * Groups all the scene component constants in one place to ease maintenance.
  85474. * @hidden
  85475. */
  85476. export class SceneComponentConstants {
  85477. static readonly NAME_EFFECTLAYER: string;
  85478. static readonly NAME_LAYER: string;
  85479. static readonly NAME_LENSFLARESYSTEM: string;
  85480. static readonly NAME_BOUNDINGBOXRENDERER: string;
  85481. static readonly NAME_PARTICLESYSTEM: string;
  85482. static readonly NAME_GAMEPAD: string;
  85483. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  85484. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  85485. static readonly NAME_DEPTHRENDERER: string;
  85486. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  85487. static readonly NAME_SPRITE: string;
  85488. static readonly NAME_OUTLINERENDERER: string;
  85489. static readonly NAME_PROCEDURALTEXTURE: string;
  85490. static readonly NAME_SHADOWGENERATOR: string;
  85491. static readonly NAME_OCTREE: string;
  85492. static readonly NAME_PHYSICSENGINE: string;
  85493. static readonly NAME_AUDIO: string;
  85494. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  85495. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85496. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  85497. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  85498. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  85499. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  85500. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  85501. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  85502. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  85503. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  85504. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  85505. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  85506. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  85507. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  85508. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  85509. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  85510. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  85511. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  85512. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  85513. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  85514. static readonly STEP_AFTERRENDER_AUDIO: number;
  85515. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  85516. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  85517. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  85518. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  85519. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  85520. static readonly STEP_POINTERMOVE_SPRITE: number;
  85521. static readonly STEP_POINTERDOWN_SPRITE: number;
  85522. static readonly STEP_POINTERUP_SPRITE: number;
  85523. }
  85524. /**
  85525. * This represents a scene component.
  85526. *
  85527. * This is used to decouple the dependency the scene is having on the different workloads like
  85528. * layers, post processes...
  85529. */
  85530. export interface ISceneComponent {
  85531. /**
  85532. * The name of the component. Each component must have a unique name.
  85533. */
  85534. name: string;
  85535. /**
  85536. * The scene the component belongs to.
  85537. */
  85538. scene: Scene;
  85539. /**
  85540. * Register the component to one instance of a scene.
  85541. */
  85542. register(): void;
  85543. /**
  85544. * Rebuilds the elements related to this component in case of
  85545. * context lost for instance.
  85546. */
  85547. rebuild(): void;
  85548. /**
  85549. * Disposes the component and the associated ressources.
  85550. */
  85551. dispose(): void;
  85552. }
  85553. /**
  85554. * This represents a SERIALIZABLE scene component.
  85555. *
  85556. * This extends Scene Component to add Serialization methods on top.
  85557. */
  85558. export interface ISceneSerializableComponent extends ISceneComponent {
  85559. /**
  85560. * Adds all the elements from the container to the scene
  85561. * @param container the container holding the elements
  85562. */
  85563. addFromContainer(container: AbstractScene): void;
  85564. /**
  85565. * Removes all the elements in the container from the scene
  85566. * @param container contains the elements to remove
  85567. * @param dispose if the removed element should be disposed (default: false)
  85568. */
  85569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  85570. /**
  85571. * Serializes the component data to the specified json object
  85572. * @param serializationObject The object to serialize to
  85573. */
  85574. serialize(serializationObject: any): void;
  85575. }
  85576. /**
  85577. * Strong typing of a Mesh related stage step action
  85578. */
  85579. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  85580. /**
  85581. * Strong typing of a Evaluate Sub Mesh related stage step action
  85582. */
  85583. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  85584. /**
  85585. * Strong typing of a Active Mesh related stage step action
  85586. */
  85587. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  85588. /**
  85589. * Strong typing of a Camera related stage step action
  85590. */
  85591. export type CameraStageAction = (camera: Camera) => void;
  85592. /**
  85593. * Strong typing of a Camera Frame buffer related stage step action
  85594. */
  85595. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  85596. /**
  85597. * Strong typing of a Render Target related stage step action
  85598. */
  85599. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  85600. /**
  85601. * Strong typing of a RenderingGroup related stage step action
  85602. */
  85603. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  85604. /**
  85605. * Strong typing of a Mesh Render related stage step action
  85606. */
  85607. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  85608. /**
  85609. * Strong typing of a simple stage step action
  85610. */
  85611. export type SimpleStageAction = () => void;
  85612. /**
  85613. * Strong typing of a render target action.
  85614. */
  85615. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  85616. /**
  85617. * Strong typing of a pointer move action.
  85618. */
  85619. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  85620. /**
  85621. * Strong typing of a pointer up/down action.
  85622. */
  85623. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  85624. /**
  85625. * Representation of a stage in the scene (Basically a list of ordered steps)
  85626. * @hidden
  85627. */
  85628. export class Stage<T extends Function> extends Array<{
  85629. index: number;
  85630. component: ISceneComponent;
  85631. action: T;
  85632. }> {
  85633. /**
  85634. * Hide ctor from the rest of the world.
  85635. * @param items The items to add.
  85636. */
  85637. private constructor();
  85638. /**
  85639. * Creates a new Stage.
  85640. * @returns A new instance of a Stage
  85641. */
  85642. static Create<T extends Function>(): Stage<T>;
  85643. /**
  85644. * Registers a step in an ordered way in the targeted stage.
  85645. * @param index Defines the position to register the step in
  85646. * @param component Defines the component attached to the step
  85647. * @param action Defines the action to launch during the step
  85648. */
  85649. registerStep(index: number, component: ISceneComponent, action: T): void;
  85650. /**
  85651. * Clears all the steps from the stage.
  85652. */
  85653. clear(): void;
  85654. }
  85655. }
  85656. declare module BABYLON {
  85657. interface Scene {
  85658. /** @hidden */
  85659. _pointerOverSprite: Nullable<Sprite>;
  85660. /** @hidden */
  85661. _pickedDownSprite: Nullable<Sprite>;
  85662. /** @hidden */
  85663. _tempSpritePickingRay: Nullable<Ray>;
  85664. /**
  85665. * All of the sprite managers added to this scene
  85666. * @see http://doc.babylonjs.com/babylon101/sprites
  85667. */
  85668. spriteManagers: Array<ISpriteManager>;
  85669. /**
  85670. * An event triggered when sprites rendering is about to start
  85671. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85672. */
  85673. onBeforeSpritesRenderingObservable: Observable<Scene>;
  85674. /**
  85675. * An event triggered when sprites rendering is done
  85676. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  85677. */
  85678. onAfterSpritesRenderingObservable: Observable<Scene>;
  85679. /** @hidden */
  85680. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85681. /** Launch a ray to try to pick a sprite in the scene
  85682. * @param x position on screen
  85683. * @param y position on screen
  85684. * @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
  85685. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85686. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85687. * @returns a PickingInfo
  85688. */
  85689. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85690. /** Use the given ray to pick a sprite in the scene
  85691. * @param ray The ray (in world space) to use to pick meshes
  85692. * @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
  85693. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85694. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85695. * @returns a PickingInfo
  85696. */
  85697. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  85698. /** @hidden */
  85699. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85700. /** Launch a ray to try to pick sprites in the scene
  85701. * @param x position on screen
  85702. * @param y position on screen
  85703. * @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
  85704. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  85705. * @returns a PickingInfo array
  85706. */
  85707. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85708. /** Use the given ray to pick sprites in the scene
  85709. * @param ray The ray (in world space) to use to pick meshes
  85710. * @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
  85711. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  85712. * @returns a PickingInfo array
  85713. */
  85714. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  85715. /**
  85716. * Force the sprite under the pointer
  85717. * @param sprite defines the sprite to use
  85718. */
  85719. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  85720. /**
  85721. * Gets the sprite under the pointer
  85722. * @returns a Sprite or null if no sprite is under the pointer
  85723. */
  85724. getPointerOverSprite(): Nullable<Sprite>;
  85725. }
  85726. /**
  85727. * Defines the sprite scene component responsible to manage sprites
  85728. * in a given scene.
  85729. */
  85730. export class SpriteSceneComponent implements ISceneComponent {
  85731. /**
  85732. * The component name helpfull to identify the component in the list of scene components.
  85733. */
  85734. readonly name: string;
  85735. /**
  85736. * The scene the component belongs to.
  85737. */
  85738. scene: Scene;
  85739. /** @hidden */
  85740. private _spritePredicate;
  85741. /**
  85742. * Creates a new instance of the component for the given scene
  85743. * @param scene Defines the scene to register the component in
  85744. */
  85745. constructor(scene: Scene);
  85746. /**
  85747. * Registers the component in a given scene
  85748. */
  85749. register(): void;
  85750. /**
  85751. * Rebuilds the elements related to this component in case of
  85752. * context lost for instance.
  85753. */
  85754. rebuild(): void;
  85755. /**
  85756. * Disposes the component and the associated ressources.
  85757. */
  85758. dispose(): void;
  85759. private _pickSpriteButKeepRay;
  85760. private _pointerMove;
  85761. private _pointerDown;
  85762. private _pointerUp;
  85763. }
  85764. }
  85765. declare module BABYLON {
  85766. /** @hidden */
  85767. export var fogFragmentDeclaration: {
  85768. name: string;
  85769. shader: string;
  85770. };
  85771. }
  85772. declare module BABYLON {
  85773. /** @hidden */
  85774. export var fogFragment: {
  85775. name: string;
  85776. shader: string;
  85777. };
  85778. }
  85779. declare module BABYLON {
  85780. /** @hidden */
  85781. export var spritesPixelShader: {
  85782. name: string;
  85783. shader: string;
  85784. };
  85785. }
  85786. declare module BABYLON {
  85787. /** @hidden */
  85788. export var fogVertexDeclaration: {
  85789. name: string;
  85790. shader: string;
  85791. };
  85792. }
  85793. declare module BABYLON {
  85794. /** @hidden */
  85795. export var spritesVertexShader: {
  85796. name: string;
  85797. shader: string;
  85798. };
  85799. }
  85800. declare module BABYLON {
  85801. /**
  85802. * Defines the minimum interface to fullfil in order to be a sprite manager.
  85803. */
  85804. export interface ISpriteManager extends IDisposable {
  85805. /**
  85806. * Restricts the camera to viewing objects with the same layerMask.
  85807. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  85808. */
  85809. layerMask: number;
  85810. /**
  85811. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  85812. */
  85813. isPickable: boolean;
  85814. /**
  85815. * Specifies the rendering group id for this mesh (0 by default)
  85816. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  85817. */
  85818. renderingGroupId: number;
  85819. /**
  85820. * Defines the list of sprites managed by the manager.
  85821. */
  85822. sprites: Array<Sprite>;
  85823. /**
  85824. * Tests the intersection of a sprite with a specific ray.
  85825. * @param ray The ray we are sending to test the collision
  85826. * @param camera The camera space we are sending rays in
  85827. * @param predicate A predicate allowing excluding sprites from the list of object to test
  85828. * @param fastCheck defines if the first intersection will be used (and not the closest)
  85829. * @returns picking info or null.
  85830. */
  85831. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  85832. /**
  85833. * Intersects the sprites with a ray
  85834. * @param ray defines the ray to intersect with
  85835. * @param camera defines the current active camera
  85836. * @param predicate defines a predicate used to select candidate sprites
  85837. * @returns null if no hit or a PickingInfo array
  85838. */
  85839. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  85840. /**
  85841. * Renders the list of sprites on screen.
  85842. */
  85843. render(): void;
  85844. }
  85845. /**
  85846. * Class used to manage multiple sprites on the same spritesheet
  85847. * @see http://doc.babylonjs.com/babylon101/sprites
  85848. */
  85849. export class SpriteManager implements ISpriteManager {
  85850. /** defines the manager's name */
  85851. name: string;
  85852. /** Gets the list of sprites */
  85853. sprites: Sprite[];
  85854. /** Gets or sets the rendering group id (0 by default) */
  85855. renderingGroupId: number;
  85856. /** Gets or sets camera layer mask */
  85857. layerMask: number;
  85858. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  85859. fogEnabled: boolean;
  85860. /** Gets or sets a boolean indicating if the sprites are pickable */
  85861. isPickable: boolean;
  85862. /** Defines the default width of a cell in the spritesheet */
  85863. cellWidth: number;
  85864. /** Defines the default height of a cell in the spritesheet */
  85865. cellHeight: number;
  85866. /** Associative array from JSON sprite data file */
  85867. private _cellData;
  85868. /** Array of sprite names from JSON sprite data file */
  85869. private _spriteMap;
  85870. /** True when packed cell data from JSON file is ready*/
  85871. private _packedAndReady;
  85872. private _textureContent;
  85873. /**
  85874. * An event triggered when the manager is disposed.
  85875. */
  85876. onDisposeObservable: Observable<SpriteManager>;
  85877. private _onDisposeObserver;
  85878. /**
  85879. * Callback called when the manager is disposed
  85880. */
  85881. set onDispose(callback: () => void);
  85882. private _capacity;
  85883. private _fromPacked;
  85884. private _spriteTexture;
  85885. private _epsilon;
  85886. private _scene;
  85887. private _vertexData;
  85888. private _buffer;
  85889. private _vertexBuffers;
  85890. private _indexBuffer;
  85891. private _effectBase;
  85892. private _effectFog;
  85893. /**
  85894. * Gets or sets the spritesheet texture
  85895. */
  85896. get texture(): Texture;
  85897. set texture(value: Texture);
  85898. private _blendMode;
  85899. /**
  85900. * Blend mode use to render the particle, it can be any of
  85901. * the static Constants.ALPHA_x properties provided in this class.
  85902. * Default value is Constants.ALPHA_COMBINE
  85903. */
  85904. get blendMode(): number;
  85905. set blendMode(blendMode: number);
  85906. /** Disables writing to the depth buffer when rendering the sprites.
  85907. * It can be handy to disable depth writing when using textures without alpha channel
  85908. * and setting some specific blend modes.
  85909. */
  85910. disableDepthWrite: boolean;
  85911. /**
  85912. * Creates a new sprite manager
  85913. * @param name defines the manager's name
  85914. * @param imgUrl defines the sprite sheet url
  85915. * @param capacity defines the maximum allowed number of sprites
  85916. * @param cellSize defines the size of a sprite cell
  85917. * @param scene defines the hosting scene
  85918. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  85919. * @param samplingMode defines the smapling mode to use with spritesheet
  85920. * @param fromPacked set to false; do not alter
  85921. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  85922. */
  85923. constructor(
  85924. /** defines the manager's name */
  85925. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  85926. private _makePacked;
  85927. private _appendSpriteVertex;
  85928. private _checkTextureAlpha;
  85929. /**
  85930. * Intersects the sprites with a ray
  85931. * @param ray defines the ray to intersect with
  85932. * @param camera defines the current active camera
  85933. * @param predicate defines a predicate used to select candidate sprites
  85934. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  85935. * @returns null if no hit or a PickingInfo
  85936. */
  85937. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  85938. /**
  85939. * Intersects the sprites with a ray
  85940. * @param ray defines the ray to intersect with
  85941. * @param camera defines the current active camera
  85942. * @param predicate defines a predicate used to select candidate sprites
  85943. * @returns null if no hit or a PickingInfo array
  85944. */
  85945. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  85946. /**
  85947. * Render all child sprites
  85948. */
  85949. render(): void;
  85950. /**
  85951. * Release associated resources
  85952. */
  85953. dispose(): void;
  85954. }
  85955. }
  85956. declare module BABYLON {
  85957. /** Interface used by value gradients (color, factor, ...) */
  85958. export interface IValueGradient {
  85959. /**
  85960. * Gets or sets the gradient value (between 0 and 1)
  85961. */
  85962. gradient: number;
  85963. }
  85964. /** Class used to store color4 gradient */
  85965. export class ColorGradient implements IValueGradient {
  85966. /**
  85967. * Gets or sets the gradient value (between 0 and 1)
  85968. */
  85969. gradient: number;
  85970. /**
  85971. * Gets or sets first associated color
  85972. */
  85973. color1: Color4;
  85974. /**
  85975. * Gets or sets second associated color
  85976. */
  85977. color2?: Color4 | undefined;
  85978. /**
  85979. * Creates a new color4 gradient
  85980. * @param gradient gets or sets the gradient value (between 0 and 1)
  85981. * @param color1 gets or sets first associated color
  85982. * @param color2 gets or sets first second color
  85983. */
  85984. constructor(
  85985. /**
  85986. * Gets or sets the gradient value (between 0 and 1)
  85987. */
  85988. gradient: number,
  85989. /**
  85990. * Gets or sets first associated color
  85991. */
  85992. color1: Color4,
  85993. /**
  85994. * Gets or sets second associated color
  85995. */
  85996. color2?: Color4 | undefined);
  85997. /**
  85998. * Will get a color picked randomly between color1 and color2.
  85999. * If color2 is undefined then color1 will be used
  86000. * @param result defines the target Color4 to store the result in
  86001. */
  86002. getColorToRef(result: Color4): void;
  86003. }
  86004. /** Class used to store color 3 gradient */
  86005. export class Color3Gradient implements IValueGradient {
  86006. /**
  86007. * Gets or sets the gradient value (between 0 and 1)
  86008. */
  86009. gradient: number;
  86010. /**
  86011. * Gets or sets the associated color
  86012. */
  86013. color: Color3;
  86014. /**
  86015. * Creates a new color3 gradient
  86016. * @param gradient gets or sets the gradient value (between 0 and 1)
  86017. * @param color gets or sets associated color
  86018. */
  86019. constructor(
  86020. /**
  86021. * Gets or sets the gradient value (between 0 and 1)
  86022. */
  86023. gradient: number,
  86024. /**
  86025. * Gets or sets the associated color
  86026. */
  86027. color: Color3);
  86028. }
  86029. /** Class used to store factor gradient */
  86030. export class FactorGradient implements IValueGradient {
  86031. /**
  86032. * Gets or sets the gradient value (between 0 and 1)
  86033. */
  86034. gradient: number;
  86035. /**
  86036. * Gets or sets first associated factor
  86037. */
  86038. factor1: number;
  86039. /**
  86040. * Gets or sets second associated factor
  86041. */
  86042. factor2?: number | undefined;
  86043. /**
  86044. * Creates a new factor gradient
  86045. * @param gradient gets or sets the gradient value (between 0 and 1)
  86046. * @param factor1 gets or sets first associated factor
  86047. * @param factor2 gets or sets second associated factor
  86048. */
  86049. constructor(
  86050. /**
  86051. * Gets or sets the gradient value (between 0 and 1)
  86052. */
  86053. gradient: number,
  86054. /**
  86055. * Gets or sets first associated factor
  86056. */
  86057. factor1: number,
  86058. /**
  86059. * Gets or sets second associated factor
  86060. */
  86061. factor2?: number | undefined);
  86062. /**
  86063. * Will get a number picked randomly between factor1 and factor2.
  86064. * If factor2 is undefined then factor1 will be used
  86065. * @returns the picked number
  86066. */
  86067. getFactor(): number;
  86068. }
  86069. /**
  86070. * Helper used to simplify some generic gradient tasks
  86071. */
  86072. export class GradientHelper {
  86073. /**
  86074. * Gets the current gradient from an array of IValueGradient
  86075. * @param ratio defines the current ratio to get
  86076. * @param gradients defines the array of IValueGradient
  86077. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86078. */
  86079. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86080. }
  86081. }
  86082. declare module BABYLON {
  86083. /**
  86084. * Interface for the size containing width and height
  86085. */
  86086. export interface ISize {
  86087. /**
  86088. * Width
  86089. */
  86090. width: number;
  86091. /**
  86092. * Heighht
  86093. */
  86094. height: number;
  86095. }
  86096. /**
  86097. * Size containing widht and height
  86098. */
  86099. export class Size implements ISize {
  86100. /**
  86101. * Width
  86102. */
  86103. width: number;
  86104. /**
  86105. * Height
  86106. */
  86107. height: number;
  86108. /**
  86109. * Creates a Size object from the given width and height (floats).
  86110. * @param width width of the new size
  86111. * @param height height of the new size
  86112. */
  86113. constructor(width: number, height: number);
  86114. /**
  86115. * Returns a string with the Size width and height
  86116. * @returns a string with the Size width and height
  86117. */
  86118. toString(): string;
  86119. /**
  86120. * "Size"
  86121. * @returns the string "Size"
  86122. */
  86123. getClassName(): string;
  86124. /**
  86125. * Returns the Size hash code.
  86126. * @returns a hash code for a unique width and height
  86127. */
  86128. getHashCode(): number;
  86129. /**
  86130. * Updates the current size from the given one.
  86131. * @param src the given size
  86132. */
  86133. copyFrom(src: Size): void;
  86134. /**
  86135. * Updates in place the current Size from the given floats.
  86136. * @param width width of the new size
  86137. * @param height height of the new size
  86138. * @returns the updated Size.
  86139. */
  86140. copyFromFloats(width: number, height: number): Size;
  86141. /**
  86142. * Updates in place the current Size from the given floats.
  86143. * @param width width to set
  86144. * @param height height to set
  86145. * @returns the updated Size.
  86146. */
  86147. set(width: number, height: number): Size;
  86148. /**
  86149. * Multiplies the width and height by numbers
  86150. * @param w factor to multiple the width by
  86151. * @param h factor to multiple the height by
  86152. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86153. */
  86154. multiplyByFloats(w: number, h: number): Size;
  86155. /**
  86156. * Clones the size
  86157. * @returns a new Size copied from the given one.
  86158. */
  86159. clone(): Size;
  86160. /**
  86161. * True if the current Size and the given one width and height are strictly equal.
  86162. * @param other the other size to compare against
  86163. * @returns True if the current Size and the given one width and height are strictly equal.
  86164. */
  86165. equals(other: Size): boolean;
  86166. /**
  86167. * The surface of the Size : width * height (float).
  86168. */
  86169. get surface(): number;
  86170. /**
  86171. * Create a new size of zero
  86172. * @returns a new Size set to (0.0, 0.0)
  86173. */
  86174. static Zero(): Size;
  86175. /**
  86176. * Sums the width and height of two sizes
  86177. * @param otherSize size to add to this size
  86178. * @returns a new Size set as the addition result of the current Size and the given one.
  86179. */
  86180. add(otherSize: Size): Size;
  86181. /**
  86182. * Subtracts the width and height of two
  86183. * @param otherSize size to subtract to this size
  86184. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86185. */
  86186. subtract(otherSize: Size): Size;
  86187. /**
  86188. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86189. * @param start starting size to lerp between
  86190. * @param end end size to lerp between
  86191. * @param amount amount to lerp between the start and end values
  86192. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86193. */
  86194. static Lerp(start: Size, end: Size, amount: number): Size;
  86195. }
  86196. }
  86197. declare module BABYLON {
  86198. interface ThinEngine {
  86199. /**
  86200. * Creates a dynamic texture
  86201. * @param width defines the width of the texture
  86202. * @param height defines the height of the texture
  86203. * @param generateMipMaps defines if the engine should generate the mip levels
  86204. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86205. * @returns the dynamic texture inside an InternalTexture
  86206. */
  86207. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86208. /**
  86209. * Update the content of a dynamic texture
  86210. * @param texture defines the texture to update
  86211. * @param canvas defines the canvas containing the source
  86212. * @param invertY defines if data must be stored with Y axis inverted
  86213. * @param premulAlpha defines if alpha is stored as premultiplied
  86214. * @param format defines the format of the data
  86215. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86216. */
  86217. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86218. }
  86219. }
  86220. declare module BABYLON {
  86221. /**
  86222. * Helper class used to generate a canvas to manipulate images
  86223. */
  86224. export class CanvasGenerator {
  86225. /**
  86226. * Create a new canvas (or offscreen canvas depending on the context)
  86227. * @param width defines the expected width
  86228. * @param height defines the expected height
  86229. * @return a new canvas or offscreen canvas
  86230. */
  86231. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86232. }
  86233. }
  86234. declare module BABYLON {
  86235. /**
  86236. * A class extending Texture allowing drawing on a texture
  86237. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86238. */
  86239. export class DynamicTexture extends Texture {
  86240. private _generateMipMaps;
  86241. private _canvas;
  86242. private _context;
  86243. private _engine;
  86244. /**
  86245. * Creates a DynamicTexture
  86246. * @param name defines the name of the texture
  86247. * @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
  86248. * @param scene defines the scene where you want the texture
  86249. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86250. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86251. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86252. */
  86253. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86254. /**
  86255. * Get the current class name of the texture useful for serialization or dynamic coding.
  86256. * @returns "DynamicTexture"
  86257. */
  86258. getClassName(): string;
  86259. /**
  86260. * Gets the current state of canRescale
  86261. */
  86262. get canRescale(): boolean;
  86263. private _recreate;
  86264. /**
  86265. * Scales the texture
  86266. * @param ratio the scale factor to apply to both width and height
  86267. */
  86268. scale(ratio: number): void;
  86269. /**
  86270. * Resizes the texture
  86271. * @param width the new width
  86272. * @param height the new height
  86273. */
  86274. scaleTo(width: number, height: number): void;
  86275. /**
  86276. * Gets the context of the canvas used by the texture
  86277. * @returns the canvas context of the dynamic texture
  86278. */
  86279. getContext(): CanvasRenderingContext2D;
  86280. /**
  86281. * Clears the texture
  86282. */
  86283. clear(): void;
  86284. /**
  86285. * Updates the texture
  86286. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86287. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  86288. */
  86289. update(invertY?: boolean, premulAlpha?: boolean): void;
  86290. /**
  86291. * Draws text onto the texture
  86292. * @param text defines the text to be drawn
  86293. * @param x defines the placement of the text from the left
  86294. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  86295. * @param font defines the font to be used with font-style, font-size, font-name
  86296. * @param color defines the color used for the text
  86297. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  86298. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  86299. * @param update defines whether texture is immediately update (default is true)
  86300. */
  86301. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  86302. /**
  86303. * Clones the texture
  86304. * @returns the clone of the texture.
  86305. */
  86306. clone(): DynamicTexture;
  86307. /**
  86308. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  86309. * @returns a serialized dynamic texture object
  86310. */
  86311. serialize(): any;
  86312. /** @hidden */
  86313. _rebuild(): void;
  86314. }
  86315. }
  86316. declare module BABYLON {
  86317. interface ThinEngine {
  86318. /**
  86319. * Creates a raw texture
  86320. * @param data defines the data to store in the texture
  86321. * @param width defines the width of the texture
  86322. * @param height defines the height of the texture
  86323. * @param format defines the format of the data
  86324. * @param generateMipMaps defines if the engine should generate the mip levels
  86325. * @param invertY defines if data must be stored with Y axis inverted
  86326. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86327. * @param compression defines the compression used (null by default)
  86328. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86329. * @returns the raw texture inside an InternalTexture
  86330. */
  86331. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  86332. /**
  86333. * Update a raw texture
  86334. * @param texture defines the texture to update
  86335. * @param data defines the data to store in the texture
  86336. * @param format defines the format of the data
  86337. * @param invertY defines if data must be stored with Y axis inverted
  86338. */
  86339. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86340. /**
  86341. * Update a raw texture
  86342. * @param texture defines the texture to update
  86343. * @param data defines the data to store in the texture
  86344. * @param format defines the format of the data
  86345. * @param invertY defines if data must be stored with Y axis inverted
  86346. * @param compression defines the compression used (null by default)
  86347. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86348. */
  86349. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  86350. /**
  86351. * Creates a new raw cube texture
  86352. * @param data defines the array of data to use to create each face
  86353. * @param size defines the size of the textures
  86354. * @param format defines the format of the data
  86355. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86356. * @param generateMipMaps defines if the engine should generate the mip levels
  86357. * @param invertY defines if data must be stored with Y axis inverted
  86358. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86359. * @param compression defines the compression used (null by default)
  86360. * @returns the cube texture as an InternalTexture
  86361. */
  86362. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  86363. /**
  86364. * Update a raw cube texture
  86365. * @param texture defines the texture to udpdate
  86366. * @param data defines the data to store
  86367. * @param format defines the data format
  86368. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86369. * @param invertY defines if data must be stored with Y axis inverted
  86370. */
  86371. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  86372. /**
  86373. * Update a raw cube texture
  86374. * @param texture defines the texture to udpdate
  86375. * @param data defines the data to store
  86376. * @param format defines the data format
  86377. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86378. * @param invertY defines if data must be stored with Y axis inverted
  86379. * @param compression defines the compression used (null by default)
  86380. */
  86381. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  86382. /**
  86383. * Update a raw cube texture
  86384. * @param texture defines the texture to udpdate
  86385. * @param data defines the data to store
  86386. * @param format defines the data format
  86387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86388. * @param invertY defines if data must be stored with Y axis inverted
  86389. * @param compression defines the compression used (null by default)
  86390. * @param level defines which level of the texture to update
  86391. */
  86392. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  86393. /**
  86394. * Creates a new raw cube texture from a specified url
  86395. * @param url defines the url where the data is located
  86396. * @param scene defines the current scene
  86397. * @param size defines the size of the textures
  86398. * @param format defines the format of the data
  86399. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86400. * @param noMipmap defines if the engine should avoid generating the mip levels
  86401. * @param callback defines a callback used to extract texture data from loaded data
  86402. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86403. * @param onLoad defines a callback called when texture is loaded
  86404. * @param onError defines a callback called if there is an error
  86405. * @returns the cube texture as an InternalTexture
  86406. */
  86407. 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;
  86408. /**
  86409. * Creates a new raw cube texture from a specified url
  86410. * @param url defines the url where the data is located
  86411. * @param scene defines the current scene
  86412. * @param size defines the size of the textures
  86413. * @param format defines the format of the data
  86414. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86415. * @param noMipmap defines if the engine should avoid generating the mip levels
  86416. * @param callback defines a callback used to extract texture data from loaded data
  86417. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86418. * @param onLoad defines a callback called when texture is loaded
  86419. * @param onError defines a callback called if there is an error
  86420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86421. * @param invertY defines if data must be stored with Y axis inverted
  86422. * @returns the cube texture as an InternalTexture
  86423. */
  86424. 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;
  86425. /**
  86426. * Creates a new raw 3D texture
  86427. * @param data defines the data used to create the texture
  86428. * @param width defines the width of the texture
  86429. * @param height defines the height of the texture
  86430. * @param depth defines the depth of the texture
  86431. * @param format defines the format of the texture
  86432. * @param generateMipMaps defines if the engine must generate mip levels
  86433. * @param invertY defines if data must be stored with Y axis inverted
  86434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86435. * @param compression defines the compressed used (can be null)
  86436. * @param textureType defines the compressed used (can be null)
  86437. * @returns a new raw 3D texture (stored in an InternalTexture)
  86438. */
  86439. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86440. /**
  86441. * Update a raw 3D texture
  86442. * @param texture defines the texture to update
  86443. * @param data defines the data to store
  86444. * @param format defines the data format
  86445. * @param invertY defines if data must be stored with Y axis inverted
  86446. */
  86447. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86448. /**
  86449. * Update a raw 3D texture
  86450. * @param texture defines the texture to update
  86451. * @param data defines the data to store
  86452. * @param format defines the data format
  86453. * @param invertY defines if data must be stored with Y axis inverted
  86454. * @param compression defines the used compression (can be null)
  86455. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86456. */
  86457. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86458. /**
  86459. * Creates a new raw 2D array texture
  86460. * @param data defines the data used to create the texture
  86461. * @param width defines the width of the texture
  86462. * @param height defines the height of the texture
  86463. * @param depth defines the number of layers of the texture
  86464. * @param format defines the format of the texture
  86465. * @param generateMipMaps defines if the engine must generate mip levels
  86466. * @param invertY defines if data must be stored with Y axis inverted
  86467. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86468. * @param compression defines the compressed used (can be null)
  86469. * @param textureType defines the compressed used (can be null)
  86470. * @returns a new raw 2D array texture (stored in an InternalTexture)
  86471. */
  86472. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  86473. /**
  86474. * Update a raw 2D array texture
  86475. * @param texture defines the texture to update
  86476. * @param data defines the data to store
  86477. * @param format defines the data format
  86478. * @param invertY defines if data must be stored with Y axis inverted
  86479. */
  86480. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  86481. /**
  86482. * Update a raw 2D array texture
  86483. * @param texture defines the texture to update
  86484. * @param data defines the data to store
  86485. * @param format defines the data format
  86486. * @param invertY defines if data must be stored with Y axis inverted
  86487. * @param compression defines the used compression (can be null)
  86488. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86489. */
  86490. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  86491. }
  86492. }
  86493. declare module BABYLON {
  86494. /**
  86495. * Raw texture can help creating a texture directly from an array of data.
  86496. * This can be super useful if you either get the data from an uncompressed source or
  86497. * if you wish to create your texture pixel by pixel.
  86498. */
  86499. export class RawTexture extends Texture {
  86500. /**
  86501. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86502. */
  86503. format: number;
  86504. private _engine;
  86505. /**
  86506. * Instantiates a new RawTexture.
  86507. * Raw texture can help creating a texture directly from an array of data.
  86508. * This can be super useful if you either get the data from an uncompressed source or
  86509. * if you wish to create your texture pixel by pixel.
  86510. * @param data define the array of data to use to create the texture
  86511. * @param width define the width of the texture
  86512. * @param height define the height of the texture
  86513. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86514. * @param scene define the scene the texture belongs to
  86515. * @param generateMipMaps define whether mip maps should be generated or not
  86516. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86517. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86518. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86519. */
  86520. constructor(data: ArrayBufferView, width: number, height: number,
  86521. /**
  86522. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  86523. */
  86524. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  86525. /**
  86526. * Updates the texture underlying data.
  86527. * @param data Define the new data of the texture
  86528. */
  86529. update(data: ArrayBufferView): void;
  86530. /**
  86531. * Creates a luminance texture from some data.
  86532. * @param data Define the texture data
  86533. * @param width Define the width of the texture
  86534. * @param height Define the height of the texture
  86535. * @param scene Define the scene the texture belongs to
  86536. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86537. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86538. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86539. * @returns the luminance texture
  86540. */
  86541. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86542. /**
  86543. * Creates a luminance alpha texture from some data.
  86544. * @param data Define the texture data
  86545. * @param width Define the width of the texture
  86546. * @param height Define the height of the texture
  86547. * @param scene Define the scene the texture belongs to
  86548. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86549. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86550. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86551. * @returns the luminance alpha texture
  86552. */
  86553. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86554. /**
  86555. * Creates an alpha texture from some data.
  86556. * @param data Define the texture data
  86557. * @param width Define the width of the texture
  86558. * @param height Define the height of the texture
  86559. * @param scene Define the scene the texture belongs to
  86560. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86561. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86562. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86563. * @returns the alpha texture
  86564. */
  86565. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  86566. /**
  86567. * Creates a RGB texture from some data.
  86568. * @param data Define the texture data
  86569. * @param width Define the width of the texture
  86570. * @param height Define the height of the texture
  86571. * @param scene Define the scene the texture belongs to
  86572. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86573. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86574. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86575. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86576. * @returns the RGB alpha texture
  86577. */
  86578. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86579. /**
  86580. * Creates a RGBA texture from some data.
  86581. * @param data Define the texture data
  86582. * @param width Define the width of the texture
  86583. * @param height Define the height of the texture
  86584. * @param scene Define the scene the texture belongs to
  86585. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86586. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86587. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86588. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86589. * @returns the RGBA texture
  86590. */
  86591. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86592. /**
  86593. * Creates a R texture from some data.
  86594. * @param data Define the texture data
  86595. * @param width Define the width of the texture
  86596. * @param height Define the height of the texture
  86597. * @param scene Define the scene the texture belongs to
  86598. * @param generateMipMaps Define whether or not to create mip maps for the texture
  86599. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  86600. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  86601. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  86602. * @returns the R texture
  86603. */
  86604. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  86605. }
  86606. }
  86607. declare module BABYLON {
  86608. interface AbstractScene {
  86609. /**
  86610. * The list of procedural textures added to the scene
  86611. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86612. */
  86613. proceduralTextures: Array<ProceduralTexture>;
  86614. }
  86615. /**
  86616. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  86617. * in a given scene.
  86618. */
  86619. export class ProceduralTextureSceneComponent implements ISceneComponent {
  86620. /**
  86621. * The component name helpfull to identify the component in the list of scene components.
  86622. */
  86623. readonly name: string;
  86624. /**
  86625. * The scene the component belongs to.
  86626. */
  86627. scene: Scene;
  86628. /**
  86629. * Creates a new instance of the component for the given scene
  86630. * @param scene Defines the scene to register the component in
  86631. */
  86632. constructor(scene: Scene);
  86633. /**
  86634. * Registers the component in a given scene
  86635. */
  86636. register(): void;
  86637. /**
  86638. * Rebuilds the elements related to this component in case of
  86639. * context lost for instance.
  86640. */
  86641. rebuild(): void;
  86642. /**
  86643. * Disposes the component and the associated ressources.
  86644. */
  86645. dispose(): void;
  86646. private _beforeClear;
  86647. }
  86648. }
  86649. declare module BABYLON {
  86650. interface ThinEngine {
  86651. /**
  86652. * Creates a new render target cube texture
  86653. * @param size defines the size of the texture
  86654. * @param options defines the options used to create the texture
  86655. * @returns a new render target cube texture stored in an InternalTexture
  86656. */
  86657. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86658. }
  86659. }
  86660. declare module BABYLON {
  86661. /** @hidden */
  86662. export var proceduralVertexShader: {
  86663. name: string;
  86664. shader: string;
  86665. };
  86666. }
  86667. declare module BABYLON {
  86668. /**
  86669. * 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.
  86670. * This is the base class of any Procedural texture and contains most of the shareable code.
  86671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86672. */
  86673. export class ProceduralTexture extends Texture {
  86674. isCube: boolean;
  86675. /**
  86676. * Define if the texture is enabled or not (disabled texture will not render)
  86677. */
  86678. isEnabled: boolean;
  86679. /**
  86680. * Define if the texture must be cleared before rendering (default is true)
  86681. */
  86682. autoClear: boolean;
  86683. /**
  86684. * Callback called when the texture is generated
  86685. */
  86686. onGenerated: () => void;
  86687. /**
  86688. * Event raised when the texture is generated
  86689. */
  86690. onGeneratedObservable: Observable<ProceduralTexture>;
  86691. /** @hidden */
  86692. _generateMipMaps: boolean;
  86693. /** @hidden **/
  86694. _effect: Effect;
  86695. /** @hidden */
  86696. _textures: {
  86697. [key: string]: Texture;
  86698. };
  86699. /** @hidden */
  86700. protected _fallbackTexture: Nullable<Texture>;
  86701. private _size;
  86702. private _currentRefreshId;
  86703. private _frameId;
  86704. private _refreshRate;
  86705. private _vertexBuffers;
  86706. private _indexBuffer;
  86707. private _uniforms;
  86708. private _samplers;
  86709. private _fragment;
  86710. private _floats;
  86711. private _ints;
  86712. private _floatsArrays;
  86713. private _colors3;
  86714. private _colors4;
  86715. private _vectors2;
  86716. private _vectors3;
  86717. private _matrices;
  86718. private _fallbackTextureUsed;
  86719. private _engine;
  86720. private _cachedDefines;
  86721. private _contentUpdateId;
  86722. private _contentData;
  86723. /**
  86724. * Instantiates a new procedural texture.
  86725. * 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.
  86726. * This is the base class of any Procedural texture and contains most of the shareable code.
  86727. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  86728. * @param name Define the name of the texture
  86729. * @param size Define the size of the texture to create
  86730. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  86731. * @param scene Define the scene the texture belongs to
  86732. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  86733. * @param generateMipMaps Define if the texture should creates mip maps or not
  86734. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  86735. */
  86736. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  86737. /**
  86738. * The effect that is created when initializing the post process.
  86739. * @returns The created effect corresponding the the postprocess.
  86740. */
  86741. getEffect(): Effect;
  86742. /**
  86743. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  86744. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  86745. */
  86746. getContent(): Nullable<ArrayBufferView>;
  86747. private _createIndexBuffer;
  86748. /** @hidden */
  86749. _rebuild(): void;
  86750. /**
  86751. * Resets the texture in order to recreate its associated resources.
  86752. * This can be called in case of context loss
  86753. */
  86754. reset(): void;
  86755. protected _getDefines(): string;
  86756. /**
  86757. * Is the texture ready to be used ? (rendered at least once)
  86758. * @returns true if ready, otherwise, false.
  86759. */
  86760. isReady(): boolean;
  86761. /**
  86762. * Resets the refresh counter of the texture and start bak from scratch.
  86763. * Could be useful to regenerate the texture if it is setup to render only once.
  86764. */
  86765. resetRefreshCounter(): void;
  86766. /**
  86767. * Set the fragment shader to use in order to render the texture.
  86768. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  86769. */
  86770. setFragment(fragment: any): void;
  86771. /**
  86772. * Define the refresh rate of the texture or the rendering frequency.
  86773. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86774. */
  86775. get refreshRate(): number;
  86776. set refreshRate(value: number);
  86777. /** @hidden */
  86778. _shouldRender(): boolean;
  86779. /**
  86780. * Get the size the texture is rendering at.
  86781. * @returns the size (texture is always squared)
  86782. */
  86783. getRenderSize(): number;
  86784. /**
  86785. * Resize the texture to new value.
  86786. * @param size Define the new size the texture should have
  86787. * @param generateMipMaps Define whether the new texture should create mip maps
  86788. */
  86789. resize(size: number, generateMipMaps: boolean): void;
  86790. private _checkUniform;
  86791. /**
  86792. * Set a texture in the shader program used to render.
  86793. * @param name Define the name of the uniform samplers as defined in the shader
  86794. * @param texture Define the texture to bind to this sampler
  86795. * @return the texture itself allowing "fluent" like uniform updates
  86796. */
  86797. setTexture(name: string, texture: Texture): ProceduralTexture;
  86798. /**
  86799. * Set a float in the shader.
  86800. * @param name Define the name of the uniform as defined in the shader
  86801. * @param value Define the value to give to the uniform
  86802. * @return the texture itself allowing "fluent" like uniform updates
  86803. */
  86804. setFloat(name: string, value: number): ProceduralTexture;
  86805. /**
  86806. * Set a int in the shader.
  86807. * @param name Define the name of the uniform as defined in the shader
  86808. * @param value Define the value to give to the uniform
  86809. * @return the texture itself allowing "fluent" like uniform updates
  86810. */
  86811. setInt(name: string, value: number): ProceduralTexture;
  86812. /**
  86813. * Set an array of floats in the shader.
  86814. * @param name Define the name of the uniform as defined in the shader
  86815. * @param value Define the value to give to the uniform
  86816. * @return the texture itself allowing "fluent" like uniform updates
  86817. */
  86818. setFloats(name: string, value: number[]): ProceduralTexture;
  86819. /**
  86820. * Set a vec3 in the shader from a Color3.
  86821. * @param name Define the name of the uniform as defined in the shader
  86822. * @param value Define the value to give to the uniform
  86823. * @return the texture itself allowing "fluent" like uniform updates
  86824. */
  86825. setColor3(name: string, value: Color3): ProceduralTexture;
  86826. /**
  86827. * Set a vec4 in the shader from a Color4.
  86828. * @param name Define the name of the uniform as defined in the shader
  86829. * @param value Define the value to give to the uniform
  86830. * @return the texture itself allowing "fluent" like uniform updates
  86831. */
  86832. setColor4(name: string, value: Color4): ProceduralTexture;
  86833. /**
  86834. * Set a vec2 in the shader from a Vector2.
  86835. * @param name Define the name of the uniform as defined in the shader
  86836. * @param value Define the value to give to the uniform
  86837. * @return the texture itself allowing "fluent" like uniform updates
  86838. */
  86839. setVector2(name: string, value: Vector2): ProceduralTexture;
  86840. /**
  86841. * Set a vec3 in the shader from a Vector3.
  86842. * @param name Define the name of the uniform as defined in the shader
  86843. * @param value Define the value to give to the uniform
  86844. * @return the texture itself allowing "fluent" like uniform updates
  86845. */
  86846. setVector3(name: string, value: Vector3): ProceduralTexture;
  86847. /**
  86848. * Set a mat4 in the shader from a MAtrix.
  86849. * @param name Define the name of the uniform as defined in the shader
  86850. * @param value Define the value to give to the uniform
  86851. * @return the texture itself allowing "fluent" like uniform updates
  86852. */
  86853. setMatrix(name: string, value: Matrix): ProceduralTexture;
  86854. /**
  86855. * Render the texture to its associated render target.
  86856. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  86857. */
  86858. render(useCameraPostProcess?: boolean): void;
  86859. /**
  86860. * Clone the texture.
  86861. * @returns the cloned texture
  86862. */
  86863. clone(): ProceduralTexture;
  86864. /**
  86865. * Dispose the texture and release its asoociated resources.
  86866. */
  86867. dispose(): void;
  86868. }
  86869. }
  86870. declare module BABYLON {
  86871. /**
  86872. * This represents the base class for particle system in Babylon.
  86873. * 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.
  86874. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86875. * @example https://doc.babylonjs.com/babylon101/particles
  86876. */
  86877. export class BaseParticleSystem {
  86878. /**
  86879. * Source color is added to the destination color without alpha affecting the result
  86880. */
  86881. static BLENDMODE_ONEONE: number;
  86882. /**
  86883. * Blend current color and particle color using particle’s alpha
  86884. */
  86885. static BLENDMODE_STANDARD: number;
  86886. /**
  86887. * Add current color and particle color multiplied by particle’s alpha
  86888. */
  86889. static BLENDMODE_ADD: number;
  86890. /**
  86891. * Multiply current color with particle color
  86892. */
  86893. static BLENDMODE_MULTIPLY: number;
  86894. /**
  86895. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  86896. */
  86897. static BLENDMODE_MULTIPLYADD: number;
  86898. /**
  86899. * List of animations used by the particle system.
  86900. */
  86901. animations: Animation[];
  86902. /**
  86903. * Gets or sets the unique id of the particle system
  86904. */
  86905. uniqueId: number;
  86906. /**
  86907. * The id of the Particle system.
  86908. */
  86909. id: string;
  86910. /**
  86911. * The friendly name of the Particle system.
  86912. */
  86913. name: string;
  86914. /**
  86915. * Snippet ID if the particle system was created from the snippet server
  86916. */
  86917. snippetId: string;
  86918. /**
  86919. * The rendering group used by the Particle system to chose when to render.
  86920. */
  86921. renderingGroupId: number;
  86922. /**
  86923. * The emitter represents the Mesh or position we are attaching the particle system to.
  86924. */
  86925. emitter: Nullable<AbstractMesh | Vector3>;
  86926. /**
  86927. * The maximum number of particles to emit per frame
  86928. */
  86929. emitRate: number;
  86930. /**
  86931. * If you want to launch only a few particles at once, that can be done, as well.
  86932. */
  86933. manualEmitCount: number;
  86934. /**
  86935. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86936. */
  86937. updateSpeed: number;
  86938. /**
  86939. * The amount of time the particle system is running (depends of the overall update speed).
  86940. */
  86941. targetStopDuration: number;
  86942. /**
  86943. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86944. */
  86945. disposeOnStop: boolean;
  86946. /**
  86947. * Minimum power of emitting particles.
  86948. */
  86949. minEmitPower: number;
  86950. /**
  86951. * Maximum power of emitting particles.
  86952. */
  86953. maxEmitPower: number;
  86954. /**
  86955. * Minimum life time of emitting particles.
  86956. */
  86957. minLifeTime: number;
  86958. /**
  86959. * Maximum life time of emitting particles.
  86960. */
  86961. maxLifeTime: number;
  86962. /**
  86963. * Minimum Size of emitting particles.
  86964. */
  86965. minSize: number;
  86966. /**
  86967. * Maximum Size of emitting particles.
  86968. */
  86969. maxSize: number;
  86970. /**
  86971. * Minimum scale of emitting particles on X axis.
  86972. */
  86973. minScaleX: number;
  86974. /**
  86975. * Maximum scale of emitting particles on X axis.
  86976. */
  86977. maxScaleX: number;
  86978. /**
  86979. * Minimum scale of emitting particles on Y axis.
  86980. */
  86981. minScaleY: number;
  86982. /**
  86983. * Maximum scale of emitting particles on Y axis.
  86984. */
  86985. maxScaleY: number;
  86986. /**
  86987. * Gets or sets the minimal initial rotation in radians.
  86988. */
  86989. minInitialRotation: number;
  86990. /**
  86991. * Gets or sets the maximal initial rotation in radians.
  86992. */
  86993. maxInitialRotation: number;
  86994. /**
  86995. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86996. */
  86997. minAngularSpeed: number;
  86998. /**
  86999. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87000. */
  87001. maxAngularSpeed: number;
  87002. /**
  87003. * The texture used to render each particle. (this can be a spritesheet)
  87004. */
  87005. particleTexture: Nullable<Texture>;
  87006. /**
  87007. * The layer mask we are rendering the particles through.
  87008. */
  87009. layerMask: number;
  87010. /**
  87011. * This can help using your own shader to render the particle system.
  87012. * The according effect will be created
  87013. */
  87014. customShader: any;
  87015. /**
  87016. * By default particle system starts as soon as they are created. This prevents the
  87017. * automatic start to happen and let you decide when to start emitting particles.
  87018. */
  87019. preventAutoStart: boolean;
  87020. private _noiseTexture;
  87021. /**
  87022. * Gets or sets a texture used to add random noise to particle positions
  87023. */
  87024. get noiseTexture(): Nullable<ProceduralTexture>;
  87025. set noiseTexture(value: Nullable<ProceduralTexture>);
  87026. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87027. noiseStrength: Vector3;
  87028. /**
  87029. * Callback triggered when the particle animation is ending.
  87030. */
  87031. onAnimationEnd: Nullable<() => void>;
  87032. /**
  87033. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87034. */
  87035. blendMode: number;
  87036. /**
  87037. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87038. * to override the particles.
  87039. */
  87040. forceDepthWrite: boolean;
  87041. /** 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 */
  87042. preWarmCycles: number;
  87043. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87044. preWarmStepOffset: number;
  87045. /**
  87046. * 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)
  87047. */
  87048. spriteCellChangeSpeed: number;
  87049. /**
  87050. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87051. */
  87052. startSpriteCellID: number;
  87053. /**
  87054. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87055. */
  87056. endSpriteCellID: number;
  87057. /**
  87058. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87059. */
  87060. spriteCellWidth: number;
  87061. /**
  87062. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87063. */
  87064. spriteCellHeight: number;
  87065. /**
  87066. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87067. */
  87068. spriteRandomStartCell: boolean;
  87069. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87070. translationPivot: Vector2;
  87071. /** @hidden */
  87072. protected _isAnimationSheetEnabled: boolean;
  87073. /**
  87074. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87075. */
  87076. beginAnimationOnStart: boolean;
  87077. /**
  87078. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87079. */
  87080. beginAnimationFrom: number;
  87081. /**
  87082. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87083. */
  87084. beginAnimationTo: number;
  87085. /**
  87086. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87087. */
  87088. beginAnimationLoop: boolean;
  87089. /**
  87090. * Gets or sets a world offset applied to all particles
  87091. */
  87092. worldOffset: Vector3;
  87093. /**
  87094. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87095. */
  87096. get isAnimationSheetEnabled(): boolean;
  87097. set isAnimationSheetEnabled(value: boolean);
  87098. /**
  87099. * Get hosting scene
  87100. * @returns the scene
  87101. */
  87102. getScene(): Scene;
  87103. /**
  87104. * You can use gravity if you want to give an orientation to your particles.
  87105. */
  87106. gravity: Vector3;
  87107. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87108. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87109. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87110. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87111. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87112. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87113. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87114. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87115. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87116. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87117. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87118. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87119. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87120. /**
  87121. * Defines the delay in milliseconds before starting the system (0 by default)
  87122. */
  87123. startDelay: number;
  87124. /**
  87125. * Gets the current list of drag gradients.
  87126. * You must use addDragGradient and removeDragGradient to udpate this list
  87127. * @returns the list of drag gradients
  87128. */
  87129. getDragGradients(): Nullable<Array<FactorGradient>>;
  87130. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87131. limitVelocityDamping: number;
  87132. /**
  87133. * Gets the current list of limit velocity gradients.
  87134. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87135. * @returns the list of limit velocity gradients
  87136. */
  87137. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87138. /**
  87139. * Gets the current list of color gradients.
  87140. * You must use addColorGradient and removeColorGradient to udpate this list
  87141. * @returns the list of color gradients
  87142. */
  87143. getColorGradients(): Nullable<Array<ColorGradient>>;
  87144. /**
  87145. * Gets the current list of size gradients.
  87146. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87147. * @returns the list of size gradients
  87148. */
  87149. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87150. /**
  87151. * Gets the current list of color remap gradients.
  87152. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87153. * @returns the list of color remap gradients
  87154. */
  87155. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87156. /**
  87157. * Gets the current list of alpha remap gradients.
  87158. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87159. * @returns the list of alpha remap gradients
  87160. */
  87161. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87162. /**
  87163. * Gets the current list of life time gradients.
  87164. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87165. * @returns the list of life time gradients
  87166. */
  87167. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87168. /**
  87169. * Gets the current list of angular speed gradients.
  87170. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87171. * @returns the list of angular speed gradients
  87172. */
  87173. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87174. /**
  87175. * Gets the current list of velocity gradients.
  87176. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87177. * @returns the list of velocity gradients
  87178. */
  87179. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87180. /**
  87181. * Gets the current list of start size gradients.
  87182. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87183. * @returns the list of start size gradients
  87184. */
  87185. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87186. /**
  87187. * Gets the current list of emit rate gradients.
  87188. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87189. * @returns the list of emit rate gradients
  87190. */
  87191. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87192. /**
  87193. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87194. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87195. */
  87196. get direction1(): Vector3;
  87197. set direction1(value: Vector3);
  87198. /**
  87199. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87200. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87201. */
  87202. get direction2(): Vector3;
  87203. set direction2(value: Vector3);
  87204. /**
  87205. * 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.
  87206. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87207. */
  87208. get minEmitBox(): Vector3;
  87209. set minEmitBox(value: Vector3);
  87210. /**
  87211. * 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.
  87212. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87213. */
  87214. get maxEmitBox(): Vector3;
  87215. set maxEmitBox(value: Vector3);
  87216. /**
  87217. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87218. */
  87219. color1: Color4;
  87220. /**
  87221. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87222. */
  87223. color2: Color4;
  87224. /**
  87225. * Color the particle will have at the end of its lifetime
  87226. */
  87227. colorDead: Color4;
  87228. /**
  87229. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87230. */
  87231. textureMask: Color4;
  87232. /**
  87233. * The particle emitter type defines the emitter used by the particle system.
  87234. * It can be for example box, sphere, or cone...
  87235. */
  87236. particleEmitterType: IParticleEmitterType;
  87237. /** @hidden */
  87238. _isSubEmitter: boolean;
  87239. /**
  87240. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87241. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87242. */
  87243. billboardMode: number;
  87244. protected _isBillboardBased: boolean;
  87245. /**
  87246. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87247. */
  87248. get isBillboardBased(): boolean;
  87249. set isBillboardBased(value: boolean);
  87250. /**
  87251. * The scene the particle system belongs to.
  87252. */
  87253. protected _scene: Scene;
  87254. /**
  87255. * Local cache of defines for image processing.
  87256. */
  87257. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87258. /**
  87259. * Default configuration related to image processing available in the standard Material.
  87260. */
  87261. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87262. /**
  87263. * Gets the image processing configuration used either in this material.
  87264. */
  87265. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87266. /**
  87267. * Sets the Default image processing configuration used either in the this material.
  87268. *
  87269. * If sets to null, the scene one is in use.
  87270. */
  87271. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87272. /**
  87273. * Attaches a new image processing configuration to the Standard Material.
  87274. * @param configuration
  87275. */
  87276. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87277. /** @hidden */
  87278. protected _reset(): void;
  87279. /** @hidden */
  87280. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87281. /**
  87282. * Instantiates a particle system.
  87283. * 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.
  87284. * @param name The name of the particle system
  87285. */
  87286. constructor(name: string);
  87287. /**
  87288. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87289. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87290. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87291. * @returns the emitter
  87292. */
  87293. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87294. /**
  87295. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87296. * @param radius The radius of the hemisphere to emit from
  87297. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87298. * @returns the emitter
  87299. */
  87300. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87301. /**
  87302. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87303. * @param radius The radius of the sphere to emit from
  87304. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87305. * @returns the emitter
  87306. */
  87307. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87308. /**
  87309. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87310. * @param radius The radius of the sphere to emit from
  87311. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87312. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87313. * @returns the emitter
  87314. */
  87315. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87316. /**
  87317. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87318. * @param radius The radius of the emission cylinder
  87319. * @param height The height of the emission cylinder
  87320. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87321. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87322. * @returns the emitter
  87323. */
  87324. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87325. /**
  87326. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87327. * @param radius The radius of the cylinder to emit from
  87328. * @param height The height of the emission cylinder
  87329. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87330. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87331. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87332. * @returns the emitter
  87333. */
  87334. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87335. /**
  87336. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87337. * @param radius The radius of the cone to emit from
  87338. * @param angle The base angle of the cone
  87339. * @returns the emitter
  87340. */
  87341. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87342. /**
  87343. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87344. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87345. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87346. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87347. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87348. * @returns the emitter
  87349. */
  87350. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87351. }
  87352. }
  87353. declare module BABYLON {
  87354. /**
  87355. * Type of sub emitter
  87356. */
  87357. export enum SubEmitterType {
  87358. /**
  87359. * Attached to the particle over it's lifetime
  87360. */
  87361. ATTACHED = 0,
  87362. /**
  87363. * Created when the particle dies
  87364. */
  87365. END = 1
  87366. }
  87367. /**
  87368. * Sub emitter class used to emit particles from an existing particle
  87369. */
  87370. export class SubEmitter {
  87371. /**
  87372. * the particle system to be used by the sub emitter
  87373. */
  87374. particleSystem: ParticleSystem;
  87375. /**
  87376. * Type of the submitter (Default: END)
  87377. */
  87378. type: SubEmitterType;
  87379. /**
  87380. * 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)
  87381. * Note: This only is supported when using an emitter of type Mesh
  87382. */
  87383. inheritDirection: boolean;
  87384. /**
  87385. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87386. */
  87387. inheritedVelocityAmount: number;
  87388. /**
  87389. * Creates a sub emitter
  87390. * @param particleSystem the particle system to be used by the sub emitter
  87391. */
  87392. constructor(
  87393. /**
  87394. * the particle system to be used by the sub emitter
  87395. */
  87396. particleSystem: ParticleSystem);
  87397. /**
  87398. * Clones the sub emitter
  87399. * @returns the cloned sub emitter
  87400. */
  87401. clone(): SubEmitter;
  87402. /**
  87403. * Serialize current object to a JSON object
  87404. * @returns the serialized object
  87405. */
  87406. serialize(): any;
  87407. /** @hidden */
  87408. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87409. /**
  87410. * Creates a new SubEmitter from a serialized JSON version
  87411. * @param serializationObject defines the JSON object to read from
  87412. * @param scene defines the hosting scene
  87413. * @param rootUrl defines the rootUrl for data loading
  87414. * @returns a new SubEmitter
  87415. */
  87416. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87417. /** Release associated resources */
  87418. dispose(): void;
  87419. }
  87420. }
  87421. declare module BABYLON {
  87422. /** @hidden */
  87423. export var imageProcessingDeclaration: {
  87424. name: string;
  87425. shader: string;
  87426. };
  87427. }
  87428. declare module BABYLON {
  87429. /** @hidden */
  87430. export var imageProcessingFunctions: {
  87431. name: string;
  87432. shader: string;
  87433. };
  87434. }
  87435. declare module BABYLON {
  87436. /** @hidden */
  87437. export var particlesPixelShader: {
  87438. name: string;
  87439. shader: string;
  87440. };
  87441. }
  87442. declare module BABYLON {
  87443. /** @hidden */
  87444. export var particlesVertexShader: {
  87445. name: string;
  87446. shader: string;
  87447. };
  87448. }
  87449. declare module BABYLON {
  87450. /**
  87451. * This represents a particle system in Babylon.
  87452. * 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.
  87453. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87454. * @example https://doc.babylonjs.com/babylon101/particles
  87455. */
  87456. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87457. /**
  87458. * Billboard mode will only apply to Y axis
  87459. */
  87460. static readonly BILLBOARDMODE_Y: number;
  87461. /**
  87462. * Billboard mode will apply to all axes
  87463. */
  87464. static readonly BILLBOARDMODE_ALL: number;
  87465. /**
  87466. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87467. */
  87468. static readonly BILLBOARDMODE_STRETCHED: number;
  87469. /**
  87470. * This function can be defined to provide custom update for active particles.
  87471. * This function will be called instead of regular update (age, position, color, etc.).
  87472. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87473. */
  87474. updateFunction: (particles: Particle[]) => void;
  87475. private _emitterWorldMatrix;
  87476. /**
  87477. * This function can be defined to specify initial direction for every new particle.
  87478. * It by default use the emitterType defined function
  87479. */
  87480. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87481. /**
  87482. * This function can be defined to specify initial position for every new particle.
  87483. * It by default use the emitterType defined function
  87484. */
  87485. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  87486. /**
  87487. * @hidden
  87488. */
  87489. _inheritedVelocityOffset: Vector3;
  87490. /**
  87491. * An event triggered when the system is disposed
  87492. */
  87493. onDisposeObservable: Observable<ParticleSystem>;
  87494. private _onDisposeObserver;
  87495. /**
  87496. * Sets a callback that will be triggered when the system is disposed
  87497. */
  87498. set onDispose(callback: () => void);
  87499. private _particles;
  87500. private _epsilon;
  87501. private _capacity;
  87502. private _stockParticles;
  87503. private _newPartsExcess;
  87504. private _vertexData;
  87505. private _vertexBuffer;
  87506. private _vertexBuffers;
  87507. private _spriteBuffer;
  87508. private _indexBuffer;
  87509. private _effect;
  87510. private _customEffect;
  87511. private _cachedDefines;
  87512. private _scaledColorStep;
  87513. private _colorDiff;
  87514. private _scaledDirection;
  87515. private _scaledGravity;
  87516. private _currentRenderId;
  87517. private _alive;
  87518. private _useInstancing;
  87519. private _started;
  87520. private _stopped;
  87521. private _actualFrame;
  87522. private _scaledUpdateSpeed;
  87523. private _vertexBufferSize;
  87524. /** @hidden */
  87525. _currentEmitRateGradient: Nullable<FactorGradient>;
  87526. /** @hidden */
  87527. _currentEmitRate1: number;
  87528. /** @hidden */
  87529. _currentEmitRate2: number;
  87530. /** @hidden */
  87531. _currentStartSizeGradient: Nullable<FactorGradient>;
  87532. /** @hidden */
  87533. _currentStartSize1: number;
  87534. /** @hidden */
  87535. _currentStartSize2: number;
  87536. private readonly _rawTextureWidth;
  87537. private _rampGradientsTexture;
  87538. private _useRampGradients;
  87539. /** Gets or sets a boolean indicating that ramp gradients must be used
  87540. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87541. */
  87542. get useRampGradients(): boolean;
  87543. set useRampGradients(value: boolean);
  87544. /**
  87545. * 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.
  87546. * 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: [])
  87547. */
  87548. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  87549. private _subEmitters;
  87550. /**
  87551. * @hidden
  87552. * If the particle systems emitter should be disposed when the particle system is disposed
  87553. */
  87554. _disposeEmitterOnDispose: boolean;
  87555. /**
  87556. * The current active Sub-systems, this property is used by the root particle system only.
  87557. */
  87558. activeSubSystems: Array<ParticleSystem>;
  87559. /**
  87560. * Specifies if the particles are updated in emitter local space or world space
  87561. */
  87562. isLocal: boolean;
  87563. private _rootParticleSystem;
  87564. /**
  87565. * Gets the current list of active particles
  87566. */
  87567. get particles(): Particle[];
  87568. /**
  87569. * Gets the number of particles active at the same time.
  87570. * @returns The number of active particles.
  87571. */
  87572. getActiveCount(): number;
  87573. /**
  87574. * Returns the string "ParticleSystem"
  87575. * @returns a string containing the class name
  87576. */
  87577. getClassName(): string;
  87578. /**
  87579. * Gets a boolean indicating that the system is stopping
  87580. * @returns true if the system is currently stopping
  87581. */
  87582. isStopping(): boolean;
  87583. /**
  87584. * Instantiates a particle system.
  87585. * 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.
  87586. * @param name The name of the particle system
  87587. * @param capacity The max number of particles alive at the same time
  87588. * @param scene The scene the particle system belongs to
  87589. * @param customEffect a custom effect used to change the way particles are rendered by default
  87590. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  87591. * @param epsilon Offset used to render the particles
  87592. */
  87593. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  87594. private _addFactorGradient;
  87595. private _removeFactorGradient;
  87596. /**
  87597. * Adds a new life time gradient
  87598. * @param gradient defines the gradient to use (between 0 and 1)
  87599. * @param factor defines the life time factor to affect to the specified gradient
  87600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87601. * @returns the current particle system
  87602. */
  87603. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87604. /**
  87605. * Remove a specific life time gradient
  87606. * @param gradient defines the gradient to remove
  87607. * @returns the current particle system
  87608. */
  87609. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87610. /**
  87611. * Adds a new size gradient
  87612. * @param gradient defines the gradient to use (between 0 and 1)
  87613. * @param factor defines the size factor to affect to the specified gradient
  87614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87615. * @returns the current particle system
  87616. */
  87617. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87618. /**
  87619. * Remove a specific size gradient
  87620. * @param gradient defines the gradient to remove
  87621. * @returns the current particle system
  87622. */
  87623. removeSizeGradient(gradient: number): IParticleSystem;
  87624. /**
  87625. * Adds a new color remap gradient
  87626. * @param gradient defines the gradient to use (between 0 and 1)
  87627. * @param min defines the color remap minimal range
  87628. * @param max defines the color remap maximal range
  87629. * @returns the current particle system
  87630. */
  87631. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87632. /**
  87633. * Remove a specific color remap gradient
  87634. * @param gradient defines the gradient to remove
  87635. * @returns the current particle system
  87636. */
  87637. removeColorRemapGradient(gradient: number): IParticleSystem;
  87638. /**
  87639. * Adds a new alpha remap gradient
  87640. * @param gradient defines the gradient to use (between 0 and 1)
  87641. * @param min defines the alpha remap minimal range
  87642. * @param max defines the alpha remap maximal range
  87643. * @returns the current particle system
  87644. */
  87645. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87646. /**
  87647. * Remove a specific alpha remap gradient
  87648. * @param gradient defines the gradient to remove
  87649. * @returns the current particle system
  87650. */
  87651. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  87652. /**
  87653. * Adds a new angular speed gradient
  87654. * @param gradient defines the gradient to use (between 0 and 1)
  87655. * @param factor defines the angular speed to affect to the specified gradient
  87656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87657. * @returns the current particle system
  87658. */
  87659. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87660. /**
  87661. * Remove a specific angular speed gradient
  87662. * @param gradient defines the gradient to remove
  87663. * @returns the current particle system
  87664. */
  87665. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87666. /**
  87667. * Adds a new velocity gradient
  87668. * @param gradient defines the gradient to use (between 0 and 1)
  87669. * @param factor defines the velocity to affect to the specified gradient
  87670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87671. * @returns the current particle system
  87672. */
  87673. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87674. /**
  87675. * Remove a specific velocity gradient
  87676. * @param gradient defines the gradient to remove
  87677. * @returns the current particle system
  87678. */
  87679. removeVelocityGradient(gradient: number): IParticleSystem;
  87680. /**
  87681. * Adds a new limit velocity gradient
  87682. * @param gradient defines the gradient to use (between 0 and 1)
  87683. * @param factor defines the limit velocity value to affect to the specified gradient
  87684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87685. * @returns the current particle system
  87686. */
  87687. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87688. /**
  87689. * Remove a specific limit velocity gradient
  87690. * @param gradient defines the gradient to remove
  87691. * @returns the current particle system
  87692. */
  87693. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87694. /**
  87695. * Adds a new drag gradient
  87696. * @param gradient defines the gradient to use (between 0 and 1)
  87697. * @param factor defines the drag value to affect to the specified gradient
  87698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87699. * @returns the current particle system
  87700. */
  87701. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87702. /**
  87703. * Remove a specific drag gradient
  87704. * @param gradient defines the gradient to remove
  87705. * @returns the current particle system
  87706. */
  87707. removeDragGradient(gradient: number): IParticleSystem;
  87708. /**
  87709. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87710. * @param gradient defines the gradient to use (between 0 and 1)
  87711. * @param factor defines the emit rate value to affect to the specified gradient
  87712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87713. * @returns the current particle system
  87714. */
  87715. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87716. /**
  87717. * Remove a specific emit rate gradient
  87718. * @param gradient defines the gradient to remove
  87719. * @returns the current particle system
  87720. */
  87721. removeEmitRateGradient(gradient: number): IParticleSystem;
  87722. /**
  87723. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87724. * @param gradient defines the gradient to use (between 0 and 1)
  87725. * @param factor defines the start size value to affect to the specified gradient
  87726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87727. * @returns the current particle system
  87728. */
  87729. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87730. /**
  87731. * Remove a specific start size gradient
  87732. * @param gradient defines the gradient to remove
  87733. * @returns the current particle system
  87734. */
  87735. removeStartSizeGradient(gradient: number): IParticleSystem;
  87736. private _createRampGradientTexture;
  87737. /**
  87738. * Gets the current list of ramp gradients.
  87739. * You must use addRampGradient and removeRampGradient to udpate this list
  87740. * @returns the list of ramp gradients
  87741. */
  87742. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87743. /** Force the system to rebuild all gradients that need to be resync */
  87744. forceRefreshGradients(): void;
  87745. private _syncRampGradientTexture;
  87746. /**
  87747. * Adds a new ramp gradient used to remap particle colors
  87748. * @param gradient defines the gradient to use (between 0 and 1)
  87749. * @param color defines the color to affect to the specified gradient
  87750. * @returns the current particle system
  87751. */
  87752. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  87753. /**
  87754. * Remove a specific ramp gradient
  87755. * @param gradient defines the gradient to remove
  87756. * @returns the current particle system
  87757. */
  87758. removeRampGradient(gradient: number): ParticleSystem;
  87759. /**
  87760. * Adds a new color gradient
  87761. * @param gradient defines the gradient to use (between 0 and 1)
  87762. * @param color1 defines the color to affect to the specified gradient
  87763. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87764. * @returns this particle system
  87765. */
  87766. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87767. /**
  87768. * Remove a specific color gradient
  87769. * @param gradient defines the gradient to remove
  87770. * @returns this particle system
  87771. */
  87772. removeColorGradient(gradient: number): IParticleSystem;
  87773. private _fetchR;
  87774. protected _reset(): void;
  87775. private _resetEffect;
  87776. private _createVertexBuffers;
  87777. private _createIndexBuffer;
  87778. /**
  87779. * Gets the maximum number of particles active at the same time.
  87780. * @returns The max number of active particles.
  87781. */
  87782. getCapacity(): number;
  87783. /**
  87784. * Gets whether there are still active particles in the system.
  87785. * @returns True if it is alive, otherwise false.
  87786. */
  87787. isAlive(): boolean;
  87788. /**
  87789. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87790. * @returns True if it has been started, otherwise false.
  87791. */
  87792. isStarted(): boolean;
  87793. private _prepareSubEmitterInternalArray;
  87794. /**
  87795. * Starts the particle system and begins to emit
  87796. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  87797. */
  87798. start(delay?: number): void;
  87799. /**
  87800. * Stops the particle system.
  87801. * @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.
  87802. */
  87803. stop(stopSubEmitters?: boolean): void;
  87804. /**
  87805. * Remove all active particles
  87806. */
  87807. reset(): void;
  87808. /**
  87809. * @hidden (for internal use only)
  87810. */
  87811. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  87812. /**
  87813. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  87814. * Its lifetime will start back at 0.
  87815. */
  87816. recycleParticle: (particle: Particle) => void;
  87817. private _stopSubEmitters;
  87818. private _createParticle;
  87819. private _removeFromRoot;
  87820. private _emitFromParticle;
  87821. private _update;
  87822. /** @hidden */
  87823. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  87824. /** @hidden */
  87825. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  87826. /** @hidden */
  87827. private _getEffect;
  87828. /**
  87829. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  87830. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  87831. */
  87832. animate(preWarmOnly?: boolean): void;
  87833. private _appendParticleVertices;
  87834. /**
  87835. * Rebuilds the particle system.
  87836. */
  87837. rebuild(): void;
  87838. /**
  87839. * Is this system ready to be used/rendered
  87840. * @return true if the system is ready
  87841. */
  87842. isReady(): boolean;
  87843. private _render;
  87844. /**
  87845. * Renders the particle system in its current state.
  87846. * @returns the current number of particles
  87847. */
  87848. render(): number;
  87849. /**
  87850. * Disposes the particle system and free the associated resources
  87851. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87852. */
  87853. dispose(disposeTexture?: boolean): void;
  87854. /**
  87855. * Clones the particle system.
  87856. * @param name The name of the cloned object
  87857. * @param newEmitter The new emitter to use
  87858. * @returns the cloned particle system
  87859. */
  87860. clone(name: string, newEmitter: any): ParticleSystem;
  87861. /**
  87862. * Serializes the particle system to a JSON object
  87863. * @param serializeTexture defines if the texture must be serialized as well
  87864. * @returns the JSON object
  87865. */
  87866. serialize(serializeTexture?: boolean): any;
  87867. /** @hidden */
  87868. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  87869. /** @hidden */
  87870. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  87871. /**
  87872. * Parses a JSON object to create a particle system.
  87873. * @param parsedParticleSystem The JSON object to parse
  87874. * @param scene The scene to create the particle system in
  87875. * @param rootUrl The root url to use to load external dependencies like texture
  87876. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  87877. * @returns the Parsed particle system
  87878. */
  87879. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  87880. }
  87881. }
  87882. declare module BABYLON {
  87883. /**
  87884. * A particle represents one of the element emitted by a particle system.
  87885. * This is mainly define by its coordinates, direction, velocity and age.
  87886. */
  87887. export class Particle {
  87888. /**
  87889. * The particle system the particle belongs to.
  87890. */
  87891. particleSystem: ParticleSystem;
  87892. private static _Count;
  87893. /**
  87894. * Unique ID of the particle
  87895. */
  87896. id: number;
  87897. /**
  87898. * The world position of the particle in the scene.
  87899. */
  87900. position: Vector3;
  87901. /**
  87902. * The world direction of the particle in the scene.
  87903. */
  87904. direction: Vector3;
  87905. /**
  87906. * The color of the particle.
  87907. */
  87908. color: Color4;
  87909. /**
  87910. * The color change of the particle per step.
  87911. */
  87912. colorStep: Color4;
  87913. /**
  87914. * Defines how long will the life of the particle be.
  87915. */
  87916. lifeTime: number;
  87917. /**
  87918. * The current age of the particle.
  87919. */
  87920. age: number;
  87921. /**
  87922. * The current size of the particle.
  87923. */
  87924. size: number;
  87925. /**
  87926. * The current scale of the particle.
  87927. */
  87928. scale: Vector2;
  87929. /**
  87930. * The current angle of the particle.
  87931. */
  87932. angle: number;
  87933. /**
  87934. * Defines how fast is the angle changing.
  87935. */
  87936. angularSpeed: number;
  87937. /**
  87938. * Defines the cell index used by the particle to be rendered from a sprite.
  87939. */
  87940. cellIndex: number;
  87941. /**
  87942. * The information required to support color remapping
  87943. */
  87944. remapData: Vector4;
  87945. /** @hidden */
  87946. _randomCellOffset?: number;
  87947. /** @hidden */
  87948. _initialDirection: Nullable<Vector3>;
  87949. /** @hidden */
  87950. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  87951. /** @hidden */
  87952. _initialStartSpriteCellID: number;
  87953. /** @hidden */
  87954. _initialEndSpriteCellID: number;
  87955. /** @hidden */
  87956. _currentColorGradient: Nullable<ColorGradient>;
  87957. /** @hidden */
  87958. _currentColor1: Color4;
  87959. /** @hidden */
  87960. _currentColor2: Color4;
  87961. /** @hidden */
  87962. _currentSizeGradient: Nullable<FactorGradient>;
  87963. /** @hidden */
  87964. _currentSize1: number;
  87965. /** @hidden */
  87966. _currentSize2: number;
  87967. /** @hidden */
  87968. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  87969. /** @hidden */
  87970. _currentAngularSpeed1: number;
  87971. /** @hidden */
  87972. _currentAngularSpeed2: number;
  87973. /** @hidden */
  87974. _currentVelocityGradient: Nullable<FactorGradient>;
  87975. /** @hidden */
  87976. _currentVelocity1: number;
  87977. /** @hidden */
  87978. _currentVelocity2: number;
  87979. /** @hidden */
  87980. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  87981. /** @hidden */
  87982. _currentLimitVelocity1: number;
  87983. /** @hidden */
  87984. _currentLimitVelocity2: number;
  87985. /** @hidden */
  87986. _currentDragGradient: Nullable<FactorGradient>;
  87987. /** @hidden */
  87988. _currentDrag1: number;
  87989. /** @hidden */
  87990. _currentDrag2: number;
  87991. /** @hidden */
  87992. _randomNoiseCoordinates1: Vector3;
  87993. /** @hidden */
  87994. _randomNoiseCoordinates2: Vector3;
  87995. /** @hidden */
  87996. _localPosition?: Vector3;
  87997. /**
  87998. * Creates a new instance Particle
  87999. * @param particleSystem the particle system the particle belongs to
  88000. */
  88001. constructor(
  88002. /**
  88003. * The particle system the particle belongs to.
  88004. */
  88005. particleSystem: ParticleSystem);
  88006. private updateCellInfoFromSystem;
  88007. /**
  88008. * Defines how the sprite cell index is updated for the particle
  88009. */
  88010. updateCellIndex(): void;
  88011. /** @hidden */
  88012. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88013. /** @hidden */
  88014. _inheritParticleInfoToSubEmitters(): void;
  88015. /** @hidden */
  88016. _reset(): void;
  88017. /**
  88018. * Copy the properties of particle to another one.
  88019. * @param other the particle to copy the information to.
  88020. */
  88021. copyTo(other: Particle): void;
  88022. }
  88023. }
  88024. declare module BABYLON {
  88025. /**
  88026. * Particle emitter represents a volume emitting particles.
  88027. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88028. */
  88029. export interface IParticleEmitterType {
  88030. /**
  88031. * Called by the particle System when the direction is computed for the created particle.
  88032. * @param worldMatrix is the world matrix of the particle system
  88033. * @param directionToUpdate is the direction vector to update with the result
  88034. * @param particle is the particle we are computed the direction for
  88035. * @param isLocal defines if the direction should be set in local space
  88036. */
  88037. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88038. /**
  88039. * Called by the particle System when the position is computed for the created particle.
  88040. * @param worldMatrix is the world matrix of the particle system
  88041. * @param positionToUpdate is the position vector to update with the result
  88042. * @param particle is the particle we are computed the position for
  88043. * @param isLocal defines if the position should be set in local space
  88044. */
  88045. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88046. /**
  88047. * Clones the current emitter and returns a copy of it
  88048. * @returns the new emitter
  88049. */
  88050. clone(): IParticleEmitterType;
  88051. /**
  88052. * Called by the GPUParticleSystem to setup the update shader
  88053. * @param effect defines the update shader
  88054. */
  88055. applyToShader(effect: Effect): void;
  88056. /**
  88057. * Returns a string to use to update the GPU particles update shader
  88058. * @returns the effect defines string
  88059. */
  88060. getEffectDefines(): string;
  88061. /**
  88062. * Returns a string representing the class name
  88063. * @returns a string containing the class name
  88064. */
  88065. getClassName(): string;
  88066. /**
  88067. * Serializes the particle system to a JSON object.
  88068. * @returns the JSON object
  88069. */
  88070. serialize(): any;
  88071. /**
  88072. * Parse properties from a JSON object
  88073. * @param serializationObject defines the JSON object
  88074. * @param scene defines the hosting scene
  88075. */
  88076. parse(serializationObject: any, scene: Scene): void;
  88077. }
  88078. }
  88079. declare module BABYLON {
  88080. /**
  88081. * Particle emitter emitting particles from the inside of a box.
  88082. * It emits the particles randomly between 2 given directions.
  88083. */
  88084. export class BoxParticleEmitter implements IParticleEmitterType {
  88085. /**
  88086. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88087. */
  88088. direction1: Vector3;
  88089. /**
  88090. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88091. */
  88092. direction2: Vector3;
  88093. /**
  88094. * 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.
  88095. */
  88096. minEmitBox: Vector3;
  88097. /**
  88098. * 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.
  88099. */
  88100. maxEmitBox: Vector3;
  88101. /**
  88102. * Creates a new instance BoxParticleEmitter
  88103. */
  88104. constructor();
  88105. /**
  88106. * Called by the particle System when the direction is computed for the created particle.
  88107. * @param worldMatrix is the world matrix of the particle system
  88108. * @param directionToUpdate is the direction vector to update with the result
  88109. * @param particle is the particle we are computed the direction for
  88110. * @param isLocal defines if the direction should be set in local space
  88111. */
  88112. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88113. /**
  88114. * Called by the particle System when the position is computed for the created particle.
  88115. * @param worldMatrix is the world matrix of the particle system
  88116. * @param positionToUpdate is the position vector to update with the result
  88117. * @param particle is the particle we are computed the position for
  88118. * @param isLocal defines if the position should be set in local space
  88119. */
  88120. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88121. /**
  88122. * Clones the current emitter and returns a copy of it
  88123. * @returns the new emitter
  88124. */
  88125. clone(): BoxParticleEmitter;
  88126. /**
  88127. * Called by the GPUParticleSystem to setup the update shader
  88128. * @param effect defines the update shader
  88129. */
  88130. applyToShader(effect: Effect): void;
  88131. /**
  88132. * Returns a string to use to update the GPU particles update shader
  88133. * @returns a string containng the defines string
  88134. */
  88135. getEffectDefines(): string;
  88136. /**
  88137. * Returns the string "BoxParticleEmitter"
  88138. * @returns a string containing the class name
  88139. */
  88140. getClassName(): string;
  88141. /**
  88142. * Serializes the particle system to a JSON object.
  88143. * @returns the JSON object
  88144. */
  88145. serialize(): any;
  88146. /**
  88147. * Parse properties from a JSON object
  88148. * @param serializationObject defines the JSON object
  88149. */
  88150. parse(serializationObject: any): void;
  88151. }
  88152. }
  88153. declare module BABYLON {
  88154. /**
  88155. * Particle emitter emitting particles from the inside of a cone.
  88156. * It emits the particles alongside the cone volume from the base to the particle.
  88157. * The emission direction might be randomized.
  88158. */
  88159. export class ConeParticleEmitter implements IParticleEmitterType {
  88160. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88161. directionRandomizer: number;
  88162. private _radius;
  88163. private _angle;
  88164. private _height;
  88165. /**
  88166. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88167. */
  88168. radiusRange: number;
  88169. /**
  88170. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88171. */
  88172. heightRange: number;
  88173. /**
  88174. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88175. */
  88176. emitFromSpawnPointOnly: boolean;
  88177. /**
  88178. * Gets or sets the radius of the emission cone
  88179. */
  88180. get radius(): number;
  88181. set radius(value: number);
  88182. /**
  88183. * Gets or sets the angle of the emission cone
  88184. */
  88185. get angle(): number;
  88186. set angle(value: number);
  88187. private _buildHeight;
  88188. /**
  88189. * Creates a new instance ConeParticleEmitter
  88190. * @param radius the radius of the emission cone (1 by default)
  88191. * @param angle the cone base angle (PI by default)
  88192. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88193. */
  88194. constructor(radius?: number, angle?: number,
  88195. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88196. directionRandomizer?: number);
  88197. /**
  88198. * Called by the particle System when the direction is computed for the created particle.
  88199. * @param worldMatrix is the world matrix of the particle system
  88200. * @param directionToUpdate is the direction vector to update with the result
  88201. * @param particle is the particle we are computed the direction for
  88202. * @param isLocal defines if the direction should be set in local space
  88203. */
  88204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88205. /**
  88206. * Called by the particle System when the position is computed for the created particle.
  88207. * @param worldMatrix is the world matrix of the particle system
  88208. * @param positionToUpdate is the position vector to update with the result
  88209. * @param particle is the particle we are computed the position for
  88210. * @param isLocal defines if the position should be set in local space
  88211. */
  88212. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88213. /**
  88214. * Clones the current emitter and returns a copy of it
  88215. * @returns the new emitter
  88216. */
  88217. clone(): ConeParticleEmitter;
  88218. /**
  88219. * Called by the GPUParticleSystem to setup the update shader
  88220. * @param effect defines the update shader
  88221. */
  88222. applyToShader(effect: Effect): void;
  88223. /**
  88224. * Returns a string to use to update the GPU particles update shader
  88225. * @returns a string containng the defines string
  88226. */
  88227. getEffectDefines(): string;
  88228. /**
  88229. * Returns the string "ConeParticleEmitter"
  88230. * @returns a string containing the class name
  88231. */
  88232. getClassName(): string;
  88233. /**
  88234. * Serializes the particle system to a JSON object.
  88235. * @returns the JSON object
  88236. */
  88237. serialize(): any;
  88238. /**
  88239. * Parse properties from a JSON object
  88240. * @param serializationObject defines the JSON object
  88241. */
  88242. parse(serializationObject: any): void;
  88243. }
  88244. }
  88245. declare module BABYLON {
  88246. /**
  88247. * Particle emitter emitting particles from the inside of a cylinder.
  88248. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88249. */
  88250. export class CylinderParticleEmitter implements IParticleEmitterType {
  88251. /**
  88252. * The radius of the emission cylinder.
  88253. */
  88254. radius: number;
  88255. /**
  88256. * The height of the emission cylinder.
  88257. */
  88258. height: number;
  88259. /**
  88260. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88261. */
  88262. radiusRange: number;
  88263. /**
  88264. * How much to randomize the particle direction [0-1].
  88265. */
  88266. directionRandomizer: number;
  88267. /**
  88268. * Creates a new instance CylinderParticleEmitter
  88269. * @param radius the radius of the emission cylinder (1 by default)
  88270. * @param height the height of the emission cylinder (1 by default)
  88271. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88272. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88273. */
  88274. constructor(
  88275. /**
  88276. * The radius of the emission cylinder.
  88277. */
  88278. radius?: number,
  88279. /**
  88280. * The height of the emission cylinder.
  88281. */
  88282. height?: number,
  88283. /**
  88284. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88285. */
  88286. radiusRange?: number,
  88287. /**
  88288. * How much to randomize the particle direction [0-1].
  88289. */
  88290. directionRandomizer?: number);
  88291. /**
  88292. * Called by the particle System when the direction is computed for the created particle.
  88293. * @param worldMatrix is the world matrix of the particle system
  88294. * @param directionToUpdate is the direction vector to update with the result
  88295. * @param particle is the particle we are computed the direction for
  88296. * @param isLocal defines if the direction should be set in local space
  88297. */
  88298. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88299. /**
  88300. * Called by the particle System when the position is computed for the created particle.
  88301. * @param worldMatrix is the world matrix of the particle system
  88302. * @param positionToUpdate is the position vector to update with the result
  88303. * @param particle is the particle we are computed the position for
  88304. * @param isLocal defines if the position should be set in local space
  88305. */
  88306. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88307. /**
  88308. * Clones the current emitter and returns a copy of it
  88309. * @returns the new emitter
  88310. */
  88311. clone(): CylinderParticleEmitter;
  88312. /**
  88313. * Called by the GPUParticleSystem to setup the update shader
  88314. * @param effect defines the update shader
  88315. */
  88316. applyToShader(effect: Effect): void;
  88317. /**
  88318. * Returns a string to use to update the GPU particles update shader
  88319. * @returns a string containng the defines string
  88320. */
  88321. getEffectDefines(): string;
  88322. /**
  88323. * Returns the string "CylinderParticleEmitter"
  88324. * @returns a string containing the class name
  88325. */
  88326. getClassName(): string;
  88327. /**
  88328. * Serializes the particle system to a JSON object.
  88329. * @returns the JSON object
  88330. */
  88331. serialize(): any;
  88332. /**
  88333. * Parse properties from a JSON object
  88334. * @param serializationObject defines the JSON object
  88335. */
  88336. parse(serializationObject: any): void;
  88337. }
  88338. /**
  88339. * Particle emitter emitting particles from the inside of a cylinder.
  88340. * It emits the particles randomly between two vectors.
  88341. */
  88342. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88343. /**
  88344. * The min limit of the emission direction.
  88345. */
  88346. direction1: Vector3;
  88347. /**
  88348. * The max limit of the emission direction.
  88349. */
  88350. direction2: Vector3;
  88351. /**
  88352. * Creates a new instance CylinderDirectedParticleEmitter
  88353. * @param radius the radius of the emission cylinder (1 by default)
  88354. * @param height the height of the emission cylinder (1 by default)
  88355. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88356. * @param direction1 the min limit of the emission direction (up vector by default)
  88357. * @param direction2 the max limit of the emission direction (up vector by default)
  88358. */
  88359. constructor(radius?: number, height?: number, radiusRange?: number,
  88360. /**
  88361. * The min limit of the emission direction.
  88362. */
  88363. direction1?: Vector3,
  88364. /**
  88365. * The max limit of the emission direction.
  88366. */
  88367. direction2?: Vector3);
  88368. /**
  88369. * Called by the particle System when the direction is computed for the created particle.
  88370. * @param worldMatrix is the world matrix of the particle system
  88371. * @param directionToUpdate is the direction vector to update with the result
  88372. * @param particle is the particle we are computed the direction for
  88373. */
  88374. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88375. /**
  88376. * Clones the current emitter and returns a copy of it
  88377. * @returns the new emitter
  88378. */
  88379. clone(): CylinderDirectedParticleEmitter;
  88380. /**
  88381. * Called by the GPUParticleSystem to setup the update shader
  88382. * @param effect defines the update shader
  88383. */
  88384. applyToShader(effect: Effect): void;
  88385. /**
  88386. * Returns a string to use to update the GPU particles update shader
  88387. * @returns a string containng the defines string
  88388. */
  88389. getEffectDefines(): string;
  88390. /**
  88391. * Returns the string "CylinderDirectedParticleEmitter"
  88392. * @returns a string containing the class name
  88393. */
  88394. getClassName(): string;
  88395. /**
  88396. * Serializes the particle system to a JSON object.
  88397. * @returns the JSON object
  88398. */
  88399. serialize(): any;
  88400. /**
  88401. * Parse properties from a JSON object
  88402. * @param serializationObject defines the JSON object
  88403. */
  88404. parse(serializationObject: any): void;
  88405. }
  88406. }
  88407. declare module BABYLON {
  88408. /**
  88409. * Particle emitter emitting particles from the inside of a hemisphere.
  88410. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88411. */
  88412. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88413. /**
  88414. * The radius of the emission hemisphere.
  88415. */
  88416. radius: number;
  88417. /**
  88418. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88419. */
  88420. radiusRange: number;
  88421. /**
  88422. * How much to randomize the particle direction [0-1].
  88423. */
  88424. directionRandomizer: number;
  88425. /**
  88426. * Creates a new instance HemisphericParticleEmitter
  88427. * @param radius the radius of the emission hemisphere (1 by default)
  88428. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88429. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88430. */
  88431. constructor(
  88432. /**
  88433. * The radius of the emission hemisphere.
  88434. */
  88435. radius?: number,
  88436. /**
  88437. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88438. */
  88439. radiusRange?: number,
  88440. /**
  88441. * How much to randomize the particle direction [0-1].
  88442. */
  88443. directionRandomizer?: number);
  88444. /**
  88445. * Called by the particle System when the direction is computed for the created particle.
  88446. * @param worldMatrix is the world matrix of the particle system
  88447. * @param directionToUpdate is the direction vector to update with the result
  88448. * @param particle is the particle we are computed the direction for
  88449. * @param isLocal defines if the direction should be set in local space
  88450. */
  88451. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88452. /**
  88453. * Called by the particle System when the position is computed for the created particle.
  88454. * @param worldMatrix is the world matrix of the particle system
  88455. * @param positionToUpdate is the position vector to update with the result
  88456. * @param particle is the particle we are computed the position for
  88457. * @param isLocal defines if the position should be set in local space
  88458. */
  88459. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88460. /**
  88461. * Clones the current emitter and returns a copy of it
  88462. * @returns the new emitter
  88463. */
  88464. clone(): HemisphericParticleEmitter;
  88465. /**
  88466. * Called by the GPUParticleSystem to setup the update shader
  88467. * @param effect defines the update shader
  88468. */
  88469. applyToShader(effect: Effect): void;
  88470. /**
  88471. * Returns a string to use to update the GPU particles update shader
  88472. * @returns a string containng the defines string
  88473. */
  88474. getEffectDefines(): string;
  88475. /**
  88476. * Returns the string "HemisphericParticleEmitter"
  88477. * @returns a string containing the class name
  88478. */
  88479. getClassName(): string;
  88480. /**
  88481. * Serializes the particle system to a JSON object.
  88482. * @returns the JSON object
  88483. */
  88484. serialize(): any;
  88485. /**
  88486. * Parse properties from a JSON object
  88487. * @param serializationObject defines the JSON object
  88488. */
  88489. parse(serializationObject: any): void;
  88490. }
  88491. }
  88492. declare module BABYLON {
  88493. /**
  88494. * Particle emitter emitting particles from a point.
  88495. * It emits the particles randomly between 2 given directions.
  88496. */
  88497. export class PointParticleEmitter implements IParticleEmitterType {
  88498. /**
  88499. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88500. */
  88501. direction1: Vector3;
  88502. /**
  88503. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88504. */
  88505. direction2: Vector3;
  88506. /**
  88507. * Creates a new instance PointParticleEmitter
  88508. */
  88509. constructor();
  88510. /**
  88511. * Called by the particle System when the direction is computed for the created particle.
  88512. * @param worldMatrix is the world matrix of the particle system
  88513. * @param directionToUpdate is the direction vector to update with the result
  88514. * @param particle is the particle we are computed the direction for
  88515. * @param isLocal defines if the direction should be set in local space
  88516. */
  88517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88518. /**
  88519. * Called by the particle System when the position is computed for the created particle.
  88520. * @param worldMatrix is the world matrix of the particle system
  88521. * @param positionToUpdate is the position vector to update with the result
  88522. * @param particle is the particle we are computed the position for
  88523. * @param isLocal defines if the position should be set in local space
  88524. */
  88525. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88526. /**
  88527. * Clones the current emitter and returns a copy of it
  88528. * @returns the new emitter
  88529. */
  88530. clone(): PointParticleEmitter;
  88531. /**
  88532. * Called by the GPUParticleSystem to setup the update shader
  88533. * @param effect defines the update shader
  88534. */
  88535. applyToShader(effect: Effect): void;
  88536. /**
  88537. * Returns a string to use to update the GPU particles update shader
  88538. * @returns a string containng the defines string
  88539. */
  88540. getEffectDefines(): string;
  88541. /**
  88542. * Returns the string "PointParticleEmitter"
  88543. * @returns a string containing the class name
  88544. */
  88545. getClassName(): string;
  88546. /**
  88547. * Serializes the particle system to a JSON object.
  88548. * @returns the JSON object
  88549. */
  88550. serialize(): any;
  88551. /**
  88552. * Parse properties from a JSON object
  88553. * @param serializationObject defines the JSON object
  88554. */
  88555. parse(serializationObject: any): void;
  88556. }
  88557. }
  88558. declare module BABYLON {
  88559. /**
  88560. * Particle emitter emitting particles from the inside of a sphere.
  88561. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88562. */
  88563. export class SphereParticleEmitter implements IParticleEmitterType {
  88564. /**
  88565. * The radius of the emission sphere.
  88566. */
  88567. radius: number;
  88568. /**
  88569. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88570. */
  88571. radiusRange: number;
  88572. /**
  88573. * How much to randomize the particle direction [0-1].
  88574. */
  88575. directionRandomizer: number;
  88576. /**
  88577. * Creates a new instance SphereParticleEmitter
  88578. * @param radius the radius of the emission sphere (1 by default)
  88579. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88580. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88581. */
  88582. constructor(
  88583. /**
  88584. * The radius of the emission sphere.
  88585. */
  88586. radius?: number,
  88587. /**
  88588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88589. */
  88590. radiusRange?: number,
  88591. /**
  88592. * How much to randomize the particle direction [0-1].
  88593. */
  88594. directionRandomizer?: number);
  88595. /**
  88596. * Called by the particle System when the direction is computed for the created particle.
  88597. * @param worldMatrix is the world matrix of the particle system
  88598. * @param directionToUpdate is the direction vector to update with the result
  88599. * @param particle is the particle we are computed the direction for
  88600. * @param isLocal defines if the direction should be set in local space
  88601. */
  88602. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88603. /**
  88604. * Called by the particle System when the position is computed for the created particle.
  88605. * @param worldMatrix is the world matrix of the particle system
  88606. * @param positionToUpdate is the position vector to update with the result
  88607. * @param particle is the particle we are computed the position for
  88608. * @param isLocal defines if the position should be set in local space
  88609. */
  88610. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88611. /**
  88612. * Clones the current emitter and returns a copy of it
  88613. * @returns the new emitter
  88614. */
  88615. clone(): SphereParticleEmitter;
  88616. /**
  88617. * Called by the GPUParticleSystem to setup the update shader
  88618. * @param effect defines the update shader
  88619. */
  88620. applyToShader(effect: Effect): void;
  88621. /**
  88622. * Returns a string to use to update the GPU particles update shader
  88623. * @returns a string containng the defines string
  88624. */
  88625. getEffectDefines(): string;
  88626. /**
  88627. * Returns the string "SphereParticleEmitter"
  88628. * @returns a string containing the class name
  88629. */
  88630. getClassName(): string;
  88631. /**
  88632. * Serializes the particle system to a JSON object.
  88633. * @returns the JSON object
  88634. */
  88635. serialize(): any;
  88636. /**
  88637. * Parse properties from a JSON object
  88638. * @param serializationObject defines the JSON object
  88639. */
  88640. parse(serializationObject: any): void;
  88641. }
  88642. /**
  88643. * Particle emitter emitting particles from the inside of a sphere.
  88644. * It emits the particles randomly between two vectors.
  88645. */
  88646. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  88647. /**
  88648. * The min limit of the emission direction.
  88649. */
  88650. direction1: Vector3;
  88651. /**
  88652. * The max limit of the emission direction.
  88653. */
  88654. direction2: Vector3;
  88655. /**
  88656. * Creates a new instance SphereDirectedParticleEmitter
  88657. * @param radius the radius of the emission sphere (1 by default)
  88658. * @param direction1 the min limit of the emission direction (up vector by default)
  88659. * @param direction2 the max limit of the emission direction (up vector by default)
  88660. */
  88661. constructor(radius?: number,
  88662. /**
  88663. * The min limit of the emission direction.
  88664. */
  88665. direction1?: Vector3,
  88666. /**
  88667. * The max limit of the emission direction.
  88668. */
  88669. direction2?: Vector3);
  88670. /**
  88671. * Called by the particle System when the direction is computed for the created particle.
  88672. * @param worldMatrix is the world matrix of the particle system
  88673. * @param directionToUpdate is the direction vector to update with the result
  88674. * @param particle is the particle we are computed the direction for
  88675. */
  88676. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88677. /**
  88678. * Clones the current emitter and returns a copy of it
  88679. * @returns the new emitter
  88680. */
  88681. clone(): SphereDirectedParticleEmitter;
  88682. /**
  88683. * Called by the GPUParticleSystem to setup the update shader
  88684. * @param effect defines the update shader
  88685. */
  88686. applyToShader(effect: Effect): void;
  88687. /**
  88688. * Returns a string to use to update the GPU particles update shader
  88689. * @returns a string containng the defines string
  88690. */
  88691. getEffectDefines(): string;
  88692. /**
  88693. * Returns the string "SphereDirectedParticleEmitter"
  88694. * @returns a string containing the class name
  88695. */
  88696. getClassName(): string;
  88697. /**
  88698. * Serializes the particle system to a JSON object.
  88699. * @returns the JSON object
  88700. */
  88701. serialize(): any;
  88702. /**
  88703. * Parse properties from a JSON object
  88704. * @param serializationObject defines the JSON object
  88705. */
  88706. parse(serializationObject: any): void;
  88707. }
  88708. }
  88709. declare module BABYLON {
  88710. /**
  88711. * Particle emitter emitting particles from a custom list of positions.
  88712. */
  88713. export class CustomParticleEmitter implements IParticleEmitterType {
  88714. /**
  88715. * Gets or sets the position generator that will create the inital position of each particle.
  88716. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88717. */
  88718. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  88719. /**
  88720. * Gets or sets the destination generator that will create the final destination of each particle.
  88721. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  88722. */
  88723. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  88724. /**
  88725. * Creates a new instance CustomParticleEmitter
  88726. */
  88727. constructor();
  88728. /**
  88729. * Called by the particle System when the direction is computed for the created particle.
  88730. * @param worldMatrix is the world matrix of the particle system
  88731. * @param directionToUpdate is the direction vector to update with the result
  88732. * @param particle is the particle we are computed the direction for
  88733. * @param isLocal defines if the direction should be set in local space
  88734. */
  88735. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88736. /**
  88737. * Called by the particle System when the position is computed for the created particle.
  88738. * @param worldMatrix is the world matrix of the particle system
  88739. * @param positionToUpdate is the position vector to update with the result
  88740. * @param particle is the particle we are computed the position for
  88741. * @param isLocal defines if the position should be set in local space
  88742. */
  88743. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88744. /**
  88745. * Clones the current emitter and returns a copy of it
  88746. * @returns the new emitter
  88747. */
  88748. clone(): CustomParticleEmitter;
  88749. /**
  88750. * Called by the GPUParticleSystem to setup the update shader
  88751. * @param effect defines the update shader
  88752. */
  88753. applyToShader(effect: Effect): void;
  88754. /**
  88755. * Returns a string to use to update the GPU particles update shader
  88756. * @returns a string containng the defines string
  88757. */
  88758. getEffectDefines(): string;
  88759. /**
  88760. * Returns the string "PointParticleEmitter"
  88761. * @returns a string containing the class name
  88762. */
  88763. getClassName(): string;
  88764. /**
  88765. * Serializes the particle system to a JSON object.
  88766. * @returns the JSON object
  88767. */
  88768. serialize(): any;
  88769. /**
  88770. * Parse properties from a JSON object
  88771. * @param serializationObject defines the JSON object
  88772. */
  88773. parse(serializationObject: any): void;
  88774. }
  88775. }
  88776. declare module BABYLON {
  88777. /**
  88778. * Particle emitter emitting particles from the inside of a box.
  88779. * It emits the particles randomly between 2 given directions.
  88780. */
  88781. export class MeshParticleEmitter implements IParticleEmitterType {
  88782. private _indices;
  88783. private _positions;
  88784. private _normals;
  88785. private _storedNormal;
  88786. private _mesh;
  88787. /**
  88788. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88789. */
  88790. direction1: Vector3;
  88791. /**
  88792. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88793. */
  88794. direction2: Vector3;
  88795. /**
  88796. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  88797. */
  88798. useMeshNormalsForDirection: boolean;
  88799. /** Defines the mesh to use as source */
  88800. get mesh(): Nullable<AbstractMesh>;
  88801. set mesh(value: Nullable<AbstractMesh>);
  88802. /**
  88803. * Creates a new instance MeshParticleEmitter
  88804. * @param mesh defines the mesh to use as source
  88805. */
  88806. constructor(mesh?: Nullable<AbstractMesh>);
  88807. /**
  88808. * Called by the particle System when the direction is computed for the created particle.
  88809. * @param worldMatrix is the world matrix of the particle system
  88810. * @param directionToUpdate is the direction vector to update with the result
  88811. * @param particle is the particle we are computed the direction for
  88812. * @param isLocal defines if the direction should be set in local space
  88813. */
  88814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88815. /**
  88816. * Called by the particle System when the position is computed for the created particle.
  88817. * @param worldMatrix is the world matrix of the particle system
  88818. * @param positionToUpdate is the position vector to update with the result
  88819. * @param particle is the particle we are computed the position for
  88820. * @param isLocal defines if the position should be set in local space
  88821. */
  88822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  88823. /**
  88824. * Clones the current emitter and returns a copy of it
  88825. * @returns the new emitter
  88826. */
  88827. clone(): MeshParticleEmitter;
  88828. /**
  88829. * Called by the GPUParticleSystem to setup the update shader
  88830. * @param effect defines the update shader
  88831. */
  88832. applyToShader(effect: Effect): void;
  88833. /**
  88834. * Returns a string to use to update the GPU particles update shader
  88835. * @returns a string containng the defines string
  88836. */
  88837. getEffectDefines(): string;
  88838. /**
  88839. * Returns the string "BoxParticleEmitter"
  88840. * @returns a string containing the class name
  88841. */
  88842. getClassName(): string;
  88843. /**
  88844. * Serializes the particle system to a JSON object.
  88845. * @returns the JSON object
  88846. */
  88847. serialize(): any;
  88848. /**
  88849. * Parse properties from a JSON object
  88850. * @param serializationObject defines the JSON object
  88851. * @param scene defines the hosting scene
  88852. */
  88853. parse(serializationObject: any, scene: Scene): void;
  88854. }
  88855. }
  88856. declare module BABYLON {
  88857. /**
  88858. * Interface representing a particle system in Babylon.js.
  88859. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  88860. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  88861. */
  88862. export interface IParticleSystem {
  88863. /**
  88864. * List of animations used by the particle system.
  88865. */
  88866. animations: Animation[];
  88867. /**
  88868. * The id of the Particle system.
  88869. */
  88870. id: string;
  88871. /**
  88872. * The name of the Particle system.
  88873. */
  88874. name: string;
  88875. /**
  88876. * The emitter represents the Mesh or position we are attaching the particle system to.
  88877. */
  88878. emitter: Nullable<AbstractMesh | Vector3>;
  88879. /**
  88880. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  88881. */
  88882. isBillboardBased: boolean;
  88883. /**
  88884. * The rendering group used by the Particle system to chose when to render.
  88885. */
  88886. renderingGroupId: number;
  88887. /**
  88888. * The layer mask we are rendering the particles through.
  88889. */
  88890. layerMask: number;
  88891. /**
  88892. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  88893. */
  88894. updateSpeed: number;
  88895. /**
  88896. * The amount of time the particle system is running (depends of the overall update speed).
  88897. */
  88898. targetStopDuration: number;
  88899. /**
  88900. * The texture used to render each particle. (this can be a spritesheet)
  88901. */
  88902. particleTexture: Nullable<Texture>;
  88903. /**
  88904. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  88905. */
  88906. blendMode: number;
  88907. /**
  88908. * Minimum life time of emitting particles.
  88909. */
  88910. minLifeTime: number;
  88911. /**
  88912. * Maximum life time of emitting particles.
  88913. */
  88914. maxLifeTime: number;
  88915. /**
  88916. * Minimum Size of emitting particles.
  88917. */
  88918. minSize: number;
  88919. /**
  88920. * Maximum Size of emitting particles.
  88921. */
  88922. maxSize: number;
  88923. /**
  88924. * Minimum scale of emitting particles on X axis.
  88925. */
  88926. minScaleX: number;
  88927. /**
  88928. * Maximum scale of emitting particles on X axis.
  88929. */
  88930. maxScaleX: number;
  88931. /**
  88932. * Minimum scale of emitting particles on Y axis.
  88933. */
  88934. minScaleY: number;
  88935. /**
  88936. * Maximum scale of emitting particles on Y axis.
  88937. */
  88938. maxScaleY: number;
  88939. /**
  88940. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  88941. */
  88942. color1: Color4;
  88943. /**
  88944. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  88945. */
  88946. color2: Color4;
  88947. /**
  88948. * Color the particle will have at the end of its lifetime.
  88949. */
  88950. colorDead: Color4;
  88951. /**
  88952. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  88953. */
  88954. emitRate: number;
  88955. /**
  88956. * You can use gravity if you want to give an orientation to your particles.
  88957. */
  88958. gravity: Vector3;
  88959. /**
  88960. * Minimum power of emitting particles.
  88961. */
  88962. minEmitPower: number;
  88963. /**
  88964. * Maximum power of emitting particles.
  88965. */
  88966. maxEmitPower: number;
  88967. /**
  88968. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  88969. */
  88970. minAngularSpeed: number;
  88971. /**
  88972. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  88973. */
  88974. maxAngularSpeed: number;
  88975. /**
  88976. * Gets or sets the minimal initial rotation in radians.
  88977. */
  88978. minInitialRotation: number;
  88979. /**
  88980. * Gets or sets the maximal initial rotation in radians.
  88981. */
  88982. maxInitialRotation: number;
  88983. /**
  88984. * The particle emitter type defines the emitter used by the particle system.
  88985. * It can be for example box, sphere, or cone...
  88986. */
  88987. particleEmitterType: Nullable<IParticleEmitterType>;
  88988. /**
  88989. * Defines the delay in milliseconds before starting the system (0 by default)
  88990. */
  88991. startDelay: number;
  88992. /**
  88993. * 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
  88994. */
  88995. preWarmCycles: number;
  88996. /**
  88997. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  88998. */
  88999. preWarmStepOffset: number;
  89000. /**
  89001. * 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)
  89002. */
  89003. spriteCellChangeSpeed: number;
  89004. /**
  89005. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89006. */
  89007. startSpriteCellID: number;
  89008. /**
  89009. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89010. */
  89011. endSpriteCellID: number;
  89012. /**
  89013. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89014. */
  89015. spriteCellWidth: number;
  89016. /**
  89017. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89018. */
  89019. spriteCellHeight: number;
  89020. /**
  89021. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89022. */
  89023. spriteRandomStartCell: boolean;
  89024. /**
  89025. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89026. */
  89027. isAnimationSheetEnabled: boolean;
  89028. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89029. translationPivot: Vector2;
  89030. /**
  89031. * Gets or sets a texture used to add random noise to particle positions
  89032. */
  89033. noiseTexture: Nullable<BaseTexture>;
  89034. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89035. noiseStrength: Vector3;
  89036. /**
  89037. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89038. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89039. */
  89040. billboardMode: number;
  89041. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89042. limitVelocityDamping: number;
  89043. /**
  89044. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89045. */
  89046. beginAnimationOnStart: boolean;
  89047. /**
  89048. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89049. */
  89050. beginAnimationFrom: number;
  89051. /**
  89052. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89053. */
  89054. beginAnimationTo: number;
  89055. /**
  89056. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89057. */
  89058. beginAnimationLoop: boolean;
  89059. /**
  89060. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89061. */
  89062. disposeOnStop: boolean;
  89063. /**
  89064. * Specifies if the particles are updated in emitter local space or world space
  89065. */
  89066. isLocal: boolean;
  89067. /** Snippet ID if the particle system was created from the snippet server */
  89068. snippetId: string;
  89069. /**
  89070. * Gets the maximum number of particles active at the same time.
  89071. * @returns The max number of active particles.
  89072. */
  89073. getCapacity(): number;
  89074. /**
  89075. * Gets the number of particles active at the same time.
  89076. * @returns The number of active particles.
  89077. */
  89078. getActiveCount(): number;
  89079. /**
  89080. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89081. * @returns True if it has been started, otherwise false.
  89082. */
  89083. isStarted(): boolean;
  89084. /**
  89085. * Animates the particle system for this frame.
  89086. */
  89087. animate(): void;
  89088. /**
  89089. * Renders the particle system in its current state.
  89090. * @returns the current number of particles
  89091. */
  89092. render(): number;
  89093. /**
  89094. * Dispose the particle system and frees its associated resources.
  89095. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89096. */
  89097. dispose(disposeTexture?: boolean): void;
  89098. /**
  89099. * Clones the particle system.
  89100. * @param name The name of the cloned object
  89101. * @param newEmitter The new emitter to use
  89102. * @returns the cloned particle system
  89103. */
  89104. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89105. /**
  89106. * Serializes the particle system to a JSON object
  89107. * @param serializeTexture defines if the texture must be serialized as well
  89108. * @returns the JSON object
  89109. */
  89110. serialize(serializeTexture: boolean): any;
  89111. /**
  89112. * Rebuild the particle system
  89113. */
  89114. rebuild(): void;
  89115. /** Force the system to rebuild all gradients that need to be resync */
  89116. forceRefreshGradients(): void;
  89117. /**
  89118. * Starts the particle system and begins to emit
  89119. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89120. */
  89121. start(delay?: number): void;
  89122. /**
  89123. * Stops the particle system.
  89124. */
  89125. stop(): void;
  89126. /**
  89127. * Remove all active particles
  89128. */
  89129. reset(): void;
  89130. /**
  89131. * Gets a boolean indicating that the system is stopping
  89132. * @returns true if the system is currently stopping
  89133. */
  89134. isStopping(): boolean;
  89135. /**
  89136. * Is this system ready to be used/rendered
  89137. * @return true if the system is ready
  89138. */
  89139. isReady(): boolean;
  89140. /**
  89141. * Returns the string "ParticleSystem"
  89142. * @returns a string containing the class name
  89143. */
  89144. getClassName(): string;
  89145. /**
  89146. * Adds a new color gradient
  89147. * @param gradient defines the gradient to use (between 0 and 1)
  89148. * @param color1 defines the color to affect to the specified gradient
  89149. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89150. * @returns the current particle system
  89151. */
  89152. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89153. /**
  89154. * Remove a specific color gradient
  89155. * @param gradient defines the gradient to remove
  89156. * @returns the current particle system
  89157. */
  89158. removeColorGradient(gradient: number): IParticleSystem;
  89159. /**
  89160. * Adds a new size gradient
  89161. * @param gradient defines the gradient to use (between 0 and 1)
  89162. * @param factor defines the size factor to affect to the specified gradient
  89163. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89164. * @returns the current particle system
  89165. */
  89166. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89167. /**
  89168. * Remove a specific size gradient
  89169. * @param gradient defines the gradient to remove
  89170. * @returns the current particle system
  89171. */
  89172. removeSizeGradient(gradient: number): IParticleSystem;
  89173. /**
  89174. * Gets the current list of color gradients.
  89175. * You must use addColorGradient and removeColorGradient to udpate this list
  89176. * @returns the list of color gradients
  89177. */
  89178. getColorGradients(): Nullable<Array<ColorGradient>>;
  89179. /**
  89180. * Gets the current list of size gradients.
  89181. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89182. * @returns the list of size gradients
  89183. */
  89184. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89185. /**
  89186. * Gets the current list of angular speed gradients.
  89187. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89188. * @returns the list of angular speed gradients
  89189. */
  89190. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89191. /**
  89192. * Adds a new angular speed gradient
  89193. * @param gradient defines the gradient to use (between 0 and 1)
  89194. * @param factor defines the angular speed to affect to the specified gradient
  89195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89196. * @returns the current particle system
  89197. */
  89198. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89199. /**
  89200. * Remove a specific angular speed gradient
  89201. * @param gradient defines the gradient to remove
  89202. * @returns the current particle system
  89203. */
  89204. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89205. /**
  89206. * Gets the current list of velocity gradients.
  89207. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89208. * @returns the list of velocity gradients
  89209. */
  89210. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89211. /**
  89212. * Adds a new velocity gradient
  89213. * @param gradient defines the gradient to use (between 0 and 1)
  89214. * @param factor defines the velocity to affect to the specified gradient
  89215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89216. * @returns the current particle system
  89217. */
  89218. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89219. /**
  89220. * Remove a specific velocity gradient
  89221. * @param gradient defines the gradient to remove
  89222. * @returns the current particle system
  89223. */
  89224. removeVelocityGradient(gradient: number): IParticleSystem;
  89225. /**
  89226. * Gets the current list of limit velocity gradients.
  89227. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89228. * @returns the list of limit velocity gradients
  89229. */
  89230. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89231. /**
  89232. * Adds a new limit velocity gradient
  89233. * @param gradient defines the gradient to use (between 0 and 1)
  89234. * @param factor defines the limit velocity to affect to the specified gradient
  89235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89236. * @returns the current particle system
  89237. */
  89238. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89239. /**
  89240. * Remove a specific limit velocity gradient
  89241. * @param gradient defines the gradient to remove
  89242. * @returns the current particle system
  89243. */
  89244. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89245. /**
  89246. * Adds a new drag gradient
  89247. * @param gradient defines the gradient to use (between 0 and 1)
  89248. * @param factor defines the drag to affect to the specified gradient
  89249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89250. * @returns the current particle system
  89251. */
  89252. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89253. /**
  89254. * Remove a specific drag gradient
  89255. * @param gradient defines the gradient to remove
  89256. * @returns the current particle system
  89257. */
  89258. removeDragGradient(gradient: number): IParticleSystem;
  89259. /**
  89260. * Gets the current list of drag gradients.
  89261. * You must use addDragGradient and removeDragGradient to udpate this list
  89262. * @returns the list of drag gradients
  89263. */
  89264. getDragGradients(): Nullable<Array<FactorGradient>>;
  89265. /**
  89266. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89267. * @param gradient defines the gradient to use (between 0 and 1)
  89268. * @param factor defines the emit rate to affect to the specified gradient
  89269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89270. * @returns the current particle system
  89271. */
  89272. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89273. /**
  89274. * Remove a specific emit rate gradient
  89275. * @param gradient defines the gradient to remove
  89276. * @returns the current particle system
  89277. */
  89278. removeEmitRateGradient(gradient: number): IParticleSystem;
  89279. /**
  89280. * Gets the current list of emit rate gradients.
  89281. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89282. * @returns the list of emit rate gradients
  89283. */
  89284. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89285. /**
  89286. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89287. * @param gradient defines the gradient to use (between 0 and 1)
  89288. * @param factor defines the start size to affect to the specified gradient
  89289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89290. * @returns the current particle system
  89291. */
  89292. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89293. /**
  89294. * Remove a specific start size gradient
  89295. * @param gradient defines the gradient to remove
  89296. * @returns the current particle system
  89297. */
  89298. removeStartSizeGradient(gradient: number): IParticleSystem;
  89299. /**
  89300. * Gets the current list of start size gradients.
  89301. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89302. * @returns the list of start size gradients
  89303. */
  89304. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89305. /**
  89306. * Adds a new life time gradient
  89307. * @param gradient defines the gradient to use (between 0 and 1)
  89308. * @param factor defines the life time factor to affect to the specified gradient
  89309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89310. * @returns the current particle system
  89311. */
  89312. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89313. /**
  89314. * Remove a specific life time gradient
  89315. * @param gradient defines the gradient to remove
  89316. * @returns the current particle system
  89317. */
  89318. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89319. /**
  89320. * Gets the current list of life time gradients.
  89321. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89322. * @returns the list of life time gradients
  89323. */
  89324. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89325. /**
  89326. * Gets the current list of color gradients.
  89327. * You must use addColorGradient and removeColorGradient to udpate this list
  89328. * @returns the list of color gradients
  89329. */
  89330. getColorGradients(): Nullable<Array<ColorGradient>>;
  89331. /**
  89332. * Adds a new ramp gradient used to remap particle colors
  89333. * @param gradient defines the gradient to use (between 0 and 1)
  89334. * @param color defines the color to affect to the specified gradient
  89335. * @returns the current particle system
  89336. */
  89337. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89338. /**
  89339. * Gets the current list of ramp gradients.
  89340. * You must use addRampGradient and removeRampGradient to udpate this list
  89341. * @returns the list of ramp gradients
  89342. */
  89343. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89344. /** Gets or sets a boolean indicating that ramp gradients must be used
  89345. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89346. */
  89347. useRampGradients: boolean;
  89348. /**
  89349. * Adds a new color remap gradient
  89350. * @param gradient defines the gradient to use (between 0 and 1)
  89351. * @param min defines the color remap minimal range
  89352. * @param max defines the color remap maximal range
  89353. * @returns the current particle system
  89354. */
  89355. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89356. /**
  89357. * Gets the current list of color remap gradients.
  89358. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89359. * @returns the list of color remap gradients
  89360. */
  89361. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89362. /**
  89363. * Adds a new alpha remap gradient
  89364. * @param gradient defines the gradient to use (between 0 and 1)
  89365. * @param min defines the alpha remap minimal range
  89366. * @param max defines the alpha remap maximal range
  89367. * @returns the current particle system
  89368. */
  89369. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89370. /**
  89371. * Gets the current list of alpha remap gradients.
  89372. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89373. * @returns the list of alpha remap gradients
  89374. */
  89375. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89376. /**
  89377. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89378. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89379. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89380. * @returns the emitter
  89381. */
  89382. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89383. /**
  89384. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89385. * @param radius The radius of the hemisphere to emit from
  89386. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89387. * @returns the emitter
  89388. */
  89389. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89390. /**
  89391. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89392. * @param radius The radius of the sphere to emit from
  89393. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89394. * @returns the emitter
  89395. */
  89396. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89397. /**
  89398. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89399. * @param radius The radius of the sphere to emit from
  89400. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89401. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89402. * @returns the emitter
  89403. */
  89404. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89405. /**
  89406. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89407. * @param radius The radius of the emission cylinder
  89408. * @param height The height of the emission cylinder
  89409. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89410. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89411. * @returns the emitter
  89412. */
  89413. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89414. /**
  89415. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89416. * @param radius The radius of the cylinder to emit from
  89417. * @param height The height of the emission cylinder
  89418. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89419. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89420. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89421. * @returns the emitter
  89422. */
  89423. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89424. /**
  89425. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89426. * @param radius The radius of the cone to emit from
  89427. * @param angle The base angle of the cone
  89428. * @returns the emitter
  89429. */
  89430. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89431. /**
  89432. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89433. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89434. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89435. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89436. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89437. * @returns the emitter
  89438. */
  89439. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89440. /**
  89441. * Get hosting scene
  89442. * @returns the scene
  89443. */
  89444. getScene(): Scene;
  89445. }
  89446. }
  89447. declare module BABYLON {
  89448. /**
  89449. * 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.
  89450. * @see https://doc.babylonjs.com/how_to/transformnode
  89451. */
  89452. export class TransformNode extends Node {
  89453. /**
  89454. * Object will not rotate to face the camera
  89455. */
  89456. static BILLBOARDMODE_NONE: number;
  89457. /**
  89458. * Object will rotate to face the camera but only on the x axis
  89459. */
  89460. static BILLBOARDMODE_X: number;
  89461. /**
  89462. * Object will rotate to face the camera but only on the y axis
  89463. */
  89464. static BILLBOARDMODE_Y: number;
  89465. /**
  89466. * Object will rotate to face the camera but only on the z axis
  89467. */
  89468. static BILLBOARDMODE_Z: number;
  89469. /**
  89470. * Object will rotate to face the camera
  89471. */
  89472. static BILLBOARDMODE_ALL: number;
  89473. /**
  89474. * Object will rotate to face the camera's position instead of orientation
  89475. */
  89476. static BILLBOARDMODE_USE_POSITION: number;
  89477. private _forward;
  89478. private _forwardInverted;
  89479. private _up;
  89480. private _right;
  89481. private _rightInverted;
  89482. private _position;
  89483. private _rotation;
  89484. private _rotationQuaternion;
  89485. protected _scaling: Vector3;
  89486. protected _isDirty: boolean;
  89487. private _transformToBoneReferal;
  89488. private _isAbsoluteSynced;
  89489. private _billboardMode;
  89490. /**
  89491. * Gets or sets the billboard mode. Default is 0.
  89492. *
  89493. * | Value | Type | Description |
  89494. * | --- | --- | --- |
  89495. * | 0 | BILLBOARDMODE_NONE | |
  89496. * | 1 | BILLBOARDMODE_X | |
  89497. * | 2 | BILLBOARDMODE_Y | |
  89498. * | 4 | BILLBOARDMODE_Z | |
  89499. * | 7 | BILLBOARDMODE_ALL | |
  89500. *
  89501. */
  89502. get billboardMode(): number;
  89503. set billboardMode(value: number);
  89504. private _preserveParentRotationForBillboard;
  89505. /**
  89506. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  89507. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  89508. */
  89509. get preserveParentRotationForBillboard(): boolean;
  89510. set preserveParentRotationForBillboard(value: boolean);
  89511. /**
  89512. * 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
  89513. */
  89514. scalingDeterminant: number;
  89515. private _infiniteDistance;
  89516. /**
  89517. * Gets or sets the distance of the object to max, often used by skybox
  89518. */
  89519. get infiniteDistance(): boolean;
  89520. set infiniteDistance(value: boolean);
  89521. /**
  89522. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  89523. * By default the system will update normals to compensate
  89524. */
  89525. ignoreNonUniformScaling: boolean;
  89526. /**
  89527. * 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
  89528. */
  89529. reIntegrateRotationIntoRotationQuaternion: boolean;
  89530. /** @hidden */
  89531. _poseMatrix: Nullable<Matrix>;
  89532. /** @hidden */
  89533. _localMatrix: Matrix;
  89534. private _usePivotMatrix;
  89535. private _absolutePosition;
  89536. private _absoluteScaling;
  89537. private _absoluteRotationQuaternion;
  89538. private _pivotMatrix;
  89539. private _pivotMatrixInverse;
  89540. protected _postMultiplyPivotMatrix: boolean;
  89541. protected _isWorldMatrixFrozen: boolean;
  89542. /** @hidden */
  89543. _indexInSceneTransformNodesArray: number;
  89544. /**
  89545. * An event triggered after the world matrix is updated
  89546. */
  89547. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  89548. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  89549. /**
  89550. * Gets a string identifying the name of the class
  89551. * @returns "TransformNode" string
  89552. */
  89553. getClassName(): string;
  89554. /**
  89555. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  89556. */
  89557. get position(): Vector3;
  89558. set position(newPosition: Vector3);
  89559. /**
  89560. * 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)).
  89561. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  89562. */
  89563. get rotation(): Vector3;
  89564. set rotation(newRotation: Vector3);
  89565. /**
  89566. * 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)).
  89567. */
  89568. get scaling(): Vector3;
  89569. set scaling(newScaling: Vector3);
  89570. /**
  89571. * 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).
  89572. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  89573. */
  89574. get rotationQuaternion(): Nullable<Quaternion>;
  89575. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  89576. /**
  89577. * The forward direction of that transform in world space.
  89578. */
  89579. get forward(): Vector3;
  89580. /**
  89581. * The up direction of that transform in world space.
  89582. */
  89583. get up(): Vector3;
  89584. /**
  89585. * The right direction of that transform in world space.
  89586. */
  89587. get right(): Vector3;
  89588. /**
  89589. * Copies the parameter passed Matrix into the mesh Pose matrix.
  89590. * @param matrix the matrix to copy the pose from
  89591. * @returns this TransformNode.
  89592. */
  89593. updatePoseMatrix(matrix: Matrix): TransformNode;
  89594. /**
  89595. * Returns the mesh Pose matrix.
  89596. * @returns the pose matrix
  89597. */
  89598. getPoseMatrix(): Matrix;
  89599. /** @hidden */
  89600. _isSynchronized(): boolean;
  89601. /** @hidden */
  89602. _initCache(): void;
  89603. /**
  89604. * Flag the transform node as dirty (Forcing it to update everything)
  89605. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  89606. * @returns this transform node
  89607. */
  89608. markAsDirty(property: string): TransformNode;
  89609. /**
  89610. * Returns the current mesh absolute position.
  89611. * Returns a Vector3.
  89612. */
  89613. get absolutePosition(): Vector3;
  89614. /**
  89615. * Returns the current mesh absolute scaling.
  89616. * Returns a Vector3.
  89617. */
  89618. get absoluteScaling(): Vector3;
  89619. /**
  89620. * Returns the current mesh absolute rotation.
  89621. * Returns a Quaternion.
  89622. */
  89623. get absoluteRotationQuaternion(): Quaternion;
  89624. /**
  89625. * Sets a new matrix to apply before all other transformation
  89626. * @param matrix defines the transform matrix
  89627. * @returns the current TransformNode
  89628. */
  89629. setPreTransformMatrix(matrix: Matrix): TransformNode;
  89630. /**
  89631. * Sets a new pivot matrix to the current node
  89632. * @param matrix defines the new pivot matrix to use
  89633. * @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
  89634. * @returns the current TransformNode
  89635. */
  89636. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  89637. /**
  89638. * Returns the mesh pivot matrix.
  89639. * Default : Identity.
  89640. * @returns the matrix
  89641. */
  89642. getPivotMatrix(): Matrix;
  89643. /**
  89644. * Instantiate (when possible) or clone that node with its hierarchy
  89645. * @param newParent defines the new parent to use for the instance (or clone)
  89646. * @param options defines options to configure how copy is done
  89647. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  89648. * @returns an instance (or a clone) of the current node with its hiearchy
  89649. */
  89650. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  89651. doNotInstantiate: boolean;
  89652. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  89653. /**
  89654. * Prevents the World matrix to be computed any longer
  89655. * @param newWorldMatrix defines an optional matrix to use as world matrix
  89656. * @returns the TransformNode.
  89657. */
  89658. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  89659. /**
  89660. * Allows back the World matrix computation.
  89661. * @returns the TransformNode.
  89662. */
  89663. unfreezeWorldMatrix(): this;
  89664. /**
  89665. * True if the World matrix has been frozen.
  89666. */
  89667. get isWorldMatrixFrozen(): boolean;
  89668. /**
  89669. * Retuns the mesh absolute position in the World.
  89670. * @returns a Vector3.
  89671. */
  89672. getAbsolutePosition(): Vector3;
  89673. /**
  89674. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  89675. * @param absolutePosition the absolute position to set
  89676. * @returns the TransformNode.
  89677. */
  89678. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89679. /**
  89680. * Sets the mesh position in its local space.
  89681. * @param vector3 the position to set in localspace
  89682. * @returns the TransformNode.
  89683. */
  89684. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  89685. /**
  89686. * Returns the mesh position in the local space from the current World matrix values.
  89687. * @returns a new Vector3.
  89688. */
  89689. getPositionExpressedInLocalSpace(): Vector3;
  89690. /**
  89691. * Translates the mesh along the passed Vector3 in its local space.
  89692. * @param vector3 the distance to translate in localspace
  89693. * @returns the TransformNode.
  89694. */
  89695. locallyTranslate(vector3: Vector3): TransformNode;
  89696. private static _lookAtVectorCache;
  89697. /**
  89698. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  89699. * @param targetPoint the position (must be in same space as current mesh) to look at
  89700. * @param yawCor optional yaw (y-axis) correction in radians
  89701. * @param pitchCor optional pitch (x-axis) correction in radians
  89702. * @param rollCor optional roll (z-axis) correction in radians
  89703. * @param space the choosen space of the target
  89704. * @returns the TransformNode.
  89705. */
  89706. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  89707. /**
  89708. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89709. * This Vector3 is expressed in the World space.
  89710. * @param localAxis axis to rotate
  89711. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  89712. */
  89713. getDirection(localAxis: Vector3): Vector3;
  89714. /**
  89715. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  89716. * localAxis is expressed in the mesh local space.
  89717. * result is computed in the Wordl space from the mesh World matrix.
  89718. * @param localAxis axis to rotate
  89719. * @param result the resulting transformnode
  89720. * @returns this TransformNode.
  89721. */
  89722. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  89723. /**
  89724. * Sets this transform node rotation to the given local axis.
  89725. * @param localAxis the axis in local space
  89726. * @param yawCor optional yaw (y-axis) correction in radians
  89727. * @param pitchCor optional pitch (x-axis) correction in radians
  89728. * @param rollCor optional roll (z-axis) correction in radians
  89729. * @returns this TransformNode
  89730. */
  89731. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  89732. /**
  89733. * Sets a new pivot point to the current node
  89734. * @param point defines the new pivot point to use
  89735. * @param space defines if the point is in world or local space (local by default)
  89736. * @returns the current TransformNode
  89737. */
  89738. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  89739. /**
  89740. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  89741. * @returns the pivot point
  89742. */
  89743. getPivotPoint(): Vector3;
  89744. /**
  89745. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  89746. * @param result the vector3 to store the result
  89747. * @returns this TransformNode.
  89748. */
  89749. getPivotPointToRef(result: Vector3): TransformNode;
  89750. /**
  89751. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  89752. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  89753. */
  89754. getAbsolutePivotPoint(): Vector3;
  89755. /**
  89756. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  89757. * @param result vector3 to store the result
  89758. * @returns this TransformNode.
  89759. */
  89760. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  89761. /**
  89762. * Defines the passed node as the parent of the current node.
  89763. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  89764. * @see https://doc.babylonjs.com/how_to/parenting
  89765. * @param node the node ot set as the parent
  89766. * @returns this TransformNode.
  89767. */
  89768. setParent(node: Nullable<Node>): TransformNode;
  89769. private _nonUniformScaling;
  89770. /**
  89771. * True if the scaling property of this object is non uniform eg. (1,2,1)
  89772. */
  89773. get nonUniformScaling(): boolean;
  89774. /** @hidden */
  89775. _updateNonUniformScalingState(value: boolean): boolean;
  89776. /**
  89777. * Attach the current TransformNode to another TransformNode associated with a bone
  89778. * @param bone Bone affecting the TransformNode
  89779. * @param affectedTransformNode TransformNode associated with the bone
  89780. * @returns this object
  89781. */
  89782. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  89783. /**
  89784. * Detach the transform node if its associated with a bone
  89785. * @returns this object
  89786. */
  89787. detachFromBone(): TransformNode;
  89788. private static _rotationAxisCache;
  89789. /**
  89790. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  89791. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89792. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89793. * The passed axis is also normalized.
  89794. * @param axis the axis to rotate around
  89795. * @param amount the amount to rotate in radians
  89796. * @param space Space to rotate in (Default: local)
  89797. * @returns the TransformNode.
  89798. */
  89799. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89800. /**
  89801. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  89802. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  89803. * The passed axis is also normalized. .
  89804. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  89805. * @param point the point to rotate around
  89806. * @param axis the axis to rotate around
  89807. * @param amount the amount to rotate in radians
  89808. * @returns the TransformNode
  89809. */
  89810. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  89811. /**
  89812. * Translates the mesh along the axis vector for the passed distance in the given space.
  89813. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  89814. * @param axis the axis to translate in
  89815. * @param distance the distance to translate
  89816. * @param space Space to rotate in (Default: local)
  89817. * @returns the TransformNode.
  89818. */
  89819. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89820. /**
  89821. * Adds a rotation step to the mesh current rotation.
  89822. * x, y, z are Euler angles expressed in radians.
  89823. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  89824. * This means this rotation is made in the mesh local space only.
  89825. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  89826. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  89827. * ```javascript
  89828. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  89829. * ```
  89830. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  89831. * 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.
  89832. * @param x Rotation to add
  89833. * @param y Rotation to add
  89834. * @param z Rotation to add
  89835. * @returns the TransformNode.
  89836. */
  89837. addRotation(x: number, y: number, z: number): TransformNode;
  89838. /**
  89839. * @hidden
  89840. */
  89841. protected _getEffectiveParent(): Nullable<Node>;
  89842. /**
  89843. * Computes the world matrix of the node
  89844. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89845. * @returns the world matrix
  89846. */
  89847. computeWorldMatrix(force?: boolean): Matrix;
  89848. /**
  89849. * Resets this nodeTransform's local matrix to Matrix.Identity().
  89850. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  89851. */
  89852. resetLocalMatrix(independentOfChildren?: boolean): void;
  89853. protected _afterComputeWorldMatrix(): void;
  89854. /**
  89855. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  89856. * @param func callback function to add
  89857. *
  89858. * @returns the TransformNode.
  89859. */
  89860. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  89861. /**
  89862. * Removes a registered callback function.
  89863. * @param func callback function to remove
  89864. * @returns the TransformNode.
  89865. */
  89866. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  89867. /**
  89868. * Gets the position of the current mesh in camera space
  89869. * @param camera defines the camera to use
  89870. * @returns a position
  89871. */
  89872. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  89873. /**
  89874. * Returns the distance from the mesh to the active camera
  89875. * @param camera defines the camera to use
  89876. * @returns the distance
  89877. */
  89878. getDistanceToCamera(camera?: Nullable<Camera>): number;
  89879. /**
  89880. * Clone the current transform node
  89881. * @param name Name of the new clone
  89882. * @param newParent New parent for the clone
  89883. * @param doNotCloneChildren Do not clone children hierarchy
  89884. * @returns the new transform node
  89885. */
  89886. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  89887. /**
  89888. * Serializes the objects information.
  89889. * @param currentSerializationObject defines the object to serialize in
  89890. * @returns the serialized object
  89891. */
  89892. serialize(currentSerializationObject?: any): any;
  89893. /**
  89894. * Returns a new TransformNode object parsed from the source provided.
  89895. * @param parsedTransformNode is the source.
  89896. * @param scene the scne the object belongs to
  89897. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  89898. * @returns a new TransformNode object parsed from the source provided.
  89899. */
  89900. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  89901. /**
  89902. * Get all child-transformNodes of this node
  89903. * @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
  89904. * @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
  89905. * @returns an array of TransformNode
  89906. */
  89907. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  89908. /**
  89909. * Releases resources associated with this transform node.
  89910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89912. */
  89913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89914. /**
  89915. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89916. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89917. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89918. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89919. * @returns the current mesh
  89920. */
  89921. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  89922. private _syncAbsoluteScalingAndRotation;
  89923. }
  89924. }
  89925. declare module BABYLON {
  89926. /**
  89927. * Class used to override all child animations of a given target
  89928. */
  89929. export class AnimationPropertiesOverride {
  89930. /**
  89931. * Gets or sets a value indicating if animation blending must be used
  89932. */
  89933. enableBlending: boolean;
  89934. /**
  89935. * Gets or sets the blending speed to use when enableBlending is true
  89936. */
  89937. blendingSpeed: number;
  89938. /**
  89939. * Gets or sets the default loop mode to use
  89940. */
  89941. loopMode: number;
  89942. }
  89943. }
  89944. declare module BABYLON {
  89945. /**
  89946. * Class used to store bone information
  89947. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89948. */
  89949. export class Bone extends Node {
  89950. /**
  89951. * defines the bone name
  89952. */
  89953. name: string;
  89954. private static _tmpVecs;
  89955. private static _tmpQuat;
  89956. private static _tmpMats;
  89957. /**
  89958. * Gets the list of child bones
  89959. */
  89960. children: Bone[];
  89961. /** Gets the animations associated with this bone */
  89962. animations: Animation[];
  89963. /**
  89964. * Gets or sets bone length
  89965. */
  89966. length: number;
  89967. /**
  89968. * @hidden Internal only
  89969. * Set this value to map this bone to a different index in the transform matrices
  89970. * Set this value to -1 to exclude the bone from the transform matrices
  89971. */
  89972. _index: Nullable<number>;
  89973. private _skeleton;
  89974. private _localMatrix;
  89975. private _restPose;
  89976. private _baseMatrix;
  89977. private _absoluteTransform;
  89978. private _invertedAbsoluteTransform;
  89979. private _parent;
  89980. private _scalingDeterminant;
  89981. private _worldTransform;
  89982. private _localScaling;
  89983. private _localRotation;
  89984. private _localPosition;
  89985. private _needToDecompose;
  89986. private _needToCompose;
  89987. /** @hidden */
  89988. _linkedTransformNode: Nullable<TransformNode>;
  89989. /** @hidden */
  89990. _waitingTransformNodeId: Nullable<string>;
  89991. /** @hidden */
  89992. get _matrix(): Matrix;
  89993. /** @hidden */
  89994. set _matrix(value: Matrix);
  89995. /**
  89996. * Create a new bone
  89997. * @param name defines the bone name
  89998. * @param skeleton defines the parent skeleton
  89999. * @param parentBone defines the parent (can be null if the bone is the root)
  90000. * @param localMatrix defines the local matrix
  90001. * @param restPose defines the rest pose matrix
  90002. * @param baseMatrix defines the base matrix
  90003. * @param index defines index of the bone in the hiearchy
  90004. */
  90005. constructor(
  90006. /**
  90007. * defines the bone name
  90008. */
  90009. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  90010. /**
  90011. * Gets the current object class name.
  90012. * @return the class name
  90013. */
  90014. getClassName(): string;
  90015. /**
  90016. * Gets the parent skeleton
  90017. * @returns a skeleton
  90018. */
  90019. getSkeleton(): Skeleton;
  90020. /**
  90021. * Gets parent bone
  90022. * @returns a bone or null if the bone is the root of the bone hierarchy
  90023. */
  90024. getParent(): Nullable<Bone>;
  90025. /**
  90026. * Returns an array containing the root bones
  90027. * @returns an array containing the root bones
  90028. */
  90029. getChildren(): Array<Bone>;
  90030. /**
  90031. * Gets the node index in matrix array generated for rendering
  90032. * @returns the node index
  90033. */
  90034. getIndex(): number;
  90035. /**
  90036. * Sets the parent bone
  90037. * @param parent defines the parent (can be null if the bone is the root)
  90038. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90039. */
  90040. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  90041. /**
  90042. * Gets the local matrix
  90043. * @returns a matrix
  90044. */
  90045. getLocalMatrix(): Matrix;
  90046. /**
  90047. * Gets the base matrix (initial matrix which remains unchanged)
  90048. * @returns a matrix
  90049. */
  90050. getBaseMatrix(): Matrix;
  90051. /**
  90052. * Gets the rest pose matrix
  90053. * @returns a matrix
  90054. */
  90055. getRestPose(): Matrix;
  90056. /**
  90057. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  90058. */
  90059. getWorldMatrix(): Matrix;
  90060. /**
  90061. * Sets the local matrix to rest pose matrix
  90062. */
  90063. returnToRest(): void;
  90064. /**
  90065. * Gets the inverse of the absolute transform matrix.
  90066. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  90067. * @returns a matrix
  90068. */
  90069. getInvertedAbsoluteTransform(): Matrix;
  90070. /**
  90071. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  90072. * @returns a matrix
  90073. */
  90074. getAbsoluteTransform(): Matrix;
  90075. /**
  90076. * Links with the given transform node.
  90077. * The local matrix of this bone is copied from the transform node every frame.
  90078. * @param transformNode defines the transform node to link to
  90079. */
  90080. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  90081. /**
  90082. * Gets the node used to drive the bone's transformation
  90083. * @returns a transform node or null
  90084. */
  90085. getTransformNode(): Nullable<TransformNode>;
  90086. /** Gets or sets current position (in local space) */
  90087. get position(): Vector3;
  90088. set position(newPosition: Vector3);
  90089. /** Gets or sets current rotation (in local space) */
  90090. get rotation(): Vector3;
  90091. set rotation(newRotation: Vector3);
  90092. /** Gets or sets current rotation quaternion (in local space) */
  90093. get rotationQuaternion(): Quaternion;
  90094. set rotationQuaternion(newRotation: Quaternion);
  90095. /** Gets or sets current scaling (in local space) */
  90096. get scaling(): Vector3;
  90097. set scaling(newScaling: Vector3);
  90098. /**
  90099. * Gets the animation properties override
  90100. */
  90101. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  90102. private _decompose;
  90103. private _compose;
  90104. /**
  90105. * Update the base and local matrices
  90106. * @param matrix defines the new base or local matrix
  90107. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  90108. * @param updateLocalMatrix defines if the local matrix should be updated
  90109. */
  90110. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  90111. /** @hidden */
  90112. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  90113. /**
  90114. * Flag the bone as dirty (Forcing it to update everything)
  90115. */
  90116. markAsDirty(): void;
  90117. /** @hidden */
  90118. _markAsDirtyAndCompose(): void;
  90119. private _markAsDirtyAndDecompose;
  90120. /**
  90121. * Translate the bone in local or world space
  90122. * @param vec The amount to translate the bone
  90123. * @param space The space that the translation is in
  90124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90125. */
  90126. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90127. /**
  90128. * Set the postion of the bone in local or world space
  90129. * @param position The position to set the bone
  90130. * @param space The space that the position is in
  90131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90132. */
  90133. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90134. /**
  90135. * Set the absolute position of the bone (world space)
  90136. * @param position The position to set the bone
  90137. * @param mesh The mesh that this bone is attached to
  90138. */
  90139. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  90140. /**
  90141. * Scale the bone on the x, y and z axes (in local space)
  90142. * @param x The amount to scale the bone on the x axis
  90143. * @param y The amount to scale the bone on the y axis
  90144. * @param z The amount to scale the bone on the z axis
  90145. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  90146. */
  90147. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  90148. /**
  90149. * Set the bone scaling in local space
  90150. * @param scale defines the scaling vector
  90151. */
  90152. setScale(scale: Vector3): void;
  90153. /**
  90154. * Gets the current scaling in local space
  90155. * @returns the current scaling vector
  90156. */
  90157. getScale(): Vector3;
  90158. /**
  90159. * Gets the current scaling in local space and stores it in a target vector
  90160. * @param result defines the target vector
  90161. */
  90162. getScaleToRef(result: Vector3): void;
  90163. /**
  90164. * Set the yaw, pitch, and roll of the bone in local or world space
  90165. * @param yaw The rotation of the bone on the y axis
  90166. * @param pitch The rotation of the bone on the x axis
  90167. * @param roll The rotation of the bone on the z axis
  90168. * @param space The space that the axes of rotation are in
  90169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90170. */
  90171. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  90172. /**
  90173. * Add a rotation to the bone on an axis in local or world space
  90174. * @param axis The axis to rotate the bone on
  90175. * @param amount The amount to rotate the bone
  90176. * @param space The space that the axis is in
  90177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90178. */
  90179. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  90180. /**
  90181. * Set the rotation of the bone to a particular axis angle in local or world space
  90182. * @param axis The axis to rotate the bone on
  90183. * @param angle The angle that the bone should be rotated to
  90184. * @param space The space that the axis is in
  90185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90186. */
  90187. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  90188. /**
  90189. * Set the euler rotation of the bone in local of world space
  90190. * @param rotation The euler rotation that the bone should be set to
  90191. * @param space The space that the rotation is in
  90192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90193. */
  90194. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  90195. /**
  90196. * Set the quaternion rotation of the bone in local of world space
  90197. * @param quat The quaternion rotation that the bone should be set to
  90198. * @param space The space that the rotation is in
  90199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90200. */
  90201. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  90202. /**
  90203. * Set the rotation matrix of the bone in local of world space
  90204. * @param rotMat The rotation matrix that the bone should be set to
  90205. * @param space The space that the rotation is in
  90206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90207. */
  90208. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  90209. private _rotateWithMatrix;
  90210. private _getNegativeRotationToRef;
  90211. /**
  90212. * Get the position of the bone in local or world space
  90213. * @param space The space that the returned position is in
  90214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90215. * @returns The position of the bone
  90216. */
  90217. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90218. /**
  90219. * Copy the position of the bone to a vector3 in local or world space
  90220. * @param space The space that the returned position is in
  90221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90222. * @param result The vector3 to copy the position to
  90223. */
  90224. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  90225. /**
  90226. * Get the absolute position of the bone (world space)
  90227. * @param mesh The mesh that this bone is attached to
  90228. * @returns The absolute position of the bone
  90229. */
  90230. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  90231. /**
  90232. * Copy the absolute position of the bone (world space) to the result param
  90233. * @param mesh The mesh that this bone is attached to
  90234. * @param result The vector3 to copy the absolute position to
  90235. */
  90236. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  90237. /**
  90238. * Compute the absolute transforms of this bone and its children
  90239. */
  90240. computeAbsoluteTransforms(): void;
  90241. /**
  90242. * Get the world direction from an axis that is in the local space of the bone
  90243. * @param localAxis The local direction that is used to compute the world direction
  90244. * @param mesh The mesh that this bone is attached to
  90245. * @returns The world direction
  90246. */
  90247. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90248. /**
  90249. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  90250. * @param localAxis The local direction that is used to compute the world direction
  90251. * @param mesh The mesh that this bone is attached to
  90252. * @param result The vector3 that the world direction will be copied to
  90253. */
  90254. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90255. /**
  90256. * Get the euler rotation of the bone in local or world space
  90257. * @param space The space that the rotation should be in
  90258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90259. * @returns The euler rotation
  90260. */
  90261. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  90262. /**
  90263. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  90264. * @param space The space that the rotation should be in
  90265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90266. * @param result The vector3 that the rotation should be copied to
  90267. */
  90268. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90269. /**
  90270. * Get the quaternion rotation of the bone in either local or world space
  90271. * @param space The space that the rotation should be in
  90272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90273. * @returns The quaternion rotation
  90274. */
  90275. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  90276. /**
  90277. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  90278. * @param space The space that the rotation should be in
  90279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90280. * @param result The quaternion that the rotation should be copied to
  90281. */
  90282. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  90283. /**
  90284. * Get the rotation matrix of the bone in local or world space
  90285. * @param space The space that the rotation should be in
  90286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90287. * @returns The rotation matrix
  90288. */
  90289. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  90290. /**
  90291. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  90292. * @param space The space that the rotation should be in
  90293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  90294. * @param result The quaternion that the rotation should be copied to
  90295. */
  90296. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  90297. /**
  90298. * Get the world position of a point that is in the local space of the bone
  90299. * @param position The local position
  90300. * @param mesh The mesh that this bone is attached to
  90301. * @returns The world position
  90302. */
  90303. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90304. /**
  90305. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  90306. * @param position The local position
  90307. * @param mesh The mesh that this bone is attached to
  90308. * @param result The vector3 that the world position should be copied to
  90309. */
  90310. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90311. /**
  90312. * Get the local position of a point that is in world space
  90313. * @param position The world position
  90314. * @param mesh The mesh that this bone is attached to
  90315. * @returns The local position
  90316. */
  90317. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  90318. /**
  90319. * Get the local position of a point that is in world space and copy it to the result param
  90320. * @param position The world position
  90321. * @param mesh The mesh that this bone is attached to
  90322. * @param result The vector3 that the local position should be copied to
  90323. */
  90324. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  90325. }
  90326. }
  90327. declare module BABYLON {
  90328. /**
  90329. * Defines a runtime animation
  90330. */
  90331. export class RuntimeAnimation {
  90332. private _events;
  90333. /**
  90334. * The current frame of the runtime animation
  90335. */
  90336. private _currentFrame;
  90337. /**
  90338. * The animation used by the runtime animation
  90339. */
  90340. private _animation;
  90341. /**
  90342. * The target of the runtime animation
  90343. */
  90344. private _target;
  90345. /**
  90346. * The initiating animatable
  90347. */
  90348. private _host;
  90349. /**
  90350. * The original value of the runtime animation
  90351. */
  90352. private _originalValue;
  90353. /**
  90354. * The original blend value of the runtime animation
  90355. */
  90356. private _originalBlendValue;
  90357. /**
  90358. * The offsets cache of the runtime animation
  90359. */
  90360. private _offsetsCache;
  90361. /**
  90362. * The high limits cache of the runtime animation
  90363. */
  90364. private _highLimitsCache;
  90365. /**
  90366. * Specifies if the runtime animation has been stopped
  90367. */
  90368. private _stopped;
  90369. /**
  90370. * The blending factor of the runtime animation
  90371. */
  90372. private _blendingFactor;
  90373. /**
  90374. * The BabylonJS scene
  90375. */
  90376. private _scene;
  90377. /**
  90378. * The current value of the runtime animation
  90379. */
  90380. private _currentValue;
  90381. /** @hidden */
  90382. _animationState: _IAnimationState;
  90383. /**
  90384. * The active target of the runtime animation
  90385. */
  90386. private _activeTargets;
  90387. private _currentActiveTarget;
  90388. private _directTarget;
  90389. /**
  90390. * The target path of the runtime animation
  90391. */
  90392. private _targetPath;
  90393. /**
  90394. * The weight of the runtime animation
  90395. */
  90396. private _weight;
  90397. /**
  90398. * The ratio offset of the runtime animation
  90399. */
  90400. private _ratioOffset;
  90401. /**
  90402. * The previous delay of the runtime animation
  90403. */
  90404. private _previousDelay;
  90405. /**
  90406. * The previous ratio of the runtime animation
  90407. */
  90408. private _previousRatio;
  90409. private _enableBlending;
  90410. private _keys;
  90411. private _minFrame;
  90412. private _maxFrame;
  90413. private _minValue;
  90414. private _maxValue;
  90415. private _targetIsArray;
  90416. /**
  90417. * Gets the current frame of the runtime animation
  90418. */
  90419. get currentFrame(): number;
  90420. /**
  90421. * Gets the weight of the runtime animation
  90422. */
  90423. get weight(): number;
  90424. /**
  90425. * Gets the current value of the runtime animation
  90426. */
  90427. get currentValue(): any;
  90428. /**
  90429. * Gets the target path of the runtime animation
  90430. */
  90431. get targetPath(): string;
  90432. /**
  90433. * Gets the actual target of the runtime animation
  90434. */
  90435. get target(): any;
  90436. /**
  90437. * Gets the additive state of the runtime animation
  90438. */
  90439. get isAdditive(): boolean;
  90440. /** @hidden */
  90441. _onLoop: () => void;
  90442. /**
  90443. * Create a new RuntimeAnimation object
  90444. * @param target defines the target of the animation
  90445. * @param animation defines the source animation object
  90446. * @param scene defines the hosting scene
  90447. * @param host defines the initiating Animatable
  90448. */
  90449. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  90450. private _preparePath;
  90451. /**
  90452. * Gets the animation from the runtime animation
  90453. */
  90454. get animation(): Animation;
  90455. /**
  90456. * Resets the runtime animation to the beginning
  90457. * @param restoreOriginal defines whether to restore the target property to the original value
  90458. */
  90459. reset(restoreOriginal?: boolean): void;
  90460. /**
  90461. * Specifies if the runtime animation is stopped
  90462. * @returns Boolean specifying if the runtime animation is stopped
  90463. */
  90464. isStopped(): boolean;
  90465. /**
  90466. * Disposes of the runtime animation
  90467. */
  90468. dispose(): void;
  90469. /**
  90470. * Apply the interpolated value to the target
  90471. * @param currentValue defines the value computed by the animation
  90472. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  90473. */
  90474. setValue(currentValue: any, weight: number): void;
  90475. private _getOriginalValues;
  90476. private _setValue;
  90477. /**
  90478. * Gets the loop pmode of the runtime animation
  90479. * @returns Loop Mode
  90480. */
  90481. private _getCorrectLoopMode;
  90482. /**
  90483. * Move the current animation to a given frame
  90484. * @param frame defines the frame to move to
  90485. */
  90486. goToFrame(frame: number): void;
  90487. /**
  90488. * @hidden Internal use only
  90489. */
  90490. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  90491. /**
  90492. * Execute the current animation
  90493. * @param delay defines the delay to add to the current frame
  90494. * @param from defines the lower bound of the animation range
  90495. * @param to defines the upper bound of the animation range
  90496. * @param loop defines if the current animation must loop
  90497. * @param speedRatio defines the current speed ratio
  90498. * @param weight defines the weight of the animation (default is -1 so no weight)
  90499. * @param onLoop optional callback called when animation loops
  90500. * @returns a boolean indicating if the animation is running
  90501. */
  90502. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  90503. }
  90504. }
  90505. declare module BABYLON {
  90506. /**
  90507. * Class used to store an actual running animation
  90508. */
  90509. export class Animatable {
  90510. /** defines the target object */
  90511. target: any;
  90512. /** defines the starting frame number (default is 0) */
  90513. fromFrame: number;
  90514. /** defines the ending frame number (default is 100) */
  90515. toFrame: number;
  90516. /** defines if the animation must loop (default is false) */
  90517. loopAnimation: boolean;
  90518. /** defines a callback to call when animation ends if it is not looping */
  90519. onAnimationEnd?: (() => void) | null | undefined;
  90520. /** defines a callback to call when animation loops */
  90521. onAnimationLoop?: (() => void) | null | undefined;
  90522. /** defines whether the animation should be evaluated additively */
  90523. isAdditive: boolean;
  90524. private _localDelayOffset;
  90525. private _pausedDelay;
  90526. private _runtimeAnimations;
  90527. private _paused;
  90528. private _scene;
  90529. private _speedRatio;
  90530. private _weight;
  90531. private _syncRoot;
  90532. /**
  90533. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  90534. * This will only apply for non looping animation (default is true)
  90535. */
  90536. disposeOnEnd: boolean;
  90537. /**
  90538. * Gets a boolean indicating if the animation has started
  90539. */
  90540. animationStarted: boolean;
  90541. /**
  90542. * Observer raised when the animation ends
  90543. */
  90544. onAnimationEndObservable: Observable<Animatable>;
  90545. /**
  90546. * Observer raised when the animation loops
  90547. */
  90548. onAnimationLoopObservable: Observable<Animatable>;
  90549. /**
  90550. * Gets the root Animatable used to synchronize and normalize animations
  90551. */
  90552. get syncRoot(): Nullable<Animatable>;
  90553. /**
  90554. * Gets the current frame of the first RuntimeAnimation
  90555. * Used to synchronize Animatables
  90556. */
  90557. get masterFrame(): number;
  90558. /**
  90559. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  90560. */
  90561. get weight(): number;
  90562. set weight(value: number);
  90563. /**
  90564. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  90565. */
  90566. get speedRatio(): number;
  90567. set speedRatio(value: number);
  90568. /**
  90569. * Creates a new Animatable
  90570. * @param scene defines the hosting scene
  90571. * @param target defines the target object
  90572. * @param fromFrame defines the starting frame number (default is 0)
  90573. * @param toFrame defines the ending frame number (default is 100)
  90574. * @param loopAnimation defines if the animation must loop (default is false)
  90575. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  90576. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  90577. * @param animations defines a group of animation to add to the new Animatable
  90578. * @param onAnimationLoop defines a callback to call when animation loops
  90579. * @param isAdditive defines whether the animation should be evaluated additively
  90580. */
  90581. constructor(scene: Scene,
  90582. /** defines the target object */
  90583. target: any,
  90584. /** defines the starting frame number (default is 0) */
  90585. fromFrame?: number,
  90586. /** defines the ending frame number (default is 100) */
  90587. toFrame?: number,
  90588. /** defines if the animation must loop (default is false) */
  90589. loopAnimation?: boolean, speedRatio?: number,
  90590. /** defines a callback to call when animation ends if it is not looping */
  90591. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  90592. /** defines a callback to call when animation loops */
  90593. onAnimationLoop?: (() => void) | null | undefined,
  90594. /** defines whether the animation should be evaluated additively */
  90595. isAdditive?: boolean);
  90596. /**
  90597. * Synchronize and normalize current Animatable with a source Animatable
  90598. * This is useful when using animation weights and when animations are not of the same length
  90599. * @param root defines the root Animatable to synchronize with
  90600. * @returns the current Animatable
  90601. */
  90602. syncWith(root: Animatable): Animatable;
  90603. /**
  90604. * Gets the list of runtime animations
  90605. * @returns an array of RuntimeAnimation
  90606. */
  90607. getAnimations(): RuntimeAnimation[];
  90608. /**
  90609. * Adds more animations to the current animatable
  90610. * @param target defines the target of the animations
  90611. * @param animations defines the new animations to add
  90612. */
  90613. appendAnimations(target: any, animations: Animation[]): void;
  90614. /**
  90615. * Gets the source animation for a specific property
  90616. * @param property defines the propertyu to look for
  90617. * @returns null or the source animation for the given property
  90618. */
  90619. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  90620. /**
  90621. * Gets the runtime animation for a specific property
  90622. * @param property defines the propertyu to look for
  90623. * @returns null or the runtime animation for the given property
  90624. */
  90625. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  90626. /**
  90627. * Resets the animatable to its original state
  90628. */
  90629. reset(): void;
  90630. /**
  90631. * Allows the animatable to blend with current running animations
  90632. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90633. * @param blendingSpeed defines the blending speed to use
  90634. */
  90635. enableBlending(blendingSpeed: number): void;
  90636. /**
  90637. * Disable animation blending
  90638. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  90639. */
  90640. disableBlending(): void;
  90641. /**
  90642. * Jump directly to a given frame
  90643. * @param frame defines the frame to jump to
  90644. */
  90645. goToFrame(frame: number): void;
  90646. /**
  90647. * Pause the animation
  90648. */
  90649. pause(): void;
  90650. /**
  90651. * Restart the animation
  90652. */
  90653. restart(): void;
  90654. private _raiseOnAnimationEnd;
  90655. /**
  90656. * Stop and delete the current animation
  90657. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  90658. * @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)
  90659. */
  90660. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  90661. /**
  90662. * Wait asynchronously for the animation to end
  90663. * @returns a promise which will be fullfilled when the animation ends
  90664. */
  90665. waitAsync(): Promise<Animatable>;
  90666. /** @hidden */
  90667. _animate(delay: number): boolean;
  90668. }
  90669. interface Scene {
  90670. /** @hidden */
  90671. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  90672. /** @hidden */
  90673. _processLateAnimationBindingsForMatrices(holder: {
  90674. totalWeight: number;
  90675. totalAdditiveWeight: number;
  90676. animations: RuntimeAnimation[];
  90677. additiveAnimations: RuntimeAnimation[];
  90678. originalValue: Matrix;
  90679. }): any;
  90680. /** @hidden */
  90681. _processLateAnimationBindingsForQuaternions(holder: {
  90682. totalWeight: number;
  90683. totalAdditiveWeight: number;
  90684. animations: RuntimeAnimation[];
  90685. additiveAnimations: RuntimeAnimation[];
  90686. originalValue: Quaternion;
  90687. }, refQuaternion: Quaternion): Quaternion;
  90688. /** @hidden */
  90689. _processLateAnimationBindings(): void;
  90690. /**
  90691. * Will start the animation sequence of a given target
  90692. * @param target defines the target
  90693. * @param from defines from which frame should animation start
  90694. * @param to defines until which frame should animation run.
  90695. * @param weight defines the weight to apply to the animation (1.0 by default)
  90696. * @param loop defines if the animation loops
  90697. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90698. * @param onAnimationEnd defines the function to be executed when the animation ends
  90699. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90700. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90701. * @param onAnimationLoop defines the callback to call when an animation loops
  90702. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90703. * @returns the animatable object created for this animation
  90704. */
  90705. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  90706. /**
  90707. * Will start the animation sequence of a given target
  90708. * @param target defines the target
  90709. * @param from defines from which frame should animation start
  90710. * @param to defines until which frame should animation run.
  90711. * @param loop defines if the animation loops
  90712. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90713. * @param onAnimationEnd defines the function to be executed when the animation ends
  90714. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90715. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90716. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  90717. * @param onAnimationLoop defines the callback to call when an animation loops
  90718. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90719. * @returns the animatable object created for this animation
  90720. */
  90721. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  90722. /**
  90723. * Will start the animation sequence of a given target and its hierarchy
  90724. * @param target defines the target
  90725. * @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.
  90726. * @param from defines from which frame should animation start
  90727. * @param to defines until which frame should animation run.
  90728. * @param loop defines if the animation loops
  90729. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  90730. * @param onAnimationEnd defines the function to be executed when the animation ends
  90731. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  90732. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  90733. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  90734. * @param onAnimationLoop defines the callback to call when an animation loops
  90735. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90736. * @returns the list of created animatables
  90737. */
  90738. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  90739. /**
  90740. * Begin a new animation on a given node
  90741. * @param target defines the target where the animation will take place
  90742. * @param animations defines the list of animations to start
  90743. * @param from defines the initial value
  90744. * @param to defines the final value
  90745. * @param loop defines if you want animation to loop (off by default)
  90746. * @param speedRatio defines the speed ratio to apply to all animations
  90747. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90748. * @param onAnimationLoop defines the callback to call when an animation loops
  90749. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90750. * @returns the list of created animatables
  90751. */
  90752. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  90753. /**
  90754. * Begin a new animation on a given node and its hierarchy
  90755. * @param target defines the root node where the animation will take place
  90756. * @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.
  90757. * @param animations defines the list of animations to start
  90758. * @param from defines the initial value
  90759. * @param to defines the final value
  90760. * @param loop defines if you want animation to loop (off by default)
  90761. * @param speedRatio defines the speed ratio to apply to all animations
  90762. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90763. * @param onAnimationLoop defines the callback to call when an animation loops
  90764. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  90765. * @returns the list of animatables created for all nodes
  90766. */
  90767. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  90768. /**
  90769. * Gets the animatable associated with a specific target
  90770. * @param target defines the target of the animatable
  90771. * @returns the required animatable if found
  90772. */
  90773. getAnimatableByTarget(target: any): Nullable<Animatable>;
  90774. /**
  90775. * Gets all animatables associated with a given target
  90776. * @param target defines the target to look animatables for
  90777. * @returns an array of Animatables
  90778. */
  90779. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  90780. /**
  90781. * Stops and removes all animations that have been applied to the scene
  90782. */
  90783. stopAllAnimations(): void;
  90784. /**
  90785. * Gets the current delta time used by animation engine
  90786. */
  90787. deltaTime: number;
  90788. }
  90789. interface Bone {
  90790. /**
  90791. * Copy an animation range from another bone
  90792. * @param source defines the source bone
  90793. * @param rangeName defines the range name to copy
  90794. * @param frameOffset defines the frame offset
  90795. * @param rescaleAsRequired defines if rescaling must be applied if required
  90796. * @param skelDimensionsRatio defines the scaling ratio
  90797. * @returns true if operation was successful
  90798. */
  90799. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  90800. }
  90801. }
  90802. declare module BABYLON {
  90803. /**
  90804. * Class used to handle skinning animations
  90805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90806. */
  90807. export class Skeleton implements IAnimatable {
  90808. /** defines the skeleton name */
  90809. name: string;
  90810. /** defines the skeleton Id */
  90811. id: string;
  90812. /**
  90813. * Defines the list of child bones
  90814. */
  90815. bones: Bone[];
  90816. /**
  90817. * Defines an estimate of the dimension of the skeleton at rest
  90818. */
  90819. dimensionsAtRest: Vector3;
  90820. /**
  90821. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  90822. */
  90823. needInitialSkinMatrix: boolean;
  90824. /**
  90825. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  90826. */
  90827. overrideMesh: Nullable<AbstractMesh>;
  90828. /**
  90829. * Gets the list of animations attached to this skeleton
  90830. */
  90831. animations: Array<Animation>;
  90832. private _scene;
  90833. private _isDirty;
  90834. private _transformMatrices;
  90835. private _transformMatrixTexture;
  90836. private _meshesWithPoseMatrix;
  90837. private _animatables;
  90838. private _identity;
  90839. private _synchronizedWithMesh;
  90840. private _ranges;
  90841. private _lastAbsoluteTransformsUpdateId;
  90842. private _canUseTextureForBones;
  90843. private _uniqueId;
  90844. /** @hidden */
  90845. _numBonesWithLinkedTransformNode: number;
  90846. /** @hidden */
  90847. _hasWaitingData: Nullable<boolean>;
  90848. /**
  90849. * Specifies if the skeleton should be serialized
  90850. */
  90851. doNotSerialize: boolean;
  90852. private _useTextureToStoreBoneMatrices;
  90853. /**
  90854. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  90855. * Please note that this option is not available if the hardware does not support it
  90856. */
  90857. get useTextureToStoreBoneMatrices(): boolean;
  90858. set useTextureToStoreBoneMatrices(value: boolean);
  90859. private _animationPropertiesOverride;
  90860. /**
  90861. * Gets or sets the animation properties override
  90862. */
  90863. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  90864. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  90865. /**
  90866. * List of inspectable custom properties (used by the Inspector)
  90867. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90868. */
  90869. inspectableCustomProperties: IInspectable[];
  90870. /**
  90871. * An observable triggered before computing the skeleton's matrices
  90872. */
  90873. onBeforeComputeObservable: Observable<Skeleton>;
  90874. /**
  90875. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  90876. */
  90877. get isUsingTextureForMatrices(): boolean;
  90878. /**
  90879. * Gets the unique ID of this skeleton
  90880. */
  90881. get uniqueId(): number;
  90882. /**
  90883. * Creates a new skeleton
  90884. * @param name defines the skeleton name
  90885. * @param id defines the skeleton Id
  90886. * @param scene defines the hosting scene
  90887. */
  90888. constructor(
  90889. /** defines the skeleton name */
  90890. name: string,
  90891. /** defines the skeleton Id */
  90892. id: string, scene: Scene);
  90893. /**
  90894. * Gets the current object class name.
  90895. * @return the class name
  90896. */
  90897. getClassName(): string;
  90898. /**
  90899. * Returns an array containing the root bones
  90900. * @returns an array containing the root bones
  90901. */
  90902. getChildren(): Array<Bone>;
  90903. /**
  90904. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  90905. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  90906. * @returns a Float32Array containing matrices data
  90907. */
  90908. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  90909. /**
  90910. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  90911. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  90912. * @returns a raw texture containing the data
  90913. */
  90914. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  90915. /**
  90916. * Gets the current hosting scene
  90917. * @returns a scene object
  90918. */
  90919. getScene(): Scene;
  90920. /**
  90921. * Gets a string representing the current skeleton data
  90922. * @param fullDetails defines a boolean indicating if we want a verbose version
  90923. * @returns a string representing the current skeleton data
  90924. */
  90925. toString(fullDetails?: boolean): string;
  90926. /**
  90927. * Get bone's index searching by name
  90928. * @param name defines bone's name to search for
  90929. * @return the indice of the bone. Returns -1 if not found
  90930. */
  90931. getBoneIndexByName(name: string): number;
  90932. /**
  90933. * Creater a new animation range
  90934. * @param name defines the name of the range
  90935. * @param from defines the start key
  90936. * @param to defines the end key
  90937. */
  90938. createAnimationRange(name: string, from: number, to: number): void;
  90939. /**
  90940. * Delete a specific animation range
  90941. * @param name defines the name of the range
  90942. * @param deleteFrames defines if frames must be removed as well
  90943. */
  90944. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90945. /**
  90946. * Gets a specific animation range
  90947. * @param name defines the name of the range to look for
  90948. * @returns the requested animation range or null if not found
  90949. */
  90950. getAnimationRange(name: string): Nullable<AnimationRange>;
  90951. /**
  90952. * Gets the list of all animation ranges defined on this skeleton
  90953. * @returns an array
  90954. */
  90955. getAnimationRanges(): Nullable<AnimationRange>[];
  90956. /**
  90957. * Copy animation range from a source skeleton.
  90958. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  90959. * @param source defines the source skeleton
  90960. * @param name defines the name of the range to copy
  90961. * @param rescaleAsRequired defines if rescaling must be applied if required
  90962. * @returns true if operation was successful
  90963. */
  90964. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  90965. /**
  90966. * Forces the skeleton to go to rest pose
  90967. */
  90968. returnToRest(): void;
  90969. private _getHighestAnimationFrame;
  90970. /**
  90971. * Begin a specific animation range
  90972. * @param name defines the name of the range to start
  90973. * @param loop defines if looping must be turned on (false by default)
  90974. * @param speedRatio defines the speed ratio to apply (1 by default)
  90975. * @param onAnimationEnd defines a callback which will be called when animation will end
  90976. * @returns a new animatable
  90977. */
  90978. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90979. /**
  90980. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  90981. * @param skeleton defines the Skeleton containing the animation range to convert
  90982. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  90983. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  90984. * @returns the original skeleton
  90985. */
  90986. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  90987. /** @hidden */
  90988. _markAsDirty(): void;
  90989. /** @hidden */
  90990. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  90991. /** @hidden */
  90992. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  90993. private _computeTransformMatrices;
  90994. /**
  90995. * Build all resources required to render a skeleton
  90996. */
  90997. prepare(): void;
  90998. /**
  90999. * Gets the list of animatables currently running for this skeleton
  91000. * @returns an array of animatables
  91001. */
  91002. getAnimatables(): IAnimatable[];
  91003. /**
  91004. * Clone the current skeleton
  91005. * @param name defines the name of the new skeleton
  91006. * @param id defines the id of the new skeleton
  91007. * @returns the new skeleton
  91008. */
  91009. clone(name: string, id?: string): Skeleton;
  91010. /**
  91011. * Enable animation blending for this skeleton
  91012. * @param blendingSpeed defines the blending speed to apply
  91013. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  91014. */
  91015. enableBlending(blendingSpeed?: number): void;
  91016. /**
  91017. * Releases all resources associated with the current skeleton
  91018. */
  91019. dispose(): void;
  91020. /**
  91021. * Serialize the skeleton in a JSON object
  91022. * @returns a JSON object
  91023. */
  91024. serialize(): any;
  91025. /**
  91026. * Creates a new skeleton from serialized data
  91027. * @param parsedSkeleton defines the serialized data
  91028. * @param scene defines the hosting scene
  91029. * @returns a new skeleton
  91030. */
  91031. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  91032. /**
  91033. * Compute all node absolute transforms
  91034. * @param forceUpdate defines if computation must be done even if cache is up to date
  91035. */
  91036. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  91037. /**
  91038. * Gets the root pose matrix
  91039. * @returns a matrix
  91040. */
  91041. getPoseMatrix(): Nullable<Matrix>;
  91042. /**
  91043. * Sorts bones per internal index
  91044. */
  91045. sortBones(): void;
  91046. private _sortBones;
  91047. }
  91048. }
  91049. declare module BABYLON {
  91050. /**
  91051. * Creates an instance based on a source mesh.
  91052. */
  91053. export class InstancedMesh extends AbstractMesh {
  91054. private _sourceMesh;
  91055. private _currentLOD;
  91056. /** @hidden */
  91057. _indexInSourceMeshInstanceArray: number;
  91058. constructor(name: string, source: Mesh);
  91059. /**
  91060. * Returns the string "InstancedMesh".
  91061. */
  91062. getClassName(): string;
  91063. /** Gets the list of lights affecting that mesh */
  91064. get lightSources(): Light[];
  91065. _resyncLightSources(): void;
  91066. _resyncLightSource(light: Light): void;
  91067. _removeLightSource(light: Light, dispose: boolean): void;
  91068. /**
  91069. * If the source mesh receives shadows
  91070. */
  91071. get receiveShadows(): boolean;
  91072. /**
  91073. * The material of the source mesh
  91074. */
  91075. get material(): Nullable<Material>;
  91076. /**
  91077. * Visibility of the source mesh
  91078. */
  91079. get visibility(): number;
  91080. /**
  91081. * Skeleton of the source mesh
  91082. */
  91083. get skeleton(): Nullable<Skeleton>;
  91084. /**
  91085. * Rendering ground id of the source mesh
  91086. */
  91087. get renderingGroupId(): number;
  91088. set renderingGroupId(value: number);
  91089. /**
  91090. * Returns the total number of vertices (integer).
  91091. */
  91092. getTotalVertices(): number;
  91093. /**
  91094. * Returns a positive integer : the total number of indices in this mesh geometry.
  91095. * @returns the numner of indices or zero if the mesh has no geometry.
  91096. */
  91097. getTotalIndices(): number;
  91098. /**
  91099. * The source mesh of the instance
  91100. */
  91101. get sourceMesh(): Mesh;
  91102. /**
  91103. * Is this node ready to be used/rendered
  91104. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91105. * @return {boolean} is it ready
  91106. */
  91107. isReady(completeCheck?: boolean): boolean;
  91108. /**
  91109. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91110. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  91111. * @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.
  91112. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  91113. */
  91114. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  91115. /**
  91116. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91117. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91118. * The `data` are either a numeric array either a Float32Array.
  91119. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  91120. * 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).
  91121. * Note that a new underlying VertexBuffer object is created each call.
  91122. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91123. *
  91124. * Possible `kind` values :
  91125. * - VertexBuffer.PositionKind
  91126. * - VertexBuffer.UVKind
  91127. * - VertexBuffer.UV2Kind
  91128. * - VertexBuffer.UV3Kind
  91129. * - VertexBuffer.UV4Kind
  91130. * - VertexBuffer.UV5Kind
  91131. * - VertexBuffer.UV6Kind
  91132. * - VertexBuffer.ColorKind
  91133. * - VertexBuffer.MatricesIndicesKind
  91134. * - VertexBuffer.MatricesIndicesExtraKind
  91135. * - VertexBuffer.MatricesWeightsKind
  91136. * - VertexBuffer.MatricesWeightsExtraKind
  91137. *
  91138. * Returns the Mesh.
  91139. */
  91140. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91141. /**
  91142. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91143. * If the mesh has no geometry, it is simply returned as it is.
  91144. * The `data` are either a numeric array either a Float32Array.
  91145. * No new underlying VertexBuffer object is created.
  91146. * 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.
  91147. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  91148. *
  91149. * Possible `kind` values :
  91150. * - VertexBuffer.PositionKind
  91151. * - VertexBuffer.UVKind
  91152. * - VertexBuffer.UV2Kind
  91153. * - VertexBuffer.UV3Kind
  91154. * - VertexBuffer.UV4Kind
  91155. * - VertexBuffer.UV5Kind
  91156. * - VertexBuffer.UV6Kind
  91157. * - VertexBuffer.ColorKind
  91158. * - VertexBuffer.MatricesIndicesKind
  91159. * - VertexBuffer.MatricesIndicesExtraKind
  91160. * - VertexBuffer.MatricesWeightsKind
  91161. * - VertexBuffer.MatricesWeightsExtraKind
  91162. *
  91163. * Returns the Mesh.
  91164. */
  91165. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  91166. /**
  91167. * Sets the mesh indices.
  91168. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  91169. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91170. * This method creates a new index buffer each call.
  91171. * Returns the Mesh.
  91172. */
  91173. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  91174. /**
  91175. * Boolean : True if the mesh owns the requested kind of data.
  91176. */
  91177. isVerticesDataPresent(kind: string): boolean;
  91178. /**
  91179. * Returns an array of indices (IndicesArray).
  91180. */
  91181. getIndices(): Nullable<IndicesArray>;
  91182. get _positions(): Nullable<Vector3[]>;
  91183. /**
  91184. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91185. * This means the mesh underlying bounding box and sphere are recomputed.
  91186. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91187. * @returns the current mesh
  91188. */
  91189. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  91190. /** @hidden */
  91191. _preActivate(): InstancedMesh;
  91192. /** @hidden */
  91193. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91194. /** @hidden */
  91195. _postActivate(): void;
  91196. getWorldMatrix(): Matrix;
  91197. get isAnInstance(): boolean;
  91198. /**
  91199. * Returns the current associated LOD AbstractMesh.
  91200. */
  91201. getLOD(camera: Camera): AbstractMesh;
  91202. /** @hidden */
  91203. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91204. /** @hidden */
  91205. _syncSubMeshes(): InstancedMesh;
  91206. /** @hidden */
  91207. _generatePointsArray(): boolean;
  91208. /**
  91209. * Creates a new InstancedMesh from the current mesh.
  91210. * - name (string) : the cloned mesh name
  91211. * - newParent (optional Node) : the optional Node to parent the clone to.
  91212. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  91213. *
  91214. * Returns the clone.
  91215. */
  91216. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  91217. /**
  91218. * Disposes the InstancedMesh.
  91219. * Returns nothing.
  91220. */
  91221. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91222. }
  91223. interface Mesh {
  91224. /**
  91225. * Register a custom buffer that will be instanced
  91226. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91227. * @param kind defines the buffer kind
  91228. * @param stride defines the stride in floats
  91229. */
  91230. registerInstancedBuffer(kind: string, stride: number): void;
  91231. /** @hidden */
  91232. _userInstancedBuffersStorage: {
  91233. data: {
  91234. [key: string]: Float32Array;
  91235. };
  91236. sizes: {
  91237. [key: string]: number;
  91238. };
  91239. vertexBuffers: {
  91240. [key: string]: Nullable<VertexBuffer>;
  91241. };
  91242. strides: {
  91243. [key: string]: number;
  91244. };
  91245. };
  91246. }
  91247. interface AbstractMesh {
  91248. /**
  91249. * Object used to store instanced buffers defined by user
  91250. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  91251. */
  91252. instancedBuffers: {
  91253. [key: string]: any;
  91254. };
  91255. }
  91256. }
  91257. declare module BABYLON {
  91258. /**
  91259. * Defines the options associated with the creation of a shader material.
  91260. */
  91261. export interface IShaderMaterialOptions {
  91262. /**
  91263. * Does the material work in alpha blend mode
  91264. */
  91265. needAlphaBlending: boolean;
  91266. /**
  91267. * Does the material work in alpha test mode
  91268. */
  91269. needAlphaTesting: boolean;
  91270. /**
  91271. * The list of attribute names used in the shader
  91272. */
  91273. attributes: string[];
  91274. /**
  91275. * The list of unifrom names used in the shader
  91276. */
  91277. uniforms: string[];
  91278. /**
  91279. * The list of UBO names used in the shader
  91280. */
  91281. uniformBuffers: string[];
  91282. /**
  91283. * The list of sampler names used in the shader
  91284. */
  91285. samplers: string[];
  91286. /**
  91287. * The list of defines used in the shader
  91288. */
  91289. defines: string[];
  91290. }
  91291. /**
  91292. * 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.
  91293. *
  91294. * This returned material effects how the mesh will look based on the code in the shaders.
  91295. *
  91296. * @see http://doc.babylonjs.com/how_to/shader_material
  91297. */
  91298. export class ShaderMaterial extends Material {
  91299. private _shaderPath;
  91300. private _options;
  91301. private _textures;
  91302. private _textureArrays;
  91303. private _floats;
  91304. private _ints;
  91305. private _floatsArrays;
  91306. private _colors3;
  91307. private _colors3Arrays;
  91308. private _colors4;
  91309. private _colors4Arrays;
  91310. private _vectors2;
  91311. private _vectors3;
  91312. private _vectors4;
  91313. private _matrices;
  91314. private _matrixArrays;
  91315. private _matrices3x3;
  91316. private _matrices2x2;
  91317. private _vectors2Arrays;
  91318. private _vectors3Arrays;
  91319. private _vectors4Arrays;
  91320. private _cachedWorldViewMatrix;
  91321. private _cachedWorldViewProjectionMatrix;
  91322. private _renderId;
  91323. private _multiview;
  91324. private _cachedDefines;
  91325. /**
  91326. * Instantiate a new shader material.
  91327. * 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.
  91328. * This returned material effects how the mesh will look based on the code in the shaders.
  91329. * @see http://doc.babylonjs.com/how_to/shader_material
  91330. * @param name Define the name of the material in the scene
  91331. * @param scene Define the scene the material belongs to
  91332. * @param shaderPath Defines the route to the shader code in one of three ways:
  91333. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  91334. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  91335. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  91336. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  91337. * @param options Define the options used to create the shader
  91338. */
  91339. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  91340. /**
  91341. * Gets the shader path used to define the shader code
  91342. * It can be modified to trigger a new compilation
  91343. */
  91344. get shaderPath(): any;
  91345. /**
  91346. * Sets the shader path used to define the shader code
  91347. * It can be modified to trigger a new compilation
  91348. */
  91349. set shaderPath(shaderPath: any);
  91350. /**
  91351. * Gets the options used to compile the shader.
  91352. * They can be modified to trigger a new compilation
  91353. */
  91354. get options(): IShaderMaterialOptions;
  91355. /**
  91356. * Gets the current class name of the material e.g. "ShaderMaterial"
  91357. * Mainly use in serialization.
  91358. * @returns the class name
  91359. */
  91360. getClassName(): string;
  91361. /**
  91362. * Specifies if the material will require alpha blending
  91363. * @returns a boolean specifying if alpha blending is needed
  91364. */
  91365. needAlphaBlending(): boolean;
  91366. /**
  91367. * Specifies if this material should be rendered in alpha test mode
  91368. * @returns a boolean specifying if an alpha test is needed.
  91369. */
  91370. needAlphaTesting(): boolean;
  91371. private _checkUniform;
  91372. /**
  91373. * Set a texture in the shader.
  91374. * @param name Define the name of the uniform samplers as defined in the shader
  91375. * @param texture Define the texture to bind to this sampler
  91376. * @return the material itself allowing "fluent" like uniform updates
  91377. */
  91378. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  91379. /**
  91380. * Set a texture array in the shader.
  91381. * @param name Define the name of the uniform sampler array as defined in the shader
  91382. * @param textures Define the list of textures to bind to this sampler
  91383. * @return the material itself allowing "fluent" like uniform updates
  91384. */
  91385. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  91386. /**
  91387. * Set a float in the shader.
  91388. * @param name Define the name of the uniform as defined in the shader
  91389. * @param value Define the value to give to the uniform
  91390. * @return the material itself allowing "fluent" like uniform updates
  91391. */
  91392. setFloat(name: string, value: number): ShaderMaterial;
  91393. /**
  91394. * Set a int in the shader.
  91395. * @param name Define the name of the uniform as defined in the shader
  91396. * @param value Define the value to give to the uniform
  91397. * @return the material itself allowing "fluent" like uniform updates
  91398. */
  91399. setInt(name: string, value: number): ShaderMaterial;
  91400. /**
  91401. * Set an array of floats in the shader.
  91402. * @param name Define the name of the uniform as defined in the shader
  91403. * @param value Define the value to give to the uniform
  91404. * @return the material itself allowing "fluent" like uniform updates
  91405. */
  91406. setFloats(name: string, value: number[]): ShaderMaterial;
  91407. /**
  91408. * Set a vec3 in the shader from a Color3.
  91409. * @param name Define the name of the uniform as defined in the shader
  91410. * @param value Define the value to give to the uniform
  91411. * @return the material itself allowing "fluent" like uniform updates
  91412. */
  91413. setColor3(name: string, value: Color3): ShaderMaterial;
  91414. /**
  91415. * Set a vec3 array in the shader from a Color3 array.
  91416. * @param name Define the name of the uniform as defined in the shader
  91417. * @param value Define the value to give to the uniform
  91418. * @return the material itself allowing "fluent" like uniform updates
  91419. */
  91420. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  91421. /**
  91422. * Set a vec4 in the shader from a Color4.
  91423. * @param name Define the name of the uniform as defined in the shader
  91424. * @param value Define the value to give to the uniform
  91425. * @return the material itself allowing "fluent" like uniform updates
  91426. */
  91427. setColor4(name: string, value: Color4): ShaderMaterial;
  91428. /**
  91429. * Set a vec4 array in the shader from a Color4 array.
  91430. * @param name Define the name of the uniform as defined in the shader
  91431. * @param value Define the value to give to the uniform
  91432. * @return the material itself allowing "fluent" like uniform updates
  91433. */
  91434. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  91435. /**
  91436. * Set a vec2 in the shader from a Vector2.
  91437. * @param name Define the name of the uniform as defined in the shader
  91438. * @param value Define the value to give to the uniform
  91439. * @return the material itself allowing "fluent" like uniform updates
  91440. */
  91441. setVector2(name: string, value: Vector2): ShaderMaterial;
  91442. /**
  91443. * Set a vec3 in the shader from a Vector3.
  91444. * @param name Define the name of the uniform as defined in the shader
  91445. * @param value Define the value to give to the uniform
  91446. * @return the material itself allowing "fluent" like uniform updates
  91447. */
  91448. setVector3(name: string, value: Vector3): ShaderMaterial;
  91449. /**
  91450. * Set a vec4 in the shader from a Vector4.
  91451. * @param name Define the name of the uniform as defined in the shader
  91452. * @param value Define the value to give to the uniform
  91453. * @return the material itself allowing "fluent" like uniform updates
  91454. */
  91455. setVector4(name: string, value: Vector4): ShaderMaterial;
  91456. /**
  91457. * Set a mat4 in the shader from a Matrix.
  91458. * @param name Define the name of the uniform as defined in the shader
  91459. * @param value Define the value to give to the uniform
  91460. * @return the material itself allowing "fluent" like uniform updates
  91461. */
  91462. setMatrix(name: string, value: Matrix): ShaderMaterial;
  91463. /**
  91464. * Set a float32Array in the shader from a matrix array.
  91465. * @param name Define the name of the uniform as defined in the shader
  91466. * @param value Define the value to give to the uniform
  91467. * @return the material itself allowing "fluent" like uniform updates
  91468. */
  91469. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  91470. /**
  91471. * Set a mat3 in the shader from a Float32Array.
  91472. * @param name Define the name of the uniform as defined in the shader
  91473. * @param value Define the value to give to the uniform
  91474. * @return the material itself allowing "fluent" like uniform updates
  91475. */
  91476. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  91477. /**
  91478. * Set a mat2 in the shader from a Float32Array.
  91479. * @param name Define the name of the uniform as defined in the shader
  91480. * @param value Define the value to give to the uniform
  91481. * @return the material itself allowing "fluent" like uniform updates
  91482. */
  91483. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  91484. /**
  91485. * Set a vec2 array in the shader from a number array.
  91486. * @param name Define the name of the uniform as defined in the shader
  91487. * @param value Define the value to give to the uniform
  91488. * @return the material itself allowing "fluent" like uniform updates
  91489. */
  91490. setArray2(name: string, value: number[]): ShaderMaterial;
  91491. /**
  91492. * Set a vec3 array in the shader from a number array.
  91493. * @param name Define the name of the uniform as defined in the shader
  91494. * @param value Define the value to give to the uniform
  91495. * @return the material itself allowing "fluent" like uniform updates
  91496. */
  91497. setArray3(name: string, value: number[]): ShaderMaterial;
  91498. /**
  91499. * Set a vec4 array in the shader from a number array.
  91500. * @param name Define the name of the uniform as defined in the shader
  91501. * @param value Define the value to give to the uniform
  91502. * @return the material itself allowing "fluent" like uniform updates
  91503. */
  91504. setArray4(name: string, value: number[]): ShaderMaterial;
  91505. private _checkCache;
  91506. /**
  91507. * Specifies that the submesh is ready to be used
  91508. * @param mesh defines the mesh to check
  91509. * @param subMesh defines which submesh to check
  91510. * @param useInstances specifies that instances should be used
  91511. * @returns a boolean indicating that the submesh is ready or not
  91512. */
  91513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91514. /**
  91515. * Checks if the material is ready to render the requested mesh
  91516. * @param mesh Define the mesh to render
  91517. * @param useInstances Define whether or not the material is used with instances
  91518. * @returns true if ready, otherwise false
  91519. */
  91520. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91521. /**
  91522. * Binds the world matrix to the material
  91523. * @param world defines the world transformation matrix
  91524. * @param effectOverride - If provided, use this effect instead of internal effect
  91525. */
  91526. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  91527. /**
  91528. * Binds the submesh to this material by preparing the effect and shader to draw
  91529. * @param world defines the world transformation matrix
  91530. * @param mesh defines the mesh containing the submesh
  91531. * @param subMesh defines the submesh to bind the material to
  91532. */
  91533. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91534. /**
  91535. * Binds the material to the mesh
  91536. * @param world defines the world transformation matrix
  91537. * @param mesh defines the mesh to bind the material to
  91538. * @param effectOverride - If provided, use this effect instead of internal effect
  91539. */
  91540. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  91541. protected _afterBind(mesh?: Mesh): void;
  91542. /**
  91543. * Gets the active textures from the material
  91544. * @returns an array of textures
  91545. */
  91546. getActiveTextures(): BaseTexture[];
  91547. /**
  91548. * Specifies if the material uses a texture
  91549. * @param texture defines the texture to check against the material
  91550. * @returns a boolean specifying if the material uses the texture
  91551. */
  91552. hasTexture(texture: BaseTexture): boolean;
  91553. /**
  91554. * Makes a duplicate of the material, and gives it a new name
  91555. * @param name defines the new name for the duplicated material
  91556. * @returns the cloned material
  91557. */
  91558. clone(name: string): ShaderMaterial;
  91559. /**
  91560. * Disposes the material
  91561. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91562. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91563. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91564. */
  91565. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91566. /**
  91567. * Serializes this material in a JSON representation
  91568. * @returns the serialized material object
  91569. */
  91570. serialize(): any;
  91571. /**
  91572. * Creates a shader material from parsed shader material data
  91573. * @param source defines the JSON represnetation of the material
  91574. * @param scene defines the hosting scene
  91575. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91576. * @returns a new material
  91577. */
  91578. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91579. }
  91580. }
  91581. declare module BABYLON {
  91582. /** @hidden */
  91583. export var colorPixelShader: {
  91584. name: string;
  91585. shader: string;
  91586. };
  91587. }
  91588. declare module BABYLON {
  91589. /** @hidden */
  91590. export var colorVertexShader: {
  91591. name: string;
  91592. shader: string;
  91593. };
  91594. }
  91595. declare module BABYLON {
  91596. /**
  91597. * Line mesh
  91598. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91599. */
  91600. export class LinesMesh extends Mesh {
  91601. /**
  91602. * If vertex color should be applied to the mesh
  91603. */
  91604. readonly useVertexColor?: boolean | undefined;
  91605. /**
  91606. * If vertex alpha should be applied to the mesh
  91607. */
  91608. readonly useVertexAlpha?: boolean | undefined;
  91609. /**
  91610. * Color of the line (Default: White)
  91611. */
  91612. color: Color3;
  91613. /**
  91614. * Alpha of the line (Default: 1)
  91615. */
  91616. alpha: number;
  91617. /**
  91618. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91619. * This margin is expressed in world space coordinates, so its value may vary.
  91620. * Default value is 0.1
  91621. */
  91622. intersectionThreshold: number;
  91623. private _colorShader;
  91624. private color4;
  91625. /**
  91626. * Creates a new LinesMesh
  91627. * @param name defines the name
  91628. * @param scene defines the hosting scene
  91629. * @param parent defines the parent mesh if any
  91630. * @param source defines the optional source LinesMesh used to clone data from
  91631. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91632. * When false, achieved by calling a clone(), also passing False.
  91633. * This will make creation of children, recursive.
  91634. * @param useVertexColor defines if this LinesMesh supports vertex color
  91635. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91636. */
  91637. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91638. /**
  91639. * If vertex color should be applied to the mesh
  91640. */
  91641. useVertexColor?: boolean | undefined,
  91642. /**
  91643. * If vertex alpha should be applied to the mesh
  91644. */
  91645. useVertexAlpha?: boolean | undefined);
  91646. private _addClipPlaneDefine;
  91647. private _removeClipPlaneDefine;
  91648. isReady(): boolean;
  91649. /**
  91650. * Returns the string "LineMesh"
  91651. */
  91652. getClassName(): string;
  91653. /**
  91654. * @hidden
  91655. */
  91656. get material(): Material;
  91657. /**
  91658. * @hidden
  91659. */
  91660. set material(value: Material);
  91661. /**
  91662. * @hidden
  91663. */
  91664. get checkCollisions(): boolean;
  91665. /** @hidden */
  91666. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91667. /** @hidden */
  91668. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91669. /**
  91670. * Disposes of the line mesh
  91671. * @param doNotRecurse If children should be disposed
  91672. */
  91673. dispose(doNotRecurse?: boolean): void;
  91674. /**
  91675. * Returns a new LineMesh object cloned from the current one.
  91676. */
  91677. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  91678. /**
  91679. * Creates a new InstancedLinesMesh object from the mesh model.
  91680. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91681. * @param name defines the name of the new instance
  91682. * @returns a new InstancedLinesMesh
  91683. */
  91684. createInstance(name: string): InstancedLinesMesh;
  91685. }
  91686. /**
  91687. * Creates an instance based on a source LinesMesh
  91688. */
  91689. export class InstancedLinesMesh extends InstancedMesh {
  91690. /**
  91691. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91692. * This margin is expressed in world space coordinates, so its value may vary.
  91693. * Initilized with the intersectionThreshold value of the source LinesMesh
  91694. */
  91695. intersectionThreshold: number;
  91696. constructor(name: string, source: LinesMesh);
  91697. /**
  91698. * Returns the string "InstancedLinesMesh".
  91699. */
  91700. getClassName(): string;
  91701. }
  91702. }
  91703. declare module BABYLON {
  91704. /** @hidden */
  91705. export var linePixelShader: {
  91706. name: string;
  91707. shader: string;
  91708. };
  91709. }
  91710. declare module BABYLON {
  91711. /** @hidden */
  91712. export var lineVertexShader: {
  91713. name: string;
  91714. shader: string;
  91715. };
  91716. }
  91717. declare module BABYLON {
  91718. interface AbstractMesh {
  91719. /**
  91720. * Gets the edgesRenderer associated with the mesh
  91721. */
  91722. edgesRenderer: Nullable<EdgesRenderer>;
  91723. }
  91724. interface LinesMesh {
  91725. /**
  91726. * Enables the edge rendering mode on the mesh.
  91727. * This mode makes the mesh edges visible
  91728. * @param epsilon defines the maximal distance between two angles to detect a face
  91729. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91730. * @returns the currentAbstractMesh
  91731. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91732. */
  91733. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91734. }
  91735. interface InstancedLinesMesh {
  91736. /**
  91737. * Enables the edge rendering mode on the mesh.
  91738. * This mode makes the mesh edges visible
  91739. * @param epsilon defines the maximal distance between two angles to detect a face
  91740. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91741. * @returns the current InstancedLinesMesh
  91742. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91743. */
  91744. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  91745. }
  91746. /**
  91747. * Defines the minimum contract an Edges renderer should follow.
  91748. */
  91749. export interface IEdgesRenderer extends IDisposable {
  91750. /**
  91751. * Gets or sets a boolean indicating if the edgesRenderer is active
  91752. */
  91753. isEnabled: boolean;
  91754. /**
  91755. * Renders the edges of the attached mesh,
  91756. */
  91757. render(): void;
  91758. /**
  91759. * Checks wether or not the edges renderer is ready to render.
  91760. * @return true if ready, otherwise false.
  91761. */
  91762. isReady(): boolean;
  91763. }
  91764. /**
  91765. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  91766. */
  91767. export class EdgesRenderer implements IEdgesRenderer {
  91768. /**
  91769. * Define the size of the edges with an orthographic camera
  91770. */
  91771. edgesWidthScalerForOrthographic: number;
  91772. /**
  91773. * Define the size of the edges with a perspective camera
  91774. */
  91775. edgesWidthScalerForPerspective: number;
  91776. protected _source: AbstractMesh;
  91777. protected _linesPositions: number[];
  91778. protected _linesNormals: number[];
  91779. protected _linesIndices: number[];
  91780. protected _epsilon: number;
  91781. protected _indicesCount: number;
  91782. protected _lineShader: ShaderMaterial;
  91783. protected _ib: DataBuffer;
  91784. protected _buffers: {
  91785. [key: string]: Nullable<VertexBuffer>;
  91786. };
  91787. protected _checkVerticesInsteadOfIndices: boolean;
  91788. private _meshRebuildObserver;
  91789. private _meshDisposeObserver;
  91790. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  91791. isEnabled: boolean;
  91792. /**
  91793. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  91794. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  91795. * @param source Mesh used to create edges
  91796. * @param epsilon sum of angles in adjacency to check for edge
  91797. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  91798. * @param generateEdgesLines - should generate Lines or only prepare resources.
  91799. */
  91800. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  91801. protected _prepareRessources(): void;
  91802. /** @hidden */
  91803. _rebuild(): void;
  91804. /**
  91805. * Releases the required resources for the edges renderer
  91806. */
  91807. dispose(): void;
  91808. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  91809. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  91810. /**
  91811. * Checks if the pair of p0 and p1 is en edge
  91812. * @param faceIndex
  91813. * @param edge
  91814. * @param faceNormals
  91815. * @param p0
  91816. * @param p1
  91817. * @private
  91818. */
  91819. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  91820. /**
  91821. * push line into the position, normal and index buffer
  91822. * @protected
  91823. */
  91824. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  91825. /**
  91826. * Generates lines edges from adjacencjes
  91827. * @private
  91828. */
  91829. _generateEdgesLines(): void;
  91830. /**
  91831. * Checks wether or not the edges renderer is ready to render.
  91832. * @return true if ready, otherwise false.
  91833. */
  91834. isReady(): boolean;
  91835. /**
  91836. * Renders the edges of the attached mesh,
  91837. */
  91838. render(): void;
  91839. }
  91840. /**
  91841. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  91842. */
  91843. export class LineEdgesRenderer extends EdgesRenderer {
  91844. /**
  91845. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  91846. * @param source LineMesh used to generate edges
  91847. * @param epsilon not important (specified angle for edge detection)
  91848. * @param checkVerticesInsteadOfIndices not important for LineMesh
  91849. */
  91850. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  91851. /**
  91852. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  91853. */
  91854. _generateEdgesLines(): void;
  91855. }
  91856. }
  91857. declare module BABYLON {
  91858. /**
  91859. * This represents the object necessary to create a rendering group.
  91860. * This is exclusively used and created by the rendering manager.
  91861. * To modify the behavior, you use the available helpers in your scene or meshes.
  91862. * @hidden
  91863. */
  91864. export class RenderingGroup {
  91865. index: number;
  91866. private static _zeroVector;
  91867. private _scene;
  91868. private _opaqueSubMeshes;
  91869. private _transparentSubMeshes;
  91870. private _alphaTestSubMeshes;
  91871. private _depthOnlySubMeshes;
  91872. private _particleSystems;
  91873. private _spriteManagers;
  91874. private _opaqueSortCompareFn;
  91875. private _alphaTestSortCompareFn;
  91876. private _transparentSortCompareFn;
  91877. private _renderOpaque;
  91878. private _renderAlphaTest;
  91879. private _renderTransparent;
  91880. /** @hidden */
  91881. _edgesRenderers: SmartArray<IEdgesRenderer>;
  91882. onBeforeTransparentRendering: () => void;
  91883. /**
  91884. * Set the opaque sort comparison function.
  91885. * If null the sub meshes will be render in the order they were created
  91886. */
  91887. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91888. /**
  91889. * Set the alpha test sort comparison function.
  91890. * If null the sub meshes will be render in the order they were created
  91891. */
  91892. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91893. /**
  91894. * Set the transparent sort comparison function.
  91895. * If null the sub meshes will be render in the order they were created
  91896. */
  91897. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91898. /**
  91899. * Creates a new rendering group.
  91900. * @param index The rendering group index
  91901. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  91902. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  91903. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  91904. */
  91905. 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>);
  91906. /**
  91907. * Render all the sub meshes contained in the group.
  91908. * @param customRenderFunction Used to override the default render behaviour of the group.
  91909. * @returns true if rendered some submeshes.
  91910. */
  91911. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  91912. /**
  91913. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  91914. * @param subMeshes The submeshes to render
  91915. */
  91916. private renderOpaqueSorted;
  91917. /**
  91918. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  91919. * @param subMeshes The submeshes to render
  91920. */
  91921. private renderAlphaTestSorted;
  91922. /**
  91923. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  91924. * @param subMeshes The submeshes to render
  91925. */
  91926. private renderTransparentSorted;
  91927. /**
  91928. * Renders the submeshes in a specified order.
  91929. * @param subMeshes The submeshes to sort before render
  91930. * @param sortCompareFn The comparison function use to sort
  91931. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  91932. * @param transparent Specifies to activate blending if true
  91933. */
  91934. private static renderSorted;
  91935. /**
  91936. * Renders the submeshes in the order they were dispatched (no sort applied).
  91937. * @param subMeshes The submeshes to render
  91938. */
  91939. private static renderUnsorted;
  91940. /**
  91941. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91942. * are rendered back to front if in the same alpha index.
  91943. *
  91944. * @param a The first submesh
  91945. * @param b The second submesh
  91946. * @returns The result of the comparison
  91947. */
  91948. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  91949. /**
  91950. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91951. * are rendered back to front.
  91952. *
  91953. * @param a The first submesh
  91954. * @param b The second submesh
  91955. * @returns The result of the comparison
  91956. */
  91957. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  91958. /**
  91959. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91960. * are rendered front to back (prevent overdraw).
  91961. *
  91962. * @param a The first submesh
  91963. * @param b The second submesh
  91964. * @returns The result of the comparison
  91965. */
  91966. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  91967. /**
  91968. * Resets the different lists of submeshes to prepare a new frame.
  91969. */
  91970. prepare(): void;
  91971. dispose(): void;
  91972. /**
  91973. * Inserts the submesh in its correct queue depending on its material.
  91974. * @param subMesh The submesh to dispatch
  91975. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91976. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91977. */
  91978. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91979. dispatchSprites(spriteManager: ISpriteManager): void;
  91980. dispatchParticles(particleSystem: IParticleSystem): void;
  91981. private _renderParticles;
  91982. private _renderSprites;
  91983. }
  91984. }
  91985. declare module BABYLON {
  91986. /**
  91987. * Interface describing the different options available in the rendering manager
  91988. * regarding Auto Clear between groups.
  91989. */
  91990. export interface IRenderingManagerAutoClearSetup {
  91991. /**
  91992. * Defines whether or not autoclear is enable.
  91993. */
  91994. autoClear: boolean;
  91995. /**
  91996. * Defines whether or not to autoclear the depth buffer.
  91997. */
  91998. depth: boolean;
  91999. /**
  92000. * Defines whether or not to autoclear the stencil buffer.
  92001. */
  92002. stencil: boolean;
  92003. }
  92004. /**
  92005. * This class is used by the onRenderingGroupObservable
  92006. */
  92007. export class RenderingGroupInfo {
  92008. /**
  92009. * The Scene that being rendered
  92010. */
  92011. scene: Scene;
  92012. /**
  92013. * The camera currently used for the rendering pass
  92014. */
  92015. camera: Nullable<Camera>;
  92016. /**
  92017. * The ID of the renderingGroup being processed
  92018. */
  92019. renderingGroupId: number;
  92020. }
  92021. /**
  92022. * This is the manager responsible of all the rendering for meshes sprites and particles.
  92023. * It is enable to manage the different groups as well as the different necessary sort functions.
  92024. * This should not be used directly aside of the few static configurations
  92025. */
  92026. export class RenderingManager {
  92027. /**
  92028. * The max id used for rendering groups (not included)
  92029. */
  92030. static MAX_RENDERINGGROUPS: number;
  92031. /**
  92032. * The min id used for rendering groups (included)
  92033. */
  92034. static MIN_RENDERINGGROUPS: number;
  92035. /**
  92036. * Used to globally prevent autoclearing scenes.
  92037. */
  92038. static AUTOCLEAR: boolean;
  92039. /**
  92040. * @hidden
  92041. */
  92042. _useSceneAutoClearSetup: boolean;
  92043. private _scene;
  92044. private _renderingGroups;
  92045. private _depthStencilBufferAlreadyCleaned;
  92046. private _autoClearDepthStencil;
  92047. private _customOpaqueSortCompareFn;
  92048. private _customAlphaTestSortCompareFn;
  92049. private _customTransparentSortCompareFn;
  92050. private _renderingGroupInfo;
  92051. /**
  92052. * Instantiates a new rendering group for a particular scene
  92053. * @param scene Defines the scene the groups belongs to
  92054. */
  92055. constructor(scene: Scene);
  92056. private _clearDepthStencilBuffer;
  92057. /**
  92058. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  92059. * @hidden
  92060. */
  92061. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  92062. /**
  92063. * Resets the different information of the group to prepare a new frame
  92064. * @hidden
  92065. */
  92066. reset(): void;
  92067. /**
  92068. * Dispose and release the group and its associated resources.
  92069. * @hidden
  92070. */
  92071. dispose(): void;
  92072. /**
  92073. * Clear the info related to rendering groups preventing retention points during dispose.
  92074. */
  92075. freeRenderingGroups(): void;
  92076. private _prepareRenderingGroup;
  92077. /**
  92078. * Add a sprite manager to the rendering manager in order to render it this frame.
  92079. * @param spriteManager Define the sprite manager to render
  92080. */
  92081. dispatchSprites(spriteManager: ISpriteManager): void;
  92082. /**
  92083. * Add a particle system to the rendering manager in order to render it this frame.
  92084. * @param particleSystem Define the particle system to render
  92085. */
  92086. dispatchParticles(particleSystem: IParticleSystem): void;
  92087. /**
  92088. * Add a submesh to the manager in order to render it this frame
  92089. * @param subMesh The submesh to dispatch
  92090. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  92091. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  92092. */
  92093. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  92094. /**
  92095. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92096. * This allowed control for front to back rendering or reversly depending of the special needs.
  92097. *
  92098. * @param renderingGroupId The rendering group id corresponding to its index
  92099. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92100. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92101. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92102. */
  92103. 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;
  92104. /**
  92105. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92106. *
  92107. * @param renderingGroupId The rendering group id corresponding to its index
  92108. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92109. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92110. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92111. */
  92112. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92113. /**
  92114. * Gets the current auto clear configuration for one rendering group of the rendering
  92115. * manager.
  92116. * @param index the rendering group index to get the information for
  92117. * @returns The auto clear setup for the requested rendering group
  92118. */
  92119. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92120. }
  92121. }
  92122. declare module BABYLON {
  92123. /**
  92124. * Defines the options associated with the creation of a custom shader for a shadow generator.
  92125. */
  92126. export interface ICustomShaderOptions {
  92127. /**
  92128. * Gets or sets the custom shader name to use
  92129. */
  92130. shaderName: string;
  92131. /**
  92132. * The list of attribute names used in the shader
  92133. */
  92134. attributes?: string[];
  92135. /**
  92136. * The list of unifrom names used in the shader
  92137. */
  92138. uniforms?: string[];
  92139. /**
  92140. * The list of sampler names used in the shader
  92141. */
  92142. samplers?: string[];
  92143. /**
  92144. * The list of defines used in the shader
  92145. */
  92146. defines?: string[];
  92147. }
  92148. /**
  92149. * Interface to implement to create a shadow generator compatible with BJS.
  92150. */
  92151. export interface IShadowGenerator {
  92152. /**
  92153. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92154. * @returns The render target texture if present otherwise, null
  92155. */
  92156. getShadowMap(): Nullable<RenderTargetTexture>;
  92157. /**
  92158. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92159. * @param subMesh The submesh we want to render in the shadow map
  92160. * @param useInstances Defines wether will draw in the map using instances
  92161. * @returns true if ready otherwise, false
  92162. */
  92163. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  92164. /**
  92165. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92166. * @param defines Defines of the material we want to update
  92167. * @param lightIndex Index of the light in the enabled light list of the material
  92168. */
  92169. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  92170. /**
  92171. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92172. * defined in the generator but impacting the effect).
  92173. * It implies the unifroms available on the materials are the standard BJS ones.
  92174. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92175. * @param effect The effect we are binfing the information for
  92176. */
  92177. bindShadowLight(lightIndex: string, effect: Effect): void;
  92178. /**
  92179. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92180. * (eq to shadow prjection matrix * light transform matrix)
  92181. * @returns The transform matrix used to create the shadow map
  92182. */
  92183. getTransformMatrix(): Matrix;
  92184. /**
  92185. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92186. * Cube and 2D textures for instance.
  92187. */
  92188. recreateShadowMap(): void;
  92189. /**
  92190. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92191. * @param onCompiled Callback triggered at the and of the effects compilation
  92192. * @param options Sets of optional options forcing the compilation with different modes
  92193. */
  92194. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92195. useInstances: boolean;
  92196. }>): void;
  92197. /**
  92198. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92199. * @param options Sets of optional options forcing the compilation with different modes
  92200. * @returns A promise that resolves when the compilation completes
  92201. */
  92202. forceCompilationAsync(options?: Partial<{
  92203. useInstances: boolean;
  92204. }>): Promise<void>;
  92205. /**
  92206. * Serializes the shadow generator setup to a json object.
  92207. * @returns The serialized JSON object
  92208. */
  92209. serialize(): any;
  92210. /**
  92211. * Disposes the Shadow map and related Textures and effects.
  92212. */
  92213. dispose(): void;
  92214. }
  92215. /**
  92216. * Default implementation IShadowGenerator.
  92217. * This is the main object responsible of generating shadows in the framework.
  92218. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  92219. */
  92220. export class ShadowGenerator implements IShadowGenerator {
  92221. /**
  92222. * Name of the shadow generator class
  92223. */
  92224. static CLASSNAME: string;
  92225. /**
  92226. * Shadow generator mode None: no filtering applied.
  92227. */
  92228. static readonly FILTER_NONE: number;
  92229. /**
  92230. * Shadow generator mode ESM: Exponential Shadow Mapping.
  92231. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92232. */
  92233. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  92234. /**
  92235. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  92236. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  92237. */
  92238. static readonly FILTER_POISSONSAMPLING: number;
  92239. /**
  92240. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  92241. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92242. */
  92243. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  92244. /**
  92245. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  92246. * edge artifacts on steep falloff.
  92247. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92248. */
  92249. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  92250. /**
  92251. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  92252. * edge artifacts on steep falloff.
  92253. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  92254. */
  92255. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  92256. /**
  92257. * Shadow generator mode PCF: Percentage Closer Filtering
  92258. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92259. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  92260. */
  92261. static readonly FILTER_PCF: number;
  92262. /**
  92263. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  92264. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  92265. * Contact Hardening
  92266. */
  92267. static readonly FILTER_PCSS: number;
  92268. /**
  92269. * Reserved for PCF and PCSS
  92270. * Highest Quality.
  92271. *
  92272. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  92273. *
  92274. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  92275. */
  92276. static readonly QUALITY_HIGH: number;
  92277. /**
  92278. * Reserved for PCF and PCSS
  92279. * Good tradeoff for quality/perf cross devices
  92280. *
  92281. * Execute PCF on a 3*3 kernel.
  92282. *
  92283. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  92284. */
  92285. static readonly QUALITY_MEDIUM: number;
  92286. /**
  92287. * Reserved for PCF and PCSS
  92288. * The lowest quality but the fastest.
  92289. *
  92290. * Execute PCF on a 1*1 kernel.
  92291. *
  92292. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  92293. */
  92294. static readonly QUALITY_LOW: number;
  92295. /** Gets or sets the custom shader name to use */
  92296. customShaderOptions: ICustomShaderOptions;
  92297. /**
  92298. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  92299. */
  92300. onBeforeShadowMapRenderObservable: Observable<Effect>;
  92301. /**
  92302. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  92303. */
  92304. onAfterShadowMapRenderObservable: Observable<Effect>;
  92305. /**
  92306. * Observable triggered before a mesh is rendered in the shadow map.
  92307. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  92308. */
  92309. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  92310. /**
  92311. * Observable triggered after a mesh is rendered in the shadow map.
  92312. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  92313. */
  92314. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  92315. protected _bias: number;
  92316. /**
  92317. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  92318. */
  92319. get bias(): number;
  92320. /**
  92321. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  92322. */
  92323. set bias(bias: number);
  92324. protected _normalBias: number;
  92325. /**
  92326. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92327. */
  92328. get normalBias(): number;
  92329. /**
  92330. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  92331. */
  92332. set normalBias(normalBias: number);
  92333. protected _blurBoxOffset: number;
  92334. /**
  92335. * Gets the blur box offset: offset applied during the blur pass.
  92336. * Only useful if useKernelBlur = false
  92337. */
  92338. get blurBoxOffset(): number;
  92339. /**
  92340. * Sets the blur box offset: offset applied during the blur pass.
  92341. * Only useful if useKernelBlur = false
  92342. */
  92343. set blurBoxOffset(value: number);
  92344. protected _blurScale: number;
  92345. /**
  92346. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  92347. * 2 means half of the size.
  92348. */
  92349. get blurScale(): number;
  92350. /**
  92351. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  92352. * 2 means half of the size.
  92353. */
  92354. set blurScale(value: number);
  92355. protected _blurKernel: number;
  92356. /**
  92357. * Gets the blur kernel: kernel size of the blur pass.
  92358. * Only useful if useKernelBlur = true
  92359. */
  92360. get blurKernel(): number;
  92361. /**
  92362. * Sets the blur kernel: kernel size of the blur pass.
  92363. * Only useful if useKernelBlur = true
  92364. */
  92365. set blurKernel(value: number);
  92366. protected _useKernelBlur: boolean;
  92367. /**
  92368. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  92369. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92370. */
  92371. get useKernelBlur(): boolean;
  92372. /**
  92373. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  92374. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  92375. */
  92376. set useKernelBlur(value: boolean);
  92377. protected _depthScale: number;
  92378. /**
  92379. * Gets the depth scale used in ESM mode.
  92380. */
  92381. get depthScale(): number;
  92382. /**
  92383. * Sets the depth scale used in ESM mode.
  92384. * This can override the scale stored on the light.
  92385. */
  92386. set depthScale(value: number);
  92387. protected _validateFilter(filter: number): number;
  92388. protected _filter: number;
  92389. /**
  92390. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  92391. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92392. */
  92393. get filter(): number;
  92394. /**
  92395. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  92396. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  92397. */
  92398. set filter(value: number);
  92399. /**
  92400. * Gets if the current filter is set to Poisson Sampling.
  92401. */
  92402. get usePoissonSampling(): boolean;
  92403. /**
  92404. * Sets the current filter to Poisson Sampling.
  92405. */
  92406. set usePoissonSampling(value: boolean);
  92407. /**
  92408. * Gets if the current filter is set to ESM.
  92409. */
  92410. get useExponentialShadowMap(): boolean;
  92411. /**
  92412. * Sets the current filter is to ESM.
  92413. */
  92414. set useExponentialShadowMap(value: boolean);
  92415. /**
  92416. * Gets if the current filter is set to filtered ESM.
  92417. */
  92418. get useBlurExponentialShadowMap(): boolean;
  92419. /**
  92420. * Gets if the current filter is set to filtered ESM.
  92421. */
  92422. set useBlurExponentialShadowMap(value: boolean);
  92423. /**
  92424. * Gets if the current filter is set to "close ESM" (using the inverse of the
  92425. * exponential to prevent steep falloff artifacts).
  92426. */
  92427. get useCloseExponentialShadowMap(): boolean;
  92428. /**
  92429. * Sets the current filter to "close ESM" (using the inverse of the
  92430. * exponential to prevent steep falloff artifacts).
  92431. */
  92432. set useCloseExponentialShadowMap(value: boolean);
  92433. /**
  92434. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  92435. * exponential to prevent steep falloff artifacts).
  92436. */
  92437. get useBlurCloseExponentialShadowMap(): boolean;
  92438. /**
  92439. * Sets the current filter to filtered "close ESM" (using the inverse of the
  92440. * exponential to prevent steep falloff artifacts).
  92441. */
  92442. set useBlurCloseExponentialShadowMap(value: boolean);
  92443. /**
  92444. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  92445. */
  92446. get usePercentageCloserFiltering(): boolean;
  92447. /**
  92448. * Sets the current filter to "PCF" (percentage closer filtering).
  92449. */
  92450. set usePercentageCloserFiltering(value: boolean);
  92451. protected _filteringQuality: number;
  92452. /**
  92453. * Gets the PCF or PCSS Quality.
  92454. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92455. */
  92456. get filteringQuality(): number;
  92457. /**
  92458. * Sets the PCF or PCSS Quality.
  92459. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  92460. */
  92461. set filteringQuality(filteringQuality: number);
  92462. /**
  92463. * Gets if the current filter is set to "PCSS" (contact hardening).
  92464. */
  92465. get useContactHardeningShadow(): boolean;
  92466. /**
  92467. * Sets the current filter to "PCSS" (contact hardening).
  92468. */
  92469. set useContactHardeningShadow(value: boolean);
  92470. protected _contactHardeningLightSizeUVRatio: number;
  92471. /**
  92472. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92473. * Using a ratio helps keeping shape stability independently of the map size.
  92474. *
  92475. * It does not account for the light projection as it was having too much
  92476. * instability during the light setup or during light position changes.
  92477. *
  92478. * Only valid if useContactHardeningShadow is true.
  92479. */
  92480. get contactHardeningLightSizeUVRatio(): number;
  92481. /**
  92482. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  92483. * Using a ratio helps keeping shape stability independently of the map size.
  92484. *
  92485. * It does not account for the light projection as it was having too much
  92486. * instability during the light setup or during light position changes.
  92487. *
  92488. * Only valid if useContactHardeningShadow is true.
  92489. */
  92490. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  92491. protected _darkness: number;
  92492. /** Gets or sets the actual darkness of a shadow */
  92493. get darkness(): number;
  92494. set darkness(value: number);
  92495. /**
  92496. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  92497. * 0 means strongest and 1 would means no shadow.
  92498. * @returns the darkness.
  92499. */
  92500. getDarkness(): number;
  92501. /**
  92502. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  92503. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  92504. * @returns the shadow generator allowing fluent coding.
  92505. */
  92506. setDarkness(darkness: number): ShadowGenerator;
  92507. protected _transparencyShadow: boolean;
  92508. /** Gets or sets the ability to have transparent shadow */
  92509. get transparencyShadow(): boolean;
  92510. set transparencyShadow(value: boolean);
  92511. /**
  92512. * Sets the ability to have transparent shadow (boolean).
  92513. * @param transparent True if transparent else False
  92514. * @returns the shadow generator allowing fluent coding
  92515. */
  92516. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  92517. protected _shadowMap: Nullable<RenderTargetTexture>;
  92518. protected _shadowMap2: Nullable<RenderTargetTexture>;
  92519. /**
  92520. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  92521. * @returns The render target texture if present otherwise, null
  92522. */
  92523. getShadowMap(): Nullable<RenderTargetTexture>;
  92524. /**
  92525. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  92526. * @returns The render target texture if the shadow map is present otherwise, null
  92527. */
  92528. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  92529. /**
  92530. * Gets the class name of that object
  92531. * @returns "ShadowGenerator"
  92532. */
  92533. getClassName(): string;
  92534. /**
  92535. * Helper function to add a mesh and its descendants to the list of shadow casters.
  92536. * @param mesh Mesh to add
  92537. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  92538. * @returns the Shadow Generator itself
  92539. */
  92540. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92541. /**
  92542. * Helper function to remove a mesh and its descendants from the list of shadow casters
  92543. * @param mesh Mesh to remove
  92544. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  92545. * @returns the Shadow Generator itself
  92546. */
  92547. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  92548. /**
  92549. * Controls the extent to which the shadows fade out at the edge of the frustum
  92550. */
  92551. frustumEdgeFalloff: number;
  92552. protected _light: IShadowLight;
  92553. /**
  92554. * Returns the associated light object.
  92555. * @returns the light generating the shadow
  92556. */
  92557. getLight(): IShadowLight;
  92558. /**
  92559. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  92560. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  92561. * It might on the other hand introduce peter panning.
  92562. */
  92563. forceBackFacesOnly: boolean;
  92564. protected _scene: Scene;
  92565. protected _lightDirection: Vector3;
  92566. protected _effect: Effect;
  92567. protected _viewMatrix: Matrix;
  92568. protected _projectionMatrix: Matrix;
  92569. protected _transformMatrix: Matrix;
  92570. protected _cachedPosition: Vector3;
  92571. protected _cachedDirection: Vector3;
  92572. protected _cachedDefines: string;
  92573. protected _currentRenderID: number;
  92574. protected _boxBlurPostprocess: Nullable<PostProcess>;
  92575. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  92576. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  92577. protected _blurPostProcesses: PostProcess[];
  92578. protected _mapSize: number;
  92579. protected _currentFaceIndex: number;
  92580. protected _currentFaceIndexCache: number;
  92581. protected _textureType: number;
  92582. protected _defaultTextureMatrix: Matrix;
  92583. protected _storedUniqueId: Nullable<number>;
  92584. /** @hidden */
  92585. static _SceneComponentInitialization: (scene: Scene) => void;
  92586. /**
  92587. * Creates a ShadowGenerator object.
  92588. * A ShadowGenerator is the required tool to use the shadows.
  92589. * Each light casting shadows needs to use its own ShadowGenerator.
  92590. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  92591. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  92592. * @param light The light object generating the shadows.
  92593. * @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.
  92594. */
  92595. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  92596. protected _initializeGenerator(): void;
  92597. protected _createTargetRenderTexture(): void;
  92598. protected _initializeShadowMap(): void;
  92599. protected _initializeBlurRTTAndPostProcesses(): void;
  92600. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  92601. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  92602. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  92603. protected _applyFilterValues(): void;
  92604. /**
  92605. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92606. * @param onCompiled Callback triggered at the and of the effects compilation
  92607. * @param options Sets of optional options forcing the compilation with different modes
  92608. */
  92609. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  92610. useInstances: boolean;
  92611. }>): void;
  92612. /**
  92613. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  92614. * @param options Sets of optional options forcing the compilation with different modes
  92615. * @returns A promise that resolves when the compilation completes
  92616. */
  92617. forceCompilationAsync(options?: Partial<{
  92618. useInstances: boolean;
  92619. }>): Promise<void>;
  92620. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  92621. private _prepareShadowDefines;
  92622. /**
  92623. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  92624. * @param subMesh The submesh we want to render in the shadow map
  92625. * @param useInstances Defines wether will draw in the map using instances
  92626. * @returns true if ready otherwise, false
  92627. */
  92628. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  92629. /**
  92630. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  92631. * @param defines Defines of the material we want to update
  92632. * @param lightIndex Index of the light in the enabled light list of the material
  92633. */
  92634. prepareDefines(defines: any, lightIndex: number): void;
  92635. /**
  92636. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  92637. * defined in the generator but impacting the effect).
  92638. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  92639. * @param effect The effect we are binfing the information for
  92640. */
  92641. bindShadowLight(lightIndex: string, effect: Effect): void;
  92642. /**
  92643. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  92644. * (eq to shadow prjection matrix * light transform matrix)
  92645. * @returns The transform matrix used to create the shadow map
  92646. */
  92647. getTransformMatrix(): Matrix;
  92648. /**
  92649. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  92650. * Cube and 2D textures for instance.
  92651. */
  92652. recreateShadowMap(): void;
  92653. protected _disposeBlurPostProcesses(): void;
  92654. protected _disposeRTTandPostProcesses(): void;
  92655. /**
  92656. * Disposes the ShadowGenerator.
  92657. * Returns nothing.
  92658. */
  92659. dispose(): void;
  92660. /**
  92661. * Serializes the shadow generator setup to a json object.
  92662. * @returns The serialized JSON object
  92663. */
  92664. serialize(): any;
  92665. /**
  92666. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  92667. * @param parsedShadowGenerator The JSON object to parse
  92668. * @param scene The scene to create the shadow map for
  92669. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  92670. * @returns The parsed shadow generator
  92671. */
  92672. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  92673. }
  92674. }
  92675. declare module BABYLON {
  92676. /**
  92677. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  92678. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  92679. * 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.
  92680. */
  92681. export abstract class Light extends Node {
  92682. /**
  92683. * Falloff Default: light is falling off following the material specification:
  92684. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  92685. */
  92686. static readonly FALLOFF_DEFAULT: number;
  92687. /**
  92688. * Falloff Physical: light is falling off following the inverse squared distance law.
  92689. */
  92690. static readonly FALLOFF_PHYSICAL: number;
  92691. /**
  92692. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  92693. * to enhance interoperability with other engines.
  92694. */
  92695. static readonly FALLOFF_GLTF: number;
  92696. /**
  92697. * Falloff Standard: light is falling off like in the standard material
  92698. * to enhance interoperability with other materials.
  92699. */
  92700. static readonly FALLOFF_STANDARD: number;
  92701. /**
  92702. * If every light affecting the material is in this lightmapMode,
  92703. * material.lightmapTexture adds or multiplies
  92704. * (depends on material.useLightmapAsShadowmap)
  92705. * after every other light calculations.
  92706. */
  92707. static readonly LIGHTMAP_DEFAULT: number;
  92708. /**
  92709. * material.lightmapTexture as only diffuse lighting from this light
  92710. * adds only specular lighting from this light
  92711. * adds dynamic shadows
  92712. */
  92713. static readonly LIGHTMAP_SPECULAR: number;
  92714. /**
  92715. * material.lightmapTexture as only lighting
  92716. * no light calculation from this light
  92717. * only adds dynamic shadows from this light
  92718. */
  92719. static readonly LIGHTMAP_SHADOWSONLY: number;
  92720. /**
  92721. * Each light type uses the default quantity according to its type:
  92722. * point/spot lights use luminous intensity
  92723. * directional lights use illuminance
  92724. */
  92725. static readonly INTENSITYMODE_AUTOMATIC: number;
  92726. /**
  92727. * lumen (lm)
  92728. */
  92729. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  92730. /**
  92731. * candela (lm/sr)
  92732. */
  92733. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  92734. /**
  92735. * lux (lm/m^2)
  92736. */
  92737. static readonly INTENSITYMODE_ILLUMINANCE: number;
  92738. /**
  92739. * nit (cd/m^2)
  92740. */
  92741. static readonly INTENSITYMODE_LUMINANCE: number;
  92742. /**
  92743. * Light type const id of the point light.
  92744. */
  92745. static readonly LIGHTTYPEID_POINTLIGHT: number;
  92746. /**
  92747. * Light type const id of the directional light.
  92748. */
  92749. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  92750. /**
  92751. * Light type const id of the spot light.
  92752. */
  92753. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  92754. /**
  92755. * Light type const id of the hemispheric light.
  92756. */
  92757. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  92758. /**
  92759. * Diffuse gives the basic color to an object.
  92760. */
  92761. diffuse: Color3;
  92762. /**
  92763. * Specular produces a highlight color on an object.
  92764. * Note: This is note affecting PBR materials.
  92765. */
  92766. specular: Color3;
  92767. /**
  92768. * Defines the falloff type for this light. This lets overrriding how punctual light are
  92769. * falling off base on range or angle.
  92770. * This can be set to any values in Light.FALLOFF_x.
  92771. *
  92772. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  92773. * other types of materials.
  92774. */
  92775. falloffType: number;
  92776. /**
  92777. * Strength of the light.
  92778. * Note: By default it is define in the framework own unit.
  92779. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  92780. */
  92781. intensity: number;
  92782. private _range;
  92783. protected _inverseSquaredRange: number;
  92784. /**
  92785. * Defines how far from the source the light is impacting in scene units.
  92786. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92787. */
  92788. get range(): number;
  92789. /**
  92790. * Defines how far from the source the light is impacting in scene units.
  92791. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  92792. */
  92793. set range(value: number);
  92794. /**
  92795. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  92796. * of light.
  92797. */
  92798. private _photometricScale;
  92799. private _intensityMode;
  92800. /**
  92801. * Gets the photometric scale used to interpret the intensity.
  92802. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  92803. */
  92804. get intensityMode(): number;
  92805. /**
  92806. * Sets the photometric scale used to interpret the intensity.
  92807. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  92808. */
  92809. set intensityMode(value: number);
  92810. private _radius;
  92811. /**
  92812. * Gets the light radius used by PBR Materials to simulate soft area lights.
  92813. */
  92814. get radius(): number;
  92815. /**
  92816. * sets the light radius used by PBR Materials to simulate soft area lights.
  92817. */
  92818. set radius(value: number);
  92819. private _renderPriority;
  92820. /**
  92821. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  92822. * exceeding the number allowed of the materials.
  92823. */
  92824. renderPriority: number;
  92825. private _shadowEnabled;
  92826. /**
  92827. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  92828. * the current shadow generator.
  92829. */
  92830. get shadowEnabled(): boolean;
  92831. /**
  92832. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  92833. * the current shadow generator.
  92834. */
  92835. set shadowEnabled(value: boolean);
  92836. private _includedOnlyMeshes;
  92837. /**
  92838. * Gets the only meshes impacted by this light.
  92839. */
  92840. get includedOnlyMeshes(): AbstractMesh[];
  92841. /**
  92842. * Sets the only meshes impacted by this light.
  92843. */
  92844. set includedOnlyMeshes(value: AbstractMesh[]);
  92845. private _excludedMeshes;
  92846. /**
  92847. * Gets the meshes not impacted by this light.
  92848. */
  92849. get excludedMeshes(): AbstractMesh[];
  92850. /**
  92851. * Sets the meshes not impacted by this light.
  92852. */
  92853. set excludedMeshes(value: AbstractMesh[]);
  92854. private _excludeWithLayerMask;
  92855. /**
  92856. * Gets the layer id use to find what meshes are not impacted by the light.
  92857. * Inactive if 0
  92858. */
  92859. get excludeWithLayerMask(): number;
  92860. /**
  92861. * Sets the layer id use to find what meshes are not impacted by the light.
  92862. * Inactive if 0
  92863. */
  92864. set excludeWithLayerMask(value: number);
  92865. private _includeOnlyWithLayerMask;
  92866. /**
  92867. * Gets the layer id use to find what meshes are impacted by the light.
  92868. * Inactive if 0
  92869. */
  92870. get includeOnlyWithLayerMask(): number;
  92871. /**
  92872. * Sets the layer id use to find what meshes are impacted by the light.
  92873. * Inactive if 0
  92874. */
  92875. set includeOnlyWithLayerMask(value: number);
  92876. private _lightmapMode;
  92877. /**
  92878. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  92879. */
  92880. get lightmapMode(): number;
  92881. /**
  92882. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  92883. */
  92884. set lightmapMode(value: number);
  92885. /**
  92886. * Shadow generator associted to the light.
  92887. * @hidden Internal use only.
  92888. */
  92889. _shadowGenerator: Nullable<IShadowGenerator>;
  92890. /**
  92891. * @hidden Internal use only.
  92892. */
  92893. _excludedMeshesIds: string[];
  92894. /**
  92895. * @hidden Internal use only.
  92896. */
  92897. _includedOnlyMeshesIds: string[];
  92898. /**
  92899. * The current light unifom buffer.
  92900. * @hidden Internal use only.
  92901. */
  92902. _uniformBuffer: UniformBuffer;
  92903. /** @hidden */
  92904. _renderId: number;
  92905. /**
  92906. * Creates a Light object in the scene.
  92907. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92908. * @param name The firendly name of the light
  92909. * @param scene The scene the light belongs too
  92910. */
  92911. constructor(name: string, scene: Scene);
  92912. protected abstract _buildUniformLayout(): void;
  92913. /**
  92914. * Sets the passed Effect "effect" with the Light information.
  92915. * @param effect The effect to update
  92916. * @param lightIndex The index of the light in the effect to update
  92917. * @returns The light
  92918. */
  92919. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  92920. /**
  92921. * Sets the passed Effect "effect" with the Light textures.
  92922. * @param effect The effect to update
  92923. * @param lightIndex The index of the light in the effect to update
  92924. * @returns The light
  92925. */
  92926. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  92927. /**
  92928. * Binds the lights information from the scene to the effect for the given mesh.
  92929. * @param lightIndex Light index
  92930. * @param scene The scene where the light belongs to
  92931. * @param effect The effect we are binding the data to
  92932. * @param useSpecular Defines if specular is supported
  92933. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  92934. */
  92935. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  92936. /**
  92937. * Sets the passed Effect "effect" with the Light information.
  92938. * @param effect The effect to update
  92939. * @param lightDataUniformName The uniform used to store light data (position or direction)
  92940. * @returns The light
  92941. */
  92942. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  92943. /**
  92944. * Returns the string "Light".
  92945. * @returns the class name
  92946. */
  92947. getClassName(): string;
  92948. /** @hidden */
  92949. readonly _isLight: boolean;
  92950. /**
  92951. * Converts the light information to a readable string for debug purpose.
  92952. * @param fullDetails Supports for multiple levels of logging within scene loading
  92953. * @returns the human readable light info
  92954. */
  92955. toString(fullDetails?: boolean): string;
  92956. /** @hidden */
  92957. protected _syncParentEnabledState(): void;
  92958. /**
  92959. * Set the enabled state of this node.
  92960. * @param value - the new enabled state
  92961. */
  92962. setEnabled(value: boolean): void;
  92963. /**
  92964. * Returns the Light associated shadow generator if any.
  92965. * @return the associated shadow generator.
  92966. */
  92967. getShadowGenerator(): Nullable<IShadowGenerator>;
  92968. /**
  92969. * Returns a Vector3, the absolute light position in the World.
  92970. * @returns the world space position of the light
  92971. */
  92972. getAbsolutePosition(): Vector3;
  92973. /**
  92974. * Specifies if the light will affect the passed mesh.
  92975. * @param mesh The mesh to test against the light
  92976. * @return true the mesh is affected otherwise, false.
  92977. */
  92978. canAffectMesh(mesh: AbstractMesh): boolean;
  92979. /**
  92980. * Sort function to order lights for rendering.
  92981. * @param a First Light object to compare to second.
  92982. * @param b Second Light object to compare first.
  92983. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  92984. */
  92985. static CompareLightsPriority(a: Light, b: Light): number;
  92986. /**
  92987. * Releases resources associated with this node.
  92988. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92989. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92990. */
  92991. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92992. /**
  92993. * Returns the light type ID (integer).
  92994. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92995. */
  92996. getTypeID(): number;
  92997. /**
  92998. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  92999. * @returns the scaled intensity in intensity mode unit
  93000. */
  93001. getScaledIntensity(): number;
  93002. /**
  93003. * Returns a new Light object, named "name", from the current one.
  93004. * @param name The name of the cloned light
  93005. * @returns the new created light
  93006. */
  93007. clone(name: string): Nullable<Light>;
  93008. /**
  93009. * Serializes the current light into a Serialization object.
  93010. * @returns the serialized object.
  93011. */
  93012. serialize(): any;
  93013. /**
  93014. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  93015. * This new light is named "name" and added to the passed scene.
  93016. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  93017. * @param name The friendly name of the light
  93018. * @param scene The scene the new light will belong to
  93019. * @returns the constructor function
  93020. */
  93021. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  93022. /**
  93023. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  93024. * @param parsedLight The JSON representation of the light
  93025. * @param scene The scene to create the parsed light in
  93026. * @returns the created light after parsing
  93027. */
  93028. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  93029. private _hookArrayForExcluded;
  93030. private _hookArrayForIncludedOnly;
  93031. private _resyncMeshes;
  93032. /**
  93033. * Forces the meshes to update their light related information in their rendering used effects
  93034. * @hidden Internal Use Only
  93035. */
  93036. _markMeshesAsLightDirty(): void;
  93037. /**
  93038. * Recomputes the cached photometric scale if needed.
  93039. */
  93040. private _computePhotometricScale;
  93041. /**
  93042. * Returns the Photometric Scale according to the light type and intensity mode.
  93043. */
  93044. private _getPhotometricScale;
  93045. /**
  93046. * Reorder the light in the scene according to their defined priority.
  93047. * @hidden Internal Use Only
  93048. */
  93049. _reorderLightsInScene(): void;
  93050. /**
  93051. * Prepares the list of defines specific to the light type.
  93052. * @param defines the list of defines
  93053. * @param lightIndex defines the index of the light for the effect
  93054. */
  93055. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93056. }
  93057. }
  93058. declare module BABYLON {
  93059. /**
  93060. * Interface used to define Action
  93061. */
  93062. export interface IAction {
  93063. /**
  93064. * Trigger for the action
  93065. */
  93066. trigger: number;
  93067. /** Options of the trigger */
  93068. triggerOptions: any;
  93069. /**
  93070. * Gets the trigger parameters
  93071. * @returns the trigger parameters
  93072. */
  93073. getTriggerParameter(): any;
  93074. /**
  93075. * Internal only - executes current action event
  93076. * @hidden
  93077. */
  93078. _executeCurrent(evt?: ActionEvent): void;
  93079. /**
  93080. * Serialize placeholder for child classes
  93081. * @param parent of child
  93082. * @returns the serialized object
  93083. */
  93084. serialize(parent: any): any;
  93085. /**
  93086. * Internal only
  93087. * @hidden
  93088. */
  93089. _prepare(): void;
  93090. /**
  93091. * Internal only - manager for action
  93092. * @hidden
  93093. */
  93094. _actionManager: AbstractActionManager;
  93095. /**
  93096. * Adds action to chain of actions, may be a DoNothingAction
  93097. * @param action defines the next action to execute
  93098. * @returns The action passed in
  93099. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93100. */
  93101. then(action: IAction): IAction;
  93102. }
  93103. /**
  93104. * The action to be carried out following a trigger
  93105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  93106. */
  93107. export class Action implements IAction {
  93108. /** the trigger, with or without parameters, for the action */
  93109. triggerOptions: any;
  93110. /**
  93111. * Trigger for the action
  93112. */
  93113. trigger: number;
  93114. /**
  93115. * Internal only - manager for action
  93116. * @hidden
  93117. */
  93118. _actionManager: ActionManager;
  93119. private _nextActiveAction;
  93120. private _child;
  93121. private _condition?;
  93122. private _triggerParameter;
  93123. /**
  93124. * An event triggered prior to action being executed.
  93125. */
  93126. onBeforeExecuteObservable: Observable<Action>;
  93127. /**
  93128. * Creates a new Action
  93129. * @param triggerOptions the trigger, with or without parameters, for the action
  93130. * @param condition an optional determinant of action
  93131. */
  93132. constructor(
  93133. /** the trigger, with or without parameters, for the action */
  93134. triggerOptions: any, condition?: Condition);
  93135. /**
  93136. * Internal only
  93137. * @hidden
  93138. */
  93139. _prepare(): void;
  93140. /**
  93141. * Gets the trigger parameters
  93142. * @returns the trigger parameters
  93143. */
  93144. getTriggerParameter(): any;
  93145. /**
  93146. * Internal only - executes current action event
  93147. * @hidden
  93148. */
  93149. _executeCurrent(evt?: ActionEvent): void;
  93150. /**
  93151. * Execute placeholder for child classes
  93152. * @param evt optional action event
  93153. */
  93154. execute(evt?: ActionEvent): void;
  93155. /**
  93156. * Skips to next active action
  93157. */
  93158. skipToNextActiveAction(): void;
  93159. /**
  93160. * Adds action to chain of actions, may be a DoNothingAction
  93161. * @param action defines the next action to execute
  93162. * @returns The action passed in
  93163. * @see https://www.babylonjs-playground.com/#1T30HR#0
  93164. */
  93165. then(action: Action): Action;
  93166. /**
  93167. * Internal only
  93168. * @hidden
  93169. */
  93170. _getProperty(propertyPath: string): string;
  93171. /**
  93172. * Internal only
  93173. * @hidden
  93174. */
  93175. _getEffectiveTarget(target: any, propertyPath: string): any;
  93176. /**
  93177. * Serialize placeholder for child classes
  93178. * @param parent of child
  93179. * @returns the serialized object
  93180. */
  93181. serialize(parent: any): any;
  93182. /**
  93183. * Internal only called by serialize
  93184. * @hidden
  93185. */
  93186. protected _serialize(serializedAction: any, parent?: any): any;
  93187. /**
  93188. * Internal only
  93189. * @hidden
  93190. */
  93191. static _SerializeValueAsString: (value: any) => string;
  93192. /**
  93193. * Internal only
  93194. * @hidden
  93195. */
  93196. static _GetTargetProperty: (target: Node | Scene) => {
  93197. name: string;
  93198. targetType: string;
  93199. value: string;
  93200. };
  93201. }
  93202. }
  93203. declare module BABYLON {
  93204. /**
  93205. * A Condition applied to an Action
  93206. */
  93207. export class Condition {
  93208. /**
  93209. * Internal only - manager for action
  93210. * @hidden
  93211. */
  93212. _actionManager: ActionManager;
  93213. /**
  93214. * Internal only
  93215. * @hidden
  93216. */
  93217. _evaluationId: number;
  93218. /**
  93219. * Internal only
  93220. * @hidden
  93221. */
  93222. _currentResult: boolean;
  93223. /**
  93224. * Creates a new Condition
  93225. * @param actionManager the manager of the action the condition is applied to
  93226. */
  93227. constructor(actionManager: ActionManager);
  93228. /**
  93229. * Check if the current condition is valid
  93230. * @returns a boolean
  93231. */
  93232. isValid(): boolean;
  93233. /**
  93234. * Internal only
  93235. * @hidden
  93236. */
  93237. _getProperty(propertyPath: string): string;
  93238. /**
  93239. * Internal only
  93240. * @hidden
  93241. */
  93242. _getEffectiveTarget(target: any, propertyPath: string): any;
  93243. /**
  93244. * Serialize placeholder for child classes
  93245. * @returns the serialized object
  93246. */
  93247. serialize(): any;
  93248. /**
  93249. * Internal only
  93250. * @hidden
  93251. */
  93252. protected _serialize(serializedCondition: any): any;
  93253. }
  93254. /**
  93255. * Defines specific conditional operators as extensions of Condition
  93256. */
  93257. export class ValueCondition extends Condition {
  93258. /** path to specify the property of the target the conditional operator uses */
  93259. propertyPath: string;
  93260. /** the value compared by the conditional operator against the current value of the property */
  93261. value: any;
  93262. /** the conditional operator, default ValueCondition.IsEqual */
  93263. operator: number;
  93264. /**
  93265. * Internal only
  93266. * @hidden
  93267. */
  93268. private static _IsEqual;
  93269. /**
  93270. * Internal only
  93271. * @hidden
  93272. */
  93273. private static _IsDifferent;
  93274. /**
  93275. * Internal only
  93276. * @hidden
  93277. */
  93278. private static _IsGreater;
  93279. /**
  93280. * Internal only
  93281. * @hidden
  93282. */
  93283. private static _IsLesser;
  93284. /**
  93285. * returns the number for IsEqual
  93286. */
  93287. static get IsEqual(): number;
  93288. /**
  93289. * Returns the number for IsDifferent
  93290. */
  93291. static get IsDifferent(): number;
  93292. /**
  93293. * Returns the number for IsGreater
  93294. */
  93295. static get IsGreater(): number;
  93296. /**
  93297. * Returns the number for IsLesser
  93298. */
  93299. static get IsLesser(): number;
  93300. /**
  93301. * Internal only The action manager for the condition
  93302. * @hidden
  93303. */
  93304. _actionManager: ActionManager;
  93305. /**
  93306. * Internal only
  93307. * @hidden
  93308. */
  93309. private _target;
  93310. /**
  93311. * Internal only
  93312. * @hidden
  93313. */
  93314. private _effectiveTarget;
  93315. /**
  93316. * Internal only
  93317. * @hidden
  93318. */
  93319. private _property;
  93320. /**
  93321. * Creates a new ValueCondition
  93322. * @param actionManager manager for the action the condition applies to
  93323. * @param target for the action
  93324. * @param propertyPath path to specify the property of the target the conditional operator uses
  93325. * @param value the value compared by the conditional operator against the current value of the property
  93326. * @param operator the conditional operator, default ValueCondition.IsEqual
  93327. */
  93328. constructor(actionManager: ActionManager, target: any,
  93329. /** path to specify the property of the target the conditional operator uses */
  93330. propertyPath: string,
  93331. /** the value compared by the conditional operator against the current value of the property */
  93332. value: any,
  93333. /** the conditional operator, default ValueCondition.IsEqual */
  93334. operator?: number);
  93335. /**
  93336. * Compares the given value with the property value for the specified conditional operator
  93337. * @returns the result of the comparison
  93338. */
  93339. isValid(): boolean;
  93340. /**
  93341. * Serialize the ValueCondition into a JSON compatible object
  93342. * @returns serialization object
  93343. */
  93344. serialize(): any;
  93345. /**
  93346. * Gets the name of the conditional operator for the ValueCondition
  93347. * @param operator the conditional operator
  93348. * @returns the name
  93349. */
  93350. static GetOperatorName(operator: number): string;
  93351. }
  93352. /**
  93353. * Defines a predicate condition as an extension of Condition
  93354. */
  93355. export class PredicateCondition extends Condition {
  93356. /** defines the predicate function used to validate the condition */
  93357. predicate: () => boolean;
  93358. /**
  93359. * Internal only - manager for action
  93360. * @hidden
  93361. */
  93362. _actionManager: ActionManager;
  93363. /**
  93364. * Creates a new PredicateCondition
  93365. * @param actionManager manager for the action the condition applies to
  93366. * @param predicate defines the predicate function used to validate the condition
  93367. */
  93368. constructor(actionManager: ActionManager,
  93369. /** defines the predicate function used to validate the condition */
  93370. predicate: () => boolean);
  93371. /**
  93372. * @returns the validity of the predicate condition
  93373. */
  93374. isValid(): boolean;
  93375. }
  93376. /**
  93377. * Defines a state condition as an extension of Condition
  93378. */
  93379. export class StateCondition extends Condition {
  93380. /** Value to compare with target state */
  93381. value: string;
  93382. /**
  93383. * Internal only - manager for action
  93384. * @hidden
  93385. */
  93386. _actionManager: ActionManager;
  93387. /**
  93388. * Internal only
  93389. * @hidden
  93390. */
  93391. private _target;
  93392. /**
  93393. * Creates a new StateCondition
  93394. * @param actionManager manager for the action the condition applies to
  93395. * @param target of the condition
  93396. * @param value to compare with target state
  93397. */
  93398. constructor(actionManager: ActionManager, target: any,
  93399. /** Value to compare with target state */
  93400. value: string);
  93401. /**
  93402. * Gets a boolean indicating if the current condition is met
  93403. * @returns the validity of the state
  93404. */
  93405. isValid(): boolean;
  93406. /**
  93407. * Serialize the StateCondition into a JSON compatible object
  93408. * @returns serialization object
  93409. */
  93410. serialize(): any;
  93411. }
  93412. }
  93413. declare module BABYLON {
  93414. /**
  93415. * This defines an action responsible to toggle a boolean once triggered.
  93416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93417. */
  93418. export class SwitchBooleanAction extends Action {
  93419. /**
  93420. * The path to the boolean property in the target object
  93421. */
  93422. propertyPath: string;
  93423. private _target;
  93424. private _effectiveTarget;
  93425. private _property;
  93426. /**
  93427. * Instantiate the action
  93428. * @param triggerOptions defines the trigger options
  93429. * @param target defines the object containing the boolean
  93430. * @param propertyPath defines the path to the boolean property in the target object
  93431. * @param condition defines the trigger related conditions
  93432. */
  93433. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  93434. /** @hidden */
  93435. _prepare(): void;
  93436. /**
  93437. * Execute the action toggle the boolean value.
  93438. */
  93439. execute(): void;
  93440. /**
  93441. * Serializes the actions and its related information.
  93442. * @param parent defines the object to serialize in
  93443. * @returns the serialized object
  93444. */
  93445. serialize(parent: any): any;
  93446. }
  93447. /**
  93448. * This defines an action responsible to set a the state field of the target
  93449. * to a desired value once triggered.
  93450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93451. */
  93452. export class SetStateAction extends Action {
  93453. /**
  93454. * The value to store in the state field.
  93455. */
  93456. value: string;
  93457. private _target;
  93458. /**
  93459. * Instantiate the action
  93460. * @param triggerOptions defines the trigger options
  93461. * @param target defines the object containing the state property
  93462. * @param value defines the value to store in the state field
  93463. * @param condition defines the trigger related conditions
  93464. */
  93465. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  93466. /**
  93467. * Execute the action and store the value on the target state property.
  93468. */
  93469. execute(): void;
  93470. /**
  93471. * Serializes the actions and its related information.
  93472. * @param parent defines the object to serialize in
  93473. * @returns the serialized object
  93474. */
  93475. serialize(parent: any): any;
  93476. }
  93477. /**
  93478. * This defines an action responsible to set a property of the target
  93479. * to a desired value once triggered.
  93480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93481. */
  93482. export class SetValueAction extends Action {
  93483. /**
  93484. * The path of the property to set in the target.
  93485. */
  93486. propertyPath: string;
  93487. /**
  93488. * The value to set in the property
  93489. */
  93490. value: any;
  93491. private _target;
  93492. private _effectiveTarget;
  93493. private _property;
  93494. /**
  93495. * Instantiate the action
  93496. * @param triggerOptions defines the trigger options
  93497. * @param target defines the object containing the property
  93498. * @param propertyPath defines the path of the property to set in the target
  93499. * @param value defines the value to set in the property
  93500. * @param condition defines the trigger related conditions
  93501. */
  93502. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93503. /** @hidden */
  93504. _prepare(): void;
  93505. /**
  93506. * Execute the action and set the targetted property to the desired value.
  93507. */
  93508. execute(): void;
  93509. /**
  93510. * Serializes the actions and its related information.
  93511. * @param parent defines the object to serialize in
  93512. * @returns the serialized object
  93513. */
  93514. serialize(parent: any): any;
  93515. }
  93516. /**
  93517. * This defines an action responsible to increment the target value
  93518. * to a desired value once triggered.
  93519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93520. */
  93521. export class IncrementValueAction extends Action {
  93522. /**
  93523. * The path of the property to increment in the target.
  93524. */
  93525. propertyPath: string;
  93526. /**
  93527. * The value we should increment the property by.
  93528. */
  93529. value: any;
  93530. private _target;
  93531. private _effectiveTarget;
  93532. private _property;
  93533. /**
  93534. * Instantiate the action
  93535. * @param triggerOptions defines the trigger options
  93536. * @param target defines the object containing the property
  93537. * @param propertyPath defines the path of the property to increment in the target
  93538. * @param value defines the value value we should increment the property by
  93539. * @param condition defines the trigger related conditions
  93540. */
  93541. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  93542. /** @hidden */
  93543. _prepare(): void;
  93544. /**
  93545. * Execute the action and increment the target of the value amount.
  93546. */
  93547. execute(): void;
  93548. /**
  93549. * Serializes the actions and its related information.
  93550. * @param parent defines the object to serialize in
  93551. * @returns the serialized object
  93552. */
  93553. serialize(parent: any): any;
  93554. }
  93555. /**
  93556. * This defines an action responsible to start an animation once triggered.
  93557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93558. */
  93559. export class PlayAnimationAction extends Action {
  93560. /**
  93561. * Where the animation should start (animation frame)
  93562. */
  93563. from: number;
  93564. /**
  93565. * Where the animation should stop (animation frame)
  93566. */
  93567. to: number;
  93568. /**
  93569. * Define if the animation should loop or stop after the first play.
  93570. */
  93571. loop?: boolean;
  93572. private _target;
  93573. /**
  93574. * Instantiate the action
  93575. * @param triggerOptions defines the trigger options
  93576. * @param target defines the target animation or animation name
  93577. * @param from defines from where the animation should start (animation frame)
  93578. * @param end defines where the animation should stop (animation frame)
  93579. * @param loop defines if the animation should loop or stop after the first play
  93580. * @param condition defines the trigger related conditions
  93581. */
  93582. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  93583. /** @hidden */
  93584. _prepare(): void;
  93585. /**
  93586. * Execute the action and play the animation.
  93587. */
  93588. execute(): void;
  93589. /**
  93590. * Serializes the actions and its related information.
  93591. * @param parent defines the object to serialize in
  93592. * @returns the serialized object
  93593. */
  93594. serialize(parent: any): any;
  93595. }
  93596. /**
  93597. * This defines an action responsible to stop an animation once triggered.
  93598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93599. */
  93600. export class StopAnimationAction extends Action {
  93601. private _target;
  93602. /**
  93603. * Instantiate the action
  93604. * @param triggerOptions defines the trigger options
  93605. * @param target defines the target animation or animation name
  93606. * @param condition defines the trigger related conditions
  93607. */
  93608. constructor(triggerOptions: any, target: any, condition?: Condition);
  93609. /** @hidden */
  93610. _prepare(): void;
  93611. /**
  93612. * Execute the action and stop the animation.
  93613. */
  93614. execute(): void;
  93615. /**
  93616. * Serializes the actions and its related information.
  93617. * @param parent defines the object to serialize in
  93618. * @returns the serialized object
  93619. */
  93620. serialize(parent: any): any;
  93621. }
  93622. /**
  93623. * This defines an action responsible that does nothing once triggered.
  93624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93625. */
  93626. export class DoNothingAction extends Action {
  93627. /**
  93628. * Instantiate the action
  93629. * @param triggerOptions defines the trigger options
  93630. * @param condition defines the trigger related conditions
  93631. */
  93632. constructor(triggerOptions?: any, condition?: Condition);
  93633. /**
  93634. * Execute the action and do nothing.
  93635. */
  93636. execute(): void;
  93637. /**
  93638. * Serializes the actions and its related information.
  93639. * @param parent defines the object to serialize in
  93640. * @returns the serialized object
  93641. */
  93642. serialize(parent: any): any;
  93643. }
  93644. /**
  93645. * This defines an action responsible to trigger several actions once triggered.
  93646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93647. */
  93648. export class CombineAction extends Action {
  93649. /**
  93650. * The list of aggregated animations to run.
  93651. */
  93652. children: Action[];
  93653. /**
  93654. * Instantiate the action
  93655. * @param triggerOptions defines the trigger options
  93656. * @param children defines the list of aggregated animations to run
  93657. * @param condition defines the trigger related conditions
  93658. */
  93659. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  93660. /** @hidden */
  93661. _prepare(): void;
  93662. /**
  93663. * Execute the action and executes all the aggregated actions.
  93664. */
  93665. execute(evt: ActionEvent): void;
  93666. /**
  93667. * Serializes the actions and its related information.
  93668. * @param parent defines the object to serialize in
  93669. * @returns the serialized object
  93670. */
  93671. serialize(parent: any): any;
  93672. }
  93673. /**
  93674. * This defines an action responsible to run code (external event) once triggered.
  93675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93676. */
  93677. export class ExecuteCodeAction extends Action {
  93678. /**
  93679. * The callback function to run.
  93680. */
  93681. func: (evt: ActionEvent) => void;
  93682. /**
  93683. * Instantiate the action
  93684. * @param triggerOptions defines the trigger options
  93685. * @param func defines the callback function to run
  93686. * @param condition defines the trigger related conditions
  93687. */
  93688. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  93689. /**
  93690. * Execute the action and run the attached code.
  93691. */
  93692. execute(evt: ActionEvent): void;
  93693. }
  93694. /**
  93695. * This defines an action responsible to set the parent property of the target once triggered.
  93696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93697. */
  93698. export class SetParentAction extends Action {
  93699. private _parent;
  93700. private _target;
  93701. /**
  93702. * Instantiate the action
  93703. * @param triggerOptions defines the trigger options
  93704. * @param target defines the target containing the parent property
  93705. * @param parent defines from where the animation should start (animation frame)
  93706. * @param condition defines the trigger related conditions
  93707. */
  93708. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  93709. /** @hidden */
  93710. _prepare(): void;
  93711. /**
  93712. * Execute the action and set the parent property.
  93713. */
  93714. execute(): void;
  93715. /**
  93716. * Serializes the actions and its related information.
  93717. * @param parent defines the object to serialize in
  93718. * @returns the serialized object
  93719. */
  93720. serialize(parent: any): any;
  93721. }
  93722. }
  93723. declare module BABYLON {
  93724. /**
  93725. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  93726. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  93727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93728. */
  93729. export class ActionManager extends AbstractActionManager {
  93730. /**
  93731. * Nothing
  93732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93733. */
  93734. static readonly NothingTrigger: number;
  93735. /**
  93736. * On pick
  93737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93738. */
  93739. static readonly OnPickTrigger: number;
  93740. /**
  93741. * On left pick
  93742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93743. */
  93744. static readonly OnLeftPickTrigger: number;
  93745. /**
  93746. * On right pick
  93747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93748. */
  93749. static readonly OnRightPickTrigger: number;
  93750. /**
  93751. * On center pick
  93752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93753. */
  93754. static readonly OnCenterPickTrigger: number;
  93755. /**
  93756. * On pick down
  93757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93758. */
  93759. static readonly OnPickDownTrigger: number;
  93760. /**
  93761. * On double pick
  93762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93763. */
  93764. static readonly OnDoublePickTrigger: number;
  93765. /**
  93766. * On pick up
  93767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93768. */
  93769. static readonly OnPickUpTrigger: number;
  93770. /**
  93771. * On pick out.
  93772. * This trigger will only be raised if you also declared a OnPickDown
  93773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93774. */
  93775. static readonly OnPickOutTrigger: number;
  93776. /**
  93777. * On long press
  93778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93779. */
  93780. static readonly OnLongPressTrigger: number;
  93781. /**
  93782. * On pointer over
  93783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93784. */
  93785. static readonly OnPointerOverTrigger: number;
  93786. /**
  93787. * On pointer out
  93788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93789. */
  93790. static readonly OnPointerOutTrigger: number;
  93791. /**
  93792. * On every frame
  93793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93794. */
  93795. static readonly OnEveryFrameTrigger: number;
  93796. /**
  93797. * On intersection enter
  93798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93799. */
  93800. static readonly OnIntersectionEnterTrigger: number;
  93801. /**
  93802. * On intersection exit
  93803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93804. */
  93805. static readonly OnIntersectionExitTrigger: number;
  93806. /**
  93807. * On key down
  93808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93809. */
  93810. static readonly OnKeyDownTrigger: number;
  93811. /**
  93812. * On key up
  93813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  93814. */
  93815. static readonly OnKeyUpTrigger: number;
  93816. private _scene;
  93817. /**
  93818. * Creates a new action manager
  93819. * @param scene defines the hosting scene
  93820. */
  93821. constructor(scene: Scene);
  93822. /**
  93823. * Releases all associated resources
  93824. */
  93825. dispose(): void;
  93826. /**
  93827. * Gets hosting scene
  93828. * @returns the hosting scene
  93829. */
  93830. getScene(): Scene;
  93831. /**
  93832. * Does this action manager handles actions of any of the given triggers
  93833. * @param triggers defines the triggers to be tested
  93834. * @return a boolean indicating whether one (or more) of the triggers is handled
  93835. */
  93836. hasSpecificTriggers(triggers: number[]): boolean;
  93837. /**
  93838. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93839. * speed.
  93840. * @param triggerA defines the trigger to be tested
  93841. * @param triggerB defines the trigger to be tested
  93842. * @return a boolean indicating whether one (or more) of the triggers is handled
  93843. */
  93844. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93845. /**
  93846. * Does this action manager handles actions of a given trigger
  93847. * @param trigger defines the trigger to be tested
  93848. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93849. * @return whether the trigger is handled
  93850. */
  93851. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93852. /**
  93853. * Does this action manager has pointer triggers
  93854. */
  93855. get hasPointerTriggers(): boolean;
  93856. /**
  93857. * Does this action manager has pick triggers
  93858. */
  93859. get hasPickTriggers(): boolean;
  93860. /**
  93861. * Registers an action to this action manager
  93862. * @param action defines the action to be registered
  93863. * @return the action amended (prepared) after registration
  93864. */
  93865. registerAction(action: IAction): Nullable<IAction>;
  93866. /**
  93867. * Unregisters an action to this action manager
  93868. * @param action defines the action to be unregistered
  93869. * @return a boolean indicating whether the action has been unregistered
  93870. */
  93871. unregisterAction(action: IAction): Boolean;
  93872. /**
  93873. * Process a specific trigger
  93874. * @param trigger defines the trigger to process
  93875. * @param evt defines the event details to be processed
  93876. */
  93877. processTrigger(trigger: number, evt?: IActionEvent): void;
  93878. /** @hidden */
  93879. _getEffectiveTarget(target: any, propertyPath: string): any;
  93880. /** @hidden */
  93881. _getProperty(propertyPath: string): string;
  93882. /**
  93883. * Serialize this manager to a JSON object
  93884. * @param name defines the property name to store this manager
  93885. * @returns a JSON representation of this manager
  93886. */
  93887. serialize(name: string): any;
  93888. /**
  93889. * Creates a new ActionManager from a JSON data
  93890. * @param parsedActions defines the JSON data to read from
  93891. * @param object defines the hosting mesh
  93892. * @param scene defines the hosting scene
  93893. */
  93894. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  93895. /**
  93896. * Get a trigger name by index
  93897. * @param trigger defines the trigger index
  93898. * @returns a trigger name
  93899. */
  93900. static GetTriggerName(trigger: number): string;
  93901. }
  93902. }
  93903. declare module BABYLON {
  93904. /**
  93905. * Class used to represent a sprite
  93906. * @see http://doc.babylonjs.com/babylon101/sprites
  93907. */
  93908. export class Sprite {
  93909. /** defines the name */
  93910. name: string;
  93911. /** Gets or sets the current world position */
  93912. position: Vector3;
  93913. /** Gets or sets the main color */
  93914. color: Color4;
  93915. /** Gets or sets the width */
  93916. width: number;
  93917. /** Gets or sets the height */
  93918. height: number;
  93919. /** Gets or sets rotation angle */
  93920. angle: number;
  93921. /** Gets or sets the cell index in the sprite sheet */
  93922. cellIndex: number;
  93923. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  93924. cellRef: string;
  93925. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  93926. invertU: number;
  93927. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  93928. invertV: number;
  93929. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  93930. disposeWhenFinishedAnimating: boolean;
  93931. /** Gets the list of attached animations */
  93932. animations: Animation[];
  93933. /** Gets or sets a boolean indicating if the sprite can be picked */
  93934. isPickable: boolean;
  93935. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  93936. useAlphaForPicking: boolean;
  93937. /** @hidden */
  93938. _xOffset: number;
  93939. /** @hidden */
  93940. _yOffset: number;
  93941. /** @hidden */
  93942. _xSize: number;
  93943. /** @hidden */
  93944. _ySize: number;
  93945. /**
  93946. * Gets or sets the associated action manager
  93947. */
  93948. actionManager: Nullable<ActionManager>;
  93949. private _animationStarted;
  93950. private _loopAnimation;
  93951. private _fromIndex;
  93952. private _toIndex;
  93953. private _delay;
  93954. private _direction;
  93955. private _manager;
  93956. private _time;
  93957. private _onAnimationEnd;
  93958. /**
  93959. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  93960. */
  93961. isVisible: boolean;
  93962. /**
  93963. * Gets or sets the sprite size
  93964. */
  93965. get size(): number;
  93966. set size(value: number);
  93967. /**
  93968. * Creates a new Sprite
  93969. * @param name defines the name
  93970. * @param manager defines the manager
  93971. */
  93972. constructor(
  93973. /** defines the name */
  93974. name: string, manager: ISpriteManager);
  93975. /**
  93976. * Starts an animation
  93977. * @param from defines the initial key
  93978. * @param to defines the end key
  93979. * @param loop defines if the animation must loop
  93980. * @param delay defines the start delay (in ms)
  93981. * @param onAnimationEnd defines a callback to call when animation ends
  93982. */
  93983. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  93984. /** Stops current animation (if any) */
  93985. stopAnimation(): void;
  93986. /** @hidden */
  93987. _animate(deltaTime: number): void;
  93988. /** Release associated resources */
  93989. dispose(): void;
  93990. }
  93991. }
  93992. declare module BABYLON {
  93993. /**
  93994. * Information about the result of picking within a scene
  93995. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  93996. */
  93997. export class PickingInfo {
  93998. /** @hidden */
  93999. _pickingUnavailable: boolean;
  94000. /**
  94001. * If the pick collided with an object
  94002. */
  94003. hit: boolean;
  94004. /**
  94005. * Distance away where the pick collided
  94006. */
  94007. distance: number;
  94008. /**
  94009. * The location of pick collision
  94010. */
  94011. pickedPoint: Nullable<Vector3>;
  94012. /**
  94013. * The mesh corresponding the the pick collision
  94014. */
  94015. pickedMesh: Nullable<AbstractMesh>;
  94016. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  94017. bu: number;
  94018. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  94019. bv: number;
  94020. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  94021. faceId: number;
  94022. /** Id of the the submesh that was picked */
  94023. subMeshId: number;
  94024. /** If a sprite was picked, this will be the sprite the pick collided with */
  94025. pickedSprite: Nullable<Sprite>;
  94026. /**
  94027. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  94028. */
  94029. originMesh: Nullable<AbstractMesh>;
  94030. /**
  94031. * The ray that was used to perform the picking.
  94032. */
  94033. ray: Nullable<Ray>;
  94034. /**
  94035. * Gets the normal correspodning to the face the pick collided with
  94036. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  94037. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  94038. * @returns The normal correspodning to the face the pick collided with
  94039. */
  94040. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  94041. /**
  94042. * Gets the texture coordinates of where the pick occured
  94043. * @returns the vector containing the coordnates of the texture
  94044. */
  94045. getTextureCoordinates(): Nullable<Vector2>;
  94046. }
  94047. }
  94048. declare module BABYLON {
  94049. /**
  94050. * Gather the list of pointer event types as constants.
  94051. */
  94052. export class PointerEventTypes {
  94053. /**
  94054. * 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.
  94055. */
  94056. static readonly POINTERDOWN: number;
  94057. /**
  94058. * The pointerup event is fired when a pointer is no longer active.
  94059. */
  94060. static readonly POINTERUP: number;
  94061. /**
  94062. * The pointermove event is fired when a pointer changes coordinates.
  94063. */
  94064. static readonly POINTERMOVE: number;
  94065. /**
  94066. * The pointerwheel event is fired when a mouse wheel has been rotated.
  94067. */
  94068. static readonly POINTERWHEEL: number;
  94069. /**
  94070. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  94071. */
  94072. static readonly POINTERPICK: number;
  94073. /**
  94074. * The pointertap event is fired when a the object has been touched and released without drag.
  94075. */
  94076. static readonly POINTERTAP: number;
  94077. /**
  94078. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  94079. */
  94080. static readonly POINTERDOUBLETAP: number;
  94081. }
  94082. /**
  94083. * Base class of pointer info types.
  94084. */
  94085. export class PointerInfoBase {
  94086. /**
  94087. * Defines the type of event (PointerEventTypes)
  94088. */
  94089. type: number;
  94090. /**
  94091. * Defines the related dom event
  94092. */
  94093. event: PointerEvent | MouseWheelEvent;
  94094. /**
  94095. * Instantiates the base class of pointers info.
  94096. * @param type Defines the type of event (PointerEventTypes)
  94097. * @param event Defines the related dom event
  94098. */
  94099. constructor(
  94100. /**
  94101. * Defines the type of event (PointerEventTypes)
  94102. */
  94103. type: number,
  94104. /**
  94105. * Defines the related dom event
  94106. */
  94107. event: PointerEvent | MouseWheelEvent);
  94108. }
  94109. /**
  94110. * This class is used to store pointer related info for the onPrePointerObservable event.
  94111. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  94112. */
  94113. export class PointerInfoPre extends PointerInfoBase {
  94114. /**
  94115. * Ray from a pointer if availible (eg. 6dof controller)
  94116. */
  94117. ray: Nullable<Ray>;
  94118. /**
  94119. * Defines the local position of the pointer on the canvas.
  94120. */
  94121. localPosition: Vector2;
  94122. /**
  94123. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  94124. */
  94125. skipOnPointerObservable: boolean;
  94126. /**
  94127. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  94128. * @param type Defines the type of event (PointerEventTypes)
  94129. * @param event Defines the related dom event
  94130. * @param localX Defines the local x coordinates of the pointer when the event occured
  94131. * @param localY Defines the local y coordinates of the pointer when the event occured
  94132. */
  94133. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  94134. }
  94135. /**
  94136. * This type contains all the data related to a pointer event in Babylon.js.
  94137. * 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.
  94138. */
  94139. export class PointerInfo extends PointerInfoBase {
  94140. /**
  94141. * Defines the picking info associated to the info (if any)\
  94142. */
  94143. pickInfo: Nullable<PickingInfo>;
  94144. /**
  94145. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  94146. * @param type Defines the type of event (PointerEventTypes)
  94147. * @param event Defines the related dom event
  94148. * @param pickInfo Defines the picking info associated to the info (if any)\
  94149. */
  94150. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  94151. /**
  94152. * Defines the picking info associated to the info (if any)\
  94153. */
  94154. pickInfo: Nullable<PickingInfo>);
  94155. }
  94156. /**
  94157. * Data relating to a touch event on the screen.
  94158. */
  94159. export interface PointerTouch {
  94160. /**
  94161. * X coordinate of touch.
  94162. */
  94163. x: number;
  94164. /**
  94165. * Y coordinate of touch.
  94166. */
  94167. y: number;
  94168. /**
  94169. * Id of touch. Unique for each finger.
  94170. */
  94171. pointerId: number;
  94172. /**
  94173. * Event type passed from DOM.
  94174. */
  94175. type: any;
  94176. }
  94177. }
  94178. declare module BABYLON {
  94179. /**
  94180. * Manage the mouse inputs to control the movement of a free camera.
  94181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94182. */
  94183. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  94184. /**
  94185. * Define if touch is enabled in the mouse input
  94186. */
  94187. touchEnabled: boolean;
  94188. /**
  94189. * Defines the camera the input is attached to.
  94190. */
  94191. camera: FreeCamera;
  94192. /**
  94193. * Defines the buttons associated with the input to handle camera move.
  94194. */
  94195. buttons: number[];
  94196. /**
  94197. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  94198. */
  94199. angularSensibility: number;
  94200. private _pointerInput;
  94201. private _onMouseMove;
  94202. private _observer;
  94203. private previousPosition;
  94204. /**
  94205. * Observable for when a pointer move event occurs containing the move offset
  94206. */
  94207. onPointerMovedObservable: Observable<{
  94208. offsetX: number;
  94209. offsetY: number;
  94210. }>;
  94211. /**
  94212. * @hidden
  94213. * If the camera should be rotated automatically based on pointer movement
  94214. */
  94215. _allowCameraRotation: boolean;
  94216. /**
  94217. * Manage the mouse inputs to control the movement of a free camera.
  94218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94219. * @param touchEnabled Defines if touch is enabled or not
  94220. */
  94221. constructor(
  94222. /**
  94223. * Define if touch is enabled in the mouse input
  94224. */
  94225. touchEnabled?: boolean);
  94226. /**
  94227. * Attach the input controls to a specific dom element to get the input from.
  94228. * @param element Defines the element the controls should be listened from
  94229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94230. */
  94231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94232. /**
  94233. * Called on JS contextmenu event.
  94234. * Override this method to provide functionality.
  94235. */
  94236. protected onContextMenu(evt: PointerEvent): void;
  94237. /**
  94238. * Detach the current controls from the specified dom element.
  94239. * @param element Defines the element to stop listening the inputs from
  94240. */
  94241. detachControl(element: Nullable<HTMLElement>): void;
  94242. /**
  94243. * Gets the class name of the current intput.
  94244. * @returns the class name
  94245. */
  94246. getClassName(): string;
  94247. /**
  94248. * Get the friendly name associated with the input class.
  94249. * @returns the input friendly name
  94250. */
  94251. getSimpleName(): string;
  94252. }
  94253. }
  94254. declare module BABYLON {
  94255. /**
  94256. * Manage the touch inputs to control the movement of a free camera.
  94257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94258. */
  94259. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  94260. /**
  94261. * Defines the camera the input is attached to.
  94262. */
  94263. camera: FreeCamera;
  94264. /**
  94265. * Defines the touch sensibility for rotation.
  94266. * The higher the faster.
  94267. */
  94268. touchAngularSensibility: number;
  94269. /**
  94270. * Defines the touch sensibility for move.
  94271. * The higher the faster.
  94272. */
  94273. touchMoveSensibility: number;
  94274. private _offsetX;
  94275. private _offsetY;
  94276. private _pointerPressed;
  94277. private _pointerInput;
  94278. private _observer;
  94279. private _onLostFocus;
  94280. /**
  94281. * Attach the input controls to a specific dom element to get the input from.
  94282. * @param element Defines the element the controls should be listened from
  94283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94284. */
  94285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94286. /**
  94287. * Detach the current controls from the specified dom element.
  94288. * @param element Defines the element to stop listening the inputs from
  94289. */
  94290. detachControl(element: Nullable<HTMLElement>): void;
  94291. /**
  94292. * Update the current camera state depending on the inputs that have been used this frame.
  94293. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94294. */
  94295. checkInputs(): void;
  94296. /**
  94297. * Gets the class name of the current intput.
  94298. * @returns the class name
  94299. */
  94300. getClassName(): string;
  94301. /**
  94302. * Get the friendly name associated with the input class.
  94303. * @returns the input friendly name
  94304. */
  94305. getSimpleName(): string;
  94306. }
  94307. }
  94308. declare module BABYLON {
  94309. /**
  94310. * Default Inputs manager for the FreeCamera.
  94311. * It groups all the default supported inputs for ease of use.
  94312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94313. */
  94314. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  94315. /**
  94316. * @hidden
  94317. */
  94318. _mouseInput: Nullable<FreeCameraMouseInput>;
  94319. /**
  94320. * Instantiates a new FreeCameraInputsManager.
  94321. * @param camera Defines the camera the inputs belong to
  94322. */
  94323. constructor(camera: FreeCamera);
  94324. /**
  94325. * Add keyboard input support to the input manager.
  94326. * @returns the current input manager
  94327. */
  94328. addKeyboard(): FreeCameraInputsManager;
  94329. /**
  94330. * Add mouse input support to the input manager.
  94331. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  94332. * @returns the current input manager
  94333. */
  94334. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  94335. /**
  94336. * Removes the mouse input support from the manager
  94337. * @returns the current input manager
  94338. */
  94339. removeMouse(): FreeCameraInputsManager;
  94340. /**
  94341. * Add touch input support to the input manager.
  94342. * @returns the current input manager
  94343. */
  94344. addTouch(): FreeCameraInputsManager;
  94345. /**
  94346. * Remove all attached input methods from a camera
  94347. */
  94348. clear(): void;
  94349. }
  94350. }
  94351. declare module BABYLON {
  94352. /**
  94353. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94354. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  94355. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94356. */
  94357. export class FreeCamera extends TargetCamera {
  94358. /**
  94359. * Define the collision ellipsoid of the camera.
  94360. * This is helpful to simulate a camera body like the player body around the camera
  94361. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94362. */
  94363. ellipsoid: Vector3;
  94364. /**
  94365. * Define an offset for the position of the ellipsoid around the camera.
  94366. * This can be helpful to determine the center of the body near the gravity center of the body
  94367. * instead of its head.
  94368. */
  94369. ellipsoidOffset: Vector3;
  94370. /**
  94371. * Enable or disable collisions of the camera with the rest of the scene objects.
  94372. */
  94373. checkCollisions: boolean;
  94374. /**
  94375. * Enable or disable gravity on the camera.
  94376. */
  94377. applyGravity: boolean;
  94378. /**
  94379. * Define the input manager associated to the camera.
  94380. */
  94381. inputs: FreeCameraInputsManager;
  94382. /**
  94383. * Gets the input sensibility for a mouse input. (default is 2000.0)
  94384. * Higher values reduce sensitivity.
  94385. */
  94386. get angularSensibility(): number;
  94387. /**
  94388. * Sets the input sensibility for a mouse input. (default is 2000.0)
  94389. * Higher values reduce sensitivity.
  94390. */
  94391. set angularSensibility(value: number);
  94392. /**
  94393. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94394. */
  94395. get keysUp(): number[];
  94396. set keysUp(value: number[]);
  94397. /**
  94398. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94399. */
  94400. get keysUpward(): number[];
  94401. set keysUpward(value: number[]);
  94402. /**
  94403. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94404. */
  94405. get keysDown(): number[];
  94406. set keysDown(value: number[]);
  94407. /**
  94408. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94409. */
  94410. get keysDownward(): number[];
  94411. set keysDownward(value: number[]);
  94412. /**
  94413. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94414. */
  94415. get keysLeft(): number[];
  94416. set keysLeft(value: number[]);
  94417. /**
  94418. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94419. */
  94420. get keysRight(): number[];
  94421. set keysRight(value: number[]);
  94422. /**
  94423. * Event raised when the camera collide with a mesh in the scene.
  94424. */
  94425. onCollide: (collidedMesh: AbstractMesh) => void;
  94426. private _collider;
  94427. private _needMoveForGravity;
  94428. private _oldPosition;
  94429. private _diffPosition;
  94430. private _newPosition;
  94431. /** @hidden */
  94432. _localDirection: Vector3;
  94433. /** @hidden */
  94434. _transformedDirection: Vector3;
  94435. /**
  94436. * Instantiates a Free Camera.
  94437. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94438. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  94439. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94440. * @param name Define the name of the camera in the scene
  94441. * @param position Define the start position of the camera in the scene
  94442. * @param scene Define the scene the camera belongs to
  94443. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94444. */
  94445. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94446. /**
  94447. * Attached controls to the current camera.
  94448. * @param element Defines the element the controls should be listened from
  94449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94450. */
  94451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94452. /**
  94453. * Detach the current controls from the camera.
  94454. * The camera will stop reacting to inputs.
  94455. * @param element Defines the element to stop listening the inputs from
  94456. */
  94457. detachControl(element: HTMLElement): void;
  94458. private _collisionMask;
  94459. /**
  94460. * Define a collision mask to limit the list of object the camera can collide with
  94461. */
  94462. get collisionMask(): number;
  94463. set collisionMask(mask: number);
  94464. /** @hidden */
  94465. _collideWithWorld(displacement: Vector3): void;
  94466. private _onCollisionPositionChange;
  94467. /** @hidden */
  94468. _checkInputs(): void;
  94469. /** @hidden */
  94470. _decideIfNeedsToMove(): boolean;
  94471. /** @hidden */
  94472. _updatePosition(): void;
  94473. /**
  94474. * Destroy the camera and release the current resources hold by it.
  94475. */
  94476. dispose(): void;
  94477. /**
  94478. * Gets the current object class name.
  94479. * @return the class name
  94480. */
  94481. getClassName(): string;
  94482. }
  94483. }
  94484. declare module BABYLON {
  94485. /**
  94486. * Represents a gamepad control stick position
  94487. */
  94488. export class StickValues {
  94489. /**
  94490. * The x component of the control stick
  94491. */
  94492. x: number;
  94493. /**
  94494. * The y component of the control stick
  94495. */
  94496. y: number;
  94497. /**
  94498. * Initializes the gamepad x and y control stick values
  94499. * @param x The x component of the gamepad control stick value
  94500. * @param y The y component of the gamepad control stick value
  94501. */
  94502. constructor(
  94503. /**
  94504. * The x component of the control stick
  94505. */
  94506. x: number,
  94507. /**
  94508. * The y component of the control stick
  94509. */
  94510. y: number);
  94511. }
  94512. /**
  94513. * An interface which manages callbacks for gamepad button changes
  94514. */
  94515. export interface GamepadButtonChanges {
  94516. /**
  94517. * Called when a gamepad has been changed
  94518. */
  94519. changed: boolean;
  94520. /**
  94521. * Called when a gamepad press event has been triggered
  94522. */
  94523. pressChanged: boolean;
  94524. /**
  94525. * Called when a touch event has been triggered
  94526. */
  94527. touchChanged: boolean;
  94528. /**
  94529. * Called when a value has changed
  94530. */
  94531. valueChanged: boolean;
  94532. }
  94533. /**
  94534. * Represents a gamepad
  94535. */
  94536. export class Gamepad {
  94537. /**
  94538. * The id of the gamepad
  94539. */
  94540. id: string;
  94541. /**
  94542. * The index of the gamepad
  94543. */
  94544. index: number;
  94545. /**
  94546. * The browser gamepad
  94547. */
  94548. browserGamepad: any;
  94549. /**
  94550. * Specifies what type of gamepad this represents
  94551. */
  94552. type: number;
  94553. private _leftStick;
  94554. private _rightStick;
  94555. /** @hidden */
  94556. _isConnected: boolean;
  94557. private _leftStickAxisX;
  94558. private _leftStickAxisY;
  94559. private _rightStickAxisX;
  94560. private _rightStickAxisY;
  94561. /**
  94562. * Triggered when the left control stick has been changed
  94563. */
  94564. private _onleftstickchanged;
  94565. /**
  94566. * Triggered when the right control stick has been changed
  94567. */
  94568. private _onrightstickchanged;
  94569. /**
  94570. * Represents a gamepad controller
  94571. */
  94572. static GAMEPAD: number;
  94573. /**
  94574. * Represents a generic controller
  94575. */
  94576. static GENERIC: number;
  94577. /**
  94578. * Represents an XBox controller
  94579. */
  94580. static XBOX: number;
  94581. /**
  94582. * Represents a pose-enabled controller
  94583. */
  94584. static POSE_ENABLED: number;
  94585. /**
  94586. * Represents an Dual Shock controller
  94587. */
  94588. static DUALSHOCK: number;
  94589. /**
  94590. * Specifies whether the left control stick should be Y-inverted
  94591. */
  94592. protected _invertLeftStickY: boolean;
  94593. /**
  94594. * Specifies if the gamepad has been connected
  94595. */
  94596. get isConnected(): boolean;
  94597. /**
  94598. * Initializes the gamepad
  94599. * @param id The id of the gamepad
  94600. * @param index The index of the gamepad
  94601. * @param browserGamepad The browser gamepad
  94602. * @param leftStickX The x component of the left joystick
  94603. * @param leftStickY The y component of the left joystick
  94604. * @param rightStickX The x component of the right joystick
  94605. * @param rightStickY The y component of the right joystick
  94606. */
  94607. constructor(
  94608. /**
  94609. * The id of the gamepad
  94610. */
  94611. id: string,
  94612. /**
  94613. * The index of the gamepad
  94614. */
  94615. index: number,
  94616. /**
  94617. * The browser gamepad
  94618. */
  94619. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  94620. /**
  94621. * Callback triggered when the left joystick has changed
  94622. * @param callback
  94623. */
  94624. onleftstickchanged(callback: (values: StickValues) => void): void;
  94625. /**
  94626. * Callback triggered when the right joystick has changed
  94627. * @param callback
  94628. */
  94629. onrightstickchanged(callback: (values: StickValues) => void): void;
  94630. /**
  94631. * Gets the left joystick
  94632. */
  94633. get leftStick(): StickValues;
  94634. /**
  94635. * Sets the left joystick values
  94636. */
  94637. set leftStick(newValues: StickValues);
  94638. /**
  94639. * Gets the right joystick
  94640. */
  94641. get rightStick(): StickValues;
  94642. /**
  94643. * Sets the right joystick value
  94644. */
  94645. set rightStick(newValues: StickValues);
  94646. /**
  94647. * Updates the gamepad joystick positions
  94648. */
  94649. update(): void;
  94650. /**
  94651. * Disposes the gamepad
  94652. */
  94653. dispose(): void;
  94654. }
  94655. /**
  94656. * Represents a generic gamepad
  94657. */
  94658. export class GenericPad extends Gamepad {
  94659. private _buttons;
  94660. private _onbuttondown;
  94661. private _onbuttonup;
  94662. /**
  94663. * Observable triggered when a button has been pressed
  94664. */
  94665. onButtonDownObservable: Observable<number>;
  94666. /**
  94667. * Observable triggered when a button has been released
  94668. */
  94669. onButtonUpObservable: Observable<number>;
  94670. /**
  94671. * Callback triggered when a button has been pressed
  94672. * @param callback Called when a button has been pressed
  94673. */
  94674. onbuttondown(callback: (buttonPressed: number) => void): void;
  94675. /**
  94676. * Callback triggered when a button has been released
  94677. * @param callback Called when a button has been released
  94678. */
  94679. onbuttonup(callback: (buttonReleased: number) => void): void;
  94680. /**
  94681. * Initializes the generic gamepad
  94682. * @param id The id of the generic gamepad
  94683. * @param index The index of the generic gamepad
  94684. * @param browserGamepad The browser gamepad
  94685. */
  94686. constructor(id: string, index: number, browserGamepad: any);
  94687. private _setButtonValue;
  94688. /**
  94689. * Updates the generic gamepad
  94690. */
  94691. update(): void;
  94692. /**
  94693. * Disposes the generic gamepad
  94694. */
  94695. dispose(): void;
  94696. }
  94697. }
  94698. declare module BABYLON {
  94699. /**
  94700. * Defines the types of pose enabled controllers that are supported
  94701. */
  94702. export enum PoseEnabledControllerType {
  94703. /**
  94704. * HTC Vive
  94705. */
  94706. VIVE = 0,
  94707. /**
  94708. * Oculus Rift
  94709. */
  94710. OCULUS = 1,
  94711. /**
  94712. * Windows mixed reality
  94713. */
  94714. WINDOWS = 2,
  94715. /**
  94716. * Samsung gear VR
  94717. */
  94718. GEAR_VR = 3,
  94719. /**
  94720. * Google Daydream
  94721. */
  94722. DAYDREAM = 4,
  94723. /**
  94724. * Generic
  94725. */
  94726. GENERIC = 5
  94727. }
  94728. /**
  94729. * Defines the MutableGamepadButton interface for the state of a gamepad button
  94730. */
  94731. export interface MutableGamepadButton {
  94732. /**
  94733. * Value of the button/trigger
  94734. */
  94735. value: number;
  94736. /**
  94737. * If the button/trigger is currently touched
  94738. */
  94739. touched: boolean;
  94740. /**
  94741. * If the button/trigger is currently pressed
  94742. */
  94743. pressed: boolean;
  94744. }
  94745. /**
  94746. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  94747. * @hidden
  94748. */
  94749. export interface ExtendedGamepadButton extends GamepadButton {
  94750. /**
  94751. * If the button/trigger is currently pressed
  94752. */
  94753. readonly pressed: boolean;
  94754. /**
  94755. * If the button/trigger is currently touched
  94756. */
  94757. readonly touched: boolean;
  94758. /**
  94759. * Value of the button/trigger
  94760. */
  94761. readonly value: number;
  94762. }
  94763. /** @hidden */
  94764. export interface _GamePadFactory {
  94765. /**
  94766. * Returns whether or not the current gamepad can be created for this type of controller.
  94767. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94768. * @returns true if it can be created, otherwise false
  94769. */
  94770. canCreate(gamepadInfo: any): boolean;
  94771. /**
  94772. * Creates a new instance of the Gamepad.
  94773. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  94774. * @returns the new gamepad instance
  94775. */
  94776. create(gamepadInfo: any): Gamepad;
  94777. }
  94778. /**
  94779. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  94780. */
  94781. export class PoseEnabledControllerHelper {
  94782. /** @hidden */
  94783. static _ControllerFactories: _GamePadFactory[];
  94784. /** @hidden */
  94785. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  94786. /**
  94787. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  94788. * @param vrGamepad the gamepad to initialized
  94789. * @returns a vr controller of the type the gamepad identified as
  94790. */
  94791. static InitiateController(vrGamepad: any): Gamepad;
  94792. }
  94793. /**
  94794. * Defines the PoseEnabledController object that contains state of a vr capable controller
  94795. */
  94796. export class PoseEnabledController extends Gamepad implements PoseControlled {
  94797. /**
  94798. * If the controller is used in a webXR session
  94799. */
  94800. isXR: boolean;
  94801. private _deviceRoomPosition;
  94802. private _deviceRoomRotationQuaternion;
  94803. /**
  94804. * The device position in babylon space
  94805. */
  94806. devicePosition: Vector3;
  94807. /**
  94808. * The device rotation in babylon space
  94809. */
  94810. deviceRotationQuaternion: Quaternion;
  94811. /**
  94812. * The scale factor of the device in babylon space
  94813. */
  94814. deviceScaleFactor: number;
  94815. /**
  94816. * (Likely devicePosition should be used instead) The device position in its room space
  94817. */
  94818. position: Vector3;
  94819. /**
  94820. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  94821. */
  94822. rotationQuaternion: Quaternion;
  94823. /**
  94824. * The type of controller (Eg. Windows mixed reality)
  94825. */
  94826. controllerType: PoseEnabledControllerType;
  94827. protected _calculatedPosition: Vector3;
  94828. private _calculatedRotation;
  94829. /**
  94830. * The raw pose from the device
  94831. */
  94832. rawPose: DevicePose;
  94833. private _trackPosition;
  94834. private _maxRotationDistFromHeadset;
  94835. private _draggedRoomRotation;
  94836. /**
  94837. * @hidden
  94838. */
  94839. _disableTrackPosition(fixedPosition: Vector3): void;
  94840. /**
  94841. * Internal, the mesh attached to the controller
  94842. * @hidden
  94843. */
  94844. _mesh: Nullable<AbstractMesh>;
  94845. private _poseControlledCamera;
  94846. private _leftHandSystemQuaternion;
  94847. /**
  94848. * Internal, matrix used to convert room space to babylon space
  94849. * @hidden
  94850. */
  94851. _deviceToWorld: Matrix;
  94852. /**
  94853. * Node to be used when casting a ray from the controller
  94854. * @hidden
  94855. */
  94856. _pointingPoseNode: Nullable<TransformNode>;
  94857. /**
  94858. * Name of the child mesh that can be used to cast a ray from the controller
  94859. */
  94860. static readonly POINTING_POSE: string;
  94861. /**
  94862. * Creates a new PoseEnabledController from a gamepad
  94863. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  94864. */
  94865. constructor(browserGamepad: any);
  94866. private _workingMatrix;
  94867. /**
  94868. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  94869. */
  94870. update(): void;
  94871. /**
  94872. * Updates only the pose device and mesh without doing any button event checking
  94873. */
  94874. protected _updatePoseAndMesh(): void;
  94875. /**
  94876. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  94877. * @param poseData raw pose fromthe device
  94878. */
  94879. updateFromDevice(poseData: DevicePose): void;
  94880. /**
  94881. * @hidden
  94882. */
  94883. _meshAttachedObservable: Observable<AbstractMesh>;
  94884. /**
  94885. * Attaches a mesh to the controller
  94886. * @param mesh the mesh to be attached
  94887. */
  94888. attachToMesh(mesh: AbstractMesh): void;
  94889. /**
  94890. * Attaches the controllers mesh to a camera
  94891. * @param camera the camera the mesh should be attached to
  94892. */
  94893. attachToPoseControlledCamera(camera: TargetCamera): void;
  94894. /**
  94895. * Disposes of the controller
  94896. */
  94897. dispose(): void;
  94898. /**
  94899. * The mesh that is attached to the controller
  94900. */
  94901. get mesh(): Nullable<AbstractMesh>;
  94902. /**
  94903. * Gets the ray of the controller in the direction the controller is pointing
  94904. * @param length the length the resulting ray should be
  94905. * @returns a ray in the direction the controller is pointing
  94906. */
  94907. getForwardRay(length?: number): Ray;
  94908. }
  94909. }
  94910. declare module BABYLON {
  94911. /**
  94912. * Defines the WebVRController object that represents controllers tracked in 3D space
  94913. */
  94914. export abstract class WebVRController extends PoseEnabledController {
  94915. /**
  94916. * Internal, the default controller model for the controller
  94917. */
  94918. protected _defaultModel: Nullable<AbstractMesh>;
  94919. /**
  94920. * Fired when the trigger state has changed
  94921. */
  94922. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  94923. /**
  94924. * Fired when the main button state has changed
  94925. */
  94926. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  94927. /**
  94928. * Fired when the secondary button state has changed
  94929. */
  94930. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  94931. /**
  94932. * Fired when the pad state has changed
  94933. */
  94934. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  94935. /**
  94936. * Fired when controllers stick values have changed
  94937. */
  94938. onPadValuesChangedObservable: Observable<StickValues>;
  94939. /**
  94940. * Array of button availible on the controller
  94941. */
  94942. protected _buttons: Array<MutableGamepadButton>;
  94943. private _onButtonStateChange;
  94944. /**
  94945. * Fired when a controller button's state has changed
  94946. * @param callback the callback containing the button that was modified
  94947. */
  94948. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  94949. /**
  94950. * X and Y axis corresponding to the controllers joystick
  94951. */
  94952. pad: StickValues;
  94953. /**
  94954. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  94955. */
  94956. hand: string;
  94957. /**
  94958. * The default controller model for the controller
  94959. */
  94960. get defaultModel(): Nullable<AbstractMesh>;
  94961. /**
  94962. * Creates a new WebVRController from a gamepad
  94963. * @param vrGamepad the gamepad that the WebVRController should be created from
  94964. */
  94965. constructor(vrGamepad: any);
  94966. /**
  94967. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  94968. */
  94969. update(): void;
  94970. /**
  94971. * Function to be called when a button is modified
  94972. */
  94973. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  94974. /**
  94975. * Loads a mesh and attaches it to the controller
  94976. * @param scene the scene the mesh should be added to
  94977. * @param meshLoaded callback for when the mesh has been loaded
  94978. */
  94979. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  94980. private _setButtonValue;
  94981. private _changes;
  94982. private _checkChanges;
  94983. /**
  94984. * Disposes of th webVRCOntroller
  94985. */
  94986. dispose(): void;
  94987. }
  94988. }
  94989. declare module BABYLON {
  94990. /**
  94991. * The HemisphericLight simulates the ambient environment light,
  94992. * so the passed direction is the light reflection direction, not the incoming direction.
  94993. */
  94994. export class HemisphericLight extends Light {
  94995. /**
  94996. * The groundColor is the light in the opposite direction to the one specified during creation.
  94997. * 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.
  94998. */
  94999. groundColor: Color3;
  95000. /**
  95001. * The light reflection direction, not the incoming direction.
  95002. */
  95003. direction: Vector3;
  95004. /**
  95005. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  95006. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  95007. * The HemisphericLight can't cast shadows.
  95008. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95009. * @param name The friendly name of the light
  95010. * @param direction The direction of the light reflection
  95011. * @param scene The scene the light belongs to
  95012. */
  95013. constructor(name: string, direction: Vector3, scene: Scene);
  95014. protected _buildUniformLayout(): void;
  95015. /**
  95016. * Returns the string "HemisphericLight".
  95017. * @return The class name
  95018. */
  95019. getClassName(): string;
  95020. /**
  95021. * Sets the HemisphericLight direction towards the passed target (Vector3).
  95022. * Returns the updated direction.
  95023. * @param target The target the direction should point to
  95024. * @return The computed direction
  95025. */
  95026. setDirectionToTarget(target: Vector3): Vector3;
  95027. /**
  95028. * Returns the shadow generator associated to the light.
  95029. * @returns Always null for hemispheric lights because it does not support shadows.
  95030. */
  95031. getShadowGenerator(): Nullable<IShadowGenerator>;
  95032. /**
  95033. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  95034. * @param effect The effect to update
  95035. * @param lightIndex The index of the light in the effect to update
  95036. * @returns The hemispheric light
  95037. */
  95038. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  95039. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  95040. /**
  95041. * Computes the world matrix of the node
  95042. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95043. * @param useWasUpdatedFlag defines a reserved property
  95044. * @returns the world matrix
  95045. */
  95046. computeWorldMatrix(): Matrix;
  95047. /**
  95048. * Returns the integer 3.
  95049. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95050. */
  95051. getTypeID(): number;
  95052. /**
  95053. * Prepares the list of defines specific to the light type.
  95054. * @param defines the list of defines
  95055. * @param lightIndex defines the index of the light for the effect
  95056. */
  95057. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95058. }
  95059. }
  95060. declare module BABYLON {
  95061. /** @hidden */
  95062. export var vrMultiviewToSingleviewPixelShader: {
  95063. name: string;
  95064. shader: string;
  95065. };
  95066. }
  95067. declare module BABYLON {
  95068. /**
  95069. * Renders to multiple views with a single draw call
  95070. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  95071. */
  95072. export class MultiviewRenderTarget extends RenderTargetTexture {
  95073. /**
  95074. * Creates a multiview render target
  95075. * @param scene scene used with the render target
  95076. * @param size the size of the render target (used for each view)
  95077. */
  95078. constructor(scene: Scene, size?: number | {
  95079. width: number;
  95080. height: number;
  95081. } | {
  95082. ratio: number;
  95083. });
  95084. /**
  95085. * @hidden
  95086. * @param faceIndex the face index, if its a cube texture
  95087. */
  95088. _bindFrameBuffer(faceIndex?: number): void;
  95089. /**
  95090. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95091. * @returns the view count
  95092. */
  95093. getViewCount(): number;
  95094. }
  95095. }
  95096. declare module BABYLON {
  95097. /**
  95098. * Represents a camera frustum
  95099. */
  95100. export class Frustum {
  95101. /**
  95102. * Gets the planes representing the frustum
  95103. * @param transform matrix to be applied to the returned planes
  95104. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  95105. */
  95106. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  95107. /**
  95108. * Gets the near frustum plane transformed by the transform matrix
  95109. * @param transform transformation matrix to be applied to the resulting frustum plane
  95110. * @param frustumPlane the resuling frustum plane
  95111. */
  95112. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95113. /**
  95114. * Gets the far frustum plane transformed by the transform matrix
  95115. * @param transform transformation matrix to be applied to the resulting frustum plane
  95116. * @param frustumPlane the resuling frustum plane
  95117. */
  95118. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95119. /**
  95120. * Gets the left frustum plane transformed by the transform matrix
  95121. * @param transform transformation matrix to be applied to the resulting frustum plane
  95122. * @param frustumPlane the resuling frustum plane
  95123. */
  95124. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95125. /**
  95126. * Gets the right frustum plane transformed by the transform matrix
  95127. * @param transform transformation matrix to be applied to the resulting frustum plane
  95128. * @param frustumPlane the resuling frustum plane
  95129. */
  95130. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95131. /**
  95132. * Gets the top frustum plane transformed by the transform matrix
  95133. * @param transform transformation matrix to be applied to the resulting frustum plane
  95134. * @param frustumPlane the resuling frustum plane
  95135. */
  95136. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95137. /**
  95138. * Gets the bottom frustum plane transformed by the transform matrix
  95139. * @param transform transformation matrix to be applied to the resulting frustum plane
  95140. * @param frustumPlane the resuling frustum plane
  95141. */
  95142. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  95143. /**
  95144. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  95145. * @param transform transformation matrix to be applied to the resulting frustum planes
  95146. * @param frustumPlanes the resuling frustum planes
  95147. */
  95148. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  95149. }
  95150. }
  95151. declare module BABYLON {
  95152. interface Engine {
  95153. /**
  95154. * Creates a new multiview render target
  95155. * @param width defines the width of the texture
  95156. * @param height defines the height of the texture
  95157. * @returns the created multiview texture
  95158. */
  95159. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  95160. /**
  95161. * Binds a multiview framebuffer to be drawn to
  95162. * @param multiviewTexture texture to bind
  95163. */
  95164. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  95165. }
  95166. interface Camera {
  95167. /**
  95168. * @hidden
  95169. * 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)
  95170. */
  95171. _useMultiviewToSingleView: boolean;
  95172. /**
  95173. * @hidden
  95174. * 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)
  95175. */
  95176. _multiviewTexture: Nullable<RenderTargetTexture>;
  95177. /**
  95178. * @hidden
  95179. * ensures the multiview texture of the camera exists and has the specified width/height
  95180. * @param width height to set on the multiview texture
  95181. * @param height width to set on the multiview texture
  95182. */
  95183. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  95184. }
  95185. interface Scene {
  95186. /** @hidden */
  95187. _transformMatrixR: Matrix;
  95188. /** @hidden */
  95189. _multiviewSceneUbo: Nullable<UniformBuffer>;
  95190. /** @hidden */
  95191. _createMultiviewUbo(): void;
  95192. /** @hidden */
  95193. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  95194. /** @hidden */
  95195. _renderMultiviewToSingleView(camera: Camera): void;
  95196. }
  95197. }
  95198. declare module BABYLON {
  95199. /**
  95200. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  95201. * This will not be used for webXR as it supports displaying texture arrays directly
  95202. */
  95203. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  95204. /**
  95205. * Initializes a VRMultiviewToSingleview
  95206. * @param name name of the post process
  95207. * @param camera camera to be applied to
  95208. * @param scaleFactor scaling factor to the size of the output texture
  95209. */
  95210. constructor(name: string, camera: Camera, scaleFactor: number);
  95211. }
  95212. }
  95213. declare module BABYLON {
  95214. /**
  95215. * Interface used to define additional presentation attributes
  95216. */
  95217. export interface IVRPresentationAttributes {
  95218. /**
  95219. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  95220. */
  95221. highRefreshRate: boolean;
  95222. /**
  95223. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  95224. */
  95225. foveationLevel: number;
  95226. }
  95227. interface Engine {
  95228. /** @hidden */
  95229. _vrDisplay: any;
  95230. /** @hidden */
  95231. _vrSupported: boolean;
  95232. /** @hidden */
  95233. _oldSize: Size;
  95234. /** @hidden */
  95235. _oldHardwareScaleFactor: number;
  95236. /** @hidden */
  95237. _vrExclusivePointerMode: boolean;
  95238. /** @hidden */
  95239. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  95240. /** @hidden */
  95241. _onVRDisplayPointerRestricted: () => void;
  95242. /** @hidden */
  95243. _onVRDisplayPointerUnrestricted: () => void;
  95244. /** @hidden */
  95245. _onVrDisplayConnect: Nullable<(display: any) => void>;
  95246. /** @hidden */
  95247. _onVrDisplayDisconnect: Nullable<() => void>;
  95248. /** @hidden */
  95249. _onVrDisplayPresentChange: Nullable<() => void>;
  95250. /**
  95251. * Observable signaled when VR display mode changes
  95252. */
  95253. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  95254. /**
  95255. * Observable signaled when VR request present is complete
  95256. */
  95257. onVRRequestPresentComplete: Observable<boolean>;
  95258. /**
  95259. * Observable signaled when VR request present starts
  95260. */
  95261. onVRRequestPresentStart: Observable<Engine>;
  95262. /**
  95263. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  95264. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  95265. */
  95266. isInVRExclusivePointerMode: boolean;
  95267. /**
  95268. * Gets a boolean indicating if a webVR device was detected
  95269. * @returns true if a webVR device was detected
  95270. */
  95271. isVRDevicePresent(): boolean;
  95272. /**
  95273. * Gets the current webVR device
  95274. * @returns the current webVR device (or null)
  95275. */
  95276. getVRDevice(): any;
  95277. /**
  95278. * Initializes a webVR display and starts listening to display change events
  95279. * The onVRDisplayChangedObservable will be notified upon these changes
  95280. * @returns A promise containing a VRDisplay and if vr is supported
  95281. */
  95282. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  95283. /** @hidden */
  95284. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  95285. /**
  95286. * Gets or sets the presentation attributes used to configure VR rendering
  95287. */
  95288. vrPresentationAttributes?: IVRPresentationAttributes;
  95289. /**
  95290. * Call this function to switch to webVR mode
  95291. * Will do nothing if webVR is not supported or if there is no webVR device
  95292. * @param options the webvr options provided to the camera. mainly used for multiview
  95293. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95294. */
  95295. enableVR(options: WebVROptions): void;
  95296. /** @hidden */
  95297. _onVRFullScreenTriggered(): void;
  95298. }
  95299. }
  95300. declare module BABYLON {
  95301. /**
  95302. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  95303. * IMPORTANT!! The data is right-hand data.
  95304. * @export
  95305. * @interface DevicePose
  95306. */
  95307. export interface DevicePose {
  95308. /**
  95309. * The position of the device, values in array are [x,y,z].
  95310. */
  95311. readonly position: Nullable<Float32Array>;
  95312. /**
  95313. * The linearVelocity of the device, values in array are [x,y,z].
  95314. */
  95315. readonly linearVelocity: Nullable<Float32Array>;
  95316. /**
  95317. * The linearAcceleration of the device, values in array are [x,y,z].
  95318. */
  95319. readonly linearAcceleration: Nullable<Float32Array>;
  95320. /**
  95321. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  95322. */
  95323. readonly orientation: Nullable<Float32Array>;
  95324. /**
  95325. * The angularVelocity of the device, values in array are [x,y,z].
  95326. */
  95327. readonly angularVelocity: Nullable<Float32Array>;
  95328. /**
  95329. * The angularAcceleration of the device, values in array are [x,y,z].
  95330. */
  95331. readonly angularAcceleration: Nullable<Float32Array>;
  95332. }
  95333. /**
  95334. * Interface representing a pose controlled object in Babylon.
  95335. * A pose controlled object has both regular pose values as well as pose values
  95336. * from an external device such as a VR head mounted display
  95337. */
  95338. export interface PoseControlled {
  95339. /**
  95340. * The position of the object in babylon space.
  95341. */
  95342. position: Vector3;
  95343. /**
  95344. * The rotation quaternion of the object in babylon space.
  95345. */
  95346. rotationQuaternion: Quaternion;
  95347. /**
  95348. * The position of the device in babylon space.
  95349. */
  95350. devicePosition?: Vector3;
  95351. /**
  95352. * The rotation quaternion of the device in babylon space.
  95353. */
  95354. deviceRotationQuaternion: Quaternion;
  95355. /**
  95356. * The raw pose coming from the device.
  95357. */
  95358. rawPose: Nullable<DevicePose>;
  95359. /**
  95360. * The scale of the device to be used when translating from device space to babylon space.
  95361. */
  95362. deviceScaleFactor: number;
  95363. /**
  95364. * Updates the poseControlled values based on the input device pose.
  95365. * @param poseData the pose data to update the object with
  95366. */
  95367. updateFromDevice(poseData: DevicePose): void;
  95368. }
  95369. /**
  95370. * Set of options to customize the webVRCamera
  95371. */
  95372. export interface WebVROptions {
  95373. /**
  95374. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  95375. */
  95376. trackPosition?: boolean;
  95377. /**
  95378. * Sets the scale of the vrDevice in babylon space. (default: 1)
  95379. */
  95380. positionScale?: number;
  95381. /**
  95382. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  95383. */
  95384. displayName?: string;
  95385. /**
  95386. * Should the native controller meshes be initialized. (default: true)
  95387. */
  95388. controllerMeshes?: boolean;
  95389. /**
  95390. * Creating a default HemiLight only on controllers. (default: true)
  95391. */
  95392. defaultLightingOnControllers?: boolean;
  95393. /**
  95394. * If you don't want to use the default VR button of the helper. (default: false)
  95395. */
  95396. useCustomVRButton?: boolean;
  95397. /**
  95398. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  95399. */
  95400. customVRButton?: HTMLButtonElement;
  95401. /**
  95402. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  95403. */
  95404. rayLength?: number;
  95405. /**
  95406. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  95407. */
  95408. defaultHeight?: number;
  95409. /**
  95410. * If multiview should be used if availible (default: false)
  95411. */
  95412. useMultiview?: boolean;
  95413. }
  95414. /**
  95415. * This represents a WebVR camera.
  95416. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  95417. * @example http://doc.babylonjs.com/how_to/webvr_camera
  95418. */
  95419. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  95420. private webVROptions;
  95421. /**
  95422. * @hidden
  95423. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  95424. */
  95425. _vrDevice: any;
  95426. /**
  95427. * The rawPose of the vrDevice.
  95428. */
  95429. rawPose: Nullable<DevicePose>;
  95430. private _onVREnabled;
  95431. private _specsVersion;
  95432. private _attached;
  95433. private _frameData;
  95434. protected _descendants: Array<Node>;
  95435. private _deviceRoomPosition;
  95436. /** @hidden */
  95437. _deviceRoomRotationQuaternion: Quaternion;
  95438. private _standingMatrix;
  95439. /**
  95440. * Represents device position in babylon space.
  95441. */
  95442. devicePosition: Vector3;
  95443. /**
  95444. * Represents device rotation in babylon space.
  95445. */
  95446. deviceRotationQuaternion: Quaternion;
  95447. /**
  95448. * The scale of the device to be used when translating from device space to babylon space.
  95449. */
  95450. deviceScaleFactor: number;
  95451. private _deviceToWorld;
  95452. private _worldToDevice;
  95453. /**
  95454. * References to the webVR controllers for the vrDevice.
  95455. */
  95456. controllers: Array<WebVRController>;
  95457. /**
  95458. * Emits an event when a controller is attached.
  95459. */
  95460. onControllersAttachedObservable: Observable<WebVRController[]>;
  95461. /**
  95462. * Emits an event when a controller's mesh has been loaded;
  95463. */
  95464. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95465. /**
  95466. * Emits an event when the HMD's pose has been updated.
  95467. */
  95468. onPoseUpdatedFromDeviceObservable: Observable<any>;
  95469. private _poseSet;
  95470. /**
  95471. * If the rig cameras be used as parent instead of this camera.
  95472. */
  95473. rigParenting: boolean;
  95474. private _lightOnControllers;
  95475. private _defaultHeight?;
  95476. /**
  95477. * Instantiates a WebVRFreeCamera.
  95478. * @param name The name of the WebVRFreeCamera
  95479. * @param position The starting anchor position for the camera
  95480. * @param scene The scene the camera belongs to
  95481. * @param webVROptions a set of customizable options for the webVRCamera
  95482. */
  95483. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  95484. /**
  95485. * Gets the device distance from the ground in meters.
  95486. * @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.
  95487. */
  95488. deviceDistanceToRoomGround(): number;
  95489. /**
  95490. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95491. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  95492. */
  95493. useStandingMatrix(callback?: (bool: boolean) => void): void;
  95494. /**
  95495. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  95496. * @returns A promise with a boolean set to if the standing matrix is supported.
  95497. */
  95498. useStandingMatrixAsync(): Promise<boolean>;
  95499. /**
  95500. * Disposes the camera
  95501. */
  95502. dispose(): void;
  95503. /**
  95504. * Gets a vrController by name.
  95505. * @param name The name of the controller to retreive
  95506. * @returns the controller matching the name specified or null if not found
  95507. */
  95508. getControllerByName(name: string): Nullable<WebVRController>;
  95509. private _leftController;
  95510. /**
  95511. * The controller corresponding to the users left hand.
  95512. */
  95513. get leftController(): Nullable<WebVRController>;
  95514. private _rightController;
  95515. /**
  95516. * The controller corresponding to the users right hand.
  95517. */
  95518. get rightController(): Nullable<WebVRController>;
  95519. /**
  95520. * Casts a ray forward from the vrCamera's gaze.
  95521. * @param length Length of the ray (default: 100)
  95522. * @returns the ray corresponding to the gaze
  95523. */
  95524. getForwardRay(length?: number): Ray;
  95525. /**
  95526. * @hidden
  95527. * Updates the camera based on device's frame data
  95528. */
  95529. _checkInputs(): void;
  95530. /**
  95531. * Updates the poseControlled values based on the input device pose.
  95532. * @param poseData Pose coming from the device
  95533. */
  95534. updateFromDevice(poseData: DevicePose): void;
  95535. private _htmlElementAttached;
  95536. private _detachIfAttached;
  95537. /**
  95538. * WebVR's attach control will start broadcasting frames to the device.
  95539. * Note that in certain browsers (chrome for example) this function must be called
  95540. * within a user-interaction callback. Example:
  95541. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  95542. *
  95543. * @param element html element to attach the vrDevice to
  95544. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  95545. */
  95546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95547. /**
  95548. * Detaches the camera from the html element and disables VR
  95549. *
  95550. * @param element html element to detach from
  95551. */
  95552. detachControl(element: HTMLElement): void;
  95553. /**
  95554. * @returns the name of this class
  95555. */
  95556. getClassName(): string;
  95557. /**
  95558. * Calls resetPose on the vrDisplay
  95559. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  95560. */
  95561. resetToCurrentRotation(): void;
  95562. /**
  95563. * @hidden
  95564. * Updates the rig cameras (left and right eye)
  95565. */
  95566. _updateRigCameras(): void;
  95567. private _workingVector;
  95568. private _oneVector;
  95569. private _workingMatrix;
  95570. private updateCacheCalled;
  95571. private _correctPositionIfNotTrackPosition;
  95572. /**
  95573. * @hidden
  95574. * Updates the cached values of the camera
  95575. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  95576. */
  95577. _updateCache(ignoreParentClass?: boolean): void;
  95578. /**
  95579. * @hidden
  95580. * Get current device position in babylon world
  95581. */
  95582. _computeDevicePosition(): void;
  95583. /**
  95584. * Updates the current device position and rotation in the babylon world
  95585. */
  95586. update(): void;
  95587. /**
  95588. * @hidden
  95589. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  95590. * @returns an identity matrix
  95591. */
  95592. _getViewMatrix(): Matrix;
  95593. private _tmpMatrix;
  95594. /**
  95595. * This function is called by the two RIG cameras.
  95596. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  95597. * @hidden
  95598. */
  95599. _getWebVRViewMatrix(): Matrix;
  95600. /** @hidden */
  95601. _getWebVRProjectionMatrix(): Matrix;
  95602. private _onGamepadConnectedObserver;
  95603. private _onGamepadDisconnectedObserver;
  95604. private _updateCacheWhenTrackingDisabledObserver;
  95605. /**
  95606. * Initializes the controllers and their meshes
  95607. */
  95608. initControllers(): void;
  95609. }
  95610. }
  95611. declare module BABYLON {
  95612. /**
  95613. * Size options for a post process
  95614. */
  95615. export type PostProcessOptions = {
  95616. width: number;
  95617. height: number;
  95618. };
  95619. /**
  95620. * PostProcess can be used to apply a shader to a texture after it has been rendered
  95621. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  95622. */
  95623. export class PostProcess {
  95624. /** Name of the PostProcess. */
  95625. name: string;
  95626. /**
  95627. * Gets or sets the unique id of the post process
  95628. */
  95629. uniqueId: number;
  95630. /**
  95631. * Width of the texture to apply the post process on
  95632. */
  95633. width: number;
  95634. /**
  95635. * Height of the texture to apply the post process on
  95636. */
  95637. height: number;
  95638. /**
  95639. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  95640. * @hidden
  95641. */
  95642. _outputTexture: Nullable<InternalTexture>;
  95643. /**
  95644. * Sampling mode used by the shader
  95645. * See https://doc.babylonjs.com/classes/3.1/texture
  95646. */
  95647. renderTargetSamplingMode: number;
  95648. /**
  95649. * Clear color to use when screen clearing
  95650. */
  95651. clearColor: Color4;
  95652. /**
  95653. * If the buffer needs to be cleared before applying the post process. (default: true)
  95654. * Should be set to false if shader will overwrite all previous pixels.
  95655. */
  95656. autoClear: boolean;
  95657. /**
  95658. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  95659. */
  95660. alphaMode: number;
  95661. /**
  95662. * Sets the setAlphaBlendConstants of the babylon engine
  95663. */
  95664. alphaConstants: Color4;
  95665. /**
  95666. * Animations to be used for the post processing
  95667. */
  95668. animations: Animation[];
  95669. /**
  95670. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  95671. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  95672. */
  95673. enablePixelPerfectMode: boolean;
  95674. /**
  95675. * Force the postprocess to be applied without taking in account viewport
  95676. */
  95677. forceFullscreenViewport: boolean;
  95678. /**
  95679. * List of inspectable custom properties (used by the Inspector)
  95680. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95681. */
  95682. inspectableCustomProperties: IInspectable[];
  95683. /**
  95684. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  95685. *
  95686. * | Value | Type | Description |
  95687. * | ----- | ----------------------------------- | ----------- |
  95688. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  95689. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  95690. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  95691. *
  95692. */
  95693. scaleMode: number;
  95694. /**
  95695. * Force textures to be a power of two (default: false)
  95696. */
  95697. alwaysForcePOT: boolean;
  95698. private _samples;
  95699. /**
  95700. * Number of sample textures (default: 1)
  95701. */
  95702. get samples(): number;
  95703. set samples(n: number);
  95704. /**
  95705. * Modify the scale of the post process to be the same as the viewport (default: false)
  95706. */
  95707. adaptScaleToCurrentViewport: boolean;
  95708. private _camera;
  95709. private _scene;
  95710. private _engine;
  95711. private _options;
  95712. private _reusable;
  95713. private _textureType;
  95714. private _textureFormat;
  95715. /**
  95716. * Smart array of input and output textures for the post process.
  95717. * @hidden
  95718. */
  95719. _textures: SmartArray<InternalTexture>;
  95720. /**
  95721. * The index in _textures that corresponds to the output texture.
  95722. * @hidden
  95723. */
  95724. _currentRenderTextureInd: number;
  95725. private _effect;
  95726. private _samplers;
  95727. private _fragmentUrl;
  95728. private _vertexUrl;
  95729. private _parameters;
  95730. private _scaleRatio;
  95731. protected _indexParameters: any;
  95732. private _shareOutputWithPostProcess;
  95733. private _texelSize;
  95734. private _forcedOutputTexture;
  95735. /**
  95736. * Returns the fragment url or shader name used in the post process.
  95737. * @returns the fragment url or name in the shader store.
  95738. */
  95739. getEffectName(): string;
  95740. /**
  95741. * An event triggered when the postprocess is activated.
  95742. */
  95743. onActivateObservable: Observable<Camera>;
  95744. private _onActivateObserver;
  95745. /**
  95746. * A function that is added to the onActivateObservable
  95747. */
  95748. set onActivate(callback: Nullable<(camera: Camera) => void>);
  95749. /**
  95750. * An event triggered when the postprocess changes its size.
  95751. */
  95752. onSizeChangedObservable: Observable<PostProcess>;
  95753. private _onSizeChangedObserver;
  95754. /**
  95755. * A function that is added to the onSizeChangedObservable
  95756. */
  95757. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  95758. /**
  95759. * An event triggered when the postprocess applies its effect.
  95760. */
  95761. onApplyObservable: Observable<Effect>;
  95762. private _onApplyObserver;
  95763. /**
  95764. * A function that is added to the onApplyObservable
  95765. */
  95766. set onApply(callback: (effect: Effect) => void);
  95767. /**
  95768. * An event triggered before rendering the postprocess
  95769. */
  95770. onBeforeRenderObservable: Observable<Effect>;
  95771. private _onBeforeRenderObserver;
  95772. /**
  95773. * A function that is added to the onBeforeRenderObservable
  95774. */
  95775. set onBeforeRender(callback: (effect: Effect) => void);
  95776. /**
  95777. * An event triggered after rendering the postprocess
  95778. */
  95779. onAfterRenderObservable: Observable<Effect>;
  95780. private _onAfterRenderObserver;
  95781. /**
  95782. * A function that is added to the onAfterRenderObservable
  95783. */
  95784. set onAfterRender(callback: (efect: Effect) => void);
  95785. /**
  95786. * 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
  95787. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  95788. */
  95789. get inputTexture(): InternalTexture;
  95790. set inputTexture(value: InternalTexture);
  95791. /**
  95792. * Gets the camera which post process is applied to.
  95793. * @returns The camera the post process is applied to.
  95794. */
  95795. getCamera(): Camera;
  95796. /**
  95797. * Gets the texel size of the postprocess.
  95798. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  95799. */
  95800. get texelSize(): Vector2;
  95801. /**
  95802. * Creates a new instance PostProcess
  95803. * @param name The name of the PostProcess.
  95804. * @param fragmentUrl The url of the fragment shader to be used.
  95805. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  95806. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  95807. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  95808. * @param camera The camera to apply the render pass to.
  95809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95810. * @param engine The engine which the post process will be applied. (default: current engine)
  95811. * @param reusable If the post process can be reused on the same frame. (default: false)
  95812. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  95813. * @param textureType Type of textures used when performing the post process. (default: 0)
  95814. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  95815. * @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
  95816. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  95817. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  95818. */
  95819. constructor(
  95820. /** Name of the PostProcess. */
  95821. 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);
  95822. /**
  95823. * Gets a string idenfifying the name of the class
  95824. * @returns "PostProcess" string
  95825. */
  95826. getClassName(): string;
  95827. /**
  95828. * Gets the engine which this post process belongs to.
  95829. * @returns The engine the post process was enabled with.
  95830. */
  95831. getEngine(): Engine;
  95832. /**
  95833. * The effect that is created when initializing the post process.
  95834. * @returns The created effect corresponding the the postprocess.
  95835. */
  95836. getEffect(): Effect;
  95837. /**
  95838. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  95839. * @param postProcess The post process to share the output with.
  95840. * @returns This post process.
  95841. */
  95842. shareOutputWith(postProcess: PostProcess): PostProcess;
  95843. /**
  95844. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  95845. * This should be called if the post process that shares output with this post process is disabled/disposed.
  95846. */
  95847. useOwnOutput(): void;
  95848. /**
  95849. * Updates the effect with the current post process compile time values and recompiles the shader.
  95850. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  95851. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  95852. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  95853. * @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
  95854. * @param onCompiled Called when the shader has been compiled.
  95855. * @param onError Called if there is an error when compiling a shader.
  95856. */
  95857. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  95858. /**
  95859. * The post process is reusable if it can be used multiple times within one frame.
  95860. * @returns If the post process is reusable
  95861. */
  95862. isReusable(): boolean;
  95863. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  95864. markTextureDirty(): void;
  95865. /**
  95866. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  95867. * 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.
  95868. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  95869. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  95870. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  95871. * @returns The target texture that was bound to be written to.
  95872. */
  95873. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  95874. /**
  95875. * If the post process is supported.
  95876. */
  95877. get isSupported(): boolean;
  95878. /**
  95879. * The aspect ratio of the output texture.
  95880. */
  95881. get aspectRatio(): number;
  95882. /**
  95883. * Get a value indicating if the post-process is ready to be used
  95884. * @returns true if the post-process is ready (shader is compiled)
  95885. */
  95886. isReady(): boolean;
  95887. /**
  95888. * Binds all textures and uniforms to the shader, this will be run on every pass.
  95889. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  95890. */
  95891. apply(): Nullable<Effect>;
  95892. private _disposeTextures;
  95893. /**
  95894. * Disposes the post process.
  95895. * @param camera The camera to dispose the post process on.
  95896. */
  95897. dispose(camera?: Camera): void;
  95898. }
  95899. }
  95900. declare module BABYLON {
  95901. /** @hidden */
  95902. export var kernelBlurVaryingDeclaration: {
  95903. name: string;
  95904. shader: string;
  95905. };
  95906. }
  95907. declare module BABYLON {
  95908. /** @hidden */
  95909. export var kernelBlurFragment: {
  95910. name: string;
  95911. shader: string;
  95912. };
  95913. }
  95914. declare module BABYLON {
  95915. /** @hidden */
  95916. export var kernelBlurFragment2: {
  95917. name: string;
  95918. shader: string;
  95919. };
  95920. }
  95921. declare module BABYLON {
  95922. /** @hidden */
  95923. export var kernelBlurPixelShader: {
  95924. name: string;
  95925. shader: string;
  95926. };
  95927. }
  95928. declare module BABYLON {
  95929. /** @hidden */
  95930. export var kernelBlurVertex: {
  95931. name: string;
  95932. shader: string;
  95933. };
  95934. }
  95935. declare module BABYLON {
  95936. /** @hidden */
  95937. export var kernelBlurVertexShader: {
  95938. name: string;
  95939. shader: string;
  95940. };
  95941. }
  95942. declare module BABYLON {
  95943. /**
  95944. * The Blur Post Process which blurs an image based on a kernel and direction.
  95945. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  95946. */
  95947. export class BlurPostProcess extends PostProcess {
  95948. /** The direction in which to blur the image. */
  95949. direction: Vector2;
  95950. private blockCompilation;
  95951. protected _kernel: number;
  95952. protected _idealKernel: number;
  95953. protected _packedFloat: boolean;
  95954. private _staticDefines;
  95955. /**
  95956. * Sets the length in pixels of the blur sample region
  95957. */
  95958. set kernel(v: number);
  95959. /**
  95960. * Gets the length in pixels of the blur sample region
  95961. */
  95962. get kernel(): number;
  95963. /**
  95964. * Sets wether or not the blur needs to unpack/repack floats
  95965. */
  95966. set packedFloat(v: boolean);
  95967. /**
  95968. * Gets wether or not the blur is unpacking/repacking floats
  95969. */
  95970. get packedFloat(): boolean;
  95971. /**
  95972. * Creates a new instance BlurPostProcess
  95973. * @param name The name of the effect.
  95974. * @param direction The direction in which to blur the image.
  95975. * @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.
  95976. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  95977. * @param camera The camera to apply the render pass to.
  95978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95979. * @param engine The engine which the post process will be applied. (default: current engine)
  95980. * @param reusable If the post process can be reused on the same frame. (default: false)
  95981. * @param textureType Type of textures used when performing the post process. (default: 0)
  95982. * @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)
  95983. */
  95984. constructor(name: string,
  95985. /** The direction in which to blur the image. */
  95986. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  95987. /**
  95988. * Updates the effect with the current post process compile time values and recompiles the shader.
  95989. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  95990. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  95991. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  95992. * @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
  95993. * @param onCompiled Called when the shader has been compiled.
  95994. * @param onError Called if there is an error when compiling a shader.
  95995. */
  95996. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  95997. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  95998. /**
  95999. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  96000. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  96001. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  96002. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  96003. * The gaps between physical kernels are compensated for in the weighting of the samples
  96004. * @param idealKernel Ideal blur kernel.
  96005. * @return Nearest best kernel.
  96006. */
  96007. protected _nearestBestKernel(idealKernel: number): number;
  96008. /**
  96009. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  96010. * @param x The point on the Gaussian distribution to sample.
  96011. * @return the value of the Gaussian function at x.
  96012. */
  96013. protected _gaussianWeight(x: number): number;
  96014. /**
  96015. * Generates a string that can be used as a floating point number in GLSL.
  96016. * @param x Value to print.
  96017. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  96018. * @return GLSL float string.
  96019. */
  96020. protected _glslFloat(x: number, decimalFigures?: number): string;
  96021. }
  96022. }
  96023. declare module BABYLON {
  96024. /**
  96025. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96026. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96027. * You can then easily use it as a reflectionTexture on a flat surface.
  96028. * In case the surface is not a plane, please consider relying on reflection probes.
  96029. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96030. */
  96031. export class MirrorTexture extends RenderTargetTexture {
  96032. private scene;
  96033. /**
  96034. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  96035. * 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.
  96036. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96037. */
  96038. mirrorPlane: Plane;
  96039. /**
  96040. * Define the blur ratio used to blur the reflection if needed.
  96041. */
  96042. set blurRatio(value: number);
  96043. get blurRatio(): number;
  96044. /**
  96045. * Define the adaptive blur kernel used to blur the reflection if needed.
  96046. * This will autocompute the closest best match for the `blurKernel`
  96047. */
  96048. set adaptiveBlurKernel(value: number);
  96049. /**
  96050. * Define the blur kernel used to blur the reflection if needed.
  96051. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96052. */
  96053. set blurKernel(value: number);
  96054. /**
  96055. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  96056. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96057. */
  96058. set blurKernelX(value: number);
  96059. get blurKernelX(): number;
  96060. /**
  96061. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  96062. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  96063. */
  96064. set blurKernelY(value: number);
  96065. get blurKernelY(): number;
  96066. private _autoComputeBlurKernel;
  96067. protected _onRatioRescale(): void;
  96068. private _updateGammaSpace;
  96069. private _imageProcessingConfigChangeObserver;
  96070. private _transformMatrix;
  96071. private _mirrorMatrix;
  96072. private _savedViewMatrix;
  96073. private _blurX;
  96074. private _blurY;
  96075. private _adaptiveBlurKernel;
  96076. private _blurKernelX;
  96077. private _blurKernelY;
  96078. private _blurRatio;
  96079. /**
  96080. * Instantiates a Mirror Texture.
  96081. * Mirror texture can be used to simulate the view from a mirror in a scene.
  96082. * It will dynamically be rendered every frame to adapt to the camera point of view.
  96083. * You can then easily use it as a reflectionTexture on a flat surface.
  96084. * In case the surface is not a plane, please consider relying on reflection probes.
  96085. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  96086. * @param name
  96087. * @param size
  96088. * @param scene
  96089. * @param generateMipMaps
  96090. * @param type
  96091. * @param samplingMode
  96092. * @param generateDepthBuffer
  96093. */
  96094. constructor(name: string, size: number | {
  96095. width: number;
  96096. height: number;
  96097. } | {
  96098. ratio: number;
  96099. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  96100. private _preparePostProcesses;
  96101. /**
  96102. * Clone the mirror texture.
  96103. * @returns the cloned texture
  96104. */
  96105. clone(): MirrorTexture;
  96106. /**
  96107. * Serialize the texture to a JSON representation you could use in Parse later on
  96108. * @returns the serialized JSON representation
  96109. */
  96110. serialize(): any;
  96111. /**
  96112. * Dispose the texture and release its associated resources.
  96113. */
  96114. dispose(): void;
  96115. }
  96116. }
  96117. declare module BABYLON {
  96118. /**
  96119. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96120. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96121. */
  96122. export class Texture extends BaseTexture {
  96123. /**
  96124. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  96125. */
  96126. static SerializeBuffers: boolean;
  96127. /** @hidden */
  96128. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  96129. /** @hidden */
  96130. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  96131. /** @hidden */
  96132. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  96133. /** nearest is mag = nearest and min = nearest and mip = linear */
  96134. static readonly NEAREST_SAMPLINGMODE: number;
  96135. /** nearest is mag = nearest and min = nearest and mip = linear */
  96136. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  96137. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96138. static readonly BILINEAR_SAMPLINGMODE: number;
  96139. /** Bilinear is mag = linear and min = linear and mip = nearest */
  96140. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  96141. /** Trilinear is mag = linear and min = linear and mip = linear */
  96142. static readonly TRILINEAR_SAMPLINGMODE: number;
  96143. /** Trilinear is mag = linear and min = linear and mip = linear */
  96144. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  96145. /** mag = nearest and min = nearest and mip = nearest */
  96146. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  96147. /** mag = nearest and min = linear and mip = nearest */
  96148. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  96149. /** mag = nearest and min = linear and mip = linear */
  96150. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  96151. /** mag = nearest and min = linear and mip = none */
  96152. static readonly NEAREST_LINEAR: number;
  96153. /** mag = nearest and min = nearest and mip = none */
  96154. static readonly NEAREST_NEAREST: number;
  96155. /** mag = linear and min = nearest and mip = nearest */
  96156. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  96157. /** mag = linear and min = nearest and mip = linear */
  96158. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  96159. /** mag = linear and min = linear and mip = none */
  96160. static readonly LINEAR_LINEAR: number;
  96161. /** mag = linear and min = nearest and mip = none */
  96162. static readonly LINEAR_NEAREST: number;
  96163. /** Explicit coordinates mode */
  96164. static readonly EXPLICIT_MODE: number;
  96165. /** Spherical coordinates mode */
  96166. static readonly SPHERICAL_MODE: number;
  96167. /** Planar coordinates mode */
  96168. static readonly PLANAR_MODE: number;
  96169. /** Cubic coordinates mode */
  96170. static readonly CUBIC_MODE: number;
  96171. /** Projection coordinates mode */
  96172. static readonly PROJECTION_MODE: number;
  96173. /** Inverse Cubic coordinates mode */
  96174. static readonly SKYBOX_MODE: number;
  96175. /** Inverse Cubic coordinates mode */
  96176. static readonly INVCUBIC_MODE: number;
  96177. /** Equirectangular coordinates mode */
  96178. static readonly EQUIRECTANGULAR_MODE: number;
  96179. /** Equirectangular Fixed coordinates mode */
  96180. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  96181. /** Equirectangular Fixed Mirrored coordinates mode */
  96182. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  96183. /** Texture is not repeating outside of 0..1 UVs */
  96184. static readonly CLAMP_ADDRESSMODE: number;
  96185. /** Texture is repeating outside of 0..1 UVs */
  96186. static readonly WRAP_ADDRESSMODE: number;
  96187. /** Texture is repeating and mirrored */
  96188. static readonly MIRROR_ADDRESSMODE: number;
  96189. /**
  96190. * 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
  96191. */
  96192. static UseSerializedUrlIfAny: boolean;
  96193. /**
  96194. * Define the url of the texture.
  96195. */
  96196. url: Nullable<string>;
  96197. /**
  96198. * Define an offset on the texture to offset the u coordinates of the UVs
  96199. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96200. */
  96201. uOffset: number;
  96202. /**
  96203. * Define an offset on the texture to offset the v coordinates of the UVs
  96204. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  96205. */
  96206. vOffset: number;
  96207. /**
  96208. * Define an offset on the texture to scale the u coordinates of the UVs
  96209. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96210. */
  96211. uScale: number;
  96212. /**
  96213. * Define an offset on the texture to scale the v coordinates of the UVs
  96214. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  96215. */
  96216. vScale: number;
  96217. /**
  96218. * Define an offset on the texture to rotate around the u coordinates of the UVs
  96219. * @see http://doc.babylonjs.com/how_to/more_materials
  96220. */
  96221. uAng: number;
  96222. /**
  96223. * Define an offset on the texture to rotate around the v coordinates of the UVs
  96224. * @see http://doc.babylonjs.com/how_to/more_materials
  96225. */
  96226. vAng: number;
  96227. /**
  96228. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  96229. * @see http://doc.babylonjs.com/how_to/more_materials
  96230. */
  96231. wAng: number;
  96232. /**
  96233. * Defines the center of rotation (U)
  96234. */
  96235. uRotationCenter: number;
  96236. /**
  96237. * Defines the center of rotation (V)
  96238. */
  96239. vRotationCenter: number;
  96240. /**
  96241. * Defines the center of rotation (W)
  96242. */
  96243. wRotationCenter: number;
  96244. /**
  96245. * Are mip maps generated for this texture or not.
  96246. */
  96247. get noMipmap(): boolean;
  96248. /**
  96249. * List of inspectable custom properties (used by the Inspector)
  96250. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96251. */
  96252. inspectableCustomProperties: Nullable<IInspectable[]>;
  96253. private _noMipmap;
  96254. /** @hidden */
  96255. _invertY: boolean;
  96256. private _rowGenerationMatrix;
  96257. private _cachedTextureMatrix;
  96258. private _projectionModeMatrix;
  96259. private _t0;
  96260. private _t1;
  96261. private _t2;
  96262. private _cachedUOffset;
  96263. private _cachedVOffset;
  96264. private _cachedUScale;
  96265. private _cachedVScale;
  96266. private _cachedUAng;
  96267. private _cachedVAng;
  96268. private _cachedWAng;
  96269. private _cachedProjectionMatrixId;
  96270. private _cachedCoordinatesMode;
  96271. /** @hidden */
  96272. protected _initialSamplingMode: number;
  96273. /** @hidden */
  96274. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  96275. private _deleteBuffer;
  96276. protected _format: Nullable<number>;
  96277. private _delayedOnLoad;
  96278. private _delayedOnError;
  96279. private _mimeType?;
  96280. /**
  96281. * Observable triggered once the texture has been loaded.
  96282. */
  96283. onLoadObservable: Observable<Texture>;
  96284. protected _isBlocking: boolean;
  96285. /**
  96286. * Is the texture preventing material to render while loading.
  96287. * If false, a default texture will be used instead of the loading one during the preparation step.
  96288. */
  96289. set isBlocking(value: boolean);
  96290. get isBlocking(): boolean;
  96291. /**
  96292. * Get the current sampling mode associated with the texture.
  96293. */
  96294. get samplingMode(): number;
  96295. /**
  96296. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  96297. */
  96298. get invertY(): boolean;
  96299. /**
  96300. * Instantiates a new texture.
  96301. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  96302. * @see http://doc.babylonjs.com/babylon101/materials#texture
  96303. * @param url defines the url of the picture to load as a texture
  96304. * @param scene defines the scene or engine the texture will belong to
  96305. * @param noMipmap defines if the texture will require mip maps or not
  96306. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  96307. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96308. * @param onLoad defines a callback triggered when the texture has been loaded
  96309. * @param onError defines a callback triggered when an error occurred during the loading session
  96310. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  96311. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  96312. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96313. * @param mimeType defines an optional mime type information
  96314. */
  96315. 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);
  96316. /**
  96317. * Update the url (and optional buffer) of this texture if url was null during construction.
  96318. * @param url the url of the texture
  96319. * @param buffer the buffer of the texture (defaults to null)
  96320. * @param onLoad callback called when the texture is loaded (defaults to null)
  96321. */
  96322. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  96323. /**
  96324. * Finish the loading sequence of a texture flagged as delayed load.
  96325. * @hidden
  96326. */
  96327. delayLoad(): void;
  96328. private _prepareRowForTextureGeneration;
  96329. /**
  96330. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  96331. * @returns the transform matrix of the texture.
  96332. */
  96333. getTextureMatrix(uBase?: number): Matrix;
  96334. /**
  96335. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  96336. * @returns The reflection texture transform
  96337. */
  96338. getReflectionTextureMatrix(): Matrix;
  96339. /**
  96340. * Clones the texture.
  96341. * @returns the cloned texture
  96342. */
  96343. clone(): Texture;
  96344. /**
  96345. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96346. * @returns The JSON representation of the texture
  96347. */
  96348. serialize(): any;
  96349. /**
  96350. * Get the current class name of the texture useful for serialization or dynamic coding.
  96351. * @returns "Texture"
  96352. */
  96353. getClassName(): string;
  96354. /**
  96355. * Dispose the texture and release its associated resources.
  96356. */
  96357. dispose(): void;
  96358. /**
  96359. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  96360. * @param parsedTexture Define the JSON representation of the texture
  96361. * @param scene Define the scene the parsed texture should be instantiated in
  96362. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  96363. * @returns The parsed texture if successful
  96364. */
  96365. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  96366. /**
  96367. * Creates a texture from its base 64 representation.
  96368. * @param data Define the base64 payload without the data: prefix
  96369. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96370. * @param scene Define the scene the texture should belong to
  96371. * @param noMipmap Forces the texture to not create mip map information if true
  96372. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96373. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96374. * @param onLoad define a callback triggered when the texture has been loaded
  96375. * @param onError define a callback triggered when an error occurred during the loading session
  96376. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96377. * @returns the created texture
  96378. */
  96379. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  96380. /**
  96381. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  96382. * @param data Define the base64 payload without the data: prefix
  96383. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  96384. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  96385. * @param scene Define the scene the texture should belong to
  96386. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  96387. * @param noMipmap Forces the texture to not create mip map information if true
  96388. * @param invertY define if the texture needs to be inverted on the y axis during loading
  96389. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  96390. * @param onLoad define a callback triggered when the texture has been loaded
  96391. * @param onError define a callback triggered when an error occurred during the loading session
  96392. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  96393. * @returns the created texture
  96394. */
  96395. 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;
  96396. }
  96397. }
  96398. declare module BABYLON {
  96399. /**
  96400. * PostProcessManager is used to manage one or more post processes or post process pipelines
  96401. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  96402. */
  96403. export class PostProcessManager {
  96404. private _scene;
  96405. private _indexBuffer;
  96406. private _vertexBuffers;
  96407. /**
  96408. * Creates a new instance PostProcess
  96409. * @param scene The scene that the post process is associated with.
  96410. */
  96411. constructor(scene: Scene);
  96412. private _prepareBuffers;
  96413. private _buildIndexBuffer;
  96414. /**
  96415. * Rebuilds the vertex buffers of the manager.
  96416. * @hidden
  96417. */
  96418. _rebuild(): void;
  96419. /**
  96420. * Prepares a frame to be run through a post process.
  96421. * @param sourceTexture The input texture to the post procesess. (default: null)
  96422. * @param postProcesses An array of post processes to be run. (default: null)
  96423. * @returns True if the post processes were able to be run.
  96424. * @hidden
  96425. */
  96426. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  96427. /**
  96428. * Manually render a set of post processes to a texture.
  96429. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  96430. * @param postProcesses An array of post processes to be run.
  96431. * @param targetTexture The target texture to render to.
  96432. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  96433. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  96434. * @param lodLevel defines which lod of the texture to render to
  96435. */
  96436. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  96437. /**
  96438. * Finalize the result of the output of the postprocesses.
  96439. * @param doNotPresent If true the result will not be displayed to the screen.
  96440. * @param targetTexture The target texture to render to.
  96441. * @param faceIndex The index of the face to bind the target texture to.
  96442. * @param postProcesses The array of post processes to render.
  96443. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  96444. * @hidden
  96445. */
  96446. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  96447. /**
  96448. * Disposes of the post process manager.
  96449. */
  96450. dispose(): void;
  96451. }
  96452. }
  96453. declare module BABYLON {
  96454. /**
  96455. * This Helps creating a texture that will be created from a camera in your scene.
  96456. * It is basically a dynamic texture that could be used to create special effects for instance.
  96457. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  96458. */
  96459. export class RenderTargetTexture extends Texture {
  96460. isCube: boolean;
  96461. /**
  96462. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  96463. */
  96464. static readonly REFRESHRATE_RENDER_ONCE: number;
  96465. /**
  96466. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  96467. */
  96468. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  96469. /**
  96470. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  96471. * the central point of your effect and can save a lot of performances.
  96472. */
  96473. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  96474. /**
  96475. * Use this predicate to dynamically define the list of mesh you want to render.
  96476. * If set, the renderList property will be overwritten.
  96477. */
  96478. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  96479. private _renderList;
  96480. /**
  96481. * Use this list to define the list of mesh you want to render.
  96482. */
  96483. get renderList(): Nullable<Array<AbstractMesh>>;
  96484. set renderList(value: Nullable<Array<AbstractMesh>>);
  96485. /**
  96486. * Use this function to overload the renderList array at rendering time.
  96487. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  96488. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  96489. * the cube (if the RTT is a cube, else layerOrFace=0).
  96490. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  96491. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  96492. * hold dummy elements!
  96493. */
  96494. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  96495. private _hookArray;
  96496. /**
  96497. * Define if particles should be rendered in your texture.
  96498. */
  96499. renderParticles: boolean;
  96500. /**
  96501. * Define if sprites should be rendered in your texture.
  96502. */
  96503. renderSprites: boolean;
  96504. /**
  96505. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  96506. */
  96507. coordinatesMode: number;
  96508. /**
  96509. * Define the camera used to render the texture.
  96510. */
  96511. activeCamera: Nullable<Camera>;
  96512. /**
  96513. * Override the mesh isReady function with your own one.
  96514. */
  96515. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  96516. /**
  96517. * Override the render function of the texture with your own one.
  96518. */
  96519. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  96520. /**
  96521. * Define if camera post processes should be use while rendering the texture.
  96522. */
  96523. useCameraPostProcesses: boolean;
  96524. /**
  96525. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  96526. */
  96527. ignoreCameraViewport: boolean;
  96528. private _postProcessManager;
  96529. private _postProcesses;
  96530. private _resizeObserver;
  96531. /**
  96532. * An event triggered when the texture is unbind.
  96533. */
  96534. onBeforeBindObservable: Observable<RenderTargetTexture>;
  96535. /**
  96536. * An event triggered when the texture is unbind.
  96537. */
  96538. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  96539. private _onAfterUnbindObserver;
  96540. /**
  96541. * Set a after unbind callback in the texture.
  96542. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  96543. */
  96544. set onAfterUnbind(callback: () => void);
  96545. /**
  96546. * An event triggered before rendering the texture
  96547. */
  96548. onBeforeRenderObservable: Observable<number>;
  96549. private _onBeforeRenderObserver;
  96550. /**
  96551. * Set a before render callback in the texture.
  96552. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  96553. */
  96554. set onBeforeRender(callback: (faceIndex: number) => void);
  96555. /**
  96556. * An event triggered after rendering the texture
  96557. */
  96558. onAfterRenderObservable: Observable<number>;
  96559. private _onAfterRenderObserver;
  96560. /**
  96561. * Set a after render callback in the texture.
  96562. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  96563. */
  96564. set onAfterRender(callback: (faceIndex: number) => void);
  96565. /**
  96566. * An event triggered after the texture clear
  96567. */
  96568. onClearObservable: Observable<Engine>;
  96569. private _onClearObserver;
  96570. /**
  96571. * Set a clear callback in the texture.
  96572. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  96573. */
  96574. set onClear(callback: (Engine: Engine) => void);
  96575. /**
  96576. * An event triggered when the texture is resized.
  96577. */
  96578. onResizeObservable: Observable<RenderTargetTexture>;
  96579. /**
  96580. * Define the clear color of the Render Target if it should be different from the scene.
  96581. */
  96582. clearColor: Color4;
  96583. protected _size: number | {
  96584. width: number;
  96585. height: number;
  96586. layers?: number;
  96587. };
  96588. protected _initialSizeParameter: number | {
  96589. width: number;
  96590. height: number;
  96591. } | {
  96592. ratio: number;
  96593. };
  96594. protected _sizeRatio: Nullable<number>;
  96595. /** @hidden */
  96596. _generateMipMaps: boolean;
  96597. protected _renderingManager: RenderingManager;
  96598. /** @hidden */
  96599. _waitingRenderList: string[];
  96600. protected _doNotChangeAspectRatio: boolean;
  96601. protected _currentRefreshId: number;
  96602. protected _refreshRate: number;
  96603. protected _textureMatrix: Matrix;
  96604. protected _samples: number;
  96605. protected _renderTargetOptions: RenderTargetCreationOptions;
  96606. /**
  96607. * Gets render target creation options that were used.
  96608. */
  96609. get renderTargetOptions(): RenderTargetCreationOptions;
  96610. protected _engine: Engine;
  96611. protected _onRatioRescale(): void;
  96612. /**
  96613. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  96614. * It must define where the camera used to render the texture is set
  96615. */
  96616. boundingBoxPosition: Vector3;
  96617. private _boundingBoxSize;
  96618. /**
  96619. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  96620. * When defined, the cubemap will switch to local mode
  96621. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  96622. * @example https://www.babylonjs-playground.com/#RNASML
  96623. */
  96624. set boundingBoxSize(value: Vector3);
  96625. get boundingBoxSize(): Vector3;
  96626. /**
  96627. * In case the RTT has been created with a depth texture, get the associated
  96628. * depth texture.
  96629. * Otherwise, return null.
  96630. */
  96631. get depthStencilTexture(): Nullable<InternalTexture>;
  96632. /**
  96633. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  96634. * or used a shadow, depth texture...
  96635. * @param name The friendly name of the texture
  96636. * @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)
  96637. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  96638. * @param generateMipMaps True if mip maps need to be generated after render.
  96639. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  96640. * @param type The type of the buffer in the RTT (int, half float, float...)
  96641. * @param isCube True if a cube texture needs to be created
  96642. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  96643. * @param generateDepthBuffer True to generate a depth buffer
  96644. * @param generateStencilBuffer True to generate a stencil buffer
  96645. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  96646. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  96647. * @param delayAllocation if the texture allocation should be delayed (default: false)
  96648. */
  96649. constructor(name: string, size: number | {
  96650. width: number;
  96651. height: number;
  96652. layers?: number;
  96653. } | {
  96654. ratio: number;
  96655. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  96656. /**
  96657. * Creates a depth stencil texture.
  96658. * This is only available in WebGL 2 or with the depth texture extension available.
  96659. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  96660. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  96661. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  96662. */
  96663. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  96664. private _processSizeParameter;
  96665. /**
  96666. * Define the number of samples to use in case of MSAA.
  96667. * It defaults to one meaning no MSAA has been enabled.
  96668. */
  96669. get samples(): number;
  96670. set samples(value: number);
  96671. /**
  96672. * Resets the refresh counter of the texture and start bak from scratch.
  96673. * Could be useful to regenerate the texture if it is setup to render only once.
  96674. */
  96675. resetRefreshCounter(): void;
  96676. /**
  96677. * Define the refresh rate of the texture or the rendering frequency.
  96678. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  96679. */
  96680. get refreshRate(): number;
  96681. set refreshRate(value: number);
  96682. /**
  96683. * Adds a post process to the render target rendering passes.
  96684. * @param postProcess define the post process to add
  96685. */
  96686. addPostProcess(postProcess: PostProcess): void;
  96687. /**
  96688. * Clear all the post processes attached to the render target
  96689. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  96690. */
  96691. clearPostProcesses(dispose?: boolean): void;
  96692. /**
  96693. * Remove one of the post process from the list of attached post processes to the texture
  96694. * @param postProcess define the post process to remove from the list
  96695. */
  96696. removePostProcess(postProcess: PostProcess): void;
  96697. /** @hidden */
  96698. _shouldRender(): boolean;
  96699. /**
  96700. * Gets the actual render size of the texture.
  96701. * @returns the width of the render size
  96702. */
  96703. getRenderSize(): number;
  96704. /**
  96705. * Gets the actual render width of the texture.
  96706. * @returns the width of the render size
  96707. */
  96708. getRenderWidth(): number;
  96709. /**
  96710. * Gets the actual render height of the texture.
  96711. * @returns the height of the render size
  96712. */
  96713. getRenderHeight(): number;
  96714. /**
  96715. * Gets the actual number of layers of the texture.
  96716. * @returns the number of layers
  96717. */
  96718. getRenderLayers(): number;
  96719. /**
  96720. * Get if the texture can be rescaled or not.
  96721. */
  96722. get canRescale(): boolean;
  96723. /**
  96724. * Resize the texture using a ratio.
  96725. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  96726. */
  96727. scale(ratio: number): void;
  96728. /**
  96729. * Get the texture reflection matrix used to rotate/transform the reflection.
  96730. * @returns the reflection matrix
  96731. */
  96732. getReflectionTextureMatrix(): Matrix;
  96733. /**
  96734. * Resize the texture to a new desired size.
  96735. * Be carrefull as it will recreate all the data in the new texture.
  96736. * @param size Define the new size. It can be:
  96737. * - a number for squared texture,
  96738. * - an object containing { width: number, height: number }
  96739. * - or an object containing a ratio { ratio: number }
  96740. */
  96741. resize(size: number | {
  96742. width: number;
  96743. height: number;
  96744. } | {
  96745. ratio: number;
  96746. }): void;
  96747. private _defaultRenderListPrepared;
  96748. /**
  96749. * Renders all the objects from the render list into the texture.
  96750. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  96751. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  96752. */
  96753. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  96754. private _bestReflectionRenderTargetDimension;
  96755. private _prepareRenderingManager;
  96756. /**
  96757. * @hidden
  96758. * @param faceIndex face index to bind to if this is a cubetexture
  96759. * @param layer defines the index of the texture to bind in the array
  96760. */
  96761. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  96762. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  96763. private renderToTarget;
  96764. /**
  96765. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96766. * This allowed control for front to back rendering or reversly depending of the special needs.
  96767. *
  96768. * @param renderingGroupId The rendering group id corresponding to its index
  96769. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96770. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96771. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96772. */
  96773. 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;
  96774. /**
  96775. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96776. *
  96777. * @param renderingGroupId The rendering group id corresponding to its index
  96778. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96779. */
  96780. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  96781. /**
  96782. * Clones the texture.
  96783. * @returns the cloned texture
  96784. */
  96785. clone(): RenderTargetTexture;
  96786. /**
  96787. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  96788. * @returns The JSON representation of the texture
  96789. */
  96790. serialize(): any;
  96791. /**
  96792. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  96793. */
  96794. disposeFramebufferObjects(): void;
  96795. /**
  96796. * Dispose the texture and release its associated resources.
  96797. */
  96798. dispose(): void;
  96799. /** @hidden */
  96800. _rebuild(): void;
  96801. /**
  96802. * Clear the info related to rendering groups preventing retention point in material dispose.
  96803. */
  96804. freeRenderingGroups(): void;
  96805. /**
  96806. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  96807. * @returns the view count
  96808. */
  96809. getViewCount(): number;
  96810. }
  96811. }
  96812. declare module BABYLON {
  96813. /**
  96814. * Class used to manipulate GUIDs
  96815. */
  96816. export class GUID {
  96817. /**
  96818. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96819. * Be aware Math.random() could cause collisions, but:
  96820. * "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"
  96821. * @returns a pseudo random id
  96822. */
  96823. static RandomId(): string;
  96824. }
  96825. }
  96826. declare module BABYLON {
  96827. /**
  96828. * Options to be used when creating a shadow depth material
  96829. */
  96830. export interface IIOptionShadowDepthMaterial {
  96831. /** Variables in the vertex shader code that need to have their names remapped.
  96832. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  96833. * "var_name" should be either: worldPos or vNormalW
  96834. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  96835. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  96836. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  96837. */
  96838. remappedVariables?: string[];
  96839. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  96840. standalone?: boolean;
  96841. }
  96842. /**
  96843. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  96844. */
  96845. export class ShadowDepthWrapper {
  96846. private _scene;
  96847. private _options?;
  96848. private _baseMaterial;
  96849. private _onEffectCreatedObserver;
  96850. private _subMeshToEffect;
  96851. private _subMeshToDepthEffect;
  96852. private _meshes;
  96853. /** @hidden */
  96854. _matriceNames: any;
  96855. /** Gets the standalone status of the wrapper */
  96856. get standalone(): boolean;
  96857. /** Gets the base material the wrapper is built upon */
  96858. get baseMaterial(): Material;
  96859. /**
  96860. * Instantiate a new shadow depth wrapper.
  96861. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  96862. * generate the shadow depth map. For more information, please refer to the documentation:
  96863. * https://doc.babylonjs.com/babylon101/shadows
  96864. * @param baseMaterial Material to wrap
  96865. * @param scene Define the scene the material belongs to
  96866. * @param options Options used to create the wrapper
  96867. */
  96868. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  96869. /**
  96870. * Gets the effect to use to generate the depth map
  96871. * @param subMesh subMesh to get the effect for
  96872. * @param shadowGenerator shadow generator to get the effect for
  96873. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  96874. */
  96875. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  96876. /**
  96877. * Specifies that the submesh is ready to be used for depth rendering
  96878. * @param subMesh submesh to check
  96879. * @param defines the list of defines to take into account when checking the effect
  96880. * @param shadowGenerator combined with subMesh, it defines the effect to check
  96881. * @param useInstances specifies that instances should be used
  96882. * @returns a boolean indicating that the submesh is ready or not
  96883. */
  96884. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  96885. /**
  96886. * Disposes the resources
  96887. */
  96888. dispose(): void;
  96889. private _makeEffect;
  96890. }
  96891. }
  96892. declare module BABYLON {
  96893. /**
  96894. * Options for compiling materials.
  96895. */
  96896. export interface IMaterialCompilationOptions {
  96897. /**
  96898. * Defines whether clip planes are enabled.
  96899. */
  96900. clipPlane: boolean;
  96901. /**
  96902. * Defines whether instances are enabled.
  96903. */
  96904. useInstances: boolean;
  96905. }
  96906. /**
  96907. * Base class for the main features of a material in Babylon.js
  96908. */
  96909. export class Material implements IAnimatable {
  96910. /**
  96911. * Returns the triangle fill mode
  96912. */
  96913. static readonly TriangleFillMode: number;
  96914. /**
  96915. * Returns the wireframe mode
  96916. */
  96917. static readonly WireFrameFillMode: number;
  96918. /**
  96919. * Returns the point fill mode
  96920. */
  96921. static readonly PointFillMode: number;
  96922. /**
  96923. * Returns the point list draw mode
  96924. */
  96925. static readonly PointListDrawMode: number;
  96926. /**
  96927. * Returns the line list draw mode
  96928. */
  96929. static readonly LineListDrawMode: number;
  96930. /**
  96931. * Returns the line loop draw mode
  96932. */
  96933. static readonly LineLoopDrawMode: number;
  96934. /**
  96935. * Returns the line strip draw mode
  96936. */
  96937. static readonly LineStripDrawMode: number;
  96938. /**
  96939. * Returns the triangle strip draw mode
  96940. */
  96941. static readonly TriangleStripDrawMode: number;
  96942. /**
  96943. * Returns the triangle fan draw mode
  96944. */
  96945. static readonly TriangleFanDrawMode: number;
  96946. /**
  96947. * Stores the clock-wise side orientation
  96948. */
  96949. static readonly ClockWiseSideOrientation: number;
  96950. /**
  96951. * Stores the counter clock-wise side orientation
  96952. */
  96953. static readonly CounterClockWiseSideOrientation: number;
  96954. /**
  96955. * The dirty texture flag value
  96956. */
  96957. static readonly TextureDirtyFlag: number;
  96958. /**
  96959. * The dirty light flag value
  96960. */
  96961. static readonly LightDirtyFlag: number;
  96962. /**
  96963. * The dirty fresnel flag value
  96964. */
  96965. static readonly FresnelDirtyFlag: number;
  96966. /**
  96967. * The dirty attribute flag value
  96968. */
  96969. static readonly AttributesDirtyFlag: number;
  96970. /**
  96971. * The dirty misc flag value
  96972. */
  96973. static readonly MiscDirtyFlag: number;
  96974. /**
  96975. * The all dirty flag value
  96976. */
  96977. static readonly AllDirtyFlag: number;
  96978. /**
  96979. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  96980. */
  96981. static readonly MATERIAL_OPAQUE: number;
  96982. /**
  96983. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  96984. */
  96985. static readonly MATERIAL_ALPHATEST: number;
  96986. /**
  96987. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  96988. */
  96989. static readonly MATERIAL_ALPHABLEND: number;
  96990. /**
  96991. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  96992. * They are also discarded below the alpha cutoff threshold to improve performances.
  96993. */
  96994. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  96995. /**
  96996. * Custom callback helping to override the default shader used in the material.
  96997. */
  96998. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  96999. /**
  97000. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  97001. */
  97002. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  97003. /**
  97004. * The ID of the material
  97005. */
  97006. id: string;
  97007. /**
  97008. * Gets or sets the unique id of the material
  97009. */
  97010. uniqueId: number;
  97011. /**
  97012. * The name of the material
  97013. */
  97014. name: string;
  97015. /**
  97016. * Gets or sets user defined metadata
  97017. */
  97018. metadata: any;
  97019. /**
  97020. * For internal use only. Please do not use.
  97021. */
  97022. reservedDataStore: any;
  97023. /**
  97024. * Specifies if the ready state should be checked on each call
  97025. */
  97026. checkReadyOnEveryCall: boolean;
  97027. /**
  97028. * Specifies if the ready state should be checked once
  97029. */
  97030. checkReadyOnlyOnce: boolean;
  97031. /**
  97032. * The state of the material
  97033. */
  97034. state: string;
  97035. /**
  97036. * The alpha value of the material
  97037. */
  97038. protected _alpha: number;
  97039. /**
  97040. * List of inspectable custom properties (used by the Inspector)
  97041. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97042. */
  97043. inspectableCustomProperties: IInspectable[];
  97044. /**
  97045. * Sets the alpha value of the material
  97046. */
  97047. set alpha(value: number);
  97048. /**
  97049. * Gets the alpha value of the material
  97050. */
  97051. get alpha(): number;
  97052. /**
  97053. * Specifies if back face culling is enabled
  97054. */
  97055. protected _backFaceCulling: boolean;
  97056. /**
  97057. * Sets the back-face culling state
  97058. */
  97059. set backFaceCulling(value: boolean);
  97060. /**
  97061. * Gets the back-face culling state
  97062. */
  97063. get backFaceCulling(): boolean;
  97064. /**
  97065. * Stores the value for side orientation
  97066. */
  97067. sideOrientation: number;
  97068. /**
  97069. * Callback triggered when the material is compiled
  97070. */
  97071. onCompiled: Nullable<(effect: Effect) => void>;
  97072. /**
  97073. * Callback triggered when an error occurs
  97074. */
  97075. onError: Nullable<(effect: Effect, errors: string) => void>;
  97076. /**
  97077. * Callback triggered to get the render target textures
  97078. */
  97079. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  97080. /**
  97081. * Gets a boolean indicating that current material needs to register RTT
  97082. */
  97083. get hasRenderTargetTextures(): boolean;
  97084. /**
  97085. * Specifies if the material should be serialized
  97086. */
  97087. doNotSerialize: boolean;
  97088. /**
  97089. * @hidden
  97090. */
  97091. _storeEffectOnSubMeshes: boolean;
  97092. /**
  97093. * Stores the animations for the material
  97094. */
  97095. animations: Nullable<Array<Animation>>;
  97096. /**
  97097. * An event triggered when the material is disposed
  97098. */
  97099. onDisposeObservable: Observable<Material>;
  97100. /**
  97101. * An observer which watches for dispose events
  97102. */
  97103. private _onDisposeObserver;
  97104. private _onUnBindObservable;
  97105. /**
  97106. * Called during a dispose event
  97107. */
  97108. set onDispose(callback: () => void);
  97109. private _onBindObservable;
  97110. /**
  97111. * An event triggered when the material is bound
  97112. */
  97113. get onBindObservable(): Observable<AbstractMesh>;
  97114. /**
  97115. * An observer which watches for bind events
  97116. */
  97117. private _onBindObserver;
  97118. /**
  97119. * Called during a bind event
  97120. */
  97121. set onBind(callback: (Mesh: AbstractMesh) => void);
  97122. /**
  97123. * An event triggered when the material is unbound
  97124. */
  97125. get onUnBindObservable(): Observable<Material>;
  97126. protected _onEffectCreatedObservable: Nullable<Observable<{
  97127. effect: Effect;
  97128. subMesh: Nullable<SubMesh>;
  97129. }>>;
  97130. /**
  97131. * An event triggered when the effect is (re)created
  97132. */
  97133. get onEffectCreatedObservable(): Observable<{
  97134. effect: Effect;
  97135. subMesh: Nullable<SubMesh>;
  97136. }>;
  97137. /**
  97138. * Stores the value of the alpha mode
  97139. */
  97140. private _alphaMode;
  97141. /**
  97142. * Sets the value of the alpha mode.
  97143. *
  97144. * | Value | Type | Description |
  97145. * | --- | --- | --- |
  97146. * | 0 | ALPHA_DISABLE | |
  97147. * | 1 | ALPHA_ADD | |
  97148. * | 2 | ALPHA_COMBINE | |
  97149. * | 3 | ALPHA_SUBTRACT | |
  97150. * | 4 | ALPHA_MULTIPLY | |
  97151. * | 5 | ALPHA_MAXIMIZED | |
  97152. * | 6 | ALPHA_ONEONE | |
  97153. * | 7 | ALPHA_PREMULTIPLIED | |
  97154. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  97155. * | 9 | ALPHA_INTERPOLATE | |
  97156. * | 10 | ALPHA_SCREENMODE | |
  97157. *
  97158. */
  97159. set alphaMode(value: number);
  97160. /**
  97161. * Gets the value of the alpha mode
  97162. */
  97163. get alphaMode(): number;
  97164. /**
  97165. * Stores the state of the need depth pre-pass value
  97166. */
  97167. private _needDepthPrePass;
  97168. /**
  97169. * Sets the need depth pre-pass value
  97170. */
  97171. set needDepthPrePass(value: boolean);
  97172. /**
  97173. * Gets the depth pre-pass value
  97174. */
  97175. get needDepthPrePass(): boolean;
  97176. /**
  97177. * Specifies if depth writing should be disabled
  97178. */
  97179. disableDepthWrite: boolean;
  97180. /**
  97181. * Specifies if color writing should be disabled
  97182. */
  97183. disableColorWrite: boolean;
  97184. /**
  97185. * Specifies if depth writing should be forced
  97186. */
  97187. forceDepthWrite: boolean;
  97188. /**
  97189. * Specifies the depth function that should be used. 0 means the default engine function
  97190. */
  97191. depthFunction: number;
  97192. /**
  97193. * Specifies if there should be a separate pass for culling
  97194. */
  97195. separateCullingPass: boolean;
  97196. /**
  97197. * Stores the state specifing if fog should be enabled
  97198. */
  97199. private _fogEnabled;
  97200. /**
  97201. * Sets the state for enabling fog
  97202. */
  97203. set fogEnabled(value: boolean);
  97204. /**
  97205. * Gets the value of the fog enabled state
  97206. */
  97207. get fogEnabled(): boolean;
  97208. /**
  97209. * Stores the size of points
  97210. */
  97211. pointSize: number;
  97212. /**
  97213. * Stores the z offset value
  97214. */
  97215. zOffset: number;
  97216. get wireframe(): boolean;
  97217. /**
  97218. * Sets the state of wireframe mode
  97219. */
  97220. set wireframe(value: boolean);
  97221. /**
  97222. * Gets the value specifying if point clouds are enabled
  97223. */
  97224. get pointsCloud(): boolean;
  97225. /**
  97226. * Sets the state of point cloud mode
  97227. */
  97228. set pointsCloud(value: boolean);
  97229. /**
  97230. * Gets the material fill mode
  97231. */
  97232. get fillMode(): number;
  97233. /**
  97234. * Sets the material fill mode
  97235. */
  97236. set fillMode(value: number);
  97237. /**
  97238. * @hidden
  97239. * Stores the effects for the material
  97240. */
  97241. _effect: Nullable<Effect>;
  97242. /**
  97243. * Specifies if uniform buffers should be used
  97244. */
  97245. private _useUBO;
  97246. /**
  97247. * Stores a reference to the scene
  97248. */
  97249. private _scene;
  97250. /**
  97251. * Stores the fill mode state
  97252. */
  97253. private _fillMode;
  97254. /**
  97255. * Specifies if the depth write state should be cached
  97256. */
  97257. private _cachedDepthWriteState;
  97258. /**
  97259. * Specifies if the color write state should be cached
  97260. */
  97261. private _cachedColorWriteState;
  97262. /**
  97263. * Specifies if the depth function state should be cached
  97264. */
  97265. private _cachedDepthFunctionState;
  97266. /**
  97267. * Stores the uniform buffer
  97268. */
  97269. protected _uniformBuffer: UniformBuffer;
  97270. /** @hidden */
  97271. _indexInSceneMaterialArray: number;
  97272. /** @hidden */
  97273. meshMap: Nullable<{
  97274. [id: string]: AbstractMesh | undefined;
  97275. }>;
  97276. /**
  97277. * Creates a material instance
  97278. * @param name defines the name of the material
  97279. * @param scene defines the scene to reference
  97280. * @param doNotAdd specifies if the material should be added to the scene
  97281. */
  97282. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  97283. /**
  97284. * Returns a string representation of the current material
  97285. * @param fullDetails defines a boolean indicating which levels of logging is desired
  97286. * @returns a string with material information
  97287. */
  97288. toString(fullDetails?: boolean): string;
  97289. /**
  97290. * Gets the class name of the material
  97291. * @returns a string with the class name of the material
  97292. */
  97293. getClassName(): string;
  97294. /**
  97295. * Specifies if updates for the material been locked
  97296. */
  97297. get isFrozen(): boolean;
  97298. /**
  97299. * Locks updates for the material
  97300. */
  97301. freeze(): void;
  97302. /**
  97303. * Unlocks updates for the material
  97304. */
  97305. unfreeze(): void;
  97306. /**
  97307. * Specifies if the material is ready to be used
  97308. * @param mesh defines the mesh to check
  97309. * @param useInstances specifies if instances should be used
  97310. * @returns a boolean indicating if the material is ready to be used
  97311. */
  97312. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97313. /**
  97314. * Specifies that the submesh is ready to be used
  97315. * @param mesh defines the mesh to check
  97316. * @param subMesh defines which submesh to check
  97317. * @param useInstances specifies that instances should be used
  97318. * @returns a boolean indicating that the submesh is ready or not
  97319. */
  97320. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97321. /**
  97322. * Returns the material effect
  97323. * @returns the effect associated with the material
  97324. */
  97325. getEffect(): Nullable<Effect>;
  97326. /**
  97327. * Returns the current scene
  97328. * @returns a Scene
  97329. */
  97330. getScene(): Scene;
  97331. /**
  97332. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  97333. */
  97334. protected _forceAlphaTest: boolean;
  97335. /**
  97336. * The transparency mode of the material.
  97337. */
  97338. protected _transparencyMode: Nullable<number>;
  97339. /**
  97340. * Gets the current transparency mode.
  97341. */
  97342. get transparencyMode(): Nullable<number>;
  97343. /**
  97344. * Sets the transparency mode of the material.
  97345. *
  97346. * | Value | Type | Description |
  97347. * | ----- | ----------------------------------- | ----------- |
  97348. * | 0 | OPAQUE | |
  97349. * | 1 | ALPHATEST | |
  97350. * | 2 | ALPHABLEND | |
  97351. * | 3 | ALPHATESTANDBLEND | |
  97352. *
  97353. */
  97354. set transparencyMode(value: Nullable<number>);
  97355. /**
  97356. * Returns true if alpha blending should be disabled.
  97357. */
  97358. protected get _disableAlphaBlending(): boolean;
  97359. /**
  97360. * Specifies whether or not this material should be rendered in alpha blend mode.
  97361. * @returns a boolean specifying if alpha blending is needed
  97362. */
  97363. needAlphaBlending(): boolean;
  97364. /**
  97365. * Specifies if the mesh will require alpha blending
  97366. * @param mesh defines the mesh to check
  97367. * @returns a boolean specifying if alpha blending is needed for the mesh
  97368. */
  97369. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  97370. /**
  97371. * Specifies whether or not this material should be rendered in alpha test mode.
  97372. * @returns a boolean specifying if an alpha test is needed.
  97373. */
  97374. needAlphaTesting(): boolean;
  97375. /**
  97376. * Specifies if material alpha testing should be turned on for the mesh
  97377. * @param mesh defines the mesh to check
  97378. */
  97379. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  97380. /**
  97381. * Gets the texture used for the alpha test
  97382. * @returns the texture to use for alpha testing
  97383. */
  97384. getAlphaTestTexture(): Nullable<BaseTexture>;
  97385. /**
  97386. * Marks the material to indicate that it needs to be re-calculated
  97387. */
  97388. markDirty(): void;
  97389. /** @hidden */
  97390. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  97391. /**
  97392. * Binds the material to the mesh
  97393. * @param world defines the world transformation matrix
  97394. * @param mesh defines the mesh to bind the material to
  97395. */
  97396. bind(world: Matrix, mesh?: Mesh): void;
  97397. /**
  97398. * Binds the submesh to the material
  97399. * @param world defines the world transformation matrix
  97400. * @param mesh defines the mesh containing the submesh
  97401. * @param subMesh defines the submesh to bind the material to
  97402. */
  97403. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97404. /**
  97405. * Binds the world matrix to the material
  97406. * @param world defines the world transformation matrix
  97407. */
  97408. bindOnlyWorldMatrix(world: Matrix): void;
  97409. /**
  97410. * Binds the scene's uniform buffer to the effect.
  97411. * @param effect defines the effect to bind to the scene uniform buffer
  97412. * @param sceneUbo defines the uniform buffer storing scene data
  97413. */
  97414. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  97415. /**
  97416. * Binds the view matrix to the effect
  97417. * @param effect defines the effect to bind the view matrix to
  97418. */
  97419. bindView(effect: Effect): void;
  97420. /**
  97421. * Binds the view projection matrix to the effect
  97422. * @param effect defines the effect to bind the view projection matrix to
  97423. */
  97424. bindViewProjection(effect: Effect): void;
  97425. /**
  97426. * Processes to execute after binding the material to a mesh
  97427. * @param mesh defines the rendered mesh
  97428. */
  97429. protected _afterBind(mesh?: Mesh): void;
  97430. /**
  97431. * Unbinds the material from the mesh
  97432. */
  97433. unbind(): void;
  97434. /**
  97435. * Gets the active textures from the material
  97436. * @returns an array of textures
  97437. */
  97438. getActiveTextures(): BaseTexture[];
  97439. /**
  97440. * Specifies if the material uses a texture
  97441. * @param texture defines the texture to check against the material
  97442. * @returns a boolean specifying if the material uses the texture
  97443. */
  97444. hasTexture(texture: BaseTexture): boolean;
  97445. /**
  97446. * Makes a duplicate of the material, and gives it a new name
  97447. * @param name defines the new name for the duplicated material
  97448. * @returns the cloned material
  97449. */
  97450. clone(name: string): Nullable<Material>;
  97451. /**
  97452. * Gets the meshes bound to the material
  97453. * @returns an array of meshes bound to the material
  97454. */
  97455. getBindedMeshes(): AbstractMesh[];
  97456. /**
  97457. * Force shader compilation
  97458. * @param mesh defines the mesh associated with this material
  97459. * @param onCompiled defines a function to execute once the material is compiled
  97460. * @param options defines the options to configure the compilation
  97461. * @param onError defines a function to execute if the material fails compiling
  97462. */
  97463. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  97464. /**
  97465. * Force shader compilation
  97466. * @param mesh defines the mesh that will use this material
  97467. * @param options defines additional options for compiling the shaders
  97468. * @returns a promise that resolves when the compilation completes
  97469. */
  97470. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  97471. private static readonly _AllDirtyCallBack;
  97472. private static readonly _ImageProcessingDirtyCallBack;
  97473. private static readonly _TextureDirtyCallBack;
  97474. private static readonly _FresnelDirtyCallBack;
  97475. private static readonly _MiscDirtyCallBack;
  97476. private static readonly _LightsDirtyCallBack;
  97477. private static readonly _AttributeDirtyCallBack;
  97478. private static _FresnelAndMiscDirtyCallBack;
  97479. private static _TextureAndMiscDirtyCallBack;
  97480. private static readonly _DirtyCallbackArray;
  97481. private static readonly _RunDirtyCallBacks;
  97482. /**
  97483. * Marks a define in the material to indicate that it needs to be re-computed
  97484. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  97485. */
  97486. markAsDirty(flag: number): void;
  97487. /**
  97488. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  97489. * @param func defines a function which checks material defines against the submeshes
  97490. */
  97491. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  97492. /**
  97493. * Indicates that we need to re-calculated for all submeshes
  97494. */
  97495. protected _markAllSubMeshesAsAllDirty(): void;
  97496. /**
  97497. * Indicates that image processing needs to be re-calculated for all submeshes
  97498. */
  97499. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  97500. /**
  97501. * Indicates that textures need to be re-calculated for all submeshes
  97502. */
  97503. protected _markAllSubMeshesAsTexturesDirty(): void;
  97504. /**
  97505. * Indicates that fresnel needs to be re-calculated for all submeshes
  97506. */
  97507. protected _markAllSubMeshesAsFresnelDirty(): void;
  97508. /**
  97509. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  97510. */
  97511. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  97512. /**
  97513. * Indicates that lights need to be re-calculated for all submeshes
  97514. */
  97515. protected _markAllSubMeshesAsLightsDirty(): void;
  97516. /**
  97517. * Indicates that attributes need to be re-calculated for all submeshes
  97518. */
  97519. protected _markAllSubMeshesAsAttributesDirty(): void;
  97520. /**
  97521. * Indicates that misc needs to be re-calculated for all submeshes
  97522. */
  97523. protected _markAllSubMeshesAsMiscDirty(): void;
  97524. /**
  97525. * Indicates that textures and misc need to be re-calculated for all submeshes
  97526. */
  97527. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  97528. /**
  97529. * Disposes the material
  97530. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97531. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97532. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97533. */
  97534. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97535. /** @hidden */
  97536. private releaseVertexArrayObject;
  97537. /**
  97538. * Serializes this material
  97539. * @returns the serialized material object
  97540. */
  97541. serialize(): any;
  97542. /**
  97543. * Creates a material from parsed material data
  97544. * @param parsedMaterial defines parsed material data
  97545. * @param scene defines the hosting scene
  97546. * @param rootUrl defines the root URL to use to load textures
  97547. * @returns a new material
  97548. */
  97549. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  97550. }
  97551. }
  97552. declare module BABYLON {
  97553. /**
  97554. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97555. * separate meshes. This can be use to improve performances.
  97556. * @see http://doc.babylonjs.com/how_to/multi_materials
  97557. */
  97558. export class MultiMaterial extends Material {
  97559. private _subMaterials;
  97560. /**
  97561. * Gets or Sets the list of Materials used within the multi material.
  97562. * They need to be ordered according to the submeshes order in the associated mesh
  97563. */
  97564. get subMaterials(): Nullable<Material>[];
  97565. set subMaterials(value: Nullable<Material>[]);
  97566. /**
  97567. * Function used to align with Node.getChildren()
  97568. * @returns the list of Materials used within the multi material
  97569. */
  97570. getChildren(): Nullable<Material>[];
  97571. /**
  97572. * Instantiates a new Multi Material
  97573. * A multi-material is used to apply different materials to different parts of the same object without the need of
  97574. * separate meshes. This can be use to improve performances.
  97575. * @see http://doc.babylonjs.com/how_to/multi_materials
  97576. * @param name Define the name in the scene
  97577. * @param scene Define the scene the material belongs to
  97578. */
  97579. constructor(name: string, scene: Scene);
  97580. private _hookArray;
  97581. /**
  97582. * Get one of the submaterial by its index in the submaterials array
  97583. * @param index The index to look the sub material at
  97584. * @returns The Material if the index has been defined
  97585. */
  97586. getSubMaterial(index: number): Nullable<Material>;
  97587. /**
  97588. * Get the list of active textures for the whole sub materials list.
  97589. * @returns All the textures that will be used during the rendering
  97590. */
  97591. getActiveTextures(): BaseTexture[];
  97592. /**
  97593. * Gets the current class name of the material e.g. "MultiMaterial"
  97594. * Mainly use in serialization.
  97595. * @returns the class name
  97596. */
  97597. getClassName(): string;
  97598. /**
  97599. * Checks if the material is ready to render the requested sub mesh
  97600. * @param mesh Define the mesh the submesh belongs to
  97601. * @param subMesh Define the sub mesh to look readyness for
  97602. * @param useInstances Define whether or not the material is used with instances
  97603. * @returns true if ready, otherwise false
  97604. */
  97605. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  97606. /**
  97607. * Clones the current material and its related sub materials
  97608. * @param name Define the name of the newly cloned material
  97609. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  97610. * @returns the cloned material
  97611. */
  97612. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  97613. /**
  97614. * Serializes the materials into a JSON representation.
  97615. * @returns the JSON representation
  97616. */
  97617. serialize(): any;
  97618. /**
  97619. * Dispose the material and release its associated resources
  97620. * @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)
  97621. * @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)
  97622. * @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)
  97623. */
  97624. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  97625. /**
  97626. * Creates a MultiMaterial from parsed MultiMaterial data.
  97627. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  97628. * @param scene defines the hosting scene
  97629. * @returns a new MultiMaterial
  97630. */
  97631. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  97632. }
  97633. }
  97634. declare module BABYLON {
  97635. /**
  97636. * Base class for submeshes
  97637. */
  97638. export class BaseSubMesh {
  97639. /** @hidden */
  97640. _materialDefines: Nullable<MaterialDefines>;
  97641. /** @hidden */
  97642. _materialEffect: Nullable<Effect>;
  97643. /** @hidden */
  97644. _effectOverride: Nullable<Effect>;
  97645. /**
  97646. * Gets material defines used by the effect associated to the sub mesh
  97647. */
  97648. get materialDefines(): Nullable<MaterialDefines>;
  97649. /**
  97650. * Sets material defines used by the effect associated to the sub mesh
  97651. */
  97652. set materialDefines(defines: Nullable<MaterialDefines>);
  97653. /**
  97654. * Gets associated effect
  97655. */
  97656. get effect(): Nullable<Effect>;
  97657. /**
  97658. * Sets associated effect (effect used to render this submesh)
  97659. * @param effect defines the effect to associate with
  97660. * @param defines defines the set of defines used to compile this effect
  97661. */
  97662. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  97663. }
  97664. /**
  97665. * Defines a subdivision inside a mesh
  97666. */
  97667. export class SubMesh extends BaseSubMesh implements ICullable {
  97668. /** the material index to use */
  97669. materialIndex: number;
  97670. /** vertex index start */
  97671. verticesStart: number;
  97672. /** vertices count */
  97673. verticesCount: number;
  97674. /** index start */
  97675. indexStart: number;
  97676. /** indices count */
  97677. indexCount: number;
  97678. /** @hidden */
  97679. _linesIndexCount: number;
  97680. private _mesh;
  97681. private _renderingMesh;
  97682. private _boundingInfo;
  97683. private _linesIndexBuffer;
  97684. /** @hidden */
  97685. _lastColliderWorldVertices: Nullable<Vector3[]>;
  97686. /** @hidden */
  97687. _trianglePlanes: Plane[];
  97688. /** @hidden */
  97689. _lastColliderTransformMatrix: Nullable<Matrix>;
  97690. /** @hidden */
  97691. _renderId: number;
  97692. /** @hidden */
  97693. _alphaIndex: number;
  97694. /** @hidden */
  97695. _distanceToCamera: number;
  97696. /** @hidden */
  97697. _id: number;
  97698. private _currentMaterial;
  97699. /**
  97700. * Add a new submesh to a mesh
  97701. * @param materialIndex defines the material index to use
  97702. * @param verticesStart defines vertex index start
  97703. * @param verticesCount defines vertices count
  97704. * @param indexStart defines index start
  97705. * @param indexCount defines indices count
  97706. * @param mesh defines the parent mesh
  97707. * @param renderingMesh defines an optional rendering mesh
  97708. * @param createBoundingBox defines if bounding box should be created for this submesh
  97709. * @returns the new submesh
  97710. */
  97711. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  97712. /**
  97713. * Creates a new submesh
  97714. * @param materialIndex defines the material index to use
  97715. * @param verticesStart defines vertex index start
  97716. * @param verticesCount defines vertices count
  97717. * @param indexStart defines index start
  97718. * @param indexCount defines indices count
  97719. * @param mesh defines the parent mesh
  97720. * @param renderingMesh defines an optional rendering mesh
  97721. * @param createBoundingBox defines if bounding box should be created for this submesh
  97722. */
  97723. constructor(
  97724. /** the material index to use */
  97725. materialIndex: number,
  97726. /** vertex index start */
  97727. verticesStart: number,
  97728. /** vertices count */
  97729. verticesCount: number,
  97730. /** index start */
  97731. indexStart: number,
  97732. /** indices count */
  97733. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  97734. /**
  97735. * Returns true if this submesh covers the entire parent mesh
  97736. * @ignorenaming
  97737. */
  97738. get IsGlobal(): boolean;
  97739. /**
  97740. * Returns the submesh BoudingInfo object
  97741. * @returns current bounding info (or mesh's one if the submesh is global)
  97742. */
  97743. getBoundingInfo(): BoundingInfo;
  97744. /**
  97745. * Sets the submesh BoundingInfo
  97746. * @param boundingInfo defines the new bounding info to use
  97747. * @returns the SubMesh
  97748. */
  97749. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  97750. /**
  97751. * Returns the mesh of the current submesh
  97752. * @return the parent mesh
  97753. */
  97754. getMesh(): AbstractMesh;
  97755. /**
  97756. * Returns the rendering mesh of the submesh
  97757. * @returns the rendering mesh (could be different from parent mesh)
  97758. */
  97759. getRenderingMesh(): Mesh;
  97760. /**
  97761. * Returns the submesh material
  97762. * @returns null or the current material
  97763. */
  97764. getMaterial(): Nullable<Material>;
  97765. /**
  97766. * Sets a new updated BoundingInfo object to the submesh
  97767. * @param data defines an optional position array to use to determine the bounding info
  97768. * @returns the SubMesh
  97769. */
  97770. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  97771. /** @hidden */
  97772. _checkCollision(collider: Collider): boolean;
  97773. /**
  97774. * Updates the submesh BoundingInfo
  97775. * @param world defines the world matrix to use to update the bounding info
  97776. * @returns the submesh
  97777. */
  97778. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  97779. /**
  97780. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  97781. * @param frustumPlanes defines the frustum planes
  97782. * @returns true if the submesh is intersecting with the frustum
  97783. */
  97784. isInFrustum(frustumPlanes: Plane[]): boolean;
  97785. /**
  97786. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  97787. * @param frustumPlanes defines the frustum planes
  97788. * @returns true if the submesh is inside the frustum
  97789. */
  97790. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  97791. /**
  97792. * Renders the submesh
  97793. * @param enableAlphaMode defines if alpha needs to be used
  97794. * @returns the submesh
  97795. */
  97796. render(enableAlphaMode: boolean): SubMesh;
  97797. /**
  97798. * @hidden
  97799. */
  97800. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  97801. /**
  97802. * Checks if the submesh intersects with a ray
  97803. * @param ray defines the ray to test
  97804. * @returns true is the passed ray intersects the submesh bounding box
  97805. */
  97806. canIntersects(ray: Ray): boolean;
  97807. /**
  97808. * Intersects current submesh with a ray
  97809. * @param ray defines the ray to test
  97810. * @param positions defines mesh's positions array
  97811. * @param indices defines mesh's indices array
  97812. * @param fastCheck defines if the first intersection will be used (and not the closest)
  97813. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97814. * @returns intersection info or null if no intersection
  97815. */
  97816. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  97817. /** @hidden */
  97818. private _intersectLines;
  97819. /** @hidden */
  97820. private _intersectUnIndexedLines;
  97821. /** @hidden */
  97822. private _intersectTriangles;
  97823. /** @hidden */
  97824. private _intersectUnIndexedTriangles;
  97825. /** @hidden */
  97826. _rebuild(): void;
  97827. /**
  97828. * Creates a new submesh from the passed mesh
  97829. * @param newMesh defines the new hosting mesh
  97830. * @param newRenderingMesh defines an optional rendering mesh
  97831. * @returns the new submesh
  97832. */
  97833. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  97834. /**
  97835. * Release associated resources
  97836. */
  97837. dispose(): void;
  97838. /**
  97839. * Gets the class name
  97840. * @returns the string "SubMesh".
  97841. */
  97842. getClassName(): string;
  97843. /**
  97844. * Creates a new submesh from indices data
  97845. * @param materialIndex the index of the main mesh material
  97846. * @param startIndex the index where to start the copy in the mesh indices array
  97847. * @param indexCount the number of indices to copy then from the startIndex
  97848. * @param mesh the main mesh to create the submesh from
  97849. * @param renderingMesh the optional rendering mesh
  97850. * @returns a new submesh
  97851. */
  97852. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  97853. }
  97854. }
  97855. declare module BABYLON {
  97856. /**
  97857. * Class used to represent data loading progression
  97858. */
  97859. export class SceneLoaderFlags {
  97860. private static _ForceFullSceneLoadingForIncremental;
  97861. private static _ShowLoadingScreen;
  97862. private static _CleanBoneMatrixWeights;
  97863. private static _loggingLevel;
  97864. /**
  97865. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  97866. */
  97867. static get ForceFullSceneLoadingForIncremental(): boolean;
  97868. static set ForceFullSceneLoadingForIncremental(value: boolean);
  97869. /**
  97870. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  97871. */
  97872. static get ShowLoadingScreen(): boolean;
  97873. static set ShowLoadingScreen(value: boolean);
  97874. /**
  97875. * Defines the current logging level (while loading the scene)
  97876. * @ignorenaming
  97877. */
  97878. static get loggingLevel(): number;
  97879. static set loggingLevel(value: number);
  97880. /**
  97881. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  97882. */
  97883. static get CleanBoneMatrixWeights(): boolean;
  97884. static set CleanBoneMatrixWeights(value: boolean);
  97885. }
  97886. }
  97887. declare module BABYLON {
  97888. /**
  97889. * Class used to store geometry data (vertex buffers + index buffer)
  97890. */
  97891. export class Geometry implements IGetSetVerticesData {
  97892. /**
  97893. * Gets or sets the ID of the geometry
  97894. */
  97895. id: string;
  97896. /**
  97897. * Gets or sets the unique ID of the geometry
  97898. */
  97899. uniqueId: number;
  97900. /**
  97901. * Gets the delay loading state of the geometry (none by default which means not delayed)
  97902. */
  97903. delayLoadState: number;
  97904. /**
  97905. * Gets the file containing the data to load when running in delay load state
  97906. */
  97907. delayLoadingFile: Nullable<string>;
  97908. /**
  97909. * Callback called when the geometry is updated
  97910. */
  97911. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  97912. private _scene;
  97913. private _engine;
  97914. private _meshes;
  97915. private _totalVertices;
  97916. /** @hidden */
  97917. _indices: IndicesArray;
  97918. /** @hidden */
  97919. _vertexBuffers: {
  97920. [key: string]: VertexBuffer;
  97921. };
  97922. private _isDisposed;
  97923. private _extend;
  97924. private _boundingBias;
  97925. /** @hidden */
  97926. _delayInfo: Array<string>;
  97927. private _indexBuffer;
  97928. private _indexBufferIsUpdatable;
  97929. /** @hidden */
  97930. _boundingInfo: Nullable<BoundingInfo>;
  97931. /** @hidden */
  97932. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  97933. /** @hidden */
  97934. _softwareSkinningFrameId: number;
  97935. private _vertexArrayObjects;
  97936. private _updatable;
  97937. /** @hidden */
  97938. _positions: Nullable<Vector3[]>;
  97939. /**
  97940. * 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
  97941. */
  97942. get boundingBias(): Vector2;
  97943. /**
  97944. * 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
  97945. */
  97946. set boundingBias(value: Vector2);
  97947. /**
  97948. * Static function used to attach a new empty geometry to a mesh
  97949. * @param mesh defines the mesh to attach the geometry to
  97950. * @returns the new Geometry
  97951. */
  97952. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  97953. /** Get the list of meshes using this geometry */
  97954. get meshes(): Mesh[];
  97955. /**
  97956. * Creates a new geometry
  97957. * @param id defines the unique ID
  97958. * @param scene defines the hosting scene
  97959. * @param vertexData defines the VertexData used to get geometry data
  97960. * @param updatable defines if geometry must be updatable (false by default)
  97961. * @param mesh defines the mesh that will be associated with the geometry
  97962. */
  97963. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  97964. /**
  97965. * Gets the current extend of the geometry
  97966. */
  97967. get extend(): {
  97968. minimum: Vector3;
  97969. maximum: Vector3;
  97970. };
  97971. /**
  97972. * Gets the hosting scene
  97973. * @returns the hosting Scene
  97974. */
  97975. getScene(): Scene;
  97976. /**
  97977. * Gets the hosting engine
  97978. * @returns the hosting Engine
  97979. */
  97980. getEngine(): Engine;
  97981. /**
  97982. * Defines if the geometry is ready to use
  97983. * @returns true if the geometry is ready to be used
  97984. */
  97985. isReady(): boolean;
  97986. /**
  97987. * Gets a value indicating that the geometry should not be serialized
  97988. */
  97989. get doNotSerialize(): boolean;
  97990. /** @hidden */
  97991. _rebuild(): void;
  97992. /**
  97993. * Affects all geometry data in one call
  97994. * @param vertexData defines the geometry data
  97995. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  97996. */
  97997. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  97998. /**
  97999. * Set specific vertex data
  98000. * @param kind defines the data kind (Position, normal, etc...)
  98001. * @param data defines the vertex data to use
  98002. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98003. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98004. */
  98005. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  98006. /**
  98007. * Removes a specific vertex data
  98008. * @param kind defines the data kind (Position, normal, etc...)
  98009. */
  98010. removeVerticesData(kind: string): void;
  98011. /**
  98012. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  98013. * @param buffer defines the vertex buffer to use
  98014. * @param totalVertices defines the total number of vertices for position kind (could be null)
  98015. */
  98016. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  98017. /**
  98018. * Update a specific vertex buffer
  98019. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  98020. * It will do nothing if the buffer is not updatable
  98021. * @param kind defines the data kind (Position, normal, etc...)
  98022. * @param data defines the data to use
  98023. * @param offset defines the offset in the target buffer where to store the data
  98024. * @param useBytes set to true if the offset is in bytes
  98025. */
  98026. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  98027. /**
  98028. * Update a specific vertex buffer
  98029. * This function will create a new buffer if the current one is not updatable
  98030. * @param kind defines the data kind (Position, normal, etc...)
  98031. * @param data defines the data to use
  98032. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  98033. */
  98034. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  98035. private _updateBoundingInfo;
  98036. /** @hidden */
  98037. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  98038. /**
  98039. * Gets total number of vertices
  98040. * @returns the total number of vertices
  98041. */
  98042. getTotalVertices(): number;
  98043. /**
  98044. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98045. * @param kind defines the data kind (Position, normal, etc...)
  98046. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98047. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98048. * @returns a float array containing vertex data
  98049. */
  98050. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98051. /**
  98052. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  98053. * @param kind defines the data kind (Position, normal, etc...)
  98054. * @returns true if the vertex buffer with the specified kind is updatable
  98055. */
  98056. isVertexBufferUpdatable(kind: string): boolean;
  98057. /**
  98058. * Gets a specific vertex buffer
  98059. * @param kind defines the data kind (Position, normal, etc...)
  98060. * @returns a VertexBuffer
  98061. */
  98062. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98063. /**
  98064. * Returns all vertex buffers
  98065. * @return an object holding all vertex buffers indexed by kind
  98066. */
  98067. getVertexBuffers(): Nullable<{
  98068. [key: string]: VertexBuffer;
  98069. }>;
  98070. /**
  98071. * Gets a boolean indicating if specific vertex buffer is present
  98072. * @param kind defines the data kind (Position, normal, etc...)
  98073. * @returns true if data is present
  98074. */
  98075. isVerticesDataPresent(kind: string): boolean;
  98076. /**
  98077. * Gets a list of all attached data kinds (Position, normal, etc...)
  98078. * @returns a list of string containing all kinds
  98079. */
  98080. getVerticesDataKinds(): string[];
  98081. /**
  98082. * Update index buffer
  98083. * @param indices defines the indices to store in the index buffer
  98084. * @param offset defines the offset in the target buffer where to store the data
  98085. * @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)
  98086. */
  98087. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  98088. /**
  98089. * Creates a new index buffer
  98090. * @param indices defines the indices to store in the index buffer
  98091. * @param totalVertices defines the total number of vertices (could be null)
  98092. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98093. */
  98094. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  98095. /**
  98096. * Return the total number of indices
  98097. * @returns the total number of indices
  98098. */
  98099. getTotalIndices(): number;
  98100. /**
  98101. * Gets the index buffer array
  98102. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98103. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98104. * @returns the index buffer array
  98105. */
  98106. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98107. /**
  98108. * Gets the index buffer
  98109. * @return the index buffer
  98110. */
  98111. getIndexBuffer(): Nullable<DataBuffer>;
  98112. /** @hidden */
  98113. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  98114. /**
  98115. * Release the associated resources for a specific mesh
  98116. * @param mesh defines the source mesh
  98117. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  98118. */
  98119. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  98120. /**
  98121. * Apply current geometry to a given mesh
  98122. * @param mesh defines the mesh to apply geometry to
  98123. */
  98124. applyToMesh(mesh: Mesh): void;
  98125. private _updateExtend;
  98126. private _applyToMesh;
  98127. private notifyUpdate;
  98128. /**
  98129. * Load the geometry if it was flagged as delay loaded
  98130. * @param scene defines the hosting scene
  98131. * @param onLoaded defines a callback called when the geometry is loaded
  98132. */
  98133. load(scene: Scene, onLoaded?: () => void): void;
  98134. private _queueLoad;
  98135. /**
  98136. * Invert the geometry to move from a right handed system to a left handed one.
  98137. */
  98138. toLeftHanded(): void;
  98139. /** @hidden */
  98140. _resetPointsArrayCache(): void;
  98141. /** @hidden */
  98142. _generatePointsArray(): boolean;
  98143. /**
  98144. * Gets a value indicating if the geometry is disposed
  98145. * @returns true if the geometry was disposed
  98146. */
  98147. isDisposed(): boolean;
  98148. private _disposeVertexArrayObjects;
  98149. /**
  98150. * Free all associated resources
  98151. */
  98152. dispose(): void;
  98153. /**
  98154. * Clone the current geometry into a new geometry
  98155. * @param id defines the unique ID of the new geometry
  98156. * @returns a new geometry object
  98157. */
  98158. copy(id: string): Geometry;
  98159. /**
  98160. * Serialize the current geometry info (and not the vertices data) into a JSON object
  98161. * @return a JSON representation of the current geometry data (without the vertices data)
  98162. */
  98163. serialize(): any;
  98164. private toNumberArray;
  98165. /**
  98166. * Serialize all vertices data into a JSON oject
  98167. * @returns a JSON representation of the current geometry data
  98168. */
  98169. serializeVerticeData(): any;
  98170. /**
  98171. * Extracts a clone of a mesh geometry
  98172. * @param mesh defines the source mesh
  98173. * @param id defines the unique ID of the new geometry object
  98174. * @returns the new geometry object
  98175. */
  98176. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  98177. /**
  98178. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  98179. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98180. * Be aware Math.random() could cause collisions, but:
  98181. * "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"
  98182. * @returns a string containing a new GUID
  98183. */
  98184. static RandomId(): string;
  98185. /** @hidden */
  98186. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  98187. private static _CleanMatricesWeights;
  98188. /**
  98189. * Create a new geometry from persisted data (Using .babylon file format)
  98190. * @param parsedVertexData defines the persisted data
  98191. * @param scene defines the hosting scene
  98192. * @param rootUrl defines the root url to use to load assets (like delayed data)
  98193. * @returns the new geometry object
  98194. */
  98195. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  98196. }
  98197. }
  98198. declare module BABYLON {
  98199. /**
  98200. * Define an interface for all classes that will get and set the data on vertices
  98201. */
  98202. export interface IGetSetVerticesData {
  98203. /**
  98204. * Gets a boolean indicating if specific vertex data is present
  98205. * @param kind defines the vertex data kind to use
  98206. * @returns true is data kind is present
  98207. */
  98208. isVerticesDataPresent(kind: string): boolean;
  98209. /**
  98210. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  98211. * @param kind defines the data kind (Position, normal, etc...)
  98212. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  98213. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98214. * @returns a float array containing vertex data
  98215. */
  98216. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98217. /**
  98218. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98219. * @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.
  98220. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98221. * @returns the indices array or an empty array if the mesh has no geometry
  98222. */
  98223. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98224. /**
  98225. * Set specific vertex data
  98226. * @param kind defines the data kind (Position, normal, etc...)
  98227. * @param data defines the vertex data to use
  98228. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  98229. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  98230. */
  98231. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  98232. /**
  98233. * Update a specific associated vertex buffer
  98234. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98235. * - VertexBuffer.PositionKind
  98236. * - VertexBuffer.UVKind
  98237. * - VertexBuffer.UV2Kind
  98238. * - VertexBuffer.UV3Kind
  98239. * - VertexBuffer.UV4Kind
  98240. * - VertexBuffer.UV5Kind
  98241. * - VertexBuffer.UV6Kind
  98242. * - VertexBuffer.ColorKind
  98243. * - VertexBuffer.MatricesIndicesKind
  98244. * - VertexBuffer.MatricesIndicesExtraKind
  98245. * - VertexBuffer.MatricesWeightsKind
  98246. * - VertexBuffer.MatricesWeightsExtraKind
  98247. * @param data defines the data source
  98248. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98249. * @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)
  98250. */
  98251. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  98252. /**
  98253. * Creates a new index buffer
  98254. * @param indices defines the indices to store in the index buffer
  98255. * @param totalVertices defines the total number of vertices (could be null)
  98256. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  98257. */
  98258. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  98259. }
  98260. /**
  98261. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  98262. */
  98263. export class VertexData {
  98264. /**
  98265. * Mesh side orientation : usually the external or front surface
  98266. */
  98267. static readonly FRONTSIDE: number;
  98268. /**
  98269. * Mesh side orientation : usually the internal or back surface
  98270. */
  98271. static readonly BACKSIDE: number;
  98272. /**
  98273. * Mesh side orientation : both internal and external or front and back surfaces
  98274. */
  98275. static readonly DOUBLESIDE: number;
  98276. /**
  98277. * Mesh side orientation : by default, `FRONTSIDE`
  98278. */
  98279. static readonly DEFAULTSIDE: number;
  98280. /**
  98281. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  98282. */
  98283. positions: Nullable<FloatArray>;
  98284. /**
  98285. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  98286. */
  98287. normals: Nullable<FloatArray>;
  98288. /**
  98289. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  98290. */
  98291. tangents: Nullable<FloatArray>;
  98292. /**
  98293. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98294. */
  98295. uvs: Nullable<FloatArray>;
  98296. /**
  98297. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98298. */
  98299. uvs2: Nullable<FloatArray>;
  98300. /**
  98301. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98302. */
  98303. uvs3: Nullable<FloatArray>;
  98304. /**
  98305. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98306. */
  98307. uvs4: Nullable<FloatArray>;
  98308. /**
  98309. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98310. */
  98311. uvs5: Nullable<FloatArray>;
  98312. /**
  98313. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  98314. */
  98315. uvs6: Nullable<FloatArray>;
  98316. /**
  98317. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  98318. */
  98319. colors: Nullable<FloatArray>;
  98320. /**
  98321. * 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).
  98322. */
  98323. matricesIndices: Nullable<FloatArray>;
  98324. /**
  98325. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  98326. */
  98327. matricesWeights: Nullable<FloatArray>;
  98328. /**
  98329. * An array extending the number of possible indices
  98330. */
  98331. matricesIndicesExtra: Nullable<FloatArray>;
  98332. /**
  98333. * An array extending the number of possible weights when the number of indices is extended
  98334. */
  98335. matricesWeightsExtra: Nullable<FloatArray>;
  98336. /**
  98337. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  98338. */
  98339. indices: Nullable<IndicesArray>;
  98340. /**
  98341. * Uses the passed data array to set the set the values for the specified kind of data
  98342. * @param data a linear array of floating numbers
  98343. * @param kind the type of data that is being set, eg positions, colors etc
  98344. */
  98345. set(data: FloatArray, kind: string): void;
  98346. /**
  98347. * Associates the vertexData to the passed Mesh.
  98348. * Sets it as updatable or not (default `false`)
  98349. * @param mesh the mesh the vertexData is applied to
  98350. * @param updatable when used and having the value true allows new data to update the vertexData
  98351. * @returns the VertexData
  98352. */
  98353. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  98354. /**
  98355. * Associates the vertexData to the passed Geometry.
  98356. * Sets it as updatable or not (default `false`)
  98357. * @param geometry the geometry the vertexData is applied to
  98358. * @param updatable when used and having the value true allows new data to update the vertexData
  98359. * @returns VertexData
  98360. */
  98361. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  98362. /**
  98363. * Updates the associated mesh
  98364. * @param mesh the mesh to be updated
  98365. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98366. * @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
  98367. * @returns VertexData
  98368. */
  98369. updateMesh(mesh: Mesh): VertexData;
  98370. /**
  98371. * Updates the associated geometry
  98372. * @param geometry the geometry to be updated
  98373. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  98374. * @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
  98375. * @returns VertexData.
  98376. */
  98377. updateGeometry(geometry: Geometry): VertexData;
  98378. private _applyTo;
  98379. private _update;
  98380. /**
  98381. * Transforms each position and each normal of the vertexData according to the passed Matrix
  98382. * @param matrix the transforming matrix
  98383. * @returns the VertexData
  98384. */
  98385. transform(matrix: Matrix): VertexData;
  98386. /**
  98387. * Merges the passed VertexData into the current one
  98388. * @param other the VertexData to be merged into the current one
  98389. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  98390. * @returns the modified VertexData
  98391. */
  98392. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  98393. private _mergeElement;
  98394. private _validate;
  98395. /**
  98396. * Serializes the VertexData
  98397. * @returns a serialized object
  98398. */
  98399. serialize(): any;
  98400. /**
  98401. * Extracts the vertexData from a mesh
  98402. * @param mesh the mesh from which to extract the VertexData
  98403. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  98404. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98405. * @returns the object VertexData associated to the passed mesh
  98406. */
  98407. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98408. /**
  98409. * Extracts the vertexData from the geometry
  98410. * @param geometry the geometry from which to extract the VertexData
  98411. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  98412. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  98413. * @returns the object VertexData associated to the passed mesh
  98414. */
  98415. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  98416. private static _ExtractFrom;
  98417. /**
  98418. * Creates the VertexData for a Ribbon
  98419. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  98420. * * pathArray array of paths, each of which an array of successive Vector3
  98421. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  98422. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  98423. * * 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
  98424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98425. * * 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)
  98426. * * 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)
  98427. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  98428. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  98429. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  98430. * @returns the VertexData of the ribbon
  98431. */
  98432. static CreateRibbon(options: {
  98433. pathArray: Vector3[][];
  98434. closeArray?: boolean;
  98435. closePath?: boolean;
  98436. offset?: number;
  98437. sideOrientation?: number;
  98438. frontUVs?: Vector4;
  98439. backUVs?: Vector4;
  98440. invertUV?: boolean;
  98441. uvs?: Vector2[];
  98442. colors?: Color4[];
  98443. }): VertexData;
  98444. /**
  98445. * Creates the VertexData for a box
  98446. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98447. * * size sets the width, height and depth of the box to the value of size, optional default 1
  98448. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  98449. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  98450. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  98451. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98452. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98453. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98454. * * 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)
  98455. * * 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)
  98456. * @returns the VertexData of the box
  98457. */
  98458. static CreateBox(options: {
  98459. size?: number;
  98460. width?: number;
  98461. height?: number;
  98462. depth?: number;
  98463. faceUV?: Vector4[];
  98464. faceColors?: Color4[];
  98465. sideOrientation?: number;
  98466. frontUVs?: Vector4;
  98467. backUVs?: Vector4;
  98468. }): VertexData;
  98469. /**
  98470. * Creates the VertexData for a tiled box
  98471. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98472. * * faceTiles sets the pattern, tile size and number of tiles for a face
  98473. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  98474. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  98475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98476. * @returns the VertexData of the box
  98477. */
  98478. static CreateTiledBox(options: {
  98479. pattern?: number;
  98480. width?: number;
  98481. height?: number;
  98482. depth?: number;
  98483. tileSize?: number;
  98484. tileWidth?: number;
  98485. tileHeight?: number;
  98486. alignHorizontal?: number;
  98487. alignVertical?: number;
  98488. faceUV?: Vector4[];
  98489. faceColors?: Color4[];
  98490. sideOrientation?: number;
  98491. }): VertexData;
  98492. /**
  98493. * Creates the VertexData for a tiled plane
  98494. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98495. * * pattern a limited pattern arrangement depending on the number
  98496. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  98497. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  98498. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  98499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98500. * * 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)
  98501. * * 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)
  98502. * @returns the VertexData of the tiled plane
  98503. */
  98504. static CreateTiledPlane(options: {
  98505. pattern?: number;
  98506. tileSize?: number;
  98507. tileWidth?: number;
  98508. tileHeight?: number;
  98509. size?: number;
  98510. width?: number;
  98511. height?: number;
  98512. alignHorizontal?: number;
  98513. alignVertical?: number;
  98514. sideOrientation?: number;
  98515. frontUVs?: Vector4;
  98516. backUVs?: Vector4;
  98517. }): VertexData;
  98518. /**
  98519. * Creates the VertexData for an ellipsoid, defaults to a sphere
  98520. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98521. * * segments sets the number of horizontal strips optional, default 32
  98522. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  98523. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  98524. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  98525. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  98526. * * 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
  98527. * * 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
  98528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98529. * * 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)
  98530. * * 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)
  98531. * @returns the VertexData of the ellipsoid
  98532. */
  98533. static CreateSphere(options: {
  98534. segments?: number;
  98535. diameter?: number;
  98536. diameterX?: number;
  98537. diameterY?: number;
  98538. diameterZ?: number;
  98539. arc?: number;
  98540. slice?: number;
  98541. sideOrientation?: number;
  98542. frontUVs?: Vector4;
  98543. backUVs?: Vector4;
  98544. }): VertexData;
  98545. /**
  98546. * Creates the VertexData for a cylinder, cone or prism
  98547. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98548. * * height sets the height (y direction) of the cylinder, optional, default 2
  98549. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  98550. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  98551. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  98552. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98553. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  98554. * * 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
  98555. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98556. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98557. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  98558. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  98559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98560. * * 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)
  98561. * * 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)
  98562. * @returns the VertexData of the cylinder, cone or prism
  98563. */
  98564. static CreateCylinder(options: {
  98565. height?: number;
  98566. diameterTop?: number;
  98567. diameterBottom?: number;
  98568. diameter?: number;
  98569. tessellation?: number;
  98570. subdivisions?: number;
  98571. arc?: number;
  98572. faceColors?: Color4[];
  98573. faceUV?: Vector4[];
  98574. hasRings?: boolean;
  98575. enclose?: boolean;
  98576. sideOrientation?: number;
  98577. frontUVs?: Vector4;
  98578. backUVs?: Vector4;
  98579. }): VertexData;
  98580. /**
  98581. * Creates the VertexData for a torus
  98582. * @param options an object used to set the following optional parameters for the box, required but can be empty
  98583. * * diameter the diameter of the torus, optional default 1
  98584. * * thickness the diameter of the tube forming the torus, optional default 0.5
  98585. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  98586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98587. * * 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)
  98588. * * 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)
  98589. * @returns the VertexData of the torus
  98590. */
  98591. static CreateTorus(options: {
  98592. diameter?: number;
  98593. thickness?: number;
  98594. tessellation?: number;
  98595. sideOrientation?: number;
  98596. frontUVs?: Vector4;
  98597. backUVs?: Vector4;
  98598. }): VertexData;
  98599. /**
  98600. * Creates the VertexData of the LineSystem
  98601. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  98602. * - lines an array of lines, each line being an array of successive Vector3
  98603. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  98604. * @returns the VertexData of the LineSystem
  98605. */
  98606. static CreateLineSystem(options: {
  98607. lines: Vector3[][];
  98608. colors?: Nullable<Color4[][]>;
  98609. }): VertexData;
  98610. /**
  98611. * Create the VertexData for a DashedLines
  98612. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  98613. * - points an array successive Vector3
  98614. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  98615. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  98616. * - dashNb the intended total number of dashes, optional, default 200
  98617. * @returns the VertexData for the DashedLines
  98618. */
  98619. static CreateDashedLines(options: {
  98620. points: Vector3[];
  98621. dashSize?: number;
  98622. gapSize?: number;
  98623. dashNb?: number;
  98624. }): VertexData;
  98625. /**
  98626. * Creates the VertexData for a Ground
  98627. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98628. * - width the width (x direction) of the ground, optional, default 1
  98629. * - height the height (z direction) of the ground, optional, default 1
  98630. * - subdivisions the number of subdivisions per side, optional, default 1
  98631. * @returns the VertexData of the Ground
  98632. */
  98633. static CreateGround(options: {
  98634. width?: number;
  98635. height?: number;
  98636. subdivisions?: number;
  98637. subdivisionsX?: number;
  98638. subdivisionsY?: number;
  98639. }): VertexData;
  98640. /**
  98641. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  98642. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  98643. * * xmin the ground minimum X coordinate, optional, default -1
  98644. * * zmin the ground minimum Z coordinate, optional, default -1
  98645. * * xmax the ground maximum X coordinate, optional, default 1
  98646. * * zmax the ground maximum Z coordinate, optional, default 1
  98647. * * 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}
  98648. * * 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}
  98649. * @returns the VertexData of the TiledGround
  98650. */
  98651. static CreateTiledGround(options: {
  98652. xmin: number;
  98653. zmin: number;
  98654. xmax: number;
  98655. zmax: number;
  98656. subdivisions?: {
  98657. w: number;
  98658. h: number;
  98659. };
  98660. precision?: {
  98661. w: number;
  98662. h: number;
  98663. };
  98664. }): VertexData;
  98665. /**
  98666. * Creates the VertexData of the Ground designed from a heightmap
  98667. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  98668. * * width the width (x direction) of the ground
  98669. * * height the height (z direction) of the ground
  98670. * * subdivisions the number of subdivisions per side
  98671. * * minHeight the minimum altitude on the ground, optional, default 0
  98672. * * maxHeight the maximum altitude on the ground, optional default 1
  98673. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  98674. * * buffer the array holding the image color data
  98675. * * bufferWidth the width of image
  98676. * * bufferHeight the height of image
  98677. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  98678. * @returns the VertexData of the Ground designed from a heightmap
  98679. */
  98680. static CreateGroundFromHeightMap(options: {
  98681. width: number;
  98682. height: number;
  98683. subdivisions: number;
  98684. minHeight: number;
  98685. maxHeight: number;
  98686. colorFilter: Color3;
  98687. buffer: Uint8Array;
  98688. bufferWidth: number;
  98689. bufferHeight: number;
  98690. alphaFilter: number;
  98691. }): VertexData;
  98692. /**
  98693. * Creates the VertexData for a Plane
  98694. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  98695. * * size sets the width and height of the plane to the value of size, optional default 1
  98696. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  98697. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  98698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98699. * * 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)
  98700. * * 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)
  98701. * @returns the VertexData of the box
  98702. */
  98703. static CreatePlane(options: {
  98704. size?: number;
  98705. width?: number;
  98706. height?: number;
  98707. sideOrientation?: number;
  98708. frontUVs?: Vector4;
  98709. backUVs?: Vector4;
  98710. }): VertexData;
  98711. /**
  98712. * Creates the VertexData of the Disc or regular Polygon
  98713. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  98714. * * radius the radius of the disc, optional default 0.5
  98715. * * tessellation the number of polygon sides, optional, default 64
  98716. * * 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
  98717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98718. * * 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)
  98719. * * 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)
  98720. * @returns the VertexData of the box
  98721. */
  98722. static CreateDisc(options: {
  98723. radius?: number;
  98724. tessellation?: number;
  98725. arc?: number;
  98726. sideOrientation?: number;
  98727. frontUVs?: Vector4;
  98728. backUVs?: Vector4;
  98729. }): VertexData;
  98730. /**
  98731. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  98732. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  98733. * @param polygon a mesh built from polygonTriangulation.build()
  98734. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98735. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98736. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98737. * @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)
  98738. * @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)
  98739. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  98740. * @returns the VertexData of the Polygon
  98741. */
  98742. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  98743. /**
  98744. * Creates the VertexData of the IcoSphere
  98745. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  98746. * * radius the radius of the IcoSphere, optional default 1
  98747. * * radiusX allows stretching in the x direction, optional, default radius
  98748. * * radiusY allows stretching in the y direction, optional, default radius
  98749. * * radiusZ allows stretching in the z direction, optional, default radius
  98750. * * flat when true creates a flat shaded mesh, optional, default true
  98751. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98752. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98753. * * 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)
  98754. * * 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)
  98755. * @returns the VertexData of the IcoSphere
  98756. */
  98757. static CreateIcoSphere(options: {
  98758. radius?: number;
  98759. radiusX?: number;
  98760. radiusY?: number;
  98761. radiusZ?: number;
  98762. flat?: boolean;
  98763. subdivisions?: number;
  98764. sideOrientation?: number;
  98765. frontUVs?: Vector4;
  98766. backUVs?: Vector4;
  98767. }): VertexData;
  98768. /**
  98769. * Creates the VertexData for a Polyhedron
  98770. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  98771. * * type provided types are:
  98772. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  98773. * * 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)
  98774. * * size the size of the IcoSphere, optional default 1
  98775. * * sizeX allows stretching in the x direction, optional, default size
  98776. * * sizeY allows stretching in the y direction, optional, default size
  98777. * * sizeZ allows stretching in the z direction, optional, default size
  98778. * * 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
  98779. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  98780. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  98781. * * flat when true creates a flat shaded mesh, optional, default true
  98782. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  98783. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98784. * * 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)
  98785. * * 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)
  98786. * @returns the VertexData of the Polyhedron
  98787. */
  98788. static CreatePolyhedron(options: {
  98789. type?: number;
  98790. size?: number;
  98791. sizeX?: number;
  98792. sizeY?: number;
  98793. sizeZ?: number;
  98794. custom?: any;
  98795. faceUV?: Vector4[];
  98796. faceColors?: Color4[];
  98797. flat?: boolean;
  98798. sideOrientation?: number;
  98799. frontUVs?: Vector4;
  98800. backUVs?: Vector4;
  98801. }): VertexData;
  98802. /**
  98803. * Creates the VertexData for a TorusKnot
  98804. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  98805. * * radius the radius of the torus knot, optional, default 2
  98806. * * tube the thickness of the tube, optional, default 0.5
  98807. * * radialSegments the number of sides on each tube segments, optional, default 32
  98808. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  98809. * * p the number of windings around the z axis, optional, default 2
  98810. * * q the number of windings around the x axis, optional, default 3
  98811. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98812. * * 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)
  98813. * * 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)
  98814. * @returns the VertexData of the Torus Knot
  98815. */
  98816. static CreateTorusKnot(options: {
  98817. radius?: number;
  98818. tube?: number;
  98819. radialSegments?: number;
  98820. tubularSegments?: number;
  98821. p?: number;
  98822. q?: number;
  98823. sideOrientation?: number;
  98824. frontUVs?: Vector4;
  98825. backUVs?: Vector4;
  98826. }): VertexData;
  98827. /**
  98828. * Compute normals for given positions and indices
  98829. * @param positions an array of vertex positions, [...., x, y, z, ......]
  98830. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  98831. * @param normals an array of vertex normals, [...., x, y, z, ......]
  98832. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  98833. * * facetNormals : optional array of facet normals (vector3)
  98834. * * facetPositions : optional array of facet positions (vector3)
  98835. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  98836. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  98837. * * bInfo : optional bounding info, required for facetPartitioning computation
  98838. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  98839. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  98840. * * useRightHandedSystem: optional boolean to for right handed system computation
  98841. * * depthSort : optional boolean to enable the facet depth sort computation
  98842. * * distanceTo : optional Vector3 to compute the facet depth from this location
  98843. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  98844. */
  98845. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  98846. facetNormals?: any;
  98847. facetPositions?: any;
  98848. facetPartitioning?: any;
  98849. ratio?: number;
  98850. bInfo?: any;
  98851. bbSize?: Vector3;
  98852. subDiv?: any;
  98853. useRightHandedSystem?: boolean;
  98854. depthSort?: boolean;
  98855. distanceTo?: Vector3;
  98856. depthSortedFacets?: any;
  98857. }): void;
  98858. /** @hidden */
  98859. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  98860. /**
  98861. * Applies VertexData created from the imported parameters to the geometry
  98862. * @param parsedVertexData the parsed data from an imported file
  98863. * @param geometry the geometry to apply the VertexData to
  98864. */
  98865. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  98866. }
  98867. }
  98868. declare module BABYLON {
  98869. /**
  98870. * Defines a target to use with MorphTargetManager
  98871. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98872. */
  98873. export class MorphTarget implements IAnimatable {
  98874. /** defines the name of the target */
  98875. name: string;
  98876. /**
  98877. * Gets or sets the list of animations
  98878. */
  98879. animations: Animation[];
  98880. private _scene;
  98881. private _positions;
  98882. private _normals;
  98883. private _tangents;
  98884. private _uvs;
  98885. private _influence;
  98886. private _uniqueId;
  98887. /**
  98888. * Observable raised when the influence changes
  98889. */
  98890. onInfluenceChanged: Observable<boolean>;
  98891. /** @hidden */
  98892. _onDataLayoutChanged: Observable<void>;
  98893. /**
  98894. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  98895. */
  98896. get influence(): number;
  98897. set influence(influence: number);
  98898. /**
  98899. * Gets or sets the id of the morph Target
  98900. */
  98901. id: string;
  98902. private _animationPropertiesOverride;
  98903. /**
  98904. * Gets or sets the animation properties override
  98905. */
  98906. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  98907. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  98908. /**
  98909. * Creates a new MorphTarget
  98910. * @param name defines the name of the target
  98911. * @param influence defines the influence to use
  98912. * @param scene defines the scene the morphtarget belongs to
  98913. */
  98914. constructor(
  98915. /** defines the name of the target */
  98916. name: string, influence?: number, scene?: Nullable<Scene>);
  98917. /**
  98918. * Gets the unique ID of this manager
  98919. */
  98920. get uniqueId(): number;
  98921. /**
  98922. * Gets a boolean defining if the target contains position data
  98923. */
  98924. get hasPositions(): boolean;
  98925. /**
  98926. * Gets a boolean defining if the target contains normal data
  98927. */
  98928. get hasNormals(): boolean;
  98929. /**
  98930. * Gets a boolean defining if the target contains tangent data
  98931. */
  98932. get hasTangents(): boolean;
  98933. /**
  98934. * Gets a boolean defining if the target contains texture coordinates data
  98935. */
  98936. get hasUVs(): boolean;
  98937. /**
  98938. * Affects position data to this target
  98939. * @param data defines the position data to use
  98940. */
  98941. setPositions(data: Nullable<FloatArray>): void;
  98942. /**
  98943. * Gets the position data stored in this target
  98944. * @returns a FloatArray containing the position data (or null if not present)
  98945. */
  98946. getPositions(): Nullable<FloatArray>;
  98947. /**
  98948. * Affects normal data to this target
  98949. * @param data defines the normal data to use
  98950. */
  98951. setNormals(data: Nullable<FloatArray>): void;
  98952. /**
  98953. * Gets the normal data stored in this target
  98954. * @returns a FloatArray containing the normal data (or null if not present)
  98955. */
  98956. getNormals(): Nullable<FloatArray>;
  98957. /**
  98958. * Affects tangent data to this target
  98959. * @param data defines the tangent data to use
  98960. */
  98961. setTangents(data: Nullable<FloatArray>): void;
  98962. /**
  98963. * Gets the tangent data stored in this target
  98964. * @returns a FloatArray containing the tangent data (or null if not present)
  98965. */
  98966. getTangents(): Nullable<FloatArray>;
  98967. /**
  98968. * Affects texture coordinates data to this target
  98969. * @param data defines the texture coordinates data to use
  98970. */
  98971. setUVs(data: Nullable<FloatArray>): void;
  98972. /**
  98973. * Gets the texture coordinates data stored in this target
  98974. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  98975. */
  98976. getUVs(): Nullable<FloatArray>;
  98977. /**
  98978. * Clone the current target
  98979. * @returns a new MorphTarget
  98980. */
  98981. clone(): MorphTarget;
  98982. /**
  98983. * Serializes the current target into a Serialization object
  98984. * @returns the serialized object
  98985. */
  98986. serialize(): any;
  98987. /**
  98988. * Returns the string "MorphTarget"
  98989. * @returns "MorphTarget"
  98990. */
  98991. getClassName(): string;
  98992. /**
  98993. * Creates a new target from serialized data
  98994. * @param serializationObject defines the serialized data to use
  98995. * @returns a new MorphTarget
  98996. */
  98997. static Parse(serializationObject: any): MorphTarget;
  98998. /**
  98999. * Creates a MorphTarget from mesh data
  99000. * @param mesh defines the source mesh
  99001. * @param name defines the name to use for the new target
  99002. * @param influence defines the influence to attach to the target
  99003. * @returns a new MorphTarget
  99004. */
  99005. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  99006. }
  99007. }
  99008. declare module BABYLON {
  99009. /**
  99010. * This class is used to deform meshes using morphing between different targets
  99011. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  99012. */
  99013. export class MorphTargetManager {
  99014. private _targets;
  99015. private _targetInfluenceChangedObservers;
  99016. private _targetDataLayoutChangedObservers;
  99017. private _activeTargets;
  99018. private _scene;
  99019. private _influences;
  99020. private _supportsNormals;
  99021. private _supportsTangents;
  99022. private _supportsUVs;
  99023. private _vertexCount;
  99024. private _uniqueId;
  99025. private _tempInfluences;
  99026. /**
  99027. * Gets or sets a boolean indicating if normals must be morphed
  99028. */
  99029. enableNormalMorphing: boolean;
  99030. /**
  99031. * Gets or sets a boolean indicating if tangents must be morphed
  99032. */
  99033. enableTangentMorphing: boolean;
  99034. /**
  99035. * Gets or sets a boolean indicating if UV must be morphed
  99036. */
  99037. enableUVMorphing: boolean;
  99038. /**
  99039. * Creates a new MorphTargetManager
  99040. * @param scene defines the current scene
  99041. */
  99042. constructor(scene?: Nullable<Scene>);
  99043. /**
  99044. * Gets the unique ID of this manager
  99045. */
  99046. get uniqueId(): number;
  99047. /**
  99048. * Gets the number of vertices handled by this manager
  99049. */
  99050. get vertexCount(): number;
  99051. /**
  99052. * Gets a boolean indicating if this manager supports morphing of normals
  99053. */
  99054. get supportsNormals(): boolean;
  99055. /**
  99056. * Gets a boolean indicating if this manager supports morphing of tangents
  99057. */
  99058. get supportsTangents(): boolean;
  99059. /**
  99060. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  99061. */
  99062. get supportsUVs(): boolean;
  99063. /**
  99064. * Gets the number of targets stored in this manager
  99065. */
  99066. get numTargets(): number;
  99067. /**
  99068. * Gets the number of influencers (ie. the number of targets with influences > 0)
  99069. */
  99070. get numInfluencers(): number;
  99071. /**
  99072. * Gets the list of influences (one per target)
  99073. */
  99074. get influences(): Float32Array;
  99075. /**
  99076. * Gets the active target at specified index. An active target is a target with an influence > 0
  99077. * @param index defines the index to check
  99078. * @returns the requested target
  99079. */
  99080. getActiveTarget(index: number): MorphTarget;
  99081. /**
  99082. * Gets the target at specified index
  99083. * @param index defines the index to check
  99084. * @returns the requested target
  99085. */
  99086. getTarget(index: number): MorphTarget;
  99087. /**
  99088. * Add a new target to this manager
  99089. * @param target defines the target to add
  99090. */
  99091. addTarget(target: MorphTarget): void;
  99092. /**
  99093. * Removes a target from the manager
  99094. * @param target defines the target to remove
  99095. */
  99096. removeTarget(target: MorphTarget): void;
  99097. /**
  99098. * Clone the current manager
  99099. * @returns a new MorphTargetManager
  99100. */
  99101. clone(): MorphTargetManager;
  99102. /**
  99103. * Serializes the current manager into a Serialization object
  99104. * @returns the serialized object
  99105. */
  99106. serialize(): any;
  99107. private _syncActiveTargets;
  99108. /**
  99109. * Syncrhonize the targets with all the meshes using this morph target manager
  99110. */
  99111. synchronize(): void;
  99112. /**
  99113. * Creates a new MorphTargetManager from serialized data
  99114. * @param serializationObject defines the serialized data
  99115. * @param scene defines the hosting scene
  99116. * @returns the new MorphTargetManager
  99117. */
  99118. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  99119. }
  99120. }
  99121. declare module BABYLON {
  99122. /**
  99123. * Class used to represent a specific level of detail of a mesh
  99124. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  99125. */
  99126. export class MeshLODLevel {
  99127. /** Defines the distance where this level should start being displayed */
  99128. distance: number;
  99129. /** Defines the mesh to use to render this level */
  99130. mesh: Nullable<Mesh>;
  99131. /**
  99132. * Creates a new LOD level
  99133. * @param distance defines the distance where this level should star being displayed
  99134. * @param mesh defines the mesh to use to render this level
  99135. */
  99136. constructor(
  99137. /** Defines the distance where this level should start being displayed */
  99138. distance: number,
  99139. /** Defines the mesh to use to render this level */
  99140. mesh: Nullable<Mesh>);
  99141. }
  99142. }
  99143. declare module BABYLON {
  99144. /**
  99145. * Mesh representing the gorund
  99146. */
  99147. export class GroundMesh extends Mesh {
  99148. /** If octree should be generated */
  99149. generateOctree: boolean;
  99150. private _heightQuads;
  99151. /** @hidden */
  99152. _subdivisionsX: number;
  99153. /** @hidden */
  99154. _subdivisionsY: number;
  99155. /** @hidden */
  99156. _width: number;
  99157. /** @hidden */
  99158. _height: number;
  99159. /** @hidden */
  99160. _minX: number;
  99161. /** @hidden */
  99162. _maxX: number;
  99163. /** @hidden */
  99164. _minZ: number;
  99165. /** @hidden */
  99166. _maxZ: number;
  99167. constructor(name: string, scene: Scene);
  99168. /**
  99169. * "GroundMesh"
  99170. * @returns "GroundMesh"
  99171. */
  99172. getClassName(): string;
  99173. /**
  99174. * The minimum of x and y subdivisions
  99175. */
  99176. get subdivisions(): number;
  99177. /**
  99178. * X subdivisions
  99179. */
  99180. get subdivisionsX(): number;
  99181. /**
  99182. * Y subdivisions
  99183. */
  99184. get subdivisionsY(): number;
  99185. /**
  99186. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  99187. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99188. * @param chunksCount the number of subdivisions for x and y
  99189. * @param octreeBlocksSize (Default: 32)
  99190. */
  99191. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  99192. /**
  99193. * Returns a height (y) value in the Worl system :
  99194. * the ground altitude at the coordinates (x, z) expressed in the World system.
  99195. * @param x x coordinate
  99196. * @param z z coordinate
  99197. * @returns the ground y position if (x, z) are outside the ground surface.
  99198. */
  99199. getHeightAtCoordinates(x: number, z: number): number;
  99200. /**
  99201. * Returns a normalized vector (Vector3) orthogonal to the ground
  99202. * at the ground coordinates (x, z) expressed in the World system.
  99203. * @param x x coordinate
  99204. * @param z z coordinate
  99205. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  99206. */
  99207. getNormalAtCoordinates(x: number, z: number): Vector3;
  99208. /**
  99209. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  99210. * at the ground coordinates (x, z) expressed in the World system.
  99211. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  99212. * @param x x coordinate
  99213. * @param z z coordinate
  99214. * @param ref vector to store the result
  99215. * @returns the GroundMesh.
  99216. */
  99217. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  99218. /**
  99219. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  99220. * if the ground has been updated.
  99221. * This can be used in the render loop.
  99222. * @returns the GroundMesh.
  99223. */
  99224. updateCoordinateHeights(): GroundMesh;
  99225. private _getFacetAt;
  99226. private _initHeightQuads;
  99227. private _computeHeightQuads;
  99228. /**
  99229. * Serializes this ground mesh
  99230. * @param serializationObject object to write serialization to
  99231. */
  99232. serialize(serializationObject: any): void;
  99233. /**
  99234. * Parses a serialized ground mesh
  99235. * @param parsedMesh the serialized mesh
  99236. * @param scene the scene to create the ground mesh in
  99237. * @returns the created ground mesh
  99238. */
  99239. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  99240. }
  99241. }
  99242. declare module BABYLON {
  99243. /**
  99244. * Interface for Physics-Joint data
  99245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99246. */
  99247. export interface PhysicsJointData {
  99248. /**
  99249. * The main pivot of the joint
  99250. */
  99251. mainPivot?: Vector3;
  99252. /**
  99253. * The connected pivot of the joint
  99254. */
  99255. connectedPivot?: Vector3;
  99256. /**
  99257. * The main axis of the joint
  99258. */
  99259. mainAxis?: Vector3;
  99260. /**
  99261. * The connected axis of the joint
  99262. */
  99263. connectedAxis?: Vector3;
  99264. /**
  99265. * The collision of the joint
  99266. */
  99267. collision?: boolean;
  99268. /**
  99269. * Native Oimo/Cannon/Energy data
  99270. */
  99271. nativeParams?: any;
  99272. }
  99273. /**
  99274. * This is a holder class for the physics joint created by the physics plugin
  99275. * It holds a set of functions to control the underlying joint
  99276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99277. */
  99278. export class PhysicsJoint {
  99279. /**
  99280. * The type of the physics joint
  99281. */
  99282. type: number;
  99283. /**
  99284. * The data for the physics joint
  99285. */
  99286. jointData: PhysicsJointData;
  99287. private _physicsJoint;
  99288. protected _physicsPlugin: IPhysicsEnginePlugin;
  99289. /**
  99290. * Initializes the physics joint
  99291. * @param type The type of the physics joint
  99292. * @param jointData The data for the physics joint
  99293. */
  99294. constructor(
  99295. /**
  99296. * The type of the physics joint
  99297. */
  99298. type: number,
  99299. /**
  99300. * The data for the physics joint
  99301. */
  99302. jointData: PhysicsJointData);
  99303. /**
  99304. * Gets the physics joint
  99305. */
  99306. get physicsJoint(): any;
  99307. /**
  99308. * Sets the physics joint
  99309. */
  99310. set physicsJoint(newJoint: any);
  99311. /**
  99312. * Sets the physics plugin
  99313. */
  99314. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  99315. /**
  99316. * Execute a function that is physics-plugin specific.
  99317. * @param {Function} func the function that will be executed.
  99318. * It accepts two parameters: the physics world and the physics joint
  99319. */
  99320. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  99321. /**
  99322. * Distance-Joint type
  99323. */
  99324. static DistanceJoint: number;
  99325. /**
  99326. * Hinge-Joint type
  99327. */
  99328. static HingeJoint: number;
  99329. /**
  99330. * Ball-and-Socket joint type
  99331. */
  99332. static BallAndSocketJoint: number;
  99333. /**
  99334. * Wheel-Joint type
  99335. */
  99336. static WheelJoint: number;
  99337. /**
  99338. * Slider-Joint type
  99339. */
  99340. static SliderJoint: number;
  99341. /**
  99342. * Prismatic-Joint type
  99343. */
  99344. static PrismaticJoint: number;
  99345. /**
  99346. * Universal-Joint type
  99347. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  99348. */
  99349. static UniversalJoint: number;
  99350. /**
  99351. * Hinge-Joint 2 type
  99352. */
  99353. static Hinge2Joint: number;
  99354. /**
  99355. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  99356. */
  99357. static PointToPointJoint: number;
  99358. /**
  99359. * Spring-Joint type
  99360. */
  99361. static SpringJoint: number;
  99362. /**
  99363. * Lock-Joint type
  99364. */
  99365. static LockJoint: number;
  99366. }
  99367. /**
  99368. * A class representing a physics distance joint
  99369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99370. */
  99371. export class DistanceJoint extends PhysicsJoint {
  99372. /**
  99373. *
  99374. * @param jointData The data for the Distance-Joint
  99375. */
  99376. constructor(jointData: DistanceJointData);
  99377. /**
  99378. * Update the predefined distance.
  99379. * @param maxDistance The maximum preferred distance
  99380. * @param minDistance The minimum preferred distance
  99381. */
  99382. updateDistance(maxDistance: number, minDistance?: number): void;
  99383. }
  99384. /**
  99385. * Represents a Motor-Enabled Joint
  99386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99387. */
  99388. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  99389. /**
  99390. * Initializes the Motor-Enabled Joint
  99391. * @param type The type of the joint
  99392. * @param jointData The physica joint data for the joint
  99393. */
  99394. constructor(type: number, jointData: PhysicsJointData);
  99395. /**
  99396. * Set the motor values.
  99397. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99398. * @param force the force to apply
  99399. * @param maxForce max force for this motor.
  99400. */
  99401. setMotor(force?: number, maxForce?: number): void;
  99402. /**
  99403. * Set the motor's limits.
  99404. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99405. * @param upperLimit The upper limit of the motor
  99406. * @param lowerLimit The lower limit of the motor
  99407. */
  99408. setLimit(upperLimit: number, lowerLimit?: number): void;
  99409. }
  99410. /**
  99411. * This class represents a single physics Hinge-Joint
  99412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99413. */
  99414. export class HingeJoint extends MotorEnabledJoint {
  99415. /**
  99416. * Initializes the Hinge-Joint
  99417. * @param jointData The joint data for the Hinge-Joint
  99418. */
  99419. constructor(jointData: PhysicsJointData);
  99420. /**
  99421. * Set the motor values.
  99422. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99423. * @param {number} force the force to apply
  99424. * @param {number} maxForce max force for this motor.
  99425. */
  99426. setMotor(force?: number, maxForce?: number): void;
  99427. /**
  99428. * Set the motor's limits.
  99429. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99430. * @param upperLimit The upper limit of the motor
  99431. * @param lowerLimit The lower limit of the motor
  99432. */
  99433. setLimit(upperLimit: number, lowerLimit?: number): void;
  99434. }
  99435. /**
  99436. * This class represents a dual hinge physics joint (same as wheel joint)
  99437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99438. */
  99439. export class Hinge2Joint extends MotorEnabledJoint {
  99440. /**
  99441. * Initializes the Hinge2-Joint
  99442. * @param jointData The joint data for the Hinge2-Joint
  99443. */
  99444. constructor(jointData: PhysicsJointData);
  99445. /**
  99446. * Set the motor values.
  99447. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99448. * @param {number} targetSpeed the speed the motor is to reach
  99449. * @param {number} maxForce max force for this motor.
  99450. * @param {motorIndex} the motor's index, 0 or 1.
  99451. */
  99452. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  99453. /**
  99454. * Set the motor limits.
  99455. * Attention, this function is plugin specific. Engines won't react 100% the same.
  99456. * @param {number} upperLimit the upper limit
  99457. * @param {number} lowerLimit lower limit
  99458. * @param {motorIndex} the motor's index, 0 or 1.
  99459. */
  99460. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99461. }
  99462. /**
  99463. * Interface for a motor enabled joint
  99464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99465. */
  99466. export interface IMotorEnabledJoint {
  99467. /**
  99468. * Physics joint
  99469. */
  99470. physicsJoint: any;
  99471. /**
  99472. * Sets the motor of the motor-enabled joint
  99473. * @param force The force of the motor
  99474. * @param maxForce The maximum force of the motor
  99475. * @param motorIndex The index of the motor
  99476. */
  99477. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  99478. /**
  99479. * Sets the limit of the motor
  99480. * @param upperLimit The upper limit of the motor
  99481. * @param lowerLimit The lower limit of the motor
  99482. * @param motorIndex The index of the motor
  99483. */
  99484. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99485. }
  99486. /**
  99487. * Joint data for a Distance-Joint
  99488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99489. */
  99490. export interface DistanceJointData extends PhysicsJointData {
  99491. /**
  99492. * Max distance the 2 joint objects can be apart
  99493. */
  99494. maxDistance: number;
  99495. }
  99496. /**
  99497. * Joint data from a spring joint
  99498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99499. */
  99500. export interface SpringJointData extends PhysicsJointData {
  99501. /**
  99502. * Length of the spring
  99503. */
  99504. length: number;
  99505. /**
  99506. * Stiffness of the spring
  99507. */
  99508. stiffness: number;
  99509. /**
  99510. * Damping of the spring
  99511. */
  99512. damping: number;
  99513. /** this callback will be called when applying the force to the impostors. */
  99514. forceApplicationCallback: () => void;
  99515. }
  99516. }
  99517. declare module BABYLON {
  99518. /**
  99519. * Holds the data for the raycast result
  99520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99521. */
  99522. export class PhysicsRaycastResult {
  99523. private _hasHit;
  99524. private _hitDistance;
  99525. private _hitNormalWorld;
  99526. private _hitPointWorld;
  99527. private _rayFromWorld;
  99528. private _rayToWorld;
  99529. /**
  99530. * Gets if there was a hit
  99531. */
  99532. get hasHit(): boolean;
  99533. /**
  99534. * Gets the distance from the hit
  99535. */
  99536. get hitDistance(): number;
  99537. /**
  99538. * Gets the hit normal/direction in the world
  99539. */
  99540. get hitNormalWorld(): Vector3;
  99541. /**
  99542. * Gets the hit point in the world
  99543. */
  99544. get hitPointWorld(): Vector3;
  99545. /**
  99546. * Gets the ray "start point" of the ray in the world
  99547. */
  99548. get rayFromWorld(): Vector3;
  99549. /**
  99550. * Gets the ray "end point" of the ray in the world
  99551. */
  99552. get rayToWorld(): Vector3;
  99553. /**
  99554. * Sets the hit data (normal & point in world space)
  99555. * @param hitNormalWorld defines the normal in world space
  99556. * @param hitPointWorld defines the point in world space
  99557. */
  99558. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  99559. /**
  99560. * Sets the distance from the start point to the hit point
  99561. * @param distance
  99562. */
  99563. setHitDistance(distance: number): void;
  99564. /**
  99565. * Calculates the distance manually
  99566. */
  99567. calculateHitDistance(): void;
  99568. /**
  99569. * Resets all the values to default
  99570. * @param from The from point on world space
  99571. * @param to The to point on world space
  99572. */
  99573. reset(from?: Vector3, to?: Vector3): void;
  99574. }
  99575. /**
  99576. * Interface for the size containing width and height
  99577. */
  99578. interface IXYZ {
  99579. /**
  99580. * X
  99581. */
  99582. x: number;
  99583. /**
  99584. * Y
  99585. */
  99586. y: number;
  99587. /**
  99588. * Z
  99589. */
  99590. z: number;
  99591. }
  99592. }
  99593. declare module BABYLON {
  99594. /**
  99595. * Interface used to describe a physics joint
  99596. */
  99597. export interface PhysicsImpostorJoint {
  99598. /** Defines the main impostor to which the joint is linked */
  99599. mainImpostor: PhysicsImpostor;
  99600. /** Defines the impostor that is connected to the main impostor using this joint */
  99601. connectedImpostor: PhysicsImpostor;
  99602. /** Defines the joint itself */
  99603. joint: PhysicsJoint;
  99604. }
  99605. /** @hidden */
  99606. export interface IPhysicsEnginePlugin {
  99607. world: any;
  99608. name: string;
  99609. setGravity(gravity: Vector3): void;
  99610. setTimeStep(timeStep: number): void;
  99611. getTimeStep(): number;
  99612. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  99613. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99614. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  99615. generatePhysicsBody(impostor: PhysicsImpostor): void;
  99616. removePhysicsBody(impostor: PhysicsImpostor): void;
  99617. generateJoint(joint: PhysicsImpostorJoint): void;
  99618. removeJoint(joint: PhysicsImpostorJoint): void;
  99619. isSupported(): boolean;
  99620. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  99621. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  99622. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99623. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  99624. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99625. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  99626. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  99627. getBodyMass(impostor: PhysicsImpostor): number;
  99628. getBodyFriction(impostor: PhysicsImpostor): number;
  99629. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  99630. getBodyRestitution(impostor: PhysicsImpostor): number;
  99631. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  99632. getBodyPressure?(impostor: PhysicsImpostor): number;
  99633. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  99634. getBodyStiffness?(impostor: PhysicsImpostor): number;
  99635. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  99636. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  99637. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  99638. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  99639. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  99640. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99641. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  99642. sleepBody(impostor: PhysicsImpostor): void;
  99643. wakeUpBody(impostor: PhysicsImpostor): void;
  99644. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99645. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  99646. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  99647. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  99648. getRadius(impostor: PhysicsImpostor): number;
  99649. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  99650. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  99651. dispose(): void;
  99652. }
  99653. /**
  99654. * Interface used to define a physics engine
  99655. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  99656. */
  99657. export interface IPhysicsEngine {
  99658. /**
  99659. * Gets the gravity vector used by the simulation
  99660. */
  99661. gravity: Vector3;
  99662. /**
  99663. * Sets the gravity vector used by the simulation
  99664. * @param gravity defines the gravity vector to use
  99665. */
  99666. setGravity(gravity: Vector3): void;
  99667. /**
  99668. * Set the time step of the physics engine.
  99669. * Default is 1/60.
  99670. * To slow it down, enter 1/600 for example.
  99671. * To speed it up, 1/30
  99672. * @param newTimeStep the new timestep to apply to this world.
  99673. */
  99674. setTimeStep(newTimeStep: number): void;
  99675. /**
  99676. * Get the time step of the physics engine.
  99677. * @returns the current time step
  99678. */
  99679. getTimeStep(): number;
  99680. /**
  99681. * Set the sub time step of the physics engine.
  99682. * Default is 0 meaning there is no sub steps
  99683. * To increase physics resolution precision, set a small value (like 1 ms)
  99684. * @param subTimeStep defines the new sub timestep used for physics resolution.
  99685. */
  99686. setSubTimeStep(subTimeStep: number): void;
  99687. /**
  99688. * Get the sub time step of the physics engine.
  99689. * @returns the current sub time step
  99690. */
  99691. getSubTimeStep(): number;
  99692. /**
  99693. * Release all resources
  99694. */
  99695. dispose(): void;
  99696. /**
  99697. * Gets the name of the current physics plugin
  99698. * @returns the name of the plugin
  99699. */
  99700. getPhysicsPluginName(): string;
  99701. /**
  99702. * Adding a new impostor for the impostor tracking.
  99703. * This will be done by the impostor itself.
  99704. * @param impostor the impostor to add
  99705. */
  99706. addImpostor(impostor: PhysicsImpostor): void;
  99707. /**
  99708. * Remove an impostor from the engine.
  99709. * This impostor and its mesh will not longer be updated by the physics engine.
  99710. * @param impostor the impostor to remove
  99711. */
  99712. removeImpostor(impostor: PhysicsImpostor): void;
  99713. /**
  99714. * Add a joint to the physics engine
  99715. * @param mainImpostor defines the main impostor to which the joint is added.
  99716. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  99717. * @param joint defines the joint that will connect both impostors.
  99718. */
  99719. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99720. /**
  99721. * Removes a joint from the simulation
  99722. * @param mainImpostor defines the impostor used with the joint
  99723. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  99724. * @param joint defines the joint to remove
  99725. */
  99726. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  99727. /**
  99728. * Gets the current plugin used to run the simulation
  99729. * @returns current plugin
  99730. */
  99731. getPhysicsPlugin(): IPhysicsEnginePlugin;
  99732. /**
  99733. * Gets the list of physic impostors
  99734. * @returns an array of PhysicsImpostor
  99735. */
  99736. getImpostors(): Array<PhysicsImpostor>;
  99737. /**
  99738. * Gets the impostor for a physics enabled object
  99739. * @param object defines the object impersonated by the impostor
  99740. * @returns the PhysicsImpostor or null if not found
  99741. */
  99742. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  99743. /**
  99744. * Gets the impostor for a physics body object
  99745. * @param body defines physics body used by the impostor
  99746. * @returns the PhysicsImpostor or null if not found
  99747. */
  99748. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  99749. /**
  99750. * Does a raycast in the physics world
  99751. * @param from when should the ray start?
  99752. * @param to when should the ray end?
  99753. * @returns PhysicsRaycastResult
  99754. */
  99755. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  99756. /**
  99757. * Called by the scene. No need to call it.
  99758. * @param delta defines the timespam between frames
  99759. */
  99760. _step(delta: number): void;
  99761. }
  99762. }
  99763. declare module BABYLON {
  99764. /**
  99765. * The interface for the physics imposter parameters
  99766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99767. */
  99768. export interface PhysicsImpostorParameters {
  99769. /**
  99770. * The mass of the physics imposter
  99771. */
  99772. mass: number;
  99773. /**
  99774. * The friction of the physics imposter
  99775. */
  99776. friction?: number;
  99777. /**
  99778. * The coefficient of restitution of the physics imposter
  99779. */
  99780. restitution?: number;
  99781. /**
  99782. * The native options of the physics imposter
  99783. */
  99784. nativeOptions?: any;
  99785. /**
  99786. * Specifies if the parent should be ignored
  99787. */
  99788. ignoreParent?: boolean;
  99789. /**
  99790. * Specifies if bi-directional transformations should be disabled
  99791. */
  99792. disableBidirectionalTransformation?: boolean;
  99793. /**
  99794. * The pressure inside the physics imposter, soft object only
  99795. */
  99796. pressure?: number;
  99797. /**
  99798. * The stiffness the physics imposter, soft object only
  99799. */
  99800. stiffness?: number;
  99801. /**
  99802. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  99803. */
  99804. velocityIterations?: number;
  99805. /**
  99806. * The number of iterations used in maintaining consistent vertex positions, soft object only
  99807. */
  99808. positionIterations?: number;
  99809. /**
  99810. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  99811. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  99812. * Add to fix multiple points
  99813. */
  99814. fixedPoints?: number;
  99815. /**
  99816. * The collision margin around a soft object
  99817. */
  99818. margin?: number;
  99819. /**
  99820. * The collision margin around a soft object
  99821. */
  99822. damping?: number;
  99823. /**
  99824. * The path for a rope based on an extrusion
  99825. */
  99826. path?: any;
  99827. /**
  99828. * The shape of an extrusion used for a rope based on an extrusion
  99829. */
  99830. shape?: any;
  99831. }
  99832. /**
  99833. * Interface for a physics-enabled object
  99834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99835. */
  99836. export interface IPhysicsEnabledObject {
  99837. /**
  99838. * The position of the physics-enabled object
  99839. */
  99840. position: Vector3;
  99841. /**
  99842. * The rotation of the physics-enabled object
  99843. */
  99844. rotationQuaternion: Nullable<Quaternion>;
  99845. /**
  99846. * The scale of the physics-enabled object
  99847. */
  99848. scaling: Vector3;
  99849. /**
  99850. * The rotation of the physics-enabled object
  99851. */
  99852. rotation?: Vector3;
  99853. /**
  99854. * The parent of the physics-enabled object
  99855. */
  99856. parent?: any;
  99857. /**
  99858. * The bounding info of the physics-enabled object
  99859. * @returns The bounding info of the physics-enabled object
  99860. */
  99861. getBoundingInfo(): BoundingInfo;
  99862. /**
  99863. * Computes the world matrix
  99864. * @param force Specifies if the world matrix should be computed by force
  99865. * @returns A world matrix
  99866. */
  99867. computeWorldMatrix(force: boolean): Matrix;
  99868. /**
  99869. * Gets the world matrix
  99870. * @returns A world matrix
  99871. */
  99872. getWorldMatrix?(): Matrix;
  99873. /**
  99874. * Gets the child meshes
  99875. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  99876. * @returns An array of abstract meshes
  99877. */
  99878. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  99879. /**
  99880. * Gets the vertex data
  99881. * @param kind The type of vertex data
  99882. * @returns A nullable array of numbers, or a float32 array
  99883. */
  99884. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  99885. /**
  99886. * Gets the indices from the mesh
  99887. * @returns A nullable array of index arrays
  99888. */
  99889. getIndices?(): Nullable<IndicesArray>;
  99890. /**
  99891. * Gets the scene from the mesh
  99892. * @returns the indices array or null
  99893. */
  99894. getScene?(): Scene;
  99895. /**
  99896. * Gets the absolute position from the mesh
  99897. * @returns the absolute position
  99898. */
  99899. getAbsolutePosition(): Vector3;
  99900. /**
  99901. * Gets the absolute pivot point from the mesh
  99902. * @returns the absolute pivot point
  99903. */
  99904. getAbsolutePivotPoint(): Vector3;
  99905. /**
  99906. * Rotates the mesh
  99907. * @param axis The axis of rotation
  99908. * @param amount The amount of rotation
  99909. * @param space The space of the rotation
  99910. * @returns The rotation transform node
  99911. */
  99912. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  99913. /**
  99914. * Translates the mesh
  99915. * @param axis The axis of translation
  99916. * @param distance The distance of translation
  99917. * @param space The space of the translation
  99918. * @returns The transform node
  99919. */
  99920. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  99921. /**
  99922. * Sets the absolute position of the mesh
  99923. * @param absolutePosition The absolute position of the mesh
  99924. * @returns The transform node
  99925. */
  99926. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  99927. /**
  99928. * Gets the class name of the mesh
  99929. * @returns The class name
  99930. */
  99931. getClassName(): string;
  99932. }
  99933. /**
  99934. * Represents a physics imposter
  99935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  99936. */
  99937. export class PhysicsImpostor {
  99938. /**
  99939. * The physics-enabled object used as the physics imposter
  99940. */
  99941. object: IPhysicsEnabledObject;
  99942. /**
  99943. * The type of the physics imposter
  99944. */
  99945. type: number;
  99946. private _options;
  99947. private _scene?;
  99948. /**
  99949. * The default object size of the imposter
  99950. */
  99951. static DEFAULT_OBJECT_SIZE: Vector3;
  99952. /**
  99953. * The identity quaternion of the imposter
  99954. */
  99955. static IDENTITY_QUATERNION: Quaternion;
  99956. /** @hidden */
  99957. _pluginData: any;
  99958. private _physicsEngine;
  99959. private _physicsBody;
  99960. private _bodyUpdateRequired;
  99961. private _onBeforePhysicsStepCallbacks;
  99962. private _onAfterPhysicsStepCallbacks;
  99963. /** @hidden */
  99964. _onPhysicsCollideCallbacks: Array<{
  99965. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  99966. otherImpostors: Array<PhysicsImpostor>;
  99967. }>;
  99968. private _deltaPosition;
  99969. private _deltaRotation;
  99970. private _deltaRotationConjugated;
  99971. /** @hidden */
  99972. _isFromLine: boolean;
  99973. private _parent;
  99974. private _isDisposed;
  99975. private static _tmpVecs;
  99976. private static _tmpQuat;
  99977. /**
  99978. * Specifies if the physics imposter is disposed
  99979. */
  99980. get isDisposed(): boolean;
  99981. /**
  99982. * Gets the mass of the physics imposter
  99983. */
  99984. get mass(): number;
  99985. set mass(value: number);
  99986. /**
  99987. * Gets the coefficient of friction
  99988. */
  99989. get friction(): number;
  99990. /**
  99991. * Sets the coefficient of friction
  99992. */
  99993. set friction(value: number);
  99994. /**
  99995. * Gets the coefficient of restitution
  99996. */
  99997. get restitution(): number;
  99998. /**
  99999. * Sets the coefficient of restitution
  100000. */
  100001. set restitution(value: number);
  100002. /**
  100003. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  100004. */
  100005. get pressure(): number;
  100006. /**
  100007. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  100008. */
  100009. set pressure(value: number);
  100010. /**
  100011. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100012. */
  100013. get stiffness(): number;
  100014. /**
  100015. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  100016. */
  100017. set stiffness(value: number);
  100018. /**
  100019. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100020. */
  100021. get velocityIterations(): number;
  100022. /**
  100023. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  100024. */
  100025. set velocityIterations(value: number);
  100026. /**
  100027. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100028. */
  100029. get positionIterations(): number;
  100030. /**
  100031. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  100032. */
  100033. set positionIterations(value: number);
  100034. /**
  100035. * The unique id of the physics imposter
  100036. * set by the physics engine when adding this impostor to the array
  100037. */
  100038. uniqueId: number;
  100039. /**
  100040. * @hidden
  100041. */
  100042. soft: boolean;
  100043. /**
  100044. * @hidden
  100045. */
  100046. segments: number;
  100047. private _joints;
  100048. /**
  100049. * Initializes the physics imposter
  100050. * @param object The physics-enabled object used as the physics imposter
  100051. * @param type The type of the physics imposter
  100052. * @param _options The options for the physics imposter
  100053. * @param _scene The Babylon scene
  100054. */
  100055. constructor(
  100056. /**
  100057. * The physics-enabled object used as the physics imposter
  100058. */
  100059. object: IPhysicsEnabledObject,
  100060. /**
  100061. * The type of the physics imposter
  100062. */
  100063. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  100064. /**
  100065. * This function will completly initialize this impostor.
  100066. * It will create a new body - but only if this mesh has no parent.
  100067. * If it has, this impostor will not be used other than to define the impostor
  100068. * of the child mesh.
  100069. * @hidden
  100070. */
  100071. _init(): void;
  100072. private _getPhysicsParent;
  100073. /**
  100074. * Should a new body be generated.
  100075. * @returns boolean specifying if body initialization is required
  100076. */
  100077. isBodyInitRequired(): boolean;
  100078. /**
  100079. * Sets the updated scaling
  100080. * @param updated Specifies if the scaling is updated
  100081. */
  100082. setScalingUpdated(): void;
  100083. /**
  100084. * Force a regeneration of this or the parent's impostor's body.
  100085. * Use under cautious - This will remove all joints already implemented.
  100086. */
  100087. forceUpdate(): void;
  100088. /**
  100089. * Gets the body that holds this impostor. Either its own, or its parent.
  100090. */
  100091. get physicsBody(): any;
  100092. /**
  100093. * Get the parent of the physics imposter
  100094. * @returns Physics imposter or null
  100095. */
  100096. get parent(): Nullable<PhysicsImpostor>;
  100097. /**
  100098. * Sets the parent of the physics imposter
  100099. */
  100100. set parent(value: Nullable<PhysicsImpostor>);
  100101. /**
  100102. * Set the physics body. Used mainly by the physics engine/plugin
  100103. */
  100104. set physicsBody(physicsBody: any);
  100105. /**
  100106. * Resets the update flags
  100107. */
  100108. resetUpdateFlags(): void;
  100109. /**
  100110. * Gets the object extend size
  100111. * @returns the object extend size
  100112. */
  100113. getObjectExtendSize(): Vector3;
  100114. /**
  100115. * Gets the object center
  100116. * @returns The object center
  100117. */
  100118. getObjectCenter(): Vector3;
  100119. /**
  100120. * Get a specific parameter from the options parameters
  100121. * @param paramName The object parameter name
  100122. * @returns The object parameter
  100123. */
  100124. getParam(paramName: string): any;
  100125. /**
  100126. * Sets a specific parameter in the options given to the physics plugin
  100127. * @param paramName The parameter name
  100128. * @param value The value of the parameter
  100129. */
  100130. setParam(paramName: string, value: number): void;
  100131. /**
  100132. * Specifically change the body's mass option. Won't recreate the physics body object
  100133. * @param mass The mass of the physics imposter
  100134. */
  100135. setMass(mass: number): void;
  100136. /**
  100137. * Gets the linear velocity
  100138. * @returns linear velocity or null
  100139. */
  100140. getLinearVelocity(): Nullable<Vector3>;
  100141. /**
  100142. * Sets the linear velocity
  100143. * @param velocity linear velocity or null
  100144. */
  100145. setLinearVelocity(velocity: Nullable<Vector3>): void;
  100146. /**
  100147. * Gets the angular velocity
  100148. * @returns angular velocity or null
  100149. */
  100150. getAngularVelocity(): Nullable<Vector3>;
  100151. /**
  100152. * Sets the angular velocity
  100153. * @param velocity The velocity or null
  100154. */
  100155. setAngularVelocity(velocity: Nullable<Vector3>): void;
  100156. /**
  100157. * Execute a function with the physics plugin native code
  100158. * Provide a function the will have two variables - the world object and the physics body object
  100159. * @param func The function to execute with the physics plugin native code
  100160. */
  100161. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  100162. /**
  100163. * Register a function that will be executed before the physics world is stepping forward
  100164. * @param func The function to execute before the physics world is stepped forward
  100165. */
  100166. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100167. /**
  100168. * Unregister a function that will be executed before the physics world is stepping forward
  100169. * @param func The function to execute before the physics world is stepped forward
  100170. */
  100171. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100172. /**
  100173. * Register a function that will be executed after the physics step
  100174. * @param func The function to execute after physics step
  100175. */
  100176. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100177. /**
  100178. * Unregisters a function that will be executed after the physics step
  100179. * @param func The function to execute after physics step
  100180. */
  100181. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  100182. /**
  100183. * register a function that will be executed when this impostor collides against a different body
  100184. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  100185. * @param func Callback that is executed on collision
  100186. */
  100187. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  100188. /**
  100189. * Unregisters the physics imposter on contact
  100190. * @param collideAgainst The physics object to collide against
  100191. * @param func Callback to execute on collision
  100192. */
  100193. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  100194. private _tmpQuat;
  100195. private _tmpQuat2;
  100196. /**
  100197. * Get the parent rotation
  100198. * @returns The parent rotation
  100199. */
  100200. getParentsRotation(): Quaternion;
  100201. /**
  100202. * this function is executed by the physics engine.
  100203. */
  100204. beforeStep: () => void;
  100205. /**
  100206. * this function is executed by the physics engine
  100207. */
  100208. afterStep: () => void;
  100209. /**
  100210. * Legacy collision detection event support
  100211. */
  100212. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  100213. /**
  100214. * event and body object due to cannon's event-based architecture.
  100215. */
  100216. onCollide: (e: {
  100217. body: any;
  100218. }) => void;
  100219. /**
  100220. * Apply a force
  100221. * @param force The force to apply
  100222. * @param contactPoint The contact point for the force
  100223. * @returns The physics imposter
  100224. */
  100225. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100226. /**
  100227. * Apply an impulse
  100228. * @param force The impulse force
  100229. * @param contactPoint The contact point for the impulse force
  100230. * @returns The physics imposter
  100231. */
  100232. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  100233. /**
  100234. * A help function to create a joint
  100235. * @param otherImpostor A physics imposter used to create a joint
  100236. * @param jointType The type of joint
  100237. * @param jointData The data for the joint
  100238. * @returns The physics imposter
  100239. */
  100240. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  100241. /**
  100242. * Add a joint to this impostor with a different impostor
  100243. * @param otherImpostor A physics imposter used to add a joint
  100244. * @param joint The joint to add
  100245. * @returns The physics imposter
  100246. */
  100247. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  100248. /**
  100249. * Add an anchor to a cloth impostor
  100250. * @param otherImpostor rigid impostor to anchor to
  100251. * @param width ratio across width from 0 to 1
  100252. * @param height ratio up height from 0 to 1
  100253. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  100254. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  100255. * @returns impostor the soft imposter
  100256. */
  100257. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100258. /**
  100259. * Add a hook to a rope impostor
  100260. * @param otherImpostor rigid impostor to anchor to
  100261. * @param length ratio across rope from 0 to 1
  100262. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  100263. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  100264. * @returns impostor the rope imposter
  100265. */
  100266. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  100267. /**
  100268. * Will keep this body still, in a sleep mode.
  100269. * @returns the physics imposter
  100270. */
  100271. sleep(): PhysicsImpostor;
  100272. /**
  100273. * Wake the body up.
  100274. * @returns The physics imposter
  100275. */
  100276. wakeUp(): PhysicsImpostor;
  100277. /**
  100278. * Clones the physics imposter
  100279. * @param newObject The physics imposter clones to this physics-enabled object
  100280. * @returns A nullable physics imposter
  100281. */
  100282. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  100283. /**
  100284. * Disposes the physics imposter
  100285. */
  100286. dispose(): void;
  100287. /**
  100288. * Sets the delta position
  100289. * @param position The delta position amount
  100290. */
  100291. setDeltaPosition(position: Vector3): void;
  100292. /**
  100293. * Sets the delta rotation
  100294. * @param rotation The delta rotation amount
  100295. */
  100296. setDeltaRotation(rotation: Quaternion): void;
  100297. /**
  100298. * Gets the box size of the physics imposter and stores the result in the input parameter
  100299. * @param result Stores the box size
  100300. * @returns The physics imposter
  100301. */
  100302. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  100303. /**
  100304. * Gets the radius of the physics imposter
  100305. * @returns Radius of the physics imposter
  100306. */
  100307. getRadius(): number;
  100308. /**
  100309. * Sync a bone with this impostor
  100310. * @param bone The bone to sync to the impostor.
  100311. * @param boneMesh The mesh that the bone is influencing.
  100312. * @param jointPivot The pivot of the joint / bone in local space.
  100313. * @param distToJoint Optional distance from the impostor to the joint.
  100314. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100315. */
  100316. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  100317. /**
  100318. * Sync impostor to a bone
  100319. * @param bone The bone that the impostor will be synced to.
  100320. * @param boneMesh The mesh that the bone is influencing.
  100321. * @param jointPivot The pivot of the joint / bone in local space.
  100322. * @param distToJoint Optional distance from the impostor to the joint.
  100323. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  100324. * @param boneAxis Optional vector3 axis the bone is aligned with
  100325. */
  100326. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  100327. /**
  100328. * No-Imposter type
  100329. */
  100330. static NoImpostor: number;
  100331. /**
  100332. * Sphere-Imposter type
  100333. */
  100334. static SphereImpostor: number;
  100335. /**
  100336. * Box-Imposter type
  100337. */
  100338. static BoxImpostor: number;
  100339. /**
  100340. * Plane-Imposter type
  100341. */
  100342. static PlaneImpostor: number;
  100343. /**
  100344. * Mesh-imposter type
  100345. */
  100346. static MeshImpostor: number;
  100347. /**
  100348. * Capsule-Impostor type (Ammo.js plugin only)
  100349. */
  100350. static CapsuleImpostor: number;
  100351. /**
  100352. * Cylinder-Imposter type
  100353. */
  100354. static CylinderImpostor: number;
  100355. /**
  100356. * Particle-Imposter type
  100357. */
  100358. static ParticleImpostor: number;
  100359. /**
  100360. * Heightmap-Imposter type
  100361. */
  100362. static HeightmapImpostor: number;
  100363. /**
  100364. * ConvexHull-Impostor type (Ammo.js plugin only)
  100365. */
  100366. static ConvexHullImpostor: number;
  100367. /**
  100368. * Custom-Imposter type (Ammo.js plugin only)
  100369. */
  100370. static CustomImpostor: number;
  100371. /**
  100372. * Rope-Imposter type
  100373. */
  100374. static RopeImpostor: number;
  100375. /**
  100376. * Cloth-Imposter type
  100377. */
  100378. static ClothImpostor: number;
  100379. /**
  100380. * Softbody-Imposter type
  100381. */
  100382. static SoftbodyImpostor: number;
  100383. }
  100384. }
  100385. declare module BABYLON {
  100386. /**
  100387. * @hidden
  100388. **/
  100389. export class _CreationDataStorage {
  100390. closePath?: boolean;
  100391. closeArray?: boolean;
  100392. idx: number[];
  100393. dashSize: number;
  100394. gapSize: number;
  100395. path3D: Path3D;
  100396. pathArray: Vector3[][];
  100397. arc: number;
  100398. radius: number;
  100399. cap: number;
  100400. tessellation: number;
  100401. }
  100402. /**
  100403. * @hidden
  100404. **/
  100405. class _InstanceDataStorage {
  100406. visibleInstances: any;
  100407. batchCache: _InstancesBatch;
  100408. instancesBufferSize: number;
  100409. instancesBuffer: Nullable<Buffer>;
  100410. instancesData: Float32Array;
  100411. overridenInstanceCount: number;
  100412. isFrozen: boolean;
  100413. previousBatch: Nullable<_InstancesBatch>;
  100414. hardwareInstancedRendering: boolean;
  100415. sideOrientation: number;
  100416. manualUpdate: boolean;
  100417. }
  100418. /**
  100419. * @hidden
  100420. **/
  100421. export class _InstancesBatch {
  100422. mustReturn: boolean;
  100423. visibleInstances: Nullable<InstancedMesh[]>[];
  100424. renderSelf: boolean[];
  100425. hardwareInstancedRendering: boolean[];
  100426. }
  100427. /**
  100428. * Class used to represent renderable models
  100429. */
  100430. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  100431. /**
  100432. * Mesh side orientation : usually the external or front surface
  100433. */
  100434. static readonly FRONTSIDE: number;
  100435. /**
  100436. * Mesh side orientation : usually the internal or back surface
  100437. */
  100438. static readonly BACKSIDE: number;
  100439. /**
  100440. * Mesh side orientation : both internal and external or front and back surfaces
  100441. */
  100442. static readonly DOUBLESIDE: number;
  100443. /**
  100444. * Mesh side orientation : by default, `FRONTSIDE`
  100445. */
  100446. static readonly DEFAULTSIDE: number;
  100447. /**
  100448. * Mesh cap setting : no cap
  100449. */
  100450. static readonly NO_CAP: number;
  100451. /**
  100452. * Mesh cap setting : one cap at the beginning of the mesh
  100453. */
  100454. static readonly CAP_START: number;
  100455. /**
  100456. * Mesh cap setting : one cap at the end of the mesh
  100457. */
  100458. static readonly CAP_END: number;
  100459. /**
  100460. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  100461. */
  100462. static readonly CAP_ALL: number;
  100463. /**
  100464. * Mesh pattern setting : no flip or rotate
  100465. */
  100466. static readonly NO_FLIP: number;
  100467. /**
  100468. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  100469. */
  100470. static readonly FLIP_TILE: number;
  100471. /**
  100472. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  100473. */
  100474. static readonly ROTATE_TILE: number;
  100475. /**
  100476. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  100477. */
  100478. static readonly FLIP_ROW: number;
  100479. /**
  100480. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  100481. */
  100482. static readonly ROTATE_ROW: number;
  100483. /**
  100484. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  100485. */
  100486. static readonly FLIP_N_ROTATE_TILE: number;
  100487. /**
  100488. * Mesh pattern setting : rotate pattern and rotate
  100489. */
  100490. static readonly FLIP_N_ROTATE_ROW: number;
  100491. /**
  100492. * Mesh tile positioning : part tiles same on left/right or top/bottom
  100493. */
  100494. static readonly CENTER: number;
  100495. /**
  100496. * Mesh tile positioning : part tiles on left
  100497. */
  100498. static readonly LEFT: number;
  100499. /**
  100500. * Mesh tile positioning : part tiles on right
  100501. */
  100502. static readonly RIGHT: number;
  100503. /**
  100504. * Mesh tile positioning : part tiles on top
  100505. */
  100506. static readonly TOP: number;
  100507. /**
  100508. * Mesh tile positioning : part tiles on bottom
  100509. */
  100510. static readonly BOTTOM: number;
  100511. /**
  100512. * Gets the default side orientation.
  100513. * @param orientation the orientation to value to attempt to get
  100514. * @returns the default orientation
  100515. * @hidden
  100516. */
  100517. static _GetDefaultSideOrientation(orientation?: number): number;
  100518. private _internalMeshDataInfo;
  100519. /**
  100520. * An event triggered before rendering the mesh
  100521. */
  100522. get onBeforeRenderObservable(): Observable<Mesh>;
  100523. /**
  100524. * An event triggered before binding the mesh
  100525. */
  100526. get onBeforeBindObservable(): Observable<Mesh>;
  100527. /**
  100528. * An event triggered after rendering the mesh
  100529. */
  100530. get onAfterRenderObservable(): Observable<Mesh>;
  100531. /**
  100532. * An event triggered before drawing the mesh
  100533. */
  100534. get onBeforeDrawObservable(): Observable<Mesh>;
  100535. private _onBeforeDrawObserver;
  100536. /**
  100537. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  100538. */
  100539. set onBeforeDraw(callback: () => void);
  100540. get hasInstances(): boolean;
  100541. /**
  100542. * Gets the delay loading state of the mesh (when delay loading is turned on)
  100543. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  100544. */
  100545. delayLoadState: number;
  100546. /**
  100547. * Gets the list of instances created from this mesh
  100548. * it is not supposed to be modified manually.
  100549. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  100550. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  100551. */
  100552. instances: InstancedMesh[];
  100553. /**
  100554. * Gets the file containing delay loading data for this mesh
  100555. */
  100556. delayLoadingFile: string;
  100557. /** @hidden */
  100558. _binaryInfo: any;
  100559. /**
  100560. * User defined function used to change how LOD level selection is done
  100561. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  100562. */
  100563. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  100564. /**
  100565. * Gets or sets the morph target manager
  100566. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  100567. */
  100568. get morphTargetManager(): Nullable<MorphTargetManager>;
  100569. set morphTargetManager(value: Nullable<MorphTargetManager>);
  100570. /** @hidden */
  100571. _creationDataStorage: Nullable<_CreationDataStorage>;
  100572. /** @hidden */
  100573. _geometry: Nullable<Geometry>;
  100574. /** @hidden */
  100575. _delayInfo: Array<string>;
  100576. /** @hidden */
  100577. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  100578. /** @hidden */
  100579. _instanceDataStorage: _InstanceDataStorage;
  100580. private _effectiveMaterial;
  100581. /** @hidden */
  100582. _shouldGenerateFlatShading: boolean;
  100583. /** @hidden */
  100584. _originalBuilderSideOrientation: number;
  100585. /**
  100586. * Use this property to change the original side orientation defined at construction time
  100587. */
  100588. overrideMaterialSideOrientation: Nullable<number>;
  100589. /**
  100590. * Gets the source mesh (the one used to clone this one from)
  100591. */
  100592. get source(): Nullable<Mesh>;
  100593. /**
  100594. * Gets or sets a boolean indicating that this mesh does not use index buffer
  100595. */
  100596. get isUnIndexed(): boolean;
  100597. set isUnIndexed(value: boolean);
  100598. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  100599. get worldMatrixInstancedBuffer(): Float32Array;
  100600. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  100601. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  100602. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  100603. /**
  100604. * @constructor
  100605. * @param name The value used by scene.getMeshByName() to do a lookup.
  100606. * @param scene The scene to add this mesh to.
  100607. * @param parent The parent of this mesh, if it has one
  100608. * @param source An optional Mesh from which geometry is shared, cloned.
  100609. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  100610. * When false, achieved by calling a clone(), also passing False.
  100611. * This will make creation of children, recursive.
  100612. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  100613. */
  100614. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  100615. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  100616. doNotInstantiate: boolean;
  100617. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  100618. /**
  100619. * Gets the class name
  100620. * @returns the string "Mesh".
  100621. */
  100622. getClassName(): string;
  100623. /** @hidden */
  100624. get _isMesh(): boolean;
  100625. /**
  100626. * Returns a description of this mesh
  100627. * @param fullDetails define if full details about this mesh must be used
  100628. * @returns a descriptive string representing this mesh
  100629. */
  100630. toString(fullDetails?: boolean): string;
  100631. /** @hidden */
  100632. _unBindEffect(): void;
  100633. /**
  100634. * Gets a boolean indicating if this mesh has LOD
  100635. */
  100636. get hasLODLevels(): boolean;
  100637. /**
  100638. * Gets the list of MeshLODLevel associated with the current mesh
  100639. * @returns an array of MeshLODLevel
  100640. */
  100641. getLODLevels(): MeshLODLevel[];
  100642. private _sortLODLevels;
  100643. /**
  100644. * Add a mesh as LOD level triggered at the given distance.
  100645. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100646. * @param distance The distance from the center of the object to show this level
  100647. * @param mesh The mesh to be added as LOD level (can be null)
  100648. * @return This mesh (for chaining)
  100649. */
  100650. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  100651. /**
  100652. * Returns the LOD level mesh at the passed distance or null if not found.
  100653. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100654. * @param distance The distance from the center of the object to show this level
  100655. * @returns a Mesh or `null`
  100656. */
  100657. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  100658. /**
  100659. * Remove a mesh from the LOD array
  100660. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100661. * @param mesh defines the mesh to be removed
  100662. * @return This mesh (for chaining)
  100663. */
  100664. removeLODLevel(mesh: Mesh): Mesh;
  100665. /**
  100666. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  100667. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  100668. * @param camera defines the camera to use to compute distance
  100669. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  100670. * @return This mesh (for chaining)
  100671. */
  100672. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  100673. /**
  100674. * Gets the mesh internal Geometry object
  100675. */
  100676. get geometry(): Nullable<Geometry>;
  100677. /**
  100678. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  100679. * @returns the total number of vertices
  100680. */
  100681. getTotalVertices(): number;
  100682. /**
  100683. * Returns the content of an associated vertex buffer
  100684. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100685. * - VertexBuffer.PositionKind
  100686. * - VertexBuffer.UVKind
  100687. * - VertexBuffer.UV2Kind
  100688. * - VertexBuffer.UV3Kind
  100689. * - VertexBuffer.UV4Kind
  100690. * - VertexBuffer.UV5Kind
  100691. * - VertexBuffer.UV6Kind
  100692. * - VertexBuffer.ColorKind
  100693. * - VertexBuffer.MatricesIndicesKind
  100694. * - VertexBuffer.MatricesIndicesExtraKind
  100695. * - VertexBuffer.MatricesWeightsKind
  100696. * - VertexBuffer.MatricesWeightsExtraKind
  100697. * @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
  100698. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  100699. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  100700. */
  100701. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  100702. /**
  100703. * Returns the mesh VertexBuffer object from the requested `kind`
  100704. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100705. * - VertexBuffer.PositionKind
  100706. * - VertexBuffer.NormalKind
  100707. * - VertexBuffer.UVKind
  100708. * - VertexBuffer.UV2Kind
  100709. * - VertexBuffer.UV3Kind
  100710. * - VertexBuffer.UV4Kind
  100711. * - VertexBuffer.UV5Kind
  100712. * - VertexBuffer.UV6Kind
  100713. * - VertexBuffer.ColorKind
  100714. * - VertexBuffer.MatricesIndicesKind
  100715. * - VertexBuffer.MatricesIndicesExtraKind
  100716. * - VertexBuffer.MatricesWeightsKind
  100717. * - VertexBuffer.MatricesWeightsExtraKind
  100718. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  100719. */
  100720. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  100721. /**
  100722. * Tests if a specific vertex buffer is associated with this mesh
  100723. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100724. * - VertexBuffer.PositionKind
  100725. * - VertexBuffer.NormalKind
  100726. * - VertexBuffer.UVKind
  100727. * - VertexBuffer.UV2Kind
  100728. * - VertexBuffer.UV3Kind
  100729. * - VertexBuffer.UV4Kind
  100730. * - VertexBuffer.UV5Kind
  100731. * - VertexBuffer.UV6Kind
  100732. * - VertexBuffer.ColorKind
  100733. * - VertexBuffer.MatricesIndicesKind
  100734. * - VertexBuffer.MatricesIndicesExtraKind
  100735. * - VertexBuffer.MatricesWeightsKind
  100736. * - VertexBuffer.MatricesWeightsExtraKind
  100737. * @returns a boolean
  100738. */
  100739. isVerticesDataPresent(kind: string): boolean;
  100740. /**
  100741. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  100742. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  100743. * - VertexBuffer.PositionKind
  100744. * - VertexBuffer.UVKind
  100745. * - VertexBuffer.UV2Kind
  100746. * - VertexBuffer.UV3Kind
  100747. * - VertexBuffer.UV4Kind
  100748. * - VertexBuffer.UV5Kind
  100749. * - VertexBuffer.UV6Kind
  100750. * - VertexBuffer.ColorKind
  100751. * - VertexBuffer.MatricesIndicesKind
  100752. * - VertexBuffer.MatricesIndicesExtraKind
  100753. * - VertexBuffer.MatricesWeightsKind
  100754. * - VertexBuffer.MatricesWeightsExtraKind
  100755. * @returns a boolean
  100756. */
  100757. isVertexBufferUpdatable(kind: string): boolean;
  100758. /**
  100759. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  100760. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  100761. * - VertexBuffer.PositionKind
  100762. * - VertexBuffer.NormalKind
  100763. * - VertexBuffer.UVKind
  100764. * - VertexBuffer.UV2Kind
  100765. * - VertexBuffer.UV3Kind
  100766. * - VertexBuffer.UV4Kind
  100767. * - VertexBuffer.UV5Kind
  100768. * - VertexBuffer.UV6Kind
  100769. * - VertexBuffer.ColorKind
  100770. * - VertexBuffer.MatricesIndicesKind
  100771. * - VertexBuffer.MatricesIndicesExtraKind
  100772. * - VertexBuffer.MatricesWeightsKind
  100773. * - VertexBuffer.MatricesWeightsExtraKind
  100774. * @returns an array of strings
  100775. */
  100776. getVerticesDataKinds(): string[];
  100777. /**
  100778. * Returns a positive integer : the total number of indices in this mesh geometry.
  100779. * @returns the numner of indices or zero if the mesh has no geometry.
  100780. */
  100781. getTotalIndices(): number;
  100782. /**
  100783. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  100784. * @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.
  100785. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  100786. * @returns the indices array or an empty array if the mesh has no geometry
  100787. */
  100788. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  100789. get isBlocked(): boolean;
  100790. /**
  100791. * Determine if the current mesh is ready to be rendered
  100792. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  100793. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  100794. * @returns true if all associated assets are ready (material, textures, shaders)
  100795. */
  100796. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  100797. /**
  100798. * 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.
  100799. */
  100800. get areNormalsFrozen(): boolean;
  100801. /**
  100802. * 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.
  100803. * @returns the current mesh
  100804. */
  100805. freezeNormals(): Mesh;
  100806. /**
  100807. * 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
  100808. * @returns the current mesh
  100809. */
  100810. unfreezeNormals(): Mesh;
  100811. /**
  100812. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  100813. */
  100814. set overridenInstanceCount(count: number);
  100815. /** @hidden */
  100816. _preActivate(): Mesh;
  100817. /** @hidden */
  100818. _preActivateForIntermediateRendering(renderId: number): Mesh;
  100819. /** @hidden */
  100820. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  100821. /**
  100822. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  100823. * This means the mesh underlying bounding box and sphere are recomputed.
  100824. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  100825. * @returns the current mesh
  100826. */
  100827. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  100828. /** @hidden */
  100829. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  100830. /**
  100831. * This function will subdivide the mesh into multiple submeshes
  100832. * @param count defines the expected number of submeshes
  100833. */
  100834. subdivide(count: number): void;
  100835. /**
  100836. * Copy a FloatArray into a specific associated vertex buffer
  100837. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  100838. * - VertexBuffer.PositionKind
  100839. * - VertexBuffer.UVKind
  100840. * - VertexBuffer.UV2Kind
  100841. * - VertexBuffer.UV3Kind
  100842. * - VertexBuffer.UV4Kind
  100843. * - VertexBuffer.UV5Kind
  100844. * - VertexBuffer.UV6Kind
  100845. * - VertexBuffer.ColorKind
  100846. * - VertexBuffer.MatricesIndicesKind
  100847. * - VertexBuffer.MatricesIndicesExtraKind
  100848. * - VertexBuffer.MatricesWeightsKind
  100849. * - VertexBuffer.MatricesWeightsExtraKind
  100850. * @param data defines the data source
  100851. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  100852. * @param stride defines the data stride size (can be null)
  100853. * @returns the current mesh
  100854. */
  100855. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  100856. /**
  100857. * Delete a vertex buffer associated with this mesh
  100858. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  100859. * - VertexBuffer.PositionKind
  100860. * - VertexBuffer.UVKind
  100861. * - VertexBuffer.UV2Kind
  100862. * - VertexBuffer.UV3Kind
  100863. * - VertexBuffer.UV4Kind
  100864. * - VertexBuffer.UV5Kind
  100865. * - VertexBuffer.UV6Kind
  100866. * - VertexBuffer.ColorKind
  100867. * - VertexBuffer.MatricesIndicesKind
  100868. * - VertexBuffer.MatricesIndicesExtraKind
  100869. * - VertexBuffer.MatricesWeightsKind
  100870. * - VertexBuffer.MatricesWeightsExtraKind
  100871. */
  100872. removeVerticesData(kind: string): void;
  100873. /**
  100874. * Flags an associated vertex buffer as updatable
  100875. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  100876. * - VertexBuffer.PositionKind
  100877. * - VertexBuffer.UVKind
  100878. * - VertexBuffer.UV2Kind
  100879. * - VertexBuffer.UV3Kind
  100880. * - VertexBuffer.UV4Kind
  100881. * - VertexBuffer.UV5Kind
  100882. * - VertexBuffer.UV6Kind
  100883. * - VertexBuffer.ColorKind
  100884. * - VertexBuffer.MatricesIndicesKind
  100885. * - VertexBuffer.MatricesIndicesExtraKind
  100886. * - VertexBuffer.MatricesWeightsKind
  100887. * - VertexBuffer.MatricesWeightsExtraKind
  100888. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  100889. */
  100890. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  100891. /**
  100892. * Sets the mesh global Vertex Buffer
  100893. * @param buffer defines the buffer to use
  100894. * @returns the current mesh
  100895. */
  100896. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  100897. /**
  100898. * Update a specific associated vertex buffer
  100899. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  100900. * - VertexBuffer.PositionKind
  100901. * - VertexBuffer.UVKind
  100902. * - VertexBuffer.UV2Kind
  100903. * - VertexBuffer.UV3Kind
  100904. * - VertexBuffer.UV4Kind
  100905. * - VertexBuffer.UV5Kind
  100906. * - VertexBuffer.UV6Kind
  100907. * - VertexBuffer.ColorKind
  100908. * - VertexBuffer.MatricesIndicesKind
  100909. * - VertexBuffer.MatricesIndicesExtraKind
  100910. * - VertexBuffer.MatricesWeightsKind
  100911. * - VertexBuffer.MatricesWeightsExtraKind
  100912. * @param data defines the data source
  100913. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  100914. * @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)
  100915. * @returns the current mesh
  100916. */
  100917. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  100918. /**
  100919. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  100920. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  100921. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  100922. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  100923. * @returns the current mesh
  100924. */
  100925. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  100926. /**
  100927. * Creates a un-shared specific occurence of the geometry for the mesh.
  100928. * @returns the current mesh
  100929. */
  100930. makeGeometryUnique(): Mesh;
  100931. /**
  100932. * Set the index buffer of this mesh
  100933. * @param indices defines the source data
  100934. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  100935. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  100936. * @returns the current mesh
  100937. */
  100938. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  100939. /**
  100940. * Update the current index buffer
  100941. * @param indices defines the source data
  100942. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  100943. * @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)
  100944. * @returns the current mesh
  100945. */
  100946. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  100947. /**
  100948. * Invert the geometry to move from a right handed system to a left handed one.
  100949. * @returns the current mesh
  100950. */
  100951. toLeftHanded(): Mesh;
  100952. /** @hidden */
  100953. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  100954. /** @hidden */
  100955. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  100956. /**
  100957. * Registers for this mesh a javascript function called just before the rendering process
  100958. * @param func defines the function to call before rendering this mesh
  100959. * @returns the current mesh
  100960. */
  100961. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  100962. /**
  100963. * Disposes a previously registered javascript function called before the rendering
  100964. * @param func defines the function to remove
  100965. * @returns the current mesh
  100966. */
  100967. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  100968. /**
  100969. * Registers for this mesh a javascript function called just after the rendering is complete
  100970. * @param func defines the function to call after rendering this mesh
  100971. * @returns the current mesh
  100972. */
  100973. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  100974. /**
  100975. * Disposes a previously registered javascript function called after the rendering.
  100976. * @param func defines the function to remove
  100977. * @returns the current mesh
  100978. */
  100979. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  100980. /** @hidden */
  100981. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  100982. /** @hidden */
  100983. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  100984. /** @hidden */
  100985. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  100986. /** @hidden */
  100987. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  100988. /** @hidden */
  100989. _rebuild(): void;
  100990. /** @hidden */
  100991. _freeze(): void;
  100992. /** @hidden */
  100993. _unFreeze(): void;
  100994. /**
  100995. * 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
  100996. * @param subMesh defines the subMesh to render
  100997. * @param enableAlphaMode defines if alpha mode can be changed
  100998. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  100999. * @returns the current mesh
  101000. */
  101001. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  101002. private _onBeforeDraw;
  101003. /**
  101004. * Renormalize the mesh and patch it up if there are no weights
  101005. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  101006. * However in the case of zero weights then we set just a single influence to 1.
  101007. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  101008. */
  101009. cleanMatrixWeights(): void;
  101010. private normalizeSkinFourWeights;
  101011. private normalizeSkinWeightsAndExtra;
  101012. /**
  101013. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  101014. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  101015. * the user know there was an issue with importing the mesh
  101016. * @returns a validation object with skinned, valid and report string
  101017. */
  101018. validateSkinning(): {
  101019. skinned: boolean;
  101020. valid: boolean;
  101021. report: string;
  101022. };
  101023. /** @hidden */
  101024. _checkDelayState(): Mesh;
  101025. private _queueLoad;
  101026. /**
  101027. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101028. * A mesh is in the frustum if its bounding box intersects the frustum
  101029. * @param frustumPlanes defines the frustum to test
  101030. * @returns true if the mesh is in the frustum planes
  101031. */
  101032. isInFrustum(frustumPlanes: Plane[]): boolean;
  101033. /**
  101034. * Sets the mesh material by the material or multiMaterial `id` property
  101035. * @param id is a string identifying the material or the multiMaterial
  101036. * @returns the current mesh
  101037. */
  101038. setMaterialByID(id: string): Mesh;
  101039. /**
  101040. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  101041. * @returns an array of IAnimatable
  101042. */
  101043. getAnimatables(): IAnimatable[];
  101044. /**
  101045. * Modifies the mesh geometry according to the passed transformation matrix.
  101046. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  101047. * The mesh normals are modified using the same transformation.
  101048. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101049. * @param transform defines the transform matrix to use
  101050. * @see http://doc.babylonjs.com/resources/baking_transformations
  101051. * @returns the current mesh
  101052. */
  101053. bakeTransformIntoVertices(transform: Matrix): Mesh;
  101054. /**
  101055. * Modifies the mesh geometry according to its own current World Matrix.
  101056. * The mesh World Matrix is then reset.
  101057. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  101058. * Note that, under the hood, this method sets a new VertexBuffer each call.
  101059. * @see http://doc.babylonjs.com/resources/baking_transformations
  101060. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  101061. * @returns the current mesh
  101062. */
  101063. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  101064. /** @hidden */
  101065. get _positions(): Nullable<Vector3[]>;
  101066. /** @hidden */
  101067. _resetPointsArrayCache(): Mesh;
  101068. /** @hidden */
  101069. _generatePointsArray(): boolean;
  101070. /**
  101071. * Returns a new Mesh object generated from the current mesh properties.
  101072. * This method must not get confused with createInstance()
  101073. * @param name is a string, the name given to the new mesh
  101074. * @param newParent can be any Node object (default `null`)
  101075. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  101076. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  101077. * @returns a new mesh
  101078. */
  101079. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  101080. /**
  101081. * Releases resources associated with this mesh.
  101082. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101083. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101084. */
  101085. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101086. /** @hidden */
  101087. _disposeInstanceSpecificData(): void;
  101088. /**
  101089. * Modifies the mesh geometry according to a displacement map.
  101090. * 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.
  101091. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101092. * @param url is a string, the URL from the image file is to be downloaded.
  101093. * @param minHeight is the lower limit of the displacement.
  101094. * @param maxHeight is the upper limit of the displacement.
  101095. * @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.
  101096. * @param uvOffset is an optional vector2 used to offset UV.
  101097. * @param uvScale is an optional vector2 used to scale UV.
  101098. * @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.
  101099. * @returns the Mesh.
  101100. */
  101101. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101102. /**
  101103. * Modifies the mesh geometry according to a displacementMap buffer.
  101104. * 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.
  101105. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  101106. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  101107. * @param heightMapWidth is the width of the buffer image.
  101108. * @param heightMapHeight is the height of the buffer image.
  101109. * @param minHeight is the lower limit of the displacement.
  101110. * @param maxHeight is the upper limit of the displacement.
  101111. * @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.
  101112. * @param uvOffset is an optional vector2 used to offset UV.
  101113. * @param uvScale is an optional vector2 used to scale UV.
  101114. * @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.
  101115. * @returns the Mesh.
  101116. */
  101117. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  101118. /**
  101119. * Modify the mesh to get a flat shading rendering.
  101120. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  101121. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  101122. * @returns current mesh
  101123. */
  101124. convertToFlatShadedMesh(): Mesh;
  101125. /**
  101126. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  101127. * In other words, more vertices, no more indices and a single bigger VBO.
  101128. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  101129. * @returns current mesh
  101130. */
  101131. convertToUnIndexedMesh(): Mesh;
  101132. /**
  101133. * Inverses facet orientations.
  101134. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101135. * @param flipNormals will also inverts the normals
  101136. * @returns current mesh
  101137. */
  101138. flipFaces(flipNormals?: boolean): Mesh;
  101139. /**
  101140. * Increase the number of facets and hence vertices in a mesh
  101141. * Vertex normals are interpolated from existing vertex normals
  101142. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101143. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  101144. */
  101145. increaseVertices(numberPerEdge: number): void;
  101146. /**
  101147. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  101148. * This will undo any application of covertToFlatShadedMesh
  101149. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  101150. */
  101151. forceSharedVertices(): void;
  101152. /** @hidden */
  101153. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  101154. /** @hidden */
  101155. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  101156. /**
  101157. * Creates a new InstancedMesh object from the mesh model.
  101158. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  101159. * @param name defines the name of the new instance
  101160. * @returns a new InstancedMesh
  101161. */
  101162. createInstance(name: string): InstancedMesh;
  101163. /**
  101164. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  101165. * After this call, all the mesh instances have the same submeshes than the current mesh.
  101166. * @returns the current mesh
  101167. */
  101168. synchronizeInstances(): Mesh;
  101169. /**
  101170. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  101171. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  101172. * This should be used together with the simplification to avoid disappearing triangles.
  101173. * @param successCallback an optional success callback to be called after the optimization finished.
  101174. * @returns the current mesh
  101175. */
  101176. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  101177. /**
  101178. * Serialize current mesh
  101179. * @param serializationObject defines the object which will receive the serialization data
  101180. */
  101181. serialize(serializationObject: any): void;
  101182. /** @hidden */
  101183. _syncGeometryWithMorphTargetManager(): void;
  101184. /** @hidden */
  101185. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  101186. /**
  101187. * Returns a new Mesh object parsed from the source provided.
  101188. * @param parsedMesh is the source
  101189. * @param scene defines the hosting scene
  101190. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  101191. * @returns a new Mesh
  101192. */
  101193. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  101194. /**
  101195. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  101196. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101197. * @param name defines the name of the mesh to create
  101198. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  101199. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  101200. * @param closePath creates a seam between the first and the last points of each path of the path array
  101201. * @param offset is taken in account only if the `pathArray` is containing a single path
  101202. * @param scene defines the hosting scene
  101203. * @param updatable defines if the mesh must be flagged as updatable
  101204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101205. * @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)
  101206. * @returns a new Mesh
  101207. */
  101208. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101209. /**
  101210. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  101211. * @param name defines the name of the mesh to create
  101212. * @param radius sets the radius size (float) of the polygon (default 0.5)
  101213. * @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
  101214. * @param scene defines the hosting scene
  101215. * @param updatable defines if the mesh must be flagged as updatable
  101216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101217. * @returns a new Mesh
  101218. */
  101219. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101220. /**
  101221. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  101222. * @param name defines the name of the mesh to create
  101223. * @param size sets the size (float) of each box side (default 1)
  101224. * @param scene defines the hosting scene
  101225. * @param updatable defines if the mesh must be flagged as updatable
  101226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101227. * @returns a new Mesh
  101228. */
  101229. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  101230. /**
  101231. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  101232. * @param name defines the name of the mesh to create
  101233. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101234. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101235. * @param scene defines the hosting scene
  101236. * @param updatable defines if the mesh must be flagged as updatable
  101237. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101238. * @returns a new Mesh
  101239. */
  101240. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101241. /**
  101242. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  101243. * @param name defines the name of the mesh to create
  101244. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  101245. * @param diameter sets the diameter size (float) of the sphere (default 1)
  101246. * @param scene defines the hosting scene
  101247. * @returns a new Mesh
  101248. */
  101249. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  101250. /**
  101251. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  101252. * @param name defines the name of the mesh to create
  101253. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  101254. * @param diameterTop set the top cap diameter (floats, default 1)
  101255. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  101256. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  101257. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  101258. * @param scene defines the hosting scene
  101259. * @param updatable defines if the mesh must be flagged as updatable
  101260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101261. * @returns a new Mesh
  101262. */
  101263. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  101264. /**
  101265. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  101266. * @param name defines the name of the mesh to create
  101267. * @param diameter sets the diameter size (float) of the torus (default 1)
  101268. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  101269. * @param tessellation sets the number of torus sides (postive integer, default 16)
  101270. * @param scene defines the hosting scene
  101271. * @param updatable defines if the mesh must be flagged as updatable
  101272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101273. * @returns a new Mesh
  101274. */
  101275. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101276. /**
  101277. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  101278. * @param name defines the name of the mesh to create
  101279. * @param radius sets the global radius size (float) of the torus knot (default 2)
  101280. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  101281. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  101282. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  101283. * @param p the number of windings on X axis (positive integers, default 2)
  101284. * @param q the number of windings on Y axis (positive integers, default 3)
  101285. * @param scene defines the hosting scene
  101286. * @param updatable defines if the mesh must be flagged as updatable
  101287. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101288. * @returns a new Mesh
  101289. */
  101290. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101291. /**
  101292. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  101293. * @param name defines the name of the mesh to create
  101294. * @param points is an array successive Vector3
  101295. * @param scene defines the hosting scene
  101296. * @param updatable defines if the mesh must be flagged as updatable
  101297. * @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).
  101298. * @returns a new Mesh
  101299. */
  101300. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  101301. /**
  101302. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  101303. * @param name defines the name of the mesh to create
  101304. * @param points is an array successive Vector3
  101305. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  101306. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101307. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  101308. * @param scene defines the hosting scene
  101309. * @param updatable defines if the mesh must be flagged as updatable
  101310. * @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)
  101311. * @returns a new Mesh
  101312. */
  101313. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  101314. /**
  101315. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  101316. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  101317. * 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.
  101318. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101319. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101320. * Remember you can only change the shape positions, not their number when updating a polygon.
  101321. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  101322. * @param name defines the name of the mesh to create
  101323. * @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
  101324. * @param scene defines the hosting scene
  101325. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101326. * @param updatable defines if the mesh must be flagged as updatable
  101327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101328. * @param earcutInjection can be used to inject your own earcut reference
  101329. * @returns a new Mesh
  101330. */
  101331. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101332. /**
  101333. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  101334. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  101335. * @param name defines the name of the mesh to create
  101336. * @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
  101337. * @param depth defines the height of extrusion
  101338. * @param scene defines the hosting scene
  101339. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  101340. * @param updatable defines if the mesh must be flagged as updatable
  101341. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101342. * @param earcutInjection can be used to inject your own earcut reference
  101343. * @returns a new Mesh
  101344. */
  101345. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  101346. /**
  101347. * Creates an extruded shape mesh.
  101348. * 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
  101349. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101350. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101351. * @param name defines the name of the mesh to create
  101352. * @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
  101353. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101354. * @param scale is the value to scale the shape
  101355. * @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
  101356. * @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
  101357. * @param scene defines the hosting scene
  101358. * @param updatable defines if the mesh must be flagged as updatable
  101359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101360. * @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)
  101361. * @returns a new Mesh
  101362. */
  101363. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101364. /**
  101365. * Creates an custom extruded shape mesh.
  101366. * The custom extrusion is a parametric shape.
  101367. * It has no predefined shape. Its final shape will depend on the input parameters.
  101368. * Please consider using the same method from the MeshBuilder class instead
  101369. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  101370. * @param name defines the name of the mesh to create
  101371. * @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
  101372. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  101373. * @param scaleFunction is a custom Javascript function called on each path point
  101374. * @param rotationFunction is a custom Javascript function called on each path point
  101375. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  101376. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  101377. * @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
  101378. * @param scene defines the hosting scene
  101379. * @param updatable defines if the mesh must be flagged as updatable
  101380. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101381. * @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)
  101382. * @returns a new Mesh
  101383. */
  101384. 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;
  101385. /**
  101386. * Creates lathe mesh.
  101387. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  101388. * Please consider using the same method from the MeshBuilder class instead
  101389. * @param name defines the name of the mesh to create
  101390. * @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
  101391. * @param radius is the radius value of the lathe
  101392. * @param tessellation is the side number of the lathe.
  101393. * @param scene defines the hosting scene
  101394. * @param updatable defines if the mesh must be flagged as updatable
  101395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101396. * @returns a new Mesh
  101397. */
  101398. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101399. /**
  101400. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  101401. * @param name defines the name of the mesh to create
  101402. * @param size sets the size (float) of both sides of the plane at once (default 1)
  101403. * @param scene defines the hosting scene
  101404. * @param updatable defines if the mesh must be flagged as updatable
  101405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101406. * @returns a new Mesh
  101407. */
  101408. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  101409. /**
  101410. * Creates a ground mesh.
  101411. * Please consider using the same method from the MeshBuilder class instead
  101412. * @param name defines the name of the mesh to create
  101413. * @param width set the width of the ground
  101414. * @param height set the height of the ground
  101415. * @param subdivisions sets the number of subdivisions per side
  101416. * @param scene defines the hosting scene
  101417. * @param updatable defines if the mesh must be flagged as updatable
  101418. * @returns a new Mesh
  101419. */
  101420. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  101421. /**
  101422. * Creates a tiled ground mesh.
  101423. * Please consider using the same method from the MeshBuilder class instead
  101424. * @param name defines the name of the mesh to create
  101425. * @param xmin set the ground minimum X coordinate
  101426. * @param zmin set the ground minimum Y coordinate
  101427. * @param xmax set the ground maximum X coordinate
  101428. * @param zmax set the ground maximum Z coordinate
  101429. * @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
  101430. * @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
  101431. * @param scene defines the hosting scene
  101432. * @param updatable defines if the mesh must be flagged as updatable
  101433. * @returns a new Mesh
  101434. */
  101435. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  101436. w: number;
  101437. h: number;
  101438. }, precision: {
  101439. w: number;
  101440. h: number;
  101441. }, scene: Scene, updatable?: boolean): Mesh;
  101442. /**
  101443. * Creates a ground mesh from a height map.
  101444. * Please consider using the same method from the MeshBuilder class instead
  101445. * @see http://doc.babylonjs.com/babylon101/height_map
  101446. * @param name defines the name of the mesh to create
  101447. * @param url sets the URL of the height map image resource
  101448. * @param width set the ground width size
  101449. * @param height set the ground height size
  101450. * @param subdivisions sets the number of subdivision per side
  101451. * @param minHeight is the minimum altitude on the ground
  101452. * @param maxHeight is the maximum altitude on the ground
  101453. * @param scene defines the hosting scene
  101454. * @param updatable defines if the mesh must be flagged as updatable
  101455. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  101456. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101457. * @returns a new Mesh
  101458. */
  101459. 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;
  101460. /**
  101461. * Creates a tube mesh.
  101462. * The tube is a parametric shape.
  101463. * It has no predefined shape. Its final shape will depend on the input parameters.
  101464. * Please consider using the same method from the MeshBuilder class instead
  101465. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  101466. * @param name defines the name of the mesh to create
  101467. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  101468. * @param radius sets the tube radius size
  101469. * @param tessellation is the number of sides on the tubular surface
  101470. * @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
  101471. * @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
  101472. * @param scene defines the hosting scene
  101473. * @param updatable defines if the mesh must be flagged as updatable
  101474. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  101475. * @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)
  101476. * @returns a new Mesh
  101477. */
  101478. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  101479. (i: number, distance: number): number;
  101480. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  101481. /**
  101482. * Creates a polyhedron mesh.
  101483. * Please consider using the same method from the MeshBuilder class instead.
  101484. * * 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
  101485. * * The parameter `size` (positive float, default 1) sets the polygon size
  101486. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101487. * * 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`
  101488. * * 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
  101489. * * 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)`)
  101490. * * 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
  101491. * * 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
  101492. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101493. * * If you create a double-sided mesh, you can choose what parts of 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
  101494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101495. * @param name defines the name of the mesh to create
  101496. * @param options defines the options used to create the mesh
  101497. * @param scene defines the hosting scene
  101498. * @returns a new Mesh
  101499. */
  101500. static CreatePolyhedron(name: string, options: {
  101501. type?: number;
  101502. size?: number;
  101503. sizeX?: number;
  101504. sizeY?: number;
  101505. sizeZ?: number;
  101506. custom?: any;
  101507. faceUV?: Vector4[];
  101508. faceColors?: Color4[];
  101509. updatable?: boolean;
  101510. sideOrientation?: number;
  101511. }, scene: Scene): Mesh;
  101512. /**
  101513. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  101514. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  101515. * * 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`)
  101516. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  101517. * * 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
  101518. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  101519. * * If you create a double-sided mesh, you can choose what parts of 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
  101520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101521. * @param name defines the name of the mesh
  101522. * @param options defines the options used to create the mesh
  101523. * @param scene defines the hosting scene
  101524. * @returns a new Mesh
  101525. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  101526. */
  101527. static CreateIcoSphere(name: string, options: {
  101528. radius?: number;
  101529. flat?: boolean;
  101530. subdivisions?: number;
  101531. sideOrientation?: number;
  101532. updatable?: boolean;
  101533. }, scene: Scene): Mesh;
  101534. /**
  101535. * Creates a decal mesh.
  101536. * Please consider using the same method from the MeshBuilder class instead.
  101537. * A decal is a mesh usually applied as a model onto the surface of another mesh
  101538. * @param name defines the name of the mesh
  101539. * @param sourceMesh defines the mesh receiving the decal
  101540. * @param position sets the position of the decal in world coordinates
  101541. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  101542. * @param size sets the decal scaling
  101543. * @param angle sets the angle to rotate the decal
  101544. * @returns a new Mesh
  101545. */
  101546. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  101547. /**
  101548. * Prepare internal position array for software CPU skinning
  101549. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  101550. */
  101551. setPositionsForCPUSkinning(): Float32Array;
  101552. /**
  101553. * Prepare internal normal array for software CPU skinning
  101554. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  101555. */
  101556. setNormalsForCPUSkinning(): Float32Array;
  101557. /**
  101558. * Updates the vertex buffer by applying transformation from the bones
  101559. * @param skeleton defines the skeleton to apply to current mesh
  101560. * @returns the current mesh
  101561. */
  101562. applySkeleton(skeleton: Skeleton): Mesh;
  101563. /**
  101564. * 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
  101565. * @param meshes defines the list of meshes to scan
  101566. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  101567. */
  101568. static MinMax(meshes: AbstractMesh[]): {
  101569. min: Vector3;
  101570. max: Vector3;
  101571. };
  101572. /**
  101573. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  101574. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  101575. * @returns a vector3
  101576. */
  101577. static Center(meshesOrMinMaxVector: {
  101578. min: Vector3;
  101579. max: Vector3;
  101580. } | AbstractMesh[]): Vector3;
  101581. /**
  101582. * Merge the array of meshes into a single mesh for performance reasons.
  101583. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  101584. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  101585. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  101586. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  101587. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  101588. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  101589. * @returns a new mesh
  101590. */
  101591. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  101592. /** @hidden */
  101593. addInstance(instance: InstancedMesh): void;
  101594. /** @hidden */
  101595. removeInstance(instance: InstancedMesh): void;
  101596. }
  101597. }
  101598. declare module BABYLON {
  101599. /**
  101600. * This is the base class of all the camera used in the application.
  101601. * @see http://doc.babylonjs.com/features/cameras
  101602. */
  101603. export class Camera extends Node {
  101604. /** @hidden */
  101605. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  101606. /**
  101607. * This is the default projection mode used by the cameras.
  101608. * It helps recreating a feeling of perspective and better appreciate depth.
  101609. * This is the best way to simulate real life cameras.
  101610. */
  101611. static readonly PERSPECTIVE_CAMERA: number;
  101612. /**
  101613. * This helps creating camera with an orthographic mode.
  101614. * 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.
  101615. */
  101616. static readonly ORTHOGRAPHIC_CAMERA: number;
  101617. /**
  101618. * This is the default FOV mode for perspective cameras.
  101619. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  101620. */
  101621. static readonly FOVMODE_VERTICAL_FIXED: number;
  101622. /**
  101623. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  101624. */
  101625. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  101626. /**
  101627. * This specifies ther is no need for a camera rig.
  101628. * Basically only one eye is rendered corresponding to the camera.
  101629. */
  101630. static readonly RIG_MODE_NONE: number;
  101631. /**
  101632. * Simulates a camera Rig with one blue eye and one red eye.
  101633. * This can be use with 3d blue and red glasses.
  101634. */
  101635. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  101636. /**
  101637. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  101638. */
  101639. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  101640. /**
  101641. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  101642. */
  101643. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  101644. /**
  101645. * Defines that both eyes of the camera will be rendered over under each other.
  101646. */
  101647. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  101648. /**
  101649. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  101650. */
  101651. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  101652. /**
  101653. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  101654. */
  101655. static readonly RIG_MODE_VR: number;
  101656. /**
  101657. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  101658. */
  101659. static readonly RIG_MODE_WEBVR: number;
  101660. /**
  101661. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  101662. */
  101663. static readonly RIG_MODE_CUSTOM: number;
  101664. /**
  101665. * Defines if by default attaching controls should prevent the default javascript event to continue.
  101666. */
  101667. static ForceAttachControlToAlwaysPreventDefault: boolean;
  101668. /**
  101669. * Define the input manager associated with the camera.
  101670. */
  101671. inputs: CameraInputsManager<Camera>;
  101672. /** @hidden */
  101673. _position: Vector3;
  101674. /**
  101675. * Define the current local position of the camera in the scene
  101676. */
  101677. get position(): Vector3;
  101678. set position(newPosition: Vector3);
  101679. /**
  101680. * The vector the camera should consider as up.
  101681. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  101682. */
  101683. upVector: Vector3;
  101684. /**
  101685. * Define the current limit on the left side for an orthographic camera
  101686. * In scene unit
  101687. */
  101688. orthoLeft: Nullable<number>;
  101689. /**
  101690. * Define the current limit on the right side for an orthographic camera
  101691. * In scene unit
  101692. */
  101693. orthoRight: Nullable<number>;
  101694. /**
  101695. * Define the current limit on the bottom side for an orthographic camera
  101696. * In scene unit
  101697. */
  101698. orthoBottom: Nullable<number>;
  101699. /**
  101700. * Define the current limit on the top side for an orthographic camera
  101701. * In scene unit
  101702. */
  101703. orthoTop: Nullable<number>;
  101704. /**
  101705. * Field Of View is set in Radians. (default is 0.8)
  101706. */
  101707. fov: number;
  101708. /**
  101709. * Define the minimum distance the camera can see from.
  101710. * This is important to note that the depth buffer are not infinite and the closer it starts
  101711. * the more your scene might encounter depth fighting issue.
  101712. */
  101713. minZ: number;
  101714. /**
  101715. * Define the maximum distance the camera can see to.
  101716. * This is important to note that the depth buffer are not infinite and the further it end
  101717. * the more your scene might encounter depth fighting issue.
  101718. */
  101719. maxZ: number;
  101720. /**
  101721. * Define the default inertia of the camera.
  101722. * This helps giving a smooth feeling to the camera movement.
  101723. */
  101724. inertia: number;
  101725. /**
  101726. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  101727. */
  101728. mode: number;
  101729. /**
  101730. * Define whether the camera is intermediate.
  101731. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  101732. */
  101733. isIntermediate: boolean;
  101734. /**
  101735. * Define the viewport of the camera.
  101736. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  101737. */
  101738. viewport: Viewport;
  101739. /**
  101740. * Restricts the camera to viewing objects with the same layerMask.
  101741. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  101742. */
  101743. layerMask: number;
  101744. /**
  101745. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  101746. */
  101747. fovMode: number;
  101748. /**
  101749. * Rig mode of the camera.
  101750. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  101751. * This is normally controlled byt the camera themselves as internal use.
  101752. */
  101753. cameraRigMode: number;
  101754. /**
  101755. * Defines the distance between both "eyes" in case of a RIG
  101756. */
  101757. interaxialDistance: number;
  101758. /**
  101759. * Defines if stereoscopic rendering is done side by side or over under.
  101760. */
  101761. isStereoscopicSideBySide: boolean;
  101762. /**
  101763. * 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
  101764. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  101765. * else in the scene. (Eg. security camera)
  101766. *
  101767. * 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)
  101768. */
  101769. customRenderTargets: RenderTargetTexture[];
  101770. /**
  101771. * When set, the camera will render to this render target instead of the default canvas
  101772. *
  101773. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  101774. */
  101775. outputRenderTarget: Nullable<RenderTargetTexture>;
  101776. /**
  101777. * Observable triggered when the camera view matrix has changed.
  101778. */
  101779. onViewMatrixChangedObservable: Observable<Camera>;
  101780. /**
  101781. * Observable triggered when the camera Projection matrix has changed.
  101782. */
  101783. onProjectionMatrixChangedObservable: Observable<Camera>;
  101784. /**
  101785. * Observable triggered when the inputs have been processed.
  101786. */
  101787. onAfterCheckInputsObservable: Observable<Camera>;
  101788. /**
  101789. * Observable triggered when reset has been called and applied to the camera.
  101790. */
  101791. onRestoreStateObservable: Observable<Camera>;
  101792. /**
  101793. * Is this camera a part of a rig system?
  101794. */
  101795. isRigCamera: boolean;
  101796. /**
  101797. * If isRigCamera set to true this will be set with the parent camera.
  101798. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  101799. */
  101800. rigParent?: Camera;
  101801. /** @hidden */
  101802. _cameraRigParams: any;
  101803. /** @hidden */
  101804. _rigCameras: Camera[];
  101805. /** @hidden */
  101806. _rigPostProcess: Nullable<PostProcess>;
  101807. protected _webvrViewMatrix: Matrix;
  101808. /** @hidden */
  101809. _skipRendering: boolean;
  101810. /** @hidden */
  101811. _projectionMatrix: Matrix;
  101812. /** @hidden */
  101813. _postProcesses: Nullable<PostProcess>[];
  101814. /** @hidden */
  101815. _activeMeshes: SmartArray<AbstractMesh>;
  101816. protected _globalPosition: Vector3;
  101817. /** @hidden */
  101818. _computedViewMatrix: Matrix;
  101819. private _doNotComputeProjectionMatrix;
  101820. private _transformMatrix;
  101821. private _frustumPlanes;
  101822. private _refreshFrustumPlanes;
  101823. private _storedFov;
  101824. private _stateStored;
  101825. /**
  101826. * Instantiates a new camera object.
  101827. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  101828. * @see http://doc.babylonjs.com/features/cameras
  101829. * @param name Defines the name of the camera in the scene
  101830. * @param position Defines the position of the camera
  101831. * @param scene Defines the scene the camera belongs too
  101832. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  101833. */
  101834. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101835. /**
  101836. * Store current camera state (fov, position, etc..)
  101837. * @returns the camera
  101838. */
  101839. storeState(): Camera;
  101840. /**
  101841. * Restores the camera state values if it has been stored. You must call storeState() first
  101842. */
  101843. protected _restoreStateValues(): boolean;
  101844. /**
  101845. * Restored camera state. You must call storeState() first.
  101846. * @returns true if restored and false otherwise
  101847. */
  101848. restoreState(): boolean;
  101849. /**
  101850. * Gets the class name of the camera.
  101851. * @returns the class name
  101852. */
  101853. getClassName(): string;
  101854. /** @hidden */
  101855. readonly _isCamera: boolean;
  101856. /**
  101857. * Gets a string representation of the camera useful for debug purpose.
  101858. * @param fullDetails Defines that a more verboe level of logging is required
  101859. * @returns the string representation
  101860. */
  101861. toString(fullDetails?: boolean): string;
  101862. /**
  101863. * Gets the current world space position of the camera.
  101864. */
  101865. get globalPosition(): Vector3;
  101866. /**
  101867. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  101868. * @returns the active meshe list
  101869. */
  101870. getActiveMeshes(): SmartArray<AbstractMesh>;
  101871. /**
  101872. * Check whether a mesh is part of the current active mesh list of the camera
  101873. * @param mesh Defines the mesh to check
  101874. * @returns true if active, false otherwise
  101875. */
  101876. isActiveMesh(mesh: Mesh): boolean;
  101877. /**
  101878. * Is this camera ready to be used/rendered
  101879. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  101880. * @return true if the camera is ready
  101881. */
  101882. isReady(completeCheck?: boolean): boolean;
  101883. /** @hidden */
  101884. _initCache(): void;
  101885. /** @hidden */
  101886. _updateCache(ignoreParentClass?: boolean): void;
  101887. /** @hidden */
  101888. _isSynchronized(): boolean;
  101889. /** @hidden */
  101890. _isSynchronizedViewMatrix(): boolean;
  101891. /** @hidden */
  101892. _isSynchronizedProjectionMatrix(): boolean;
  101893. /**
  101894. * Attach the input controls to a specific dom element to get the input from.
  101895. * @param element Defines the element the controls should be listened from
  101896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101897. */
  101898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101899. /**
  101900. * Detach the current controls from the specified dom element.
  101901. * @param element Defines the element to stop listening the inputs from
  101902. */
  101903. detachControl(element: HTMLElement): void;
  101904. /**
  101905. * Update the camera state according to the different inputs gathered during the frame.
  101906. */
  101907. update(): void;
  101908. /** @hidden */
  101909. _checkInputs(): void;
  101910. /** @hidden */
  101911. get rigCameras(): Camera[];
  101912. /**
  101913. * Gets the post process used by the rig cameras
  101914. */
  101915. get rigPostProcess(): Nullable<PostProcess>;
  101916. /**
  101917. * Internal, gets the first post proces.
  101918. * @returns the first post process to be run on this camera.
  101919. */
  101920. _getFirstPostProcess(): Nullable<PostProcess>;
  101921. private _cascadePostProcessesToRigCams;
  101922. /**
  101923. * Attach a post process to the camera.
  101924. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  101925. * @param postProcess The post process to attach to the camera
  101926. * @param insertAt The position of the post process in case several of them are in use in the scene
  101927. * @returns the position the post process has been inserted at
  101928. */
  101929. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  101930. /**
  101931. * Detach a post process to the camera.
  101932. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  101933. * @param postProcess The post process to detach from the camera
  101934. */
  101935. detachPostProcess(postProcess: PostProcess): void;
  101936. /**
  101937. * Gets the current world matrix of the camera
  101938. */
  101939. getWorldMatrix(): Matrix;
  101940. /** @hidden */
  101941. _getViewMatrix(): Matrix;
  101942. /**
  101943. * Gets the current view matrix of the camera.
  101944. * @param force forces the camera to recompute the matrix without looking at the cached state
  101945. * @returns the view matrix
  101946. */
  101947. getViewMatrix(force?: boolean): Matrix;
  101948. /**
  101949. * Freeze the projection matrix.
  101950. * It will prevent the cache check of the camera projection compute and can speed up perf
  101951. * if no parameter of the camera are meant to change
  101952. * @param projection Defines manually a projection if necessary
  101953. */
  101954. freezeProjectionMatrix(projection?: Matrix): void;
  101955. /**
  101956. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  101957. */
  101958. unfreezeProjectionMatrix(): void;
  101959. /**
  101960. * Gets the current projection matrix of the camera.
  101961. * @param force forces the camera to recompute the matrix without looking at the cached state
  101962. * @returns the projection matrix
  101963. */
  101964. getProjectionMatrix(force?: boolean): Matrix;
  101965. /**
  101966. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  101967. * @returns a Matrix
  101968. */
  101969. getTransformationMatrix(): Matrix;
  101970. private _updateFrustumPlanes;
  101971. /**
  101972. * Checks if a cullable object (mesh...) is in the camera frustum
  101973. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  101974. * @param target The object to check
  101975. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  101976. * @returns true if the object is in frustum otherwise false
  101977. */
  101978. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  101979. /**
  101980. * Checks if a cullable object (mesh...) is in the camera frustum
  101981. * Unlike isInFrustum this cheks the full bounding box
  101982. * @param target The object to check
  101983. * @returns true if the object is in frustum otherwise false
  101984. */
  101985. isCompletelyInFrustum(target: ICullable): boolean;
  101986. /**
  101987. * Gets a ray in the forward direction from the camera.
  101988. * @param length Defines the length of the ray to create
  101989. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  101990. * @param origin Defines the start point of the ray which defaults to the camera position
  101991. * @returns the forward ray
  101992. */
  101993. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  101994. /**
  101995. * Releases resources associated with this node.
  101996. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101997. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101998. */
  101999. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102000. /** @hidden */
  102001. _isLeftCamera: boolean;
  102002. /**
  102003. * Gets the left camera of a rig setup in case of Rigged Camera
  102004. */
  102005. get isLeftCamera(): boolean;
  102006. /** @hidden */
  102007. _isRightCamera: boolean;
  102008. /**
  102009. * Gets the right camera of a rig setup in case of Rigged Camera
  102010. */
  102011. get isRightCamera(): boolean;
  102012. /**
  102013. * Gets the left camera of a rig setup in case of Rigged Camera
  102014. */
  102015. get leftCamera(): Nullable<FreeCamera>;
  102016. /**
  102017. * Gets the right camera of a rig setup in case of Rigged Camera
  102018. */
  102019. get rightCamera(): Nullable<FreeCamera>;
  102020. /**
  102021. * Gets the left camera target of a rig setup in case of Rigged Camera
  102022. * @returns the target position
  102023. */
  102024. getLeftTarget(): Nullable<Vector3>;
  102025. /**
  102026. * Gets the right camera target of a rig setup in case of Rigged Camera
  102027. * @returns the target position
  102028. */
  102029. getRightTarget(): Nullable<Vector3>;
  102030. /**
  102031. * @hidden
  102032. */
  102033. setCameraRigMode(mode: number, rigParams: any): void;
  102034. /** @hidden */
  102035. static _setStereoscopicRigMode(camera: Camera): void;
  102036. /** @hidden */
  102037. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  102038. /** @hidden */
  102039. static _setVRRigMode(camera: Camera, rigParams: any): void;
  102040. /** @hidden */
  102041. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  102042. /** @hidden */
  102043. _getVRProjectionMatrix(): Matrix;
  102044. protected _updateCameraRotationMatrix(): void;
  102045. protected _updateWebVRCameraRotationMatrix(): void;
  102046. /**
  102047. * This function MUST be overwritten by the different WebVR cameras available.
  102048. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102049. * @hidden
  102050. */
  102051. _getWebVRProjectionMatrix(): Matrix;
  102052. /**
  102053. * This function MUST be overwritten by the different WebVR cameras available.
  102054. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  102055. * @hidden
  102056. */
  102057. _getWebVRViewMatrix(): Matrix;
  102058. /** @hidden */
  102059. setCameraRigParameter(name: string, value: any): void;
  102060. /**
  102061. * needs to be overridden by children so sub has required properties to be copied
  102062. * @hidden
  102063. */
  102064. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  102065. /**
  102066. * May need to be overridden by children
  102067. * @hidden
  102068. */
  102069. _updateRigCameras(): void;
  102070. /** @hidden */
  102071. _setupInputs(): void;
  102072. /**
  102073. * Serialiaze the camera setup to a json represention
  102074. * @returns the JSON representation
  102075. */
  102076. serialize(): any;
  102077. /**
  102078. * Clones the current camera.
  102079. * @param name The cloned camera name
  102080. * @returns the cloned camera
  102081. */
  102082. clone(name: string): Camera;
  102083. /**
  102084. * Gets the direction of the camera relative to a given local axis.
  102085. * @param localAxis Defines the reference axis to provide a relative direction.
  102086. * @return the direction
  102087. */
  102088. getDirection(localAxis: Vector3): Vector3;
  102089. /**
  102090. * Returns the current camera absolute rotation
  102091. */
  102092. get absoluteRotation(): Quaternion;
  102093. /**
  102094. * Gets the direction of the camera relative to a given local axis into a passed vector.
  102095. * @param localAxis Defines the reference axis to provide a relative direction.
  102096. * @param result Defines the vector to store the result in
  102097. */
  102098. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  102099. /**
  102100. * Gets a camera constructor for a given camera type
  102101. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  102102. * @param name The name of the camera the result will be able to instantiate
  102103. * @param scene The scene the result will construct the camera in
  102104. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  102105. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  102106. * @returns a factory method to construc the camera
  102107. */
  102108. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  102109. /**
  102110. * Compute the world matrix of the camera.
  102111. * @returns the camera world matrix
  102112. */
  102113. computeWorldMatrix(): Matrix;
  102114. /**
  102115. * Parse a JSON and creates the camera from the parsed information
  102116. * @param parsedCamera The JSON to parse
  102117. * @param scene The scene to instantiate the camera in
  102118. * @returns the newly constructed camera
  102119. */
  102120. static Parse(parsedCamera: any, scene: Scene): Camera;
  102121. }
  102122. }
  102123. declare module BABYLON {
  102124. /**
  102125. * Class containing static functions to help procedurally build meshes
  102126. */
  102127. export class DiscBuilder {
  102128. /**
  102129. * Creates a plane polygonal mesh. By default, this is a disc
  102130. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  102131. * * 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
  102132. * * 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
  102133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102136. * @param name defines the name of the mesh
  102137. * @param options defines the options used to create the mesh
  102138. * @param scene defines the hosting scene
  102139. * @returns the plane polygonal mesh
  102140. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  102141. */
  102142. static CreateDisc(name: string, options: {
  102143. radius?: number;
  102144. tessellation?: number;
  102145. arc?: number;
  102146. updatable?: boolean;
  102147. sideOrientation?: number;
  102148. frontUVs?: Vector4;
  102149. backUVs?: Vector4;
  102150. }, scene?: Nullable<Scene>): Mesh;
  102151. }
  102152. }
  102153. declare module BABYLON {
  102154. /**
  102155. * Options to be used when creating a FresnelParameters.
  102156. */
  102157. export type IFresnelParametersCreationOptions = {
  102158. /**
  102159. * Define the color used on edges (grazing angle)
  102160. */
  102161. leftColor?: Color3;
  102162. /**
  102163. * Define the color used on center
  102164. */
  102165. rightColor?: Color3;
  102166. /**
  102167. * Define bias applied to computed fresnel term
  102168. */
  102169. bias?: number;
  102170. /**
  102171. * Defined the power exponent applied to fresnel term
  102172. */
  102173. power?: number;
  102174. /**
  102175. * Define if the fresnel effect is enable or not.
  102176. */
  102177. isEnabled?: boolean;
  102178. };
  102179. /**
  102180. * Serialized format for FresnelParameters.
  102181. */
  102182. export type IFresnelParametersSerialized = {
  102183. /**
  102184. * Define the color used on edges (grazing angle) [as an array]
  102185. */
  102186. leftColor: number[];
  102187. /**
  102188. * Define the color used on center [as an array]
  102189. */
  102190. rightColor: number[];
  102191. /**
  102192. * Define bias applied to computed fresnel term
  102193. */
  102194. bias: number;
  102195. /**
  102196. * Defined the power exponent applied to fresnel term
  102197. */
  102198. power?: number;
  102199. /**
  102200. * Define if the fresnel effect is enable or not.
  102201. */
  102202. isEnabled: boolean;
  102203. };
  102204. /**
  102205. * This represents all the required information to add a fresnel effect on a material:
  102206. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102207. */
  102208. export class FresnelParameters {
  102209. private _isEnabled;
  102210. /**
  102211. * Define if the fresnel effect is enable or not.
  102212. */
  102213. get isEnabled(): boolean;
  102214. set isEnabled(value: boolean);
  102215. /**
  102216. * Define the color used on edges (grazing angle)
  102217. */
  102218. leftColor: Color3;
  102219. /**
  102220. * Define the color used on center
  102221. */
  102222. rightColor: Color3;
  102223. /**
  102224. * Define bias applied to computed fresnel term
  102225. */
  102226. bias: number;
  102227. /**
  102228. * Defined the power exponent applied to fresnel term
  102229. */
  102230. power: number;
  102231. /**
  102232. * Creates a new FresnelParameters object.
  102233. *
  102234. * @param options provide your own settings to optionally to override defaults
  102235. */
  102236. constructor(options?: IFresnelParametersCreationOptions);
  102237. /**
  102238. * Clones the current fresnel and its valuues
  102239. * @returns a clone fresnel configuration
  102240. */
  102241. clone(): FresnelParameters;
  102242. /**
  102243. * Determines equality between FresnelParameters objects
  102244. * @param otherFresnelParameters defines the second operand
  102245. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  102246. */
  102247. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  102248. /**
  102249. * Serializes the current fresnel parameters to a JSON representation.
  102250. * @return the JSON serialization
  102251. */
  102252. serialize(): IFresnelParametersSerialized;
  102253. /**
  102254. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  102255. * @param parsedFresnelParameters Define the JSON representation
  102256. * @returns the parsed parameters
  102257. */
  102258. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  102259. }
  102260. }
  102261. declare module BABYLON {
  102262. /**
  102263. * Base class of materials working in push mode in babylon JS
  102264. * @hidden
  102265. */
  102266. export class PushMaterial extends Material {
  102267. protected _activeEffect: Effect;
  102268. protected _normalMatrix: Matrix;
  102269. /**
  102270. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102271. * This means that the material can keep using a previous shader while a new one is being compiled.
  102272. * This is mostly used when shader parallel compilation is supported (true by default)
  102273. */
  102274. allowShaderHotSwapping: boolean;
  102275. constructor(name: string, scene: Scene);
  102276. getEffect(): Effect;
  102277. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102278. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102279. /**
  102280. * Binds the given world matrix to the active effect
  102281. *
  102282. * @param world the matrix to bind
  102283. */
  102284. bindOnlyWorldMatrix(world: Matrix): void;
  102285. /**
  102286. * Binds the given normal matrix to the active effect
  102287. *
  102288. * @param normalMatrix the matrix to bind
  102289. */
  102290. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102291. bind(world: Matrix, mesh?: Mesh): void;
  102292. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102293. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102294. }
  102295. }
  102296. declare module BABYLON {
  102297. /**
  102298. * This groups all the flags used to control the materials channel.
  102299. */
  102300. export class MaterialFlags {
  102301. private static _DiffuseTextureEnabled;
  102302. /**
  102303. * Are diffuse textures enabled in the application.
  102304. */
  102305. static get DiffuseTextureEnabled(): boolean;
  102306. static set DiffuseTextureEnabled(value: boolean);
  102307. private static _AmbientTextureEnabled;
  102308. /**
  102309. * Are ambient textures enabled in the application.
  102310. */
  102311. static get AmbientTextureEnabled(): boolean;
  102312. static set AmbientTextureEnabled(value: boolean);
  102313. private static _OpacityTextureEnabled;
  102314. /**
  102315. * Are opacity textures enabled in the application.
  102316. */
  102317. static get OpacityTextureEnabled(): boolean;
  102318. static set OpacityTextureEnabled(value: boolean);
  102319. private static _ReflectionTextureEnabled;
  102320. /**
  102321. * Are reflection textures enabled in the application.
  102322. */
  102323. static get ReflectionTextureEnabled(): boolean;
  102324. static set ReflectionTextureEnabled(value: boolean);
  102325. private static _EmissiveTextureEnabled;
  102326. /**
  102327. * Are emissive textures enabled in the application.
  102328. */
  102329. static get EmissiveTextureEnabled(): boolean;
  102330. static set EmissiveTextureEnabled(value: boolean);
  102331. private static _SpecularTextureEnabled;
  102332. /**
  102333. * Are specular textures enabled in the application.
  102334. */
  102335. static get SpecularTextureEnabled(): boolean;
  102336. static set SpecularTextureEnabled(value: boolean);
  102337. private static _BumpTextureEnabled;
  102338. /**
  102339. * Are bump textures enabled in the application.
  102340. */
  102341. static get BumpTextureEnabled(): boolean;
  102342. static set BumpTextureEnabled(value: boolean);
  102343. private static _LightmapTextureEnabled;
  102344. /**
  102345. * Are lightmap textures enabled in the application.
  102346. */
  102347. static get LightmapTextureEnabled(): boolean;
  102348. static set LightmapTextureEnabled(value: boolean);
  102349. private static _RefractionTextureEnabled;
  102350. /**
  102351. * Are refraction textures enabled in the application.
  102352. */
  102353. static get RefractionTextureEnabled(): boolean;
  102354. static set RefractionTextureEnabled(value: boolean);
  102355. private static _ColorGradingTextureEnabled;
  102356. /**
  102357. * Are color grading textures enabled in the application.
  102358. */
  102359. static get ColorGradingTextureEnabled(): boolean;
  102360. static set ColorGradingTextureEnabled(value: boolean);
  102361. private static _FresnelEnabled;
  102362. /**
  102363. * Are fresnels enabled in the application.
  102364. */
  102365. static get FresnelEnabled(): boolean;
  102366. static set FresnelEnabled(value: boolean);
  102367. private static _ClearCoatTextureEnabled;
  102368. /**
  102369. * Are clear coat textures enabled in the application.
  102370. */
  102371. static get ClearCoatTextureEnabled(): boolean;
  102372. static set ClearCoatTextureEnabled(value: boolean);
  102373. private static _ClearCoatBumpTextureEnabled;
  102374. /**
  102375. * Are clear coat bump textures enabled in the application.
  102376. */
  102377. static get ClearCoatBumpTextureEnabled(): boolean;
  102378. static set ClearCoatBumpTextureEnabled(value: boolean);
  102379. private static _ClearCoatTintTextureEnabled;
  102380. /**
  102381. * Are clear coat tint textures enabled in the application.
  102382. */
  102383. static get ClearCoatTintTextureEnabled(): boolean;
  102384. static set ClearCoatTintTextureEnabled(value: boolean);
  102385. private static _SheenTextureEnabled;
  102386. /**
  102387. * Are sheen textures enabled in the application.
  102388. */
  102389. static get SheenTextureEnabled(): boolean;
  102390. static set SheenTextureEnabled(value: boolean);
  102391. private static _AnisotropicTextureEnabled;
  102392. /**
  102393. * Are anisotropic textures enabled in the application.
  102394. */
  102395. static get AnisotropicTextureEnabled(): boolean;
  102396. static set AnisotropicTextureEnabled(value: boolean);
  102397. private static _ThicknessTextureEnabled;
  102398. /**
  102399. * Are thickness textures enabled in the application.
  102400. */
  102401. static get ThicknessTextureEnabled(): boolean;
  102402. static set ThicknessTextureEnabled(value: boolean);
  102403. }
  102404. }
  102405. declare module BABYLON {
  102406. /** @hidden */
  102407. export var defaultFragmentDeclaration: {
  102408. name: string;
  102409. shader: string;
  102410. };
  102411. }
  102412. declare module BABYLON {
  102413. /** @hidden */
  102414. export var defaultUboDeclaration: {
  102415. name: string;
  102416. shader: string;
  102417. };
  102418. }
  102419. declare module BABYLON {
  102420. /** @hidden */
  102421. export var lightFragmentDeclaration: {
  102422. name: string;
  102423. shader: string;
  102424. };
  102425. }
  102426. declare module BABYLON {
  102427. /** @hidden */
  102428. export var lightUboDeclaration: {
  102429. name: string;
  102430. shader: string;
  102431. };
  102432. }
  102433. declare module BABYLON {
  102434. /** @hidden */
  102435. export var lightsFragmentFunctions: {
  102436. name: string;
  102437. shader: string;
  102438. };
  102439. }
  102440. declare module BABYLON {
  102441. /** @hidden */
  102442. export var shadowsFragmentFunctions: {
  102443. name: string;
  102444. shader: string;
  102445. };
  102446. }
  102447. declare module BABYLON {
  102448. /** @hidden */
  102449. export var fresnelFunction: {
  102450. name: string;
  102451. shader: string;
  102452. };
  102453. }
  102454. declare module BABYLON {
  102455. /** @hidden */
  102456. export var reflectionFunction: {
  102457. name: string;
  102458. shader: string;
  102459. };
  102460. }
  102461. declare module BABYLON {
  102462. /** @hidden */
  102463. export var bumpFragmentMainFunctions: {
  102464. name: string;
  102465. shader: string;
  102466. };
  102467. }
  102468. declare module BABYLON {
  102469. /** @hidden */
  102470. export var bumpFragmentFunctions: {
  102471. name: string;
  102472. shader: string;
  102473. };
  102474. }
  102475. declare module BABYLON {
  102476. /** @hidden */
  102477. export var logDepthDeclaration: {
  102478. name: string;
  102479. shader: string;
  102480. };
  102481. }
  102482. declare module BABYLON {
  102483. /** @hidden */
  102484. export var bumpFragment: {
  102485. name: string;
  102486. shader: string;
  102487. };
  102488. }
  102489. declare module BABYLON {
  102490. /** @hidden */
  102491. export var depthPrePass: {
  102492. name: string;
  102493. shader: string;
  102494. };
  102495. }
  102496. declare module BABYLON {
  102497. /** @hidden */
  102498. export var lightFragment: {
  102499. name: string;
  102500. shader: string;
  102501. };
  102502. }
  102503. declare module BABYLON {
  102504. /** @hidden */
  102505. export var logDepthFragment: {
  102506. name: string;
  102507. shader: string;
  102508. };
  102509. }
  102510. declare module BABYLON {
  102511. /** @hidden */
  102512. export var defaultPixelShader: {
  102513. name: string;
  102514. shader: string;
  102515. };
  102516. }
  102517. declare module BABYLON {
  102518. /** @hidden */
  102519. export var defaultVertexDeclaration: {
  102520. name: string;
  102521. shader: string;
  102522. };
  102523. }
  102524. declare module BABYLON {
  102525. /** @hidden */
  102526. export var bumpVertexDeclaration: {
  102527. name: string;
  102528. shader: string;
  102529. };
  102530. }
  102531. declare module BABYLON {
  102532. /** @hidden */
  102533. export var bumpVertex: {
  102534. name: string;
  102535. shader: string;
  102536. };
  102537. }
  102538. declare module BABYLON {
  102539. /** @hidden */
  102540. export var fogVertex: {
  102541. name: string;
  102542. shader: string;
  102543. };
  102544. }
  102545. declare module BABYLON {
  102546. /** @hidden */
  102547. export var shadowsVertex: {
  102548. name: string;
  102549. shader: string;
  102550. };
  102551. }
  102552. declare module BABYLON {
  102553. /** @hidden */
  102554. export var pointCloudVertex: {
  102555. name: string;
  102556. shader: string;
  102557. };
  102558. }
  102559. declare module BABYLON {
  102560. /** @hidden */
  102561. export var logDepthVertex: {
  102562. name: string;
  102563. shader: string;
  102564. };
  102565. }
  102566. declare module BABYLON {
  102567. /** @hidden */
  102568. export var defaultVertexShader: {
  102569. name: string;
  102570. shader: string;
  102571. };
  102572. }
  102573. declare module BABYLON {
  102574. /** @hidden */
  102575. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102576. MAINUV1: boolean;
  102577. MAINUV2: boolean;
  102578. DIFFUSE: boolean;
  102579. DIFFUSEDIRECTUV: number;
  102580. AMBIENT: boolean;
  102581. AMBIENTDIRECTUV: number;
  102582. OPACITY: boolean;
  102583. OPACITYDIRECTUV: number;
  102584. OPACITYRGB: boolean;
  102585. REFLECTION: boolean;
  102586. EMISSIVE: boolean;
  102587. EMISSIVEDIRECTUV: number;
  102588. SPECULAR: boolean;
  102589. SPECULARDIRECTUV: number;
  102590. BUMP: boolean;
  102591. BUMPDIRECTUV: number;
  102592. PARALLAX: boolean;
  102593. PARALLAXOCCLUSION: boolean;
  102594. SPECULAROVERALPHA: boolean;
  102595. CLIPPLANE: boolean;
  102596. CLIPPLANE2: boolean;
  102597. CLIPPLANE3: boolean;
  102598. CLIPPLANE4: boolean;
  102599. CLIPPLANE5: boolean;
  102600. CLIPPLANE6: boolean;
  102601. ALPHATEST: boolean;
  102602. DEPTHPREPASS: boolean;
  102603. ALPHAFROMDIFFUSE: boolean;
  102604. POINTSIZE: boolean;
  102605. FOG: boolean;
  102606. SPECULARTERM: boolean;
  102607. DIFFUSEFRESNEL: boolean;
  102608. OPACITYFRESNEL: boolean;
  102609. REFLECTIONFRESNEL: boolean;
  102610. REFRACTIONFRESNEL: boolean;
  102611. EMISSIVEFRESNEL: boolean;
  102612. FRESNEL: boolean;
  102613. NORMAL: boolean;
  102614. UV1: boolean;
  102615. UV2: boolean;
  102616. VERTEXCOLOR: boolean;
  102617. VERTEXALPHA: boolean;
  102618. NUM_BONE_INFLUENCERS: number;
  102619. BonesPerMesh: number;
  102620. BONETEXTURE: boolean;
  102621. INSTANCES: boolean;
  102622. GLOSSINESS: boolean;
  102623. ROUGHNESS: boolean;
  102624. EMISSIVEASILLUMINATION: boolean;
  102625. LINKEMISSIVEWITHDIFFUSE: boolean;
  102626. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102627. LIGHTMAP: boolean;
  102628. LIGHTMAPDIRECTUV: number;
  102629. OBJECTSPACE_NORMALMAP: boolean;
  102630. USELIGHTMAPASSHADOWMAP: boolean;
  102631. REFLECTIONMAP_3D: boolean;
  102632. REFLECTIONMAP_SPHERICAL: boolean;
  102633. REFLECTIONMAP_PLANAR: boolean;
  102634. REFLECTIONMAP_CUBIC: boolean;
  102635. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102636. REFLECTIONMAP_PROJECTION: boolean;
  102637. REFLECTIONMAP_SKYBOX: boolean;
  102638. REFLECTIONMAP_EXPLICIT: boolean;
  102639. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102640. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102641. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102642. INVERTCUBICMAP: boolean;
  102643. LOGARITHMICDEPTH: boolean;
  102644. REFRACTION: boolean;
  102645. REFRACTIONMAP_3D: boolean;
  102646. REFLECTIONOVERALPHA: boolean;
  102647. TWOSIDEDLIGHTING: boolean;
  102648. SHADOWFLOAT: boolean;
  102649. MORPHTARGETS: boolean;
  102650. MORPHTARGETS_NORMAL: boolean;
  102651. MORPHTARGETS_TANGENT: boolean;
  102652. MORPHTARGETS_UV: boolean;
  102653. NUM_MORPH_INFLUENCERS: number;
  102654. NONUNIFORMSCALING: boolean;
  102655. PREMULTIPLYALPHA: boolean;
  102656. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  102657. ALPHABLEND: boolean;
  102658. IMAGEPROCESSING: boolean;
  102659. VIGNETTE: boolean;
  102660. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102661. VIGNETTEBLENDMODEOPAQUE: boolean;
  102662. TONEMAPPING: boolean;
  102663. TONEMAPPING_ACES: boolean;
  102664. CONTRAST: boolean;
  102665. COLORCURVES: boolean;
  102666. COLORGRADING: boolean;
  102667. COLORGRADING3D: boolean;
  102668. SAMPLER3DGREENDEPTH: boolean;
  102669. SAMPLER3DBGRMAP: boolean;
  102670. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102671. MULTIVIEW: boolean;
  102672. /**
  102673. * If the reflection texture on this material is in linear color space
  102674. * @hidden
  102675. */
  102676. IS_REFLECTION_LINEAR: boolean;
  102677. /**
  102678. * If the refraction texture on this material is in linear color space
  102679. * @hidden
  102680. */
  102681. IS_REFRACTION_LINEAR: boolean;
  102682. EXPOSURE: boolean;
  102683. constructor();
  102684. setReflectionMode(modeToEnable: string): void;
  102685. }
  102686. /**
  102687. * This is the default material used in Babylon. It is the best trade off between quality
  102688. * and performances.
  102689. * @see http://doc.babylonjs.com/babylon101/materials
  102690. */
  102691. export class StandardMaterial extends PushMaterial {
  102692. private _diffuseTexture;
  102693. /**
  102694. * The basic texture of the material as viewed under a light.
  102695. */
  102696. diffuseTexture: Nullable<BaseTexture>;
  102697. private _ambientTexture;
  102698. /**
  102699. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102700. */
  102701. ambientTexture: Nullable<BaseTexture>;
  102702. private _opacityTexture;
  102703. /**
  102704. * Define the transparency of the material from a texture.
  102705. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102706. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102707. */
  102708. opacityTexture: Nullable<BaseTexture>;
  102709. private _reflectionTexture;
  102710. /**
  102711. * Define the texture used to display the reflection.
  102712. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102713. */
  102714. reflectionTexture: Nullable<BaseTexture>;
  102715. private _emissiveTexture;
  102716. /**
  102717. * Define texture of the material as if self lit.
  102718. * This will be mixed in the final result even in the absence of light.
  102719. */
  102720. emissiveTexture: Nullable<BaseTexture>;
  102721. private _specularTexture;
  102722. /**
  102723. * Define how the color and intensity of the highlight given by the light in the material.
  102724. */
  102725. specularTexture: Nullable<BaseTexture>;
  102726. private _bumpTexture;
  102727. /**
  102728. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102729. * 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.
  102730. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102731. */
  102732. bumpTexture: Nullable<BaseTexture>;
  102733. private _lightmapTexture;
  102734. /**
  102735. * Complex lighting can be computationally expensive to compute at runtime.
  102736. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102737. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102738. */
  102739. lightmapTexture: Nullable<BaseTexture>;
  102740. private _refractionTexture;
  102741. /**
  102742. * Define the texture used to display the refraction.
  102743. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102744. */
  102745. refractionTexture: Nullable<BaseTexture>;
  102746. /**
  102747. * The color of the material lit by the environmental background lighting.
  102748. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102749. */
  102750. ambientColor: Color3;
  102751. /**
  102752. * The basic color of the material as viewed under a light.
  102753. */
  102754. diffuseColor: Color3;
  102755. /**
  102756. * Define how the color and intensity of the highlight given by the light in the material.
  102757. */
  102758. specularColor: Color3;
  102759. /**
  102760. * Define the color of the material as if self lit.
  102761. * This will be mixed in the final result even in the absence of light.
  102762. */
  102763. emissiveColor: Color3;
  102764. /**
  102765. * Defines how sharp are the highlights in the material.
  102766. * The bigger the value the sharper giving a more glossy feeling to the result.
  102767. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102768. */
  102769. specularPower: number;
  102770. private _useAlphaFromDiffuseTexture;
  102771. /**
  102772. * Does the transparency come from the diffuse texture alpha channel.
  102773. */
  102774. useAlphaFromDiffuseTexture: boolean;
  102775. private _useEmissiveAsIllumination;
  102776. /**
  102777. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102778. */
  102779. useEmissiveAsIllumination: boolean;
  102780. private _linkEmissiveWithDiffuse;
  102781. /**
  102782. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102783. * the emissive level when the final color is close to one.
  102784. */
  102785. linkEmissiveWithDiffuse: boolean;
  102786. private _useSpecularOverAlpha;
  102787. /**
  102788. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102789. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102790. */
  102791. useSpecularOverAlpha: boolean;
  102792. private _useReflectionOverAlpha;
  102793. /**
  102794. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102795. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102796. */
  102797. useReflectionOverAlpha: boolean;
  102798. private _disableLighting;
  102799. /**
  102800. * Does lights from the scene impacts this material.
  102801. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102802. */
  102803. disableLighting: boolean;
  102804. private _useObjectSpaceNormalMap;
  102805. /**
  102806. * Allows using an object space normal map (instead of tangent space).
  102807. */
  102808. useObjectSpaceNormalMap: boolean;
  102809. private _useParallax;
  102810. /**
  102811. * Is parallax enabled or not.
  102812. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102813. */
  102814. useParallax: boolean;
  102815. private _useParallaxOcclusion;
  102816. /**
  102817. * Is parallax occlusion enabled or not.
  102818. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102819. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102820. */
  102821. useParallaxOcclusion: boolean;
  102822. /**
  102823. * 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.
  102824. */
  102825. parallaxScaleBias: number;
  102826. private _roughness;
  102827. /**
  102828. * Helps to define how blurry the reflections should appears in the material.
  102829. */
  102830. roughness: number;
  102831. /**
  102832. * In case of refraction, define the value of the index of refraction.
  102833. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102834. */
  102835. indexOfRefraction: number;
  102836. /**
  102837. * Invert the refraction texture alongside the y axis.
  102838. * It can be useful with procedural textures or probe for instance.
  102839. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102840. */
  102841. invertRefractionY: boolean;
  102842. /**
  102843. * Defines the alpha limits in alpha test mode.
  102844. */
  102845. alphaCutOff: number;
  102846. private _useLightmapAsShadowmap;
  102847. /**
  102848. * In case of light mapping, define whether the map contains light or shadow informations.
  102849. */
  102850. useLightmapAsShadowmap: boolean;
  102851. private _diffuseFresnelParameters;
  102852. /**
  102853. * Define the diffuse fresnel parameters of the material.
  102854. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102855. */
  102856. diffuseFresnelParameters: FresnelParameters;
  102857. private _opacityFresnelParameters;
  102858. /**
  102859. * Define the opacity fresnel parameters of the material.
  102860. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102861. */
  102862. opacityFresnelParameters: FresnelParameters;
  102863. private _reflectionFresnelParameters;
  102864. /**
  102865. * Define the reflection fresnel parameters of the material.
  102866. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102867. */
  102868. reflectionFresnelParameters: FresnelParameters;
  102869. private _refractionFresnelParameters;
  102870. /**
  102871. * Define the refraction fresnel parameters of the material.
  102872. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102873. */
  102874. refractionFresnelParameters: FresnelParameters;
  102875. private _emissiveFresnelParameters;
  102876. /**
  102877. * Define the emissive fresnel parameters of the material.
  102878. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102879. */
  102880. emissiveFresnelParameters: FresnelParameters;
  102881. private _useReflectionFresnelFromSpecular;
  102882. /**
  102883. * If true automatically deducts the fresnels values from the material specularity.
  102884. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102885. */
  102886. useReflectionFresnelFromSpecular: boolean;
  102887. private _useGlossinessFromSpecularMapAlpha;
  102888. /**
  102889. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102890. */
  102891. useGlossinessFromSpecularMapAlpha: boolean;
  102892. private _maxSimultaneousLights;
  102893. /**
  102894. * Defines the maximum number of lights that can be used in the material
  102895. */
  102896. maxSimultaneousLights: number;
  102897. private _invertNormalMapX;
  102898. /**
  102899. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102900. */
  102901. invertNormalMapX: boolean;
  102902. private _invertNormalMapY;
  102903. /**
  102904. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102905. */
  102906. invertNormalMapY: boolean;
  102907. private _twoSidedLighting;
  102908. /**
  102909. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102910. */
  102911. twoSidedLighting: boolean;
  102912. /**
  102913. * Default configuration related to image processing available in the standard Material.
  102914. */
  102915. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102916. /**
  102917. * Gets the image processing configuration used either in this material.
  102918. */
  102919. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102920. /**
  102921. * Sets the Default image processing configuration used either in the this material.
  102922. *
  102923. * If sets to null, the scene one is in use.
  102924. */
  102925. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102926. /**
  102927. * Keep track of the image processing observer to allow dispose and replace.
  102928. */
  102929. private _imageProcessingObserver;
  102930. /**
  102931. * Attaches a new image processing configuration to the Standard Material.
  102932. * @param configuration
  102933. */
  102934. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102935. /**
  102936. * Gets wether the color curves effect is enabled.
  102937. */
  102938. get cameraColorCurvesEnabled(): boolean;
  102939. /**
  102940. * Sets wether the color curves effect is enabled.
  102941. */
  102942. set cameraColorCurvesEnabled(value: boolean);
  102943. /**
  102944. * Gets wether the color grading effect is enabled.
  102945. */
  102946. get cameraColorGradingEnabled(): boolean;
  102947. /**
  102948. * Gets wether the color grading effect is enabled.
  102949. */
  102950. set cameraColorGradingEnabled(value: boolean);
  102951. /**
  102952. * Gets wether tonemapping is enabled or not.
  102953. */
  102954. get cameraToneMappingEnabled(): boolean;
  102955. /**
  102956. * Sets wether tonemapping is enabled or not
  102957. */
  102958. set cameraToneMappingEnabled(value: boolean);
  102959. /**
  102960. * The camera exposure used on this material.
  102961. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102962. * This corresponds to a photographic exposure.
  102963. */
  102964. get cameraExposure(): number;
  102965. /**
  102966. * The camera exposure used on this material.
  102967. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102968. * This corresponds to a photographic exposure.
  102969. */
  102970. set cameraExposure(value: number);
  102971. /**
  102972. * Gets The camera contrast used on this material.
  102973. */
  102974. get cameraContrast(): number;
  102975. /**
  102976. * Sets The camera contrast used on this material.
  102977. */
  102978. set cameraContrast(value: number);
  102979. /**
  102980. * Gets the Color Grading 2D Lookup Texture.
  102981. */
  102982. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  102983. /**
  102984. * Sets the Color Grading 2D Lookup Texture.
  102985. */
  102986. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  102987. /**
  102988. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102989. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102990. * 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;
  102991. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102992. */
  102993. get cameraColorCurves(): Nullable<ColorCurves>;
  102994. /**
  102995. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102996. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102997. * 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;
  102998. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102999. */
  103000. set cameraColorCurves(value: Nullable<ColorCurves>);
  103001. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103002. protected _worldViewProjectionMatrix: Matrix;
  103003. protected _globalAmbientColor: Color3;
  103004. protected _useLogarithmicDepth: boolean;
  103005. protected _rebuildInParallel: boolean;
  103006. /**
  103007. * Instantiates a new standard material.
  103008. * This is the default material used in Babylon. It is the best trade off between quality
  103009. * and performances.
  103010. * @see http://doc.babylonjs.com/babylon101/materials
  103011. * @param name Define the name of the material in the scene
  103012. * @param scene Define the scene the material belong to
  103013. */
  103014. constructor(name: string, scene: Scene);
  103015. /**
  103016. * Gets a boolean indicating that current material needs to register RTT
  103017. */
  103018. get hasRenderTargetTextures(): boolean;
  103019. /**
  103020. * Gets the current class name of the material e.g. "StandardMaterial"
  103021. * Mainly use in serialization.
  103022. * @returns the class name
  103023. */
  103024. getClassName(): string;
  103025. /**
  103026. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103027. * You can try switching to logarithmic depth.
  103028. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103029. */
  103030. get useLogarithmicDepth(): boolean;
  103031. set useLogarithmicDepth(value: boolean);
  103032. /**
  103033. * Specifies if the material will require alpha blending
  103034. * @returns a boolean specifying if alpha blending is needed
  103035. */
  103036. needAlphaBlending(): boolean;
  103037. /**
  103038. * Specifies if this material should be rendered in alpha test mode
  103039. * @returns a boolean specifying if an alpha test is needed.
  103040. */
  103041. needAlphaTesting(): boolean;
  103042. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103043. /**
  103044. * Get the texture used for alpha test purpose.
  103045. * @returns the diffuse texture in case of the standard material.
  103046. */
  103047. getAlphaTestTexture(): Nullable<BaseTexture>;
  103048. /**
  103049. * Get if the submesh is ready to be used and all its information available.
  103050. * Child classes can use it to update shaders
  103051. * @param mesh defines the mesh to check
  103052. * @param subMesh defines which submesh to check
  103053. * @param useInstances specifies that instances should be used
  103054. * @returns a boolean indicating that the submesh is ready or not
  103055. */
  103056. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103057. /**
  103058. * Builds the material UBO layouts.
  103059. * Used internally during the effect preparation.
  103060. */
  103061. buildUniformLayout(): void;
  103062. /**
  103063. * Unbinds the material from the mesh
  103064. */
  103065. unbind(): void;
  103066. /**
  103067. * Binds the submesh to this material by preparing the effect and shader to draw
  103068. * @param world defines the world transformation matrix
  103069. * @param mesh defines the mesh containing the submesh
  103070. * @param subMesh defines the submesh to bind the material to
  103071. */
  103072. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103073. /**
  103074. * Get the list of animatables in the material.
  103075. * @returns the list of animatables object used in the material
  103076. */
  103077. getAnimatables(): IAnimatable[];
  103078. /**
  103079. * Gets the active textures from the material
  103080. * @returns an array of textures
  103081. */
  103082. getActiveTextures(): BaseTexture[];
  103083. /**
  103084. * Specifies if the material uses a texture
  103085. * @param texture defines the texture to check against the material
  103086. * @returns a boolean specifying if the material uses the texture
  103087. */
  103088. hasTexture(texture: BaseTexture): boolean;
  103089. /**
  103090. * Disposes the material
  103091. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103092. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103093. */
  103094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103095. /**
  103096. * Makes a duplicate of the material, and gives it a new name
  103097. * @param name defines the new name for the duplicated material
  103098. * @returns the cloned material
  103099. */
  103100. clone(name: string): StandardMaterial;
  103101. /**
  103102. * Serializes this material in a JSON representation
  103103. * @returns the serialized material object
  103104. */
  103105. serialize(): any;
  103106. /**
  103107. * Creates a standard material from parsed material data
  103108. * @param source defines the JSON representation of the material
  103109. * @param scene defines the hosting scene
  103110. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103111. * @returns a new standard material
  103112. */
  103113. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103114. /**
  103115. * Are diffuse textures enabled in the application.
  103116. */
  103117. static get DiffuseTextureEnabled(): boolean;
  103118. static set DiffuseTextureEnabled(value: boolean);
  103119. /**
  103120. * Are ambient textures enabled in the application.
  103121. */
  103122. static get AmbientTextureEnabled(): boolean;
  103123. static set AmbientTextureEnabled(value: boolean);
  103124. /**
  103125. * Are opacity textures enabled in the application.
  103126. */
  103127. static get OpacityTextureEnabled(): boolean;
  103128. static set OpacityTextureEnabled(value: boolean);
  103129. /**
  103130. * Are reflection textures enabled in the application.
  103131. */
  103132. static get ReflectionTextureEnabled(): boolean;
  103133. static set ReflectionTextureEnabled(value: boolean);
  103134. /**
  103135. * Are emissive textures enabled in the application.
  103136. */
  103137. static get EmissiveTextureEnabled(): boolean;
  103138. static set EmissiveTextureEnabled(value: boolean);
  103139. /**
  103140. * Are specular textures enabled in the application.
  103141. */
  103142. static get SpecularTextureEnabled(): boolean;
  103143. static set SpecularTextureEnabled(value: boolean);
  103144. /**
  103145. * Are bump textures enabled in the application.
  103146. */
  103147. static get BumpTextureEnabled(): boolean;
  103148. static set BumpTextureEnabled(value: boolean);
  103149. /**
  103150. * Are lightmap textures enabled in the application.
  103151. */
  103152. static get LightmapTextureEnabled(): boolean;
  103153. static set LightmapTextureEnabled(value: boolean);
  103154. /**
  103155. * Are refraction textures enabled in the application.
  103156. */
  103157. static get RefractionTextureEnabled(): boolean;
  103158. static set RefractionTextureEnabled(value: boolean);
  103159. /**
  103160. * Are color grading textures enabled in the application.
  103161. */
  103162. static get ColorGradingTextureEnabled(): boolean;
  103163. static set ColorGradingTextureEnabled(value: boolean);
  103164. /**
  103165. * Are fresnels enabled in the application.
  103166. */
  103167. static get FresnelEnabled(): boolean;
  103168. static set FresnelEnabled(value: boolean);
  103169. }
  103170. }
  103171. declare module BABYLON {
  103172. /**
  103173. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  103174. *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.
  103175. * The SPS is also a particle system. It provides some methods to manage the particles.
  103176. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  103177. *
  103178. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  103179. */
  103180. export class SolidParticleSystem implements IDisposable {
  103181. /**
  103182. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  103183. * Example : var p = SPS.particles[i];
  103184. */
  103185. particles: SolidParticle[];
  103186. /**
  103187. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  103188. */
  103189. nbParticles: number;
  103190. /**
  103191. * If the particles must ever face the camera (default false). Useful for planar particles.
  103192. */
  103193. billboard: boolean;
  103194. /**
  103195. * Recompute normals when adding a shape
  103196. */
  103197. recomputeNormals: boolean;
  103198. /**
  103199. * This a counter ofr your own usage. It's not set by any SPS functions.
  103200. */
  103201. counter: number;
  103202. /**
  103203. * The SPS name. This name is also given to the underlying mesh.
  103204. */
  103205. name: string;
  103206. /**
  103207. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  103208. */
  103209. mesh: Mesh;
  103210. /**
  103211. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  103212. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  103213. */
  103214. vars: any;
  103215. /**
  103216. * This array is populated when the SPS is set as 'pickable'.
  103217. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  103218. * Each element of this array is an object `{idx: int, faceId: int}`.
  103219. * `idx` is the picked particle index in the `SPS.particles` array
  103220. * `faceId` is the picked face index counted within this particle.
  103221. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  103222. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  103223. * Use the method SPS.pickedParticle(pickingInfo) instead.
  103224. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103225. */
  103226. pickedParticles: {
  103227. idx: number;
  103228. faceId: number;
  103229. }[];
  103230. /**
  103231. * This array is populated when the SPS is set as 'pickable'
  103232. * Each key of this array is a submesh index.
  103233. * Each element of this array is a second array defined like this :
  103234. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  103235. * Each element of this second array is an object `{idx: int, faceId: int}`.
  103236. * `idx` is the picked particle index in the `SPS.particles` array
  103237. * `faceId` is the picked face index counted within this particle.
  103238. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  103239. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  103240. */
  103241. pickedBySubMesh: {
  103242. idx: number;
  103243. faceId: number;
  103244. }[][];
  103245. /**
  103246. * This array is populated when `enableDepthSort` is set to true.
  103247. * Each element of this array is an instance of the class DepthSortedParticle.
  103248. */
  103249. depthSortedParticles: DepthSortedParticle[];
  103250. /**
  103251. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  103252. * @hidden
  103253. */
  103254. _bSphereOnly: boolean;
  103255. /**
  103256. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  103257. * @hidden
  103258. */
  103259. _bSphereRadiusFactor: number;
  103260. private _scene;
  103261. private _positions;
  103262. private _indices;
  103263. private _normals;
  103264. private _colors;
  103265. private _uvs;
  103266. private _indices32;
  103267. private _positions32;
  103268. private _normals32;
  103269. private _fixedNormal32;
  103270. private _colors32;
  103271. private _uvs32;
  103272. private _index;
  103273. private _updatable;
  103274. private _pickable;
  103275. private _isVisibilityBoxLocked;
  103276. private _alwaysVisible;
  103277. private _depthSort;
  103278. private _expandable;
  103279. private _shapeCounter;
  103280. private _copy;
  103281. private _color;
  103282. private _computeParticleColor;
  103283. private _computeParticleTexture;
  103284. private _computeParticleRotation;
  103285. private _computeParticleVertex;
  103286. private _computeBoundingBox;
  103287. private _depthSortParticles;
  103288. private _camera;
  103289. private _mustUnrotateFixedNormals;
  103290. private _particlesIntersect;
  103291. private _needs32Bits;
  103292. private _isNotBuilt;
  103293. private _lastParticleId;
  103294. private _idxOfId;
  103295. private _multimaterialEnabled;
  103296. private _useModelMaterial;
  103297. private _indicesByMaterial;
  103298. private _materialIndexes;
  103299. private _depthSortFunction;
  103300. private _materialSortFunction;
  103301. private _materials;
  103302. private _multimaterial;
  103303. private _materialIndexesById;
  103304. private _defaultMaterial;
  103305. private _autoUpdateSubMeshes;
  103306. private _tmpVertex;
  103307. /**
  103308. * Creates a SPS (Solid Particle System) object.
  103309. * @param name (String) is the SPS name, this will be the underlying mesh name.
  103310. * @param scene (Scene) is the scene in which the SPS is added.
  103311. * @param options defines the options of the sps e.g.
  103312. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  103313. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  103314. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  103315. * * 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.
  103316. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  103317. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  103318. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  103319. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  103320. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  103321. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  103322. */
  103323. constructor(name: string, scene: Scene, options?: {
  103324. updatable?: boolean;
  103325. isPickable?: boolean;
  103326. enableDepthSort?: boolean;
  103327. particleIntersection?: boolean;
  103328. boundingSphereOnly?: boolean;
  103329. bSphereRadiusFactor?: number;
  103330. expandable?: boolean;
  103331. useModelMaterial?: boolean;
  103332. enableMultiMaterial?: boolean;
  103333. });
  103334. /**
  103335. * Builds the SPS underlying mesh. Returns a standard Mesh.
  103336. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  103337. * @returns the created mesh
  103338. */
  103339. buildMesh(): Mesh;
  103340. /**
  103341. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  103342. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  103343. * Thus the particles generated from `digest()` have their property `position` set yet.
  103344. * @param mesh ( Mesh ) is the mesh to be digested
  103345. * @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
  103346. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  103347. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  103348. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103349. * @returns the current SPS
  103350. */
  103351. digest(mesh: Mesh, options?: {
  103352. facetNb?: number;
  103353. number?: number;
  103354. delta?: number;
  103355. storage?: [];
  103356. }): SolidParticleSystem;
  103357. /**
  103358. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  103359. * @hidden
  103360. */
  103361. private _unrotateFixedNormals;
  103362. /**
  103363. * Resets the temporary working copy particle
  103364. * @hidden
  103365. */
  103366. private _resetCopy;
  103367. /**
  103368. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  103369. * @param p the current index in the positions array to be updated
  103370. * @param ind the current index in the indices array
  103371. * @param shape a Vector3 array, the shape geometry
  103372. * @param positions the positions array to be updated
  103373. * @param meshInd the shape indices array
  103374. * @param indices the indices array to be updated
  103375. * @param meshUV the shape uv array
  103376. * @param uvs the uv array to be updated
  103377. * @param meshCol the shape color array
  103378. * @param colors the color array to be updated
  103379. * @param meshNor the shape normals array
  103380. * @param normals the normals array to be updated
  103381. * @param idx the particle index
  103382. * @param idxInShape the particle index in its shape
  103383. * @param options the addShape() method passed options
  103384. * @model the particle model
  103385. * @hidden
  103386. */
  103387. private _meshBuilder;
  103388. /**
  103389. * Returns a shape Vector3 array from positions float array
  103390. * @param positions float array
  103391. * @returns a vector3 array
  103392. * @hidden
  103393. */
  103394. private _posToShape;
  103395. /**
  103396. * Returns a shapeUV array from a float uvs (array deep copy)
  103397. * @param uvs as a float array
  103398. * @returns a shapeUV array
  103399. * @hidden
  103400. */
  103401. private _uvsToShapeUV;
  103402. /**
  103403. * Adds a new particle object in the particles array
  103404. * @param idx particle index in particles array
  103405. * @param id particle id
  103406. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  103407. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  103408. * @param model particle ModelShape object
  103409. * @param shapeId model shape identifier
  103410. * @param idxInShape index of the particle in the current model
  103411. * @param bInfo model bounding info object
  103412. * @param storage target storage array, if any
  103413. * @hidden
  103414. */
  103415. private _addParticle;
  103416. /**
  103417. * Adds some particles to the SPS from the model shape. Returns the shape id.
  103418. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  103419. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  103420. * @param nb (positive integer) the number of particles to be created from this model
  103421. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  103422. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  103423. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  103424. * @returns the number of shapes in the system
  103425. */
  103426. addShape(mesh: Mesh, nb: number, options?: {
  103427. positionFunction?: any;
  103428. vertexFunction?: any;
  103429. storage?: [];
  103430. }): number;
  103431. /**
  103432. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  103433. * @hidden
  103434. */
  103435. private _rebuildParticle;
  103436. /**
  103437. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  103438. * @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.
  103439. * @returns the SPS.
  103440. */
  103441. rebuildMesh(reset?: boolean): SolidParticleSystem;
  103442. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  103443. * Returns an array with the removed particles.
  103444. * 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.
  103445. * The SPS can't be empty so at least one particle needs to remain in place.
  103446. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  103447. * @param start index of the first particle to remove
  103448. * @param end index of the last particle to remove (included)
  103449. * @returns an array populated with the removed particles
  103450. */
  103451. removeParticles(start: number, end: number): SolidParticle[];
  103452. /**
  103453. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  103454. * @param solidParticleArray an array populated with Solid Particles objects
  103455. * @returns the SPS
  103456. */
  103457. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  103458. /**
  103459. * Creates a new particle and modifies the SPS mesh geometry :
  103460. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  103461. * - calls _addParticle() to populate the particle array
  103462. * factorized code from addShape() and insertParticlesFromArray()
  103463. * @param idx particle index in the particles array
  103464. * @param i particle index in its shape
  103465. * @param modelShape particle ModelShape object
  103466. * @param shape shape vertex array
  103467. * @param meshInd shape indices array
  103468. * @param meshUV shape uv array
  103469. * @param meshCol shape color array
  103470. * @param meshNor shape normals array
  103471. * @param bbInfo shape bounding info
  103472. * @param storage target particle storage
  103473. * @options addShape() passed options
  103474. * @hidden
  103475. */
  103476. private _insertNewParticle;
  103477. /**
  103478. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  103479. * This method calls `updateParticle()` for each particle of the SPS.
  103480. * For an animated SPS, it is usually called within the render loop.
  103481. * 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.
  103482. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  103483. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  103484. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  103485. * @returns the SPS.
  103486. */
  103487. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  103488. /**
  103489. * Disposes the SPS.
  103490. */
  103491. dispose(): void;
  103492. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  103493. * idx is the particle index in the SPS
  103494. * faceId is the picked face index counted within this particle.
  103495. * Returns null if the pickInfo can't identify a picked particle.
  103496. * @param pickingInfo (PickingInfo object)
  103497. * @returns {idx: number, faceId: number} or null
  103498. */
  103499. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  103500. idx: number;
  103501. faceId: number;
  103502. }>;
  103503. /**
  103504. * Returns a SolidParticle object from its identifier : particle.id
  103505. * @param id (integer) the particle Id
  103506. * @returns the searched particle or null if not found in the SPS.
  103507. */
  103508. getParticleById(id: number): Nullable<SolidParticle>;
  103509. /**
  103510. * Returns a new array populated with the particles having the passed shapeId.
  103511. * @param shapeId (integer) the shape identifier
  103512. * @returns a new solid particle array
  103513. */
  103514. getParticlesByShapeId(shapeId: number): SolidParticle[];
  103515. /**
  103516. * Populates the passed array "ref" with the particles having the passed shapeId.
  103517. * @param shapeId the shape identifier
  103518. * @returns the SPS
  103519. * @param ref
  103520. */
  103521. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  103522. /**
  103523. * Computes the required SubMeshes according the materials assigned to the particles.
  103524. * @returns the solid particle system.
  103525. * Does nothing if called before the SPS mesh is built.
  103526. */
  103527. computeSubMeshes(): SolidParticleSystem;
  103528. /**
  103529. * Sorts the solid particles by material when MultiMaterial is enabled.
  103530. * Updates the indices32 array.
  103531. * Updates the indicesByMaterial array.
  103532. * Updates the mesh indices array.
  103533. * @returns the SPS
  103534. * @hidden
  103535. */
  103536. private _sortParticlesByMaterial;
  103537. /**
  103538. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  103539. * @hidden
  103540. */
  103541. private _setMaterialIndexesById;
  103542. /**
  103543. * Returns an array with unique values of Materials from the passed array
  103544. * @param array the material array to be checked and filtered
  103545. * @hidden
  103546. */
  103547. private _filterUniqueMaterialId;
  103548. /**
  103549. * Sets a new Standard Material as _defaultMaterial if not already set.
  103550. * @hidden
  103551. */
  103552. private _setDefaultMaterial;
  103553. /**
  103554. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  103555. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103556. * @returns the SPS.
  103557. */
  103558. refreshVisibleSize(): SolidParticleSystem;
  103559. /**
  103560. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  103561. * @param size the size (float) of the visibility box
  103562. * note : this doesn't lock the SPS mesh bounding box.
  103563. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103564. */
  103565. setVisibilityBox(size: number): void;
  103566. /**
  103567. * Gets whether the SPS as always visible or not
  103568. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103569. */
  103570. get isAlwaysVisible(): boolean;
  103571. /**
  103572. * Sets the SPS as always visible or not
  103573. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103574. */
  103575. set isAlwaysVisible(val: boolean);
  103576. /**
  103577. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103578. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103579. */
  103580. set isVisibilityBoxLocked(val: boolean);
  103581. /**
  103582. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  103583. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  103584. */
  103585. get isVisibilityBoxLocked(): boolean;
  103586. /**
  103587. * Tells to `setParticles()` to compute the particle rotations or not.
  103588. * Default value : true. The SPS is faster when it's set to false.
  103589. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103590. */
  103591. set computeParticleRotation(val: boolean);
  103592. /**
  103593. * Tells to `setParticles()` to compute the particle colors or not.
  103594. * Default value : true. The SPS is faster when it's set to false.
  103595. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103596. */
  103597. set computeParticleColor(val: boolean);
  103598. set computeParticleTexture(val: boolean);
  103599. /**
  103600. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  103601. * Default value : false. The SPS is faster when it's set to false.
  103602. * Note : the particle custom vertex positions aren't stored values.
  103603. */
  103604. set computeParticleVertex(val: boolean);
  103605. /**
  103606. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  103607. */
  103608. set computeBoundingBox(val: boolean);
  103609. /**
  103610. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  103611. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103612. * Default : `true`
  103613. */
  103614. set depthSortParticles(val: boolean);
  103615. /**
  103616. * Gets if `setParticles()` computes the particle rotations or not.
  103617. * Default value : true. The SPS is faster when it's set to false.
  103618. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  103619. */
  103620. get computeParticleRotation(): boolean;
  103621. /**
  103622. * Gets if `setParticles()` computes the particle colors or not.
  103623. * Default value : true. The SPS is faster when it's set to false.
  103624. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  103625. */
  103626. get computeParticleColor(): boolean;
  103627. /**
  103628. * Gets if `setParticles()` computes the particle textures or not.
  103629. * Default value : true. The SPS is faster when it's set to false.
  103630. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  103631. */
  103632. get computeParticleTexture(): boolean;
  103633. /**
  103634. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  103635. * Default value : false. The SPS is faster when it's set to false.
  103636. * Note : the particle custom vertex positions aren't stored values.
  103637. */
  103638. get computeParticleVertex(): boolean;
  103639. /**
  103640. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  103641. */
  103642. get computeBoundingBox(): boolean;
  103643. /**
  103644. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  103645. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  103646. * Default : `true`
  103647. */
  103648. get depthSortParticles(): boolean;
  103649. /**
  103650. * Gets if the SPS is created as expandable at construction time.
  103651. * Default : `false`
  103652. */
  103653. get expandable(): boolean;
  103654. /**
  103655. * Gets if the SPS supports the Multi Materials
  103656. */
  103657. get multimaterialEnabled(): boolean;
  103658. /**
  103659. * Gets if the SPS uses the model materials for its own multimaterial.
  103660. */
  103661. get useModelMaterial(): boolean;
  103662. /**
  103663. * The SPS used material array.
  103664. */
  103665. get materials(): Material[];
  103666. /**
  103667. * Sets the SPS MultiMaterial from the passed materials.
  103668. * Note : the passed array is internally copied and not used then by reference.
  103669. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  103670. */
  103671. setMultiMaterial(materials: Material[]): void;
  103672. /**
  103673. * The SPS computed multimaterial object
  103674. */
  103675. get multimaterial(): MultiMaterial;
  103676. set multimaterial(mm: MultiMaterial);
  103677. /**
  103678. * If the subMeshes must be updated on the next call to setParticles()
  103679. */
  103680. get autoUpdateSubMeshes(): boolean;
  103681. set autoUpdateSubMeshes(val: boolean);
  103682. /**
  103683. * This function does nothing. It may be overwritten to set all the particle first values.
  103684. * The SPS doesn't call this function, you may have to call it by your own.
  103685. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103686. */
  103687. initParticles(): void;
  103688. /**
  103689. * This function does nothing. It may be overwritten to recycle a particle.
  103690. * The SPS doesn't call this function, you may have to call it by your own.
  103691. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103692. * @param particle The particle to recycle
  103693. * @returns the recycled particle
  103694. */
  103695. recycleParticle(particle: SolidParticle): SolidParticle;
  103696. /**
  103697. * Updates a particle : this function should be overwritten by the user.
  103698. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  103699. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  103700. * @example : just set a particle position or velocity and recycle conditions
  103701. * @param particle The particle to update
  103702. * @returns the updated particle
  103703. */
  103704. updateParticle(particle: SolidParticle): SolidParticle;
  103705. /**
  103706. * Updates a vertex of a particle : it can be overwritten by the user.
  103707. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  103708. * @param particle the current particle
  103709. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  103710. * @param pt the index of the current vertex in the particle shape
  103711. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  103712. * @example : just set a vertex particle position or color
  103713. * @returns the sps
  103714. */
  103715. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  103716. /**
  103717. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  103718. * This does nothing and may be overwritten by the user.
  103719. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103720. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103721. * @param update the boolean update value actually passed to setParticles()
  103722. */
  103723. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103724. /**
  103725. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  103726. * This will be passed three parameters.
  103727. * This does nothing and may be overwritten by the user.
  103728. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103729. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  103730. * @param update the boolean update value actually passed to setParticles()
  103731. */
  103732. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  103733. }
  103734. }
  103735. declare module BABYLON {
  103736. /**
  103737. * Represents one particle of a solid particle system.
  103738. */
  103739. export class SolidParticle {
  103740. /**
  103741. * particle global index
  103742. */
  103743. idx: number;
  103744. /**
  103745. * particle identifier
  103746. */
  103747. id: number;
  103748. /**
  103749. * The color of the particle
  103750. */
  103751. color: Nullable<Color4>;
  103752. /**
  103753. * The world space position of the particle.
  103754. */
  103755. position: Vector3;
  103756. /**
  103757. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  103758. */
  103759. rotation: Vector3;
  103760. /**
  103761. * The world space rotation quaternion of the particle.
  103762. */
  103763. rotationQuaternion: Nullable<Quaternion>;
  103764. /**
  103765. * The scaling of the particle.
  103766. */
  103767. scaling: Vector3;
  103768. /**
  103769. * The uvs of the particle.
  103770. */
  103771. uvs: Vector4;
  103772. /**
  103773. * The current speed of the particle.
  103774. */
  103775. velocity: Vector3;
  103776. /**
  103777. * The pivot point in the particle local space.
  103778. */
  103779. pivot: Vector3;
  103780. /**
  103781. * Must the particle be translated from its pivot point in its local space ?
  103782. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  103783. * Default : false
  103784. */
  103785. translateFromPivot: boolean;
  103786. /**
  103787. * Is the particle active or not ?
  103788. */
  103789. alive: boolean;
  103790. /**
  103791. * Is the particle visible or not ?
  103792. */
  103793. isVisible: boolean;
  103794. /**
  103795. * Index of this particle in the global "positions" array (Internal use)
  103796. * @hidden
  103797. */
  103798. _pos: number;
  103799. /**
  103800. * @hidden Index of this particle in the global "indices" array (Internal use)
  103801. */
  103802. _ind: number;
  103803. /**
  103804. * @hidden ModelShape of this particle (Internal use)
  103805. */
  103806. _model: ModelShape;
  103807. /**
  103808. * ModelShape id of this particle
  103809. */
  103810. shapeId: number;
  103811. /**
  103812. * Index of the particle in its shape id
  103813. */
  103814. idxInShape: number;
  103815. /**
  103816. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  103817. */
  103818. _modelBoundingInfo: BoundingInfo;
  103819. /**
  103820. * @hidden Particle BoundingInfo object (Internal use)
  103821. */
  103822. _boundingInfo: BoundingInfo;
  103823. /**
  103824. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  103825. */
  103826. _sps: SolidParticleSystem;
  103827. /**
  103828. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  103829. */
  103830. _stillInvisible: boolean;
  103831. /**
  103832. * @hidden Last computed particle rotation matrix
  103833. */
  103834. _rotationMatrix: number[];
  103835. /**
  103836. * Parent particle Id, if any.
  103837. * Default null.
  103838. */
  103839. parentId: Nullable<number>;
  103840. /**
  103841. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  103842. */
  103843. materialIndex: Nullable<number>;
  103844. /**
  103845. * Custom object or properties.
  103846. */
  103847. props: Nullable<any>;
  103848. /**
  103849. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  103850. * The possible values are :
  103851. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  103852. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  103853. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  103854. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  103855. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  103856. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  103857. * */
  103858. cullingStrategy: number;
  103859. /**
  103860. * @hidden Internal global position in the SPS.
  103861. */
  103862. _globalPosition: Vector3;
  103863. /**
  103864. * Creates a Solid Particle object.
  103865. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  103866. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  103867. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  103868. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  103869. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  103870. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  103871. * @param shapeId (integer) is the model shape identifier in the SPS.
  103872. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  103873. * @param sps defines the sps it is associated to
  103874. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  103875. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  103876. */
  103877. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  103878. /**
  103879. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  103880. * @param target the particle target
  103881. * @returns the current particle
  103882. */
  103883. copyToRef(target: SolidParticle): SolidParticle;
  103884. /**
  103885. * Legacy support, changed scale to scaling
  103886. */
  103887. get scale(): Vector3;
  103888. /**
  103889. * Legacy support, changed scale to scaling
  103890. */
  103891. set scale(scale: Vector3);
  103892. /**
  103893. * Legacy support, changed quaternion to rotationQuaternion
  103894. */
  103895. get quaternion(): Nullable<Quaternion>;
  103896. /**
  103897. * Legacy support, changed quaternion to rotationQuaternion
  103898. */
  103899. set quaternion(q: Nullable<Quaternion>);
  103900. /**
  103901. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  103902. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  103903. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  103904. * @returns true if it intersects
  103905. */
  103906. intersectsMesh(target: Mesh | SolidParticle): boolean;
  103907. /**
  103908. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  103909. * A particle is in the frustum if its bounding box intersects the frustum
  103910. * @param frustumPlanes defines the frustum to test
  103911. * @returns true if the particle is in the frustum planes
  103912. */
  103913. isInFrustum(frustumPlanes: Plane[]): boolean;
  103914. /**
  103915. * get the rotation matrix of the particle
  103916. * @hidden
  103917. */
  103918. getRotationMatrix(m: Matrix): void;
  103919. }
  103920. /**
  103921. * Represents the shape of the model used by one particle of a solid particle system.
  103922. * SPS internal tool, don't use it manually.
  103923. */
  103924. export class ModelShape {
  103925. /**
  103926. * The shape id
  103927. * @hidden
  103928. */
  103929. shapeID: number;
  103930. /**
  103931. * flat array of model positions (internal use)
  103932. * @hidden
  103933. */
  103934. _shape: Vector3[];
  103935. /**
  103936. * flat array of model UVs (internal use)
  103937. * @hidden
  103938. */
  103939. _shapeUV: number[];
  103940. /**
  103941. * color array of the model
  103942. * @hidden
  103943. */
  103944. _shapeColors: number[];
  103945. /**
  103946. * indices array of the model
  103947. * @hidden
  103948. */
  103949. _indices: number[];
  103950. /**
  103951. * normals array of the model
  103952. * @hidden
  103953. */
  103954. _normals: number[];
  103955. /**
  103956. * length of the shape in the model indices array (internal use)
  103957. * @hidden
  103958. */
  103959. _indicesLength: number;
  103960. /**
  103961. * Custom position function (internal use)
  103962. * @hidden
  103963. */
  103964. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  103965. /**
  103966. * Custom vertex function (internal use)
  103967. * @hidden
  103968. */
  103969. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  103970. /**
  103971. * Model material (internal use)
  103972. * @hidden
  103973. */
  103974. _material: Nullable<Material>;
  103975. /**
  103976. * 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.
  103977. * SPS internal tool, don't use it manually.
  103978. * @hidden
  103979. */
  103980. 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>);
  103981. }
  103982. /**
  103983. * Represents a Depth Sorted Particle in the solid particle system.
  103984. * @hidden
  103985. */
  103986. export class DepthSortedParticle {
  103987. /**
  103988. * Particle index
  103989. */
  103990. idx: number;
  103991. /**
  103992. * Index of the particle in the "indices" array
  103993. */
  103994. ind: number;
  103995. /**
  103996. * Length of the particle shape in the "indices" array
  103997. */
  103998. indicesLength: number;
  103999. /**
  104000. * Squared distance from the particle to the camera
  104001. */
  104002. sqDistance: number;
  104003. /**
  104004. * Material index when used with MultiMaterials
  104005. */
  104006. materialIndex: number;
  104007. /**
  104008. * Creates a new sorted particle
  104009. * @param materialIndex
  104010. */
  104011. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  104012. }
  104013. /**
  104014. * Represents a solid particle vertex
  104015. */
  104016. export class SolidParticleVertex {
  104017. /**
  104018. * Vertex position
  104019. */
  104020. position: Vector3;
  104021. /**
  104022. * Vertex color
  104023. */
  104024. color: Color4;
  104025. /**
  104026. * Vertex UV
  104027. */
  104028. uv: Vector2;
  104029. /**
  104030. * Creates a new solid particle vertex
  104031. */
  104032. constructor();
  104033. /** Vertex x coordinate */
  104034. get x(): number;
  104035. set x(val: number);
  104036. /** Vertex y coordinate */
  104037. get y(): number;
  104038. set y(val: number);
  104039. /** Vertex z coordinate */
  104040. get z(): number;
  104041. set z(val: number);
  104042. }
  104043. }
  104044. declare module BABYLON {
  104045. /**
  104046. * @hidden
  104047. */
  104048. export class _MeshCollisionData {
  104049. _checkCollisions: boolean;
  104050. _collisionMask: number;
  104051. _collisionGroup: number;
  104052. _surroundingMeshes: Nullable<AbstractMesh[]>;
  104053. _collider: Nullable<Collider>;
  104054. _oldPositionForCollisions: Vector3;
  104055. _diffPositionForCollisions: Vector3;
  104056. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  104057. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  104058. }
  104059. }
  104060. declare module BABYLON {
  104061. /** @hidden */
  104062. class _FacetDataStorage {
  104063. facetPositions: Vector3[];
  104064. facetNormals: Vector3[];
  104065. facetPartitioning: number[][];
  104066. facetNb: number;
  104067. partitioningSubdivisions: number;
  104068. partitioningBBoxRatio: number;
  104069. facetDataEnabled: boolean;
  104070. facetParameters: any;
  104071. bbSize: Vector3;
  104072. subDiv: {
  104073. max: number;
  104074. X: number;
  104075. Y: number;
  104076. Z: number;
  104077. };
  104078. facetDepthSort: boolean;
  104079. facetDepthSortEnabled: boolean;
  104080. depthSortedIndices: IndicesArray;
  104081. depthSortedFacets: {
  104082. ind: number;
  104083. sqDistance: number;
  104084. }[];
  104085. facetDepthSortFunction: (f1: {
  104086. ind: number;
  104087. sqDistance: number;
  104088. }, f2: {
  104089. ind: number;
  104090. sqDistance: number;
  104091. }) => number;
  104092. facetDepthSortFrom: Vector3;
  104093. facetDepthSortOrigin: Vector3;
  104094. invertedMatrix: Matrix;
  104095. }
  104096. /**
  104097. * @hidden
  104098. **/
  104099. class _InternalAbstractMeshDataInfo {
  104100. _hasVertexAlpha: boolean;
  104101. _useVertexColors: boolean;
  104102. _numBoneInfluencers: number;
  104103. _applyFog: boolean;
  104104. _receiveShadows: boolean;
  104105. _facetData: _FacetDataStorage;
  104106. _visibility: number;
  104107. _skeleton: Nullable<Skeleton>;
  104108. _layerMask: number;
  104109. _computeBonesUsingShaders: boolean;
  104110. _isActive: boolean;
  104111. _onlyForInstances: boolean;
  104112. _isActiveIntermediate: boolean;
  104113. _onlyForInstancesIntermediate: boolean;
  104114. _actAsRegularMesh: boolean;
  104115. }
  104116. /**
  104117. * Class used to store all common mesh properties
  104118. */
  104119. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  104120. /** No occlusion */
  104121. static OCCLUSION_TYPE_NONE: number;
  104122. /** Occlusion set to optimisitic */
  104123. static OCCLUSION_TYPE_OPTIMISTIC: number;
  104124. /** Occlusion set to strict */
  104125. static OCCLUSION_TYPE_STRICT: number;
  104126. /** Use an accurante occlusion algorithm */
  104127. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  104128. /** Use a conservative occlusion algorithm */
  104129. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  104130. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  104131. * Test order :
  104132. * Is the bounding sphere outside the frustum ?
  104133. * If not, are the bounding box vertices outside the frustum ?
  104134. * It not, then the cullable object is in the frustum.
  104135. */
  104136. static readonly CULLINGSTRATEGY_STANDARD: number;
  104137. /** Culling strategy : Bounding Sphere Only.
  104138. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  104139. * It's also less accurate than the standard because some not visible objects can still be selected.
  104140. * Test : is the bounding sphere outside the frustum ?
  104141. * If not, then the cullable object is in the frustum.
  104142. */
  104143. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  104144. /** Culling strategy : Optimistic Inclusion.
  104145. * This in an inclusion test first, then the standard exclusion test.
  104146. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  104147. * 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.
  104148. * Anyway, it's as accurate as the standard strategy.
  104149. * Test :
  104150. * Is the cullable object bounding sphere center in the frustum ?
  104151. * If not, apply the default culling strategy.
  104152. */
  104153. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  104154. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  104155. * This in an inclusion test first, then the bounding sphere only exclusion test.
  104156. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  104157. * 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.
  104158. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  104159. * Test :
  104160. * Is the cullable object bounding sphere center in the frustum ?
  104161. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  104162. */
  104163. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  104164. /**
  104165. * No billboard
  104166. */
  104167. static get BILLBOARDMODE_NONE(): number;
  104168. /** Billboard on X axis */
  104169. static get BILLBOARDMODE_X(): number;
  104170. /** Billboard on Y axis */
  104171. static get BILLBOARDMODE_Y(): number;
  104172. /** Billboard on Z axis */
  104173. static get BILLBOARDMODE_Z(): number;
  104174. /** Billboard on all axes */
  104175. static get BILLBOARDMODE_ALL(): number;
  104176. /** Billboard on using position instead of orientation */
  104177. static get BILLBOARDMODE_USE_POSITION(): number;
  104178. /** @hidden */
  104179. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  104180. /**
  104181. * The culling strategy to use to check whether the mesh must be rendered or not.
  104182. * This value can be changed at any time and will be used on the next render mesh selection.
  104183. * The possible values are :
  104184. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  104185. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  104186. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  104187. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  104188. * Please read each static variable documentation to get details about the culling process.
  104189. * */
  104190. cullingStrategy: number;
  104191. /**
  104192. * Gets the number of facets in the mesh
  104193. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104194. */
  104195. get facetNb(): number;
  104196. /**
  104197. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  104198. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104199. */
  104200. get partitioningSubdivisions(): number;
  104201. set partitioningSubdivisions(nb: number);
  104202. /**
  104203. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  104204. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  104205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  104206. */
  104207. get partitioningBBoxRatio(): number;
  104208. set partitioningBBoxRatio(ratio: number);
  104209. /**
  104210. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  104211. * Works only for updatable meshes.
  104212. * Doesn't work with multi-materials
  104213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104214. */
  104215. get mustDepthSortFacets(): boolean;
  104216. set mustDepthSortFacets(sort: boolean);
  104217. /**
  104218. * The location (Vector3) where the facet depth sort must be computed from.
  104219. * By default, the active camera position.
  104220. * Used only when facet depth sort is enabled
  104221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  104222. */
  104223. get facetDepthSortFrom(): Vector3;
  104224. set facetDepthSortFrom(location: Vector3);
  104225. /**
  104226. * gets a boolean indicating if facetData is enabled
  104227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  104228. */
  104229. get isFacetDataEnabled(): boolean;
  104230. /** @hidden */
  104231. _updateNonUniformScalingState(value: boolean): boolean;
  104232. /**
  104233. * An event triggered when this mesh collides with another one
  104234. */
  104235. onCollideObservable: Observable<AbstractMesh>;
  104236. /** Set a function to call when this mesh collides with another one */
  104237. set onCollide(callback: () => void);
  104238. /**
  104239. * An event triggered when the collision's position changes
  104240. */
  104241. onCollisionPositionChangeObservable: Observable<Vector3>;
  104242. /** Set a function to call when the collision's position changes */
  104243. set onCollisionPositionChange(callback: () => void);
  104244. /**
  104245. * An event triggered when material is changed
  104246. */
  104247. onMaterialChangedObservable: Observable<AbstractMesh>;
  104248. /**
  104249. * Gets or sets the orientation for POV movement & rotation
  104250. */
  104251. definedFacingForward: boolean;
  104252. /** @hidden */
  104253. _occlusionQuery: Nullable<WebGLQuery>;
  104254. /** @hidden */
  104255. _renderingGroup: Nullable<RenderingGroup>;
  104256. /**
  104257. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104258. */
  104259. get visibility(): number;
  104260. /**
  104261. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  104262. */
  104263. set visibility(value: number);
  104264. /** Gets or sets the alpha index used to sort transparent meshes
  104265. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  104266. */
  104267. alphaIndex: number;
  104268. /**
  104269. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  104270. */
  104271. isVisible: boolean;
  104272. /**
  104273. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104274. */
  104275. isPickable: boolean;
  104276. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  104277. showSubMeshesBoundingBox: boolean;
  104278. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  104279. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104280. */
  104281. isBlocker: boolean;
  104282. /**
  104283. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  104284. */
  104285. enablePointerMoveEvents: boolean;
  104286. /**
  104287. * Specifies the rendering group id for this mesh (0 by default)
  104288. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104289. */
  104290. renderingGroupId: number;
  104291. private _material;
  104292. /** Gets or sets current material */
  104293. get material(): Nullable<Material>;
  104294. set material(value: Nullable<Material>);
  104295. /**
  104296. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  104297. * @see http://doc.babylonjs.com/babylon101/shadows
  104298. */
  104299. get receiveShadows(): boolean;
  104300. set receiveShadows(value: boolean);
  104301. /** Defines color to use when rendering outline */
  104302. outlineColor: Color3;
  104303. /** Define width to use when rendering outline */
  104304. outlineWidth: number;
  104305. /** Defines color to use when rendering overlay */
  104306. overlayColor: Color3;
  104307. /** Defines alpha to use when rendering overlay */
  104308. overlayAlpha: number;
  104309. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  104310. get hasVertexAlpha(): boolean;
  104311. set hasVertexAlpha(value: boolean);
  104312. /** 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) */
  104313. get useVertexColors(): boolean;
  104314. set useVertexColors(value: boolean);
  104315. /**
  104316. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  104317. */
  104318. get computeBonesUsingShaders(): boolean;
  104319. set computeBonesUsingShaders(value: boolean);
  104320. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  104321. get numBoneInfluencers(): number;
  104322. set numBoneInfluencers(value: number);
  104323. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  104324. get applyFog(): boolean;
  104325. set applyFog(value: boolean);
  104326. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  104327. useOctreeForRenderingSelection: boolean;
  104328. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  104329. useOctreeForPicking: boolean;
  104330. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  104331. useOctreeForCollisions: boolean;
  104332. /**
  104333. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  104334. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  104335. */
  104336. get layerMask(): number;
  104337. set layerMask(value: number);
  104338. /**
  104339. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  104340. */
  104341. alwaysSelectAsActiveMesh: boolean;
  104342. /**
  104343. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  104344. */
  104345. doNotSyncBoundingInfo: boolean;
  104346. /**
  104347. * Gets or sets the current action manager
  104348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104349. */
  104350. actionManager: Nullable<AbstractActionManager>;
  104351. private _meshCollisionData;
  104352. /**
  104353. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  104354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104355. */
  104356. ellipsoid: Vector3;
  104357. /**
  104358. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  104359. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104360. */
  104361. ellipsoidOffset: Vector3;
  104362. /**
  104363. * Gets or sets a collision mask used to mask collisions (default is -1).
  104364. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104365. */
  104366. get collisionMask(): number;
  104367. set collisionMask(mask: number);
  104368. /**
  104369. * Gets or sets the current collision group mask (-1 by default).
  104370. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  104371. */
  104372. get collisionGroup(): number;
  104373. set collisionGroup(mask: number);
  104374. /**
  104375. * Gets or sets current surrounding meshes (null by default).
  104376. *
  104377. * By default collision detection is tested against every mesh in the scene.
  104378. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  104379. * meshes will be tested for the collision.
  104380. *
  104381. * Note: if set to an empty array no collision will happen when this mesh is moved.
  104382. */
  104383. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  104384. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  104385. /**
  104386. * Defines edge width used when edgesRenderer is enabled
  104387. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104388. */
  104389. edgesWidth: number;
  104390. /**
  104391. * Defines edge color used when edgesRenderer is enabled
  104392. * @see https://www.babylonjs-playground.com/#10OJSG#13
  104393. */
  104394. edgesColor: Color4;
  104395. /** @hidden */
  104396. _edgesRenderer: Nullable<IEdgesRenderer>;
  104397. /** @hidden */
  104398. _masterMesh: Nullable<AbstractMesh>;
  104399. /** @hidden */
  104400. _boundingInfo: Nullable<BoundingInfo>;
  104401. /** @hidden */
  104402. _renderId: number;
  104403. /**
  104404. * Gets or sets the list of subMeshes
  104405. * @see http://doc.babylonjs.com/how_to/multi_materials
  104406. */
  104407. subMeshes: SubMesh[];
  104408. /** @hidden */
  104409. _intersectionsInProgress: AbstractMesh[];
  104410. /** @hidden */
  104411. _unIndexed: boolean;
  104412. /** @hidden */
  104413. _lightSources: Light[];
  104414. /** Gets the list of lights affecting that mesh */
  104415. get lightSources(): Light[];
  104416. /** @hidden */
  104417. get _positions(): Nullable<Vector3[]>;
  104418. /** @hidden */
  104419. _waitingData: {
  104420. lods: Nullable<any>;
  104421. actions: Nullable<any>;
  104422. freezeWorldMatrix: Nullable<boolean>;
  104423. };
  104424. /** @hidden */
  104425. _bonesTransformMatrices: Nullable<Float32Array>;
  104426. /** @hidden */
  104427. _transformMatrixTexture: Nullable<RawTexture>;
  104428. /**
  104429. * Gets or sets a skeleton to apply skining transformations
  104430. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  104431. */
  104432. set skeleton(value: Nullable<Skeleton>);
  104433. get skeleton(): Nullable<Skeleton>;
  104434. /**
  104435. * An event triggered when the mesh is rebuilt.
  104436. */
  104437. onRebuildObservable: Observable<AbstractMesh>;
  104438. /**
  104439. * Creates a new AbstractMesh
  104440. * @param name defines the name of the mesh
  104441. * @param scene defines the hosting scene
  104442. */
  104443. constructor(name: string, scene?: Nullable<Scene>);
  104444. /**
  104445. * Returns the string "AbstractMesh"
  104446. * @returns "AbstractMesh"
  104447. */
  104448. getClassName(): string;
  104449. /**
  104450. * Gets a string representation of the current mesh
  104451. * @param fullDetails defines a boolean indicating if full details must be included
  104452. * @returns a string representation of the current mesh
  104453. */
  104454. toString(fullDetails?: boolean): string;
  104455. /**
  104456. * @hidden
  104457. */
  104458. protected _getEffectiveParent(): Nullable<Node>;
  104459. /** @hidden */
  104460. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  104461. /** @hidden */
  104462. _rebuild(): void;
  104463. /** @hidden */
  104464. _resyncLightSources(): void;
  104465. /** @hidden */
  104466. _resyncLightSource(light: Light): void;
  104467. /** @hidden */
  104468. _unBindEffect(): void;
  104469. /** @hidden */
  104470. _removeLightSource(light: Light, dispose: boolean): void;
  104471. private _markSubMeshesAsDirty;
  104472. /** @hidden */
  104473. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  104474. /** @hidden */
  104475. _markSubMeshesAsAttributesDirty(): void;
  104476. /** @hidden */
  104477. _markSubMeshesAsMiscDirty(): void;
  104478. /**
  104479. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  104480. */
  104481. get scaling(): Vector3;
  104482. set scaling(newScaling: Vector3);
  104483. /**
  104484. * Returns true if the mesh is blocked. Implemented by child classes
  104485. */
  104486. get isBlocked(): boolean;
  104487. /**
  104488. * Returns the mesh itself by default. Implemented by child classes
  104489. * @param camera defines the camera to use to pick the right LOD level
  104490. * @returns the currentAbstractMesh
  104491. */
  104492. getLOD(camera: Camera): Nullable<AbstractMesh>;
  104493. /**
  104494. * Returns 0 by default. Implemented by child classes
  104495. * @returns an integer
  104496. */
  104497. getTotalVertices(): number;
  104498. /**
  104499. * Returns a positive integer : the total number of indices in this mesh geometry.
  104500. * @returns the numner of indices or zero if the mesh has no geometry.
  104501. */
  104502. getTotalIndices(): number;
  104503. /**
  104504. * Returns null by default. Implemented by child classes
  104505. * @returns null
  104506. */
  104507. getIndices(): Nullable<IndicesArray>;
  104508. /**
  104509. * Returns the array of the requested vertex data kind. Implemented by child classes
  104510. * @param kind defines the vertex data kind to use
  104511. * @returns null
  104512. */
  104513. getVerticesData(kind: string): Nullable<FloatArray>;
  104514. /**
  104515. * Sets the vertex data of the mesh geometry for the requested `kind`.
  104516. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  104517. * Note that a new underlying VertexBuffer object is created each call.
  104518. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  104519. * @param kind defines vertex data kind:
  104520. * * VertexBuffer.PositionKind
  104521. * * VertexBuffer.UVKind
  104522. * * VertexBuffer.UV2Kind
  104523. * * VertexBuffer.UV3Kind
  104524. * * VertexBuffer.UV4Kind
  104525. * * VertexBuffer.UV5Kind
  104526. * * VertexBuffer.UV6Kind
  104527. * * VertexBuffer.ColorKind
  104528. * * VertexBuffer.MatricesIndicesKind
  104529. * * VertexBuffer.MatricesIndicesExtraKind
  104530. * * VertexBuffer.MatricesWeightsKind
  104531. * * VertexBuffer.MatricesWeightsExtraKind
  104532. * @param data defines the data source
  104533. * @param updatable defines if the data must be flagged as updatable (or static)
  104534. * @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
  104535. * @returns the current mesh
  104536. */
  104537. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  104538. /**
  104539. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  104540. * If the mesh has no geometry, it is simply returned as it is.
  104541. * @param kind defines vertex data kind:
  104542. * * VertexBuffer.PositionKind
  104543. * * VertexBuffer.UVKind
  104544. * * VertexBuffer.UV2Kind
  104545. * * VertexBuffer.UV3Kind
  104546. * * VertexBuffer.UV4Kind
  104547. * * VertexBuffer.UV5Kind
  104548. * * VertexBuffer.UV6Kind
  104549. * * VertexBuffer.ColorKind
  104550. * * VertexBuffer.MatricesIndicesKind
  104551. * * VertexBuffer.MatricesIndicesExtraKind
  104552. * * VertexBuffer.MatricesWeightsKind
  104553. * * VertexBuffer.MatricesWeightsExtraKind
  104554. * @param data defines the data source
  104555. * @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
  104556. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  104557. * @returns the current mesh
  104558. */
  104559. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  104560. /**
  104561. * Sets the mesh indices,
  104562. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  104563. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  104564. * @param totalVertices Defines the total number of vertices
  104565. * @returns the current mesh
  104566. */
  104567. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  104568. /**
  104569. * Gets a boolean indicating if specific vertex data is present
  104570. * @param kind defines the vertex data kind to use
  104571. * @returns true is data kind is present
  104572. */
  104573. isVerticesDataPresent(kind: string): boolean;
  104574. /**
  104575. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  104576. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  104577. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  104578. * @returns a BoundingInfo
  104579. */
  104580. getBoundingInfo(): BoundingInfo;
  104581. /**
  104582. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  104583. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  104584. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  104585. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  104586. * @returns the current mesh
  104587. */
  104588. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  104589. /**
  104590. * Overwrite the current bounding info
  104591. * @param boundingInfo defines the new bounding info
  104592. * @returns the current mesh
  104593. */
  104594. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  104595. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  104596. get useBones(): boolean;
  104597. /** @hidden */
  104598. _preActivate(): void;
  104599. /** @hidden */
  104600. _preActivateForIntermediateRendering(renderId: number): void;
  104601. /** @hidden */
  104602. _activate(renderId: number, intermediateRendering: boolean): boolean;
  104603. /** @hidden */
  104604. _postActivate(): void;
  104605. /** @hidden */
  104606. _freeze(): void;
  104607. /** @hidden */
  104608. _unFreeze(): void;
  104609. /**
  104610. * Gets the current world matrix
  104611. * @returns a Matrix
  104612. */
  104613. getWorldMatrix(): Matrix;
  104614. /** @hidden */
  104615. _getWorldMatrixDeterminant(): number;
  104616. /**
  104617. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  104618. */
  104619. get isAnInstance(): boolean;
  104620. /**
  104621. * Gets a boolean indicating if this mesh has instances
  104622. */
  104623. get hasInstances(): boolean;
  104624. /**
  104625. * Perform relative position change from the point of view of behind the front of the mesh.
  104626. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104627. * Supports definition of mesh facing forward or backward
  104628. * @param amountRight defines the distance on the right axis
  104629. * @param amountUp defines the distance on the up axis
  104630. * @param amountForward defines the distance on the forward axis
  104631. * @returns the current mesh
  104632. */
  104633. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  104634. /**
  104635. * Calculate relative position change from the point of view of behind the front of the mesh.
  104636. * This is performed taking into account the meshes current rotation, so you do not have to care.
  104637. * Supports definition of mesh facing forward or backward
  104638. * @param amountRight defines the distance on the right axis
  104639. * @param amountUp defines the distance on the up axis
  104640. * @param amountForward defines the distance on the forward axis
  104641. * @returns the new displacement vector
  104642. */
  104643. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  104644. /**
  104645. * Perform relative rotation change from the point of view of behind the front of the mesh.
  104646. * Supports definition of mesh facing forward or backward
  104647. * @param flipBack defines the flip
  104648. * @param twirlClockwise defines the twirl
  104649. * @param tiltRight defines the tilt
  104650. * @returns the current mesh
  104651. */
  104652. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  104653. /**
  104654. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  104655. * Supports definition of mesh facing forward or backward.
  104656. * @param flipBack defines the flip
  104657. * @param twirlClockwise defines the twirl
  104658. * @param tiltRight defines the tilt
  104659. * @returns the new rotation vector
  104660. */
  104661. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  104662. /**
  104663. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  104664. * This means the mesh underlying bounding box and sphere are recomputed.
  104665. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  104666. * @returns the current mesh
  104667. */
  104668. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  104669. /** @hidden */
  104670. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  104671. /** @hidden */
  104672. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  104673. /** @hidden */
  104674. _updateBoundingInfo(): AbstractMesh;
  104675. /** @hidden */
  104676. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  104677. /** @hidden */
  104678. protected _afterComputeWorldMatrix(): void;
  104679. /** @hidden */
  104680. get _effectiveMesh(): AbstractMesh;
  104681. /**
  104682. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  104683. * A mesh is in the frustum if its bounding box intersects the frustum
  104684. * @param frustumPlanes defines the frustum to test
  104685. * @returns true if the mesh is in the frustum planes
  104686. */
  104687. isInFrustum(frustumPlanes: Plane[]): boolean;
  104688. /**
  104689. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  104690. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  104691. * @param frustumPlanes defines the frustum to test
  104692. * @returns true if the mesh is completely in the frustum planes
  104693. */
  104694. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104695. /**
  104696. * True if the mesh intersects another mesh or a SolidParticle object
  104697. * @param mesh defines a target mesh or SolidParticle to test
  104698. * @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)
  104699. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  104700. * @returns true if there is an intersection
  104701. */
  104702. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  104703. /**
  104704. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  104705. * @param point defines the point to test
  104706. * @returns true if there is an intersection
  104707. */
  104708. intersectsPoint(point: Vector3): boolean;
  104709. /**
  104710. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  104711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104712. */
  104713. get checkCollisions(): boolean;
  104714. set checkCollisions(collisionEnabled: boolean);
  104715. /**
  104716. * Gets Collider object used to compute collisions (not physics)
  104717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104718. */
  104719. get collider(): Nullable<Collider>;
  104720. /**
  104721. * Move the mesh using collision engine
  104722. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104723. * @param displacement defines the requested displacement vector
  104724. * @returns the current mesh
  104725. */
  104726. moveWithCollisions(displacement: Vector3): AbstractMesh;
  104727. private _onCollisionPositionChange;
  104728. /** @hidden */
  104729. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  104730. /** @hidden */
  104731. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  104732. /** @hidden */
  104733. _checkCollision(collider: Collider): AbstractMesh;
  104734. /** @hidden */
  104735. _generatePointsArray(): boolean;
  104736. /**
  104737. * Checks if the passed Ray intersects with the mesh
  104738. * @param ray defines the ray to use
  104739. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  104740. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104741. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  104742. * @returns the picking info
  104743. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  104744. */
  104745. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  104746. /**
  104747. * Clones the current mesh
  104748. * @param name defines the mesh name
  104749. * @param newParent defines the new mesh parent
  104750. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  104751. * @returns the new mesh
  104752. */
  104753. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  104754. /**
  104755. * Disposes all the submeshes of the current meshnp
  104756. * @returns the current mesh
  104757. */
  104758. releaseSubMeshes(): AbstractMesh;
  104759. /**
  104760. * Releases resources associated with this abstract mesh.
  104761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  104762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  104763. */
  104764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  104765. /**
  104766. * Adds the passed mesh as a child to the current mesh
  104767. * @param mesh defines the child mesh
  104768. * @returns the current mesh
  104769. */
  104770. addChild(mesh: AbstractMesh): AbstractMesh;
  104771. /**
  104772. * Removes the passed mesh from the current mesh children list
  104773. * @param mesh defines the child mesh
  104774. * @returns the current mesh
  104775. */
  104776. removeChild(mesh: AbstractMesh): AbstractMesh;
  104777. /** @hidden */
  104778. private _initFacetData;
  104779. /**
  104780. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  104781. * This method can be called within the render loop.
  104782. * 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
  104783. * @returns the current mesh
  104784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104785. */
  104786. updateFacetData(): AbstractMesh;
  104787. /**
  104788. * Returns the facetLocalNormals array.
  104789. * The normals are expressed in the mesh local spac
  104790. * @returns an array of Vector3
  104791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104792. */
  104793. getFacetLocalNormals(): Vector3[];
  104794. /**
  104795. * Returns the facetLocalPositions array.
  104796. * The facet positions are expressed in the mesh local space
  104797. * @returns an array of Vector3
  104798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104799. */
  104800. getFacetLocalPositions(): Vector3[];
  104801. /**
  104802. * Returns the facetLocalPartioning array
  104803. * @returns an array of array of numbers
  104804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104805. */
  104806. getFacetLocalPartitioning(): number[][];
  104807. /**
  104808. * Returns the i-th facet position in the world system.
  104809. * This method allocates a new Vector3 per call
  104810. * @param i defines the facet index
  104811. * @returns a new Vector3
  104812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104813. */
  104814. getFacetPosition(i: number): Vector3;
  104815. /**
  104816. * Sets the reference Vector3 with the i-th facet position in the world system
  104817. * @param i defines the facet index
  104818. * @param ref defines the target vector
  104819. * @returns the current mesh
  104820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104821. */
  104822. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  104823. /**
  104824. * Returns the i-th facet normal in the world system.
  104825. * This method allocates a new Vector3 per call
  104826. * @param i defines the facet index
  104827. * @returns a new Vector3
  104828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104829. */
  104830. getFacetNormal(i: number): Vector3;
  104831. /**
  104832. * Sets the reference Vector3 with the i-th facet normal in the world system
  104833. * @param i defines the facet index
  104834. * @param ref defines the target vector
  104835. * @returns the current mesh
  104836. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104837. */
  104838. getFacetNormalToRef(i: number, ref: Vector3): this;
  104839. /**
  104840. * 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)
  104841. * @param x defines x coordinate
  104842. * @param y defines y coordinate
  104843. * @param z defines z coordinate
  104844. * @returns the array of facet indexes
  104845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104846. */
  104847. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  104848. /**
  104849. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  104850. * @param projected sets as the (x,y,z) world projection on the facet
  104851. * @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
  104852. * @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
  104853. * @param x defines x coordinate
  104854. * @param y defines y coordinate
  104855. * @param z defines z coordinate
  104856. * @returns the face index if found (or null instead)
  104857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104858. */
  104859. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  104860. /**
  104861. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  104862. * @param projected sets as the (x,y,z) local projection on the facet
  104863. * @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
  104864. * @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
  104865. * @param x defines x coordinate
  104866. * @param y defines y coordinate
  104867. * @param z defines z coordinate
  104868. * @returns the face index if found (or null instead)
  104869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104870. */
  104871. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  104872. /**
  104873. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  104874. * @returns the parameters
  104875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104876. */
  104877. getFacetDataParameters(): any;
  104878. /**
  104879. * Disables the feature FacetData and frees the related memory
  104880. * @returns the current mesh
  104881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  104882. */
  104883. disableFacetData(): AbstractMesh;
  104884. /**
  104885. * Updates the AbstractMesh indices array
  104886. * @param indices defines the data source
  104887. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  104888. * @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)
  104889. * @returns the current mesh
  104890. */
  104891. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  104892. /**
  104893. * Creates new normals data for the mesh
  104894. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  104895. * @returns the current mesh
  104896. */
  104897. createNormals(updatable: boolean): AbstractMesh;
  104898. /**
  104899. * Align the mesh with a normal
  104900. * @param normal defines the normal to use
  104901. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  104902. * @returns the current mesh
  104903. */
  104904. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  104905. /** @hidden */
  104906. _checkOcclusionQuery(): boolean;
  104907. /**
  104908. * Disables the mesh edge rendering mode
  104909. * @returns the currentAbstractMesh
  104910. */
  104911. disableEdgesRendering(): AbstractMesh;
  104912. /**
  104913. * Enables the edge rendering mode on the mesh.
  104914. * This mode makes the mesh edges visible
  104915. * @param epsilon defines the maximal distance between two angles to detect a face
  104916. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  104917. * @returns the currentAbstractMesh
  104918. * @see https://www.babylonjs-playground.com/#19O9TU#0
  104919. */
  104920. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  104921. }
  104922. }
  104923. declare module BABYLON {
  104924. /**
  104925. * Interface used to define ActionEvent
  104926. */
  104927. export interface IActionEvent {
  104928. /** The mesh or sprite that triggered the action */
  104929. source: any;
  104930. /** The X mouse cursor position at the time of the event */
  104931. pointerX: number;
  104932. /** The Y mouse cursor position at the time of the event */
  104933. pointerY: number;
  104934. /** The mesh that is currently pointed at (can be null) */
  104935. meshUnderPointer: Nullable<AbstractMesh>;
  104936. /** the original (browser) event that triggered the ActionEvent */
  104937. sourceEvent?: any;
  104938. /** additional data for the event */
  104939. additionalData?: any;
  104940. }
  104941. /**
  104942. * ActionEvent is the event being sent when an action is triggered.
  104943. */
  104944. export class ActionEvent implements IActionEvent {
  104945. /** The mesh or sprite that triggered the action */
  104946. source: any;
  104947. /** The X mouse cursor position at the time of the event */
  104948. pointerX: number;
  104949. /** The Y mouse cursor position at the time of the event */
  104950. pointerY: number;
  104951. /** The mesh that is currently pointed at (can be null) */
  104952. meshUnderPointer: Nullable<AbstractMesh>;
  104953. /** the original (browser) event that triggered the ActionEvent */
  104954. sourceEvent?: any;
  104955. /** additional data for the event */
  104956. additionalData?: any;
  104957. /**
  104958. * Creates a new ActionEvent
  104959. * @param source The mesh or sprite that triggered the action
  104960. * @param pointerX The X mouse cursor position at the time of the event
  104961. * @param pointerY The Y mouse cursor position at the time of the event
  104962. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  104963. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  104964. * @param additionalData additional data for the event
  104965. */
  104966. constructor(
  104967. /** The mesh or sprite that triggered the action */
  104968. source: any,
  104969. /** The X mouse cursor position at the time of the event */
  104970. pointerX: number,
  104971. /** The Y mouse cursor position at the time of the event */
  104972. pointerY: number,
  104973. /** The mesh that is currently pointed at (can be null) */
  104974. meshUnderPointer: Nullable<AbstractMesh>,
  104975. /** the original (browser) event that triggered the ActionEvent */
  104976. sourceEvent?: any,
  104977. /** additional data for the event */
  104978. additionalData?: any);
  104979. /**
  104980. * Helper function to auto-create an ActionEvent from a source mesh.
  104981. * @param source The source mesh that triggered the event
  104982. * @param evt The original (browser) event
  104983. * @param additionalData additional data for the event
  104984. * @returns the new ActionEvent
  104985. */
  104986. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  104987. /**
  104988. * Helper function to auto-create an ActionEvent from a source sprite
  104989. * @param source The source sprite that triggered the event
  104990. * @param scene Scene associated with the sprite
  104991. * @param evt The original (browser) event
  104992. * @param additionalData additional data for the event
  104993. * @returns the new ActionEvent
  104994. */
  104995. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  104996. /**
  104997. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  104998. * @param scene the scene where the event occurred
  104999. * @param evt The original (browser) event
  105000. * @returns the new ActionEvent
  105001. */
  105002. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  105003. /**
  105004. * Helper function to auto-create an ActionEvent from a primitive
  105005. * @param prim defines the target primitive
  105006. * @param pointerPos defines the pointer position
  105007. * @param evt The original (browser) event
  105008. * @param additionalData additional data for the event
  105009. * @returns the new ActionEvent
  105010. */
  105011. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  105012. }
  105013. }
  105014. declare module BABYLON {
  105015. /**
  105016. * Abstract class used to decouple action Manager from scene and meshes.
  105017. * Do not instantiate.
  105018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105019. */
  105020. export abstract class AbstractActionManager implements IDisposable {
  105021. /** Gets the list of active triggers */
  105022. static Triggers: {
  105023. [key: string]: number;
  105024. };
  105025. /** Gets the cursor to use when hovering items */
  105026. hoverCursor: string;
  105027. /** Gets the list of actions */
  105028. actions: IAction[];
  105029. /**
  105030. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  105031. */
  105032. isRecursive: boolean;
  105033. /**
  105034. * Releases all associated resources
  105035. */
  105036. abstract dispose(): void;
  105037. /**
  105038. * Does this action manager has pointer triggers
  105039. */
  105040. abstract get hasPointerTriggers(): boolean;
  105041. /**
  105042. * Does this action manager has pick triggers
  105043. */
  105044. abstract get hasPickTriggers(): boolean;
  105045. /**
  105046. * Process a specific trigger
  105047. * @param trigger defines the trigger to process
  105048. * @param evt defines the event details to be processed
  105049. */
  105050. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  105051. /**
  105052. * Does this action manager handles actions of any of the given triggers
  105053. * @param triggers defines the triggers to be tested
  105054. * @return a boolean indicating whether one (or more) of the triggers is handled
  105055. */
  105056. abstract hasSpecificTriggers(triggers: number[]): boolean;
  105057. /**
  105058. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  105059. * speed.
  105060. * @param triggerA defines the trigger to be tested
  105061. * @param triggerB defines the trigger to be tested
  105062. * @return a boolean indicating whether one (or more) of the triggers is handled
  105063. */
  105064. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  105065. /**
  105066. * Does this action manager handles actions of a given trigger
  105067. * @param trigger defines the trigger to be tested
  105068. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  105069. * @return whether the trigger is handled
  105070. */
  105071. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  105072. /**
  105073. * Serialize this manager to a JSON object
  105074. * @param name defines the property name to store this manager
  105075. * @returns a JSON representation of this manager
  105076. */
  105077. abstract serialize(name: string): any;
  105078. /**
  105079. * Registers an action to this action manager
  105080. * @param action defines the action to be registered
  105081. * @return the action amended (prepared) after registration
  105082. */
  105083. abstract registerAction(action: IAction): Nullable<IAction>;
  105084. /**
  105085. * Unregisters an action to this action manager
  105086. * @param action defines the action to be unregistered
  105087. * @return a boolean indicating whether the action has been unregistered
  105088. */
  105089. abstract unregisterAction(action: IAction): Boolean;
  105090. /**
  105091. * Does exist one action manager with at least one trigger
  105092. **/
  105093. static get HasTriggers(): boolean;
  105094. /**
  105095. * Does exist one action manager with at least one pick trigger
  105096. **/
  105097. static get HasPickTriggers(): boolean;
  105098. /**
  105099. * Does exist one action manager that handles actions of a given trigger
  105100. * @param trigger defines the trigger to be tested
  105101. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  105102. **/
  105103. static HasSpecificTrigger(trigger: number): boolean;
  105104. }
  105105. }
  105106. declare module BABYLON {
  105107. /**
  105108. * Defines how a node can be built from a string name.
  105109. */
  105110. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  105111. /**
  105112. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  105113. */
  105114. export class Node implements IBehaviorAware<Node> {
  105115. /** @hidden */
  105116. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  105117. private static _NodeConstructors;
  105118. /**
  105119. * Add a new node constructor
  105120. * @param type defines the type name of the node to construct
  105121. * @param constructorFunc defines the constructor function
  105122. */
  105123. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  105124. /**
  105125. * Returns a node constructor based on type name
  105126. * @param type defines the type name
  105127. * @param name defines the new node name
  105128. * @param scene defines the hosting scene
  105129. * @param options defines optional options to transmit to constructors
  105130. * @returns the new constructor or null
  105131. */
  105132. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  105133. /**
  105134. * Gets or sets the name of the node
  105135. */
  105136. name: string;
  105137. /**
  105138. * Gets or sets the id of the node
  105139. */
  105140. id: string;
  105141. /**
  105142. * Gets or sets the unique id of the node
  105143. */
  105144. uniqueId: number;
  105145. /**
  105146. * Gets or sets a string used to store user defined state for the node
  105147. */
  105148. state: string;
  105149. /**
  105150. * Gets or sets an object used to store user defined information for the node
  105151. */
  105152. metadata: any;
  105153. /**
  105154. * For internal use only. Please do not use.
  105155. */
  105156. reservedDataStore: any;
  105157. /**
  105158. * List of inspectable custom properties (used by the Inspector)
  105159. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105160. */
  105161. inspectableCustomProperties: IInspectable[];
  105162. private _doNotSerialize;
  105163. /**
  105164. * Gets or sets a boolean used to define if the node must be serialized
  105165. */
  105166. get doNotSerialize(): boolean;
  105167. set doNotSerialize(value: boolean);
  105168. /** @hidden */
  105169. _isDisposed: boolean;
  105170. /**
  105171. * Gets a list of Animations associated with the node
  105172. */
  105173. animations: Animation[];
  105174. protected _ranges: {
  105175. [name: string]: Nullable<AnimationRange>;
  105176. };
  105177. /**
  105178. * Callback raised when the node is ready to be used
  105179. */
  105180. onReady: Nullable<(node: Node) => void>;
  105181. private _isEnabled;
  105182. private _isParentEnabled;
  105183. private _isReady;
  105184. /** @hidden */
  105185. _currentRenderId: number;
  105186. private _parentUpdateId;
  105187. /** @hidden */
  105188. _childUpdateId: number;
  105189. /** @hidden */
  105190. _waitingParentId: Nullable<string>;
  105191. /** @hidden */
  105192. _scene: Scene;
  105193. /** @hidden */
  105194. _cache: any;
  105195. private _parentNode;
  105196. private _children;
  105197. /** @hidden */
  105198. _worldMatrix: Matrix;
  105199. /** @hidden */
  105200. _worldMatrixDeterminant: number;
  105201. /** @hidden */
  105202. _worldMatrixDeterminantIsDirty: boolean;
  105203. /** @hidden */
  105204. private _sceneRootNodesIndex;
  105205. /**
  105206. * Gets a boolean indicating if the node has been disposed
  105207. * @returns true if the node was disposed
  105208. */
  105209. isDisposed(): boolean;
  105210. /**
  105211. * Gets or sets the parent of the node (without keeping the current position in the scene)
  105212. * @see https://doc.babylonjs.com/how_to/parenting
  105213. */
  105214. set parent(parent: Nullable<Node>);
  105215. get parent(): Nullable<Node>;
  105216. /** @hidden */
  105217. _addToSceneRootNodes(): void;
  105218. /** @hidden */
  105219. _removeFromSceneRootNodes(): void;
  105220. private _animationPropertiesOverride;
  105221. /**
  105222. * Gets or sets the animation properties override
  105223. */
  105224. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105225. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105226. /**
  105227. * Gets a string idenfifying the name of the class
  105228. * @returns "Node" string
  105229. */
  105230. getClassName(): string;
  105231. /** @hidden */
  105232. readonly _isNode: boolean;
  105233. /**
  105234. * An event triggered when the mesh is disposed
  105235. */
  105236. onDisposeObservable: Observable<Node>;
  105237. private _onDisposeObserver;
  105238. /**
  105239. * Sets a callback that will be raised when the node will be disposed
  105240. */
  105241. set onDispose(callback: () => void);
  105242. /**
  105243. * Creates a new Node
  105244. * @param name the name and id to be given to this node
  105245. * @param scene the scene this node will be added to
  105246. */
  105247. constructor(name: string, scene?: Nullable<Scene>);
  105248. /**
  105249. * Gets the scene of the node
  105250. * @returns a scene
  105251. */
  105252. getScene(): Scene;
  105253. /**
  105254. * Gets the engine of the node
  105255. * @returns a Engine
  105256. */
  105257. getEngine(): Engine;
  105258. private _behaviors;
  105259. /**
  105260. * Attach a behavior to the node
  105261. * @see http://doc.babylonjs.com/features/behaviour
  105262. * @param behavior defines the behavior to attach
  105263. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  105264. * @returns the current Node
  105265. */
  105266. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  105267. /**
  105268. * Remove an attached behavior
  105269. * @see http://doc.babylonjs.com/features/behaviour
  105270. * @param behavior defines the behavior to attach
  105271. * @returns the current Node
  105272. */
  105273. removeBehavior(behavior: Behavior<Node>): Node;
  105274. /**
  105275. * Gets the list of attached behaviors
  105276. * @see http://doc.babylonjs.com/features/behaviour
  105277. */
  105278. get behaviors(): Behavior<Node>[];
  105279. /**
  105280. * Gets an attached behavior by name
  105281. * @param name defines the name of the behavior to look for
  105282. * @see http://doc.babylonjs.com/features/behaviour
  105283. * @returns null if behavior was not found else the requested behavior
  105284. */
  105285. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  105286. /**
  105287. * Returns the latest update of the World matrix
  105288. * @returns a Matrix
  105289. */
  105290. getWorldMatrix(): Matrix;
  105291. /** @hidden */
  105292. _getWorldMatrixDeterminant(): number;
  105293. /**
  105294. * Returns directly the latest state of the mesh World matrix.
  105295. * A Matrix is returned.
  105296. */
  105297. get worldMatrixFromCache(): Matrix;
  105298. /** @hidden */
  105299. _initCache(): void;
  105300. /** @hidden */
  105301. updateCache(force?: boolean): void;
  105302. /** @hidden */
  105303. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  105304. /** @hidden */
  105305. _updateCache(ignoreParentClass?: boolean): void;
  105306. /** @hidden */
  105307. _isSynchronized(): boolean;
  105308. /** @hidden */
  105309. _markSyncedWithParent(): void;
  105310. /** @hidden */
  105311. isSynchronizedWithParent(): boolean;
  105312. /** @hidden */
  105313. isSynchronized(): boolean;
  105314. /**
  105315. * Is this node ready to be used/rendered
  105316. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105317. * @return true if the node is ready
  105318. */
  105319. isReady(completeCheck?: boolean): boolean;
  105320. /**
  105321. * Is this node enabled?
  105322. * 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
  105323. * @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
  105324. * @return whether this node (and its parent) is enabled
  105325. */
  105326. isEnabled(checkAncestors?: boolean): boolean;
  105327. /** @hidden */
  105328. protected _syncParentEnabledState(): void;
  105329. /**
  105330. * Set the enabled state of this node
  105331. * @param value defines the new enabled state
  105332. */
  105333. setEnabled(value: boolean): void;
  105334. /**
  105335. * Is this node a descendant of the given node?
  105336. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  105337. * @param ancestor defines the parent node to inspect
  105338. * @returns a boolean indicating if this node is a descendant of the given node
  105339. */
  105340. isDescendantOf(ancestor: Node): boolean;
  105341. /** @hidden */
  105342. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  105343. /**
  105344. * Will return all nodes that have this node as ascendant
  105345. * @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
  105346. * @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
  105347. * @return all children nodes of all types
  105348. */
  105349. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  105350. /**
  105351. * Get all child-meshes of this node
  105352. * @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)
  105353. * @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
  105354. * @returns an array of AbstractMesh
  105355. */
  105356. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  105357. /**
  105358. * Get all direct children of this node
  105359. * @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
  105360. * @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)
  105361. * @returns an array of Node
  105362. */
  105363. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  105364. /** @hidden */
  105365. _setReady(state: boolean): void;
  105366. /**
  105367. * Get an animation by name
  105368. * @param name defines the name of the animation to look for
  105369. * @returns null if not found else the requested animation
  105370. */
  105371. getAnimationByName(name: string): Nullable<Animation>;
  105372. /**
  105373. * Creates an animation range for this node
  105374. * @param name defines the name of the range
  105375. * @param from defines the starting key
  105376. * @param to defines the end key
  105377. */
  105378. createAnimationRange(name: string, from: number, to: number): void;
  105379. /**
  105380. * Delete a specific animation range
  105381. * @param name defines the name of the range to delete
  105382. * @param deleteFrames defines if animation frames from the range must be deleted as well
  105383. */
  105384. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  105385. /**
  105386. * Get an animation range by name
  105387. * @param name defines the name of the animation range to look for
  105388. * @returns null if not found else the requested animation range
  105389. */
  105390. getAnimationRange(name: string): Nullable<AnimationRange>;
  105391. /**
  105392. * Gets the list of all animation ranges defined on this node
  105393. * @returns an array
  105394. */
  105395. getAnimationRanges(): Nullable<AnimationRange>[];
  105396. /**
  105397. * Will start the animation sequence
  105398. * @param name defines the range frames for animation sequence
  105399. * @param loop defines if the animation should loop (false by default)
  105400. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  105401. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  105402. * @returns the object created for this animation. If range does not exist, it will return null
  105403. */
  105404. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  105405. /**
  105406. * Serialize animation ranges into a JSON compatible object
  105407. * @returns serialization object
  105408. */
  105409. serializeAnimationRanges(): any;
  105410. /**
  105411. * Computes the world matrix of the node
  105412. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  105413. * @returns the world matrix
  105414. */
  105415. computeWorldMatrix(force?: boolean): Matrix;
  105416. /**
  105417. * Releases resources associated with this node.
  105418. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105419. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105420. */
  105421. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105422. /**
  105423. * Parse animation range data from a serialization object and store them into a given node
  105424. * @param node defines where to store the animation ranges
  105425. * @param parsedNode defines the serialization object to read data from
  105426. * @param scene defines the hosting scene
  105427. */
  105428. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  105429. /**
  105430. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  105431. * @param includeDescendants Include bounding info from descendants as well (true by default)
  105432. * @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
  105433. * @returns the new bounding vectors
  105434. */
  105435. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  105436. min: Vector3;
  105437. max: Vector3;
  105438. };
  105439. }
  105440. }
  105441. declare module BABYLON {
  105442. /**
  105443. * @hidden
  105444. */
  105445. export class _IAnimationState {
  105446. key: number;
  105447. repeatCount: number;
  105448. workValue?: any;
  105449. loopMode?: number;
  105450. offsetValue?: any;
  105451. highLimitValue?: any;
  105452. }
  105453. /**
  105454. * Class used to store any kind of animation
  105455. */
  105456. export class Animation {
  105457. /**Name of the animation */
  105458. name: string;
  105459. /**Property to animate */
  105460. targetProperty: string;
  105461. /**The frames per second of the animation */
  105462. framePerSecond: number;
  105463. /**The data type of the animation */
  105464. dataType: number;
  105465. /**The loop mode of the animation */
  105466. loopMode?: number | undefined;
  105467. /**Specifies if blending should be enabled */
  105468. enableBlending?: boolean | undefined;
  105469. /**
  105470. * Use matrix interpolation instead of using direct key value when animating matrices
  105471. */
  105472. static AllowMatricesInterpolation: boolean;
  105473. /**
  105474. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  105475. */
  105476. static AllowMatrixDecomposeForInterpolation: boolean;
  105477. /**
  105478. * Stores the key frames of the animation
  105479. */
  105480. private _keys;
  105481. /**
  105482. * Stores the easing function of the animation
  105483. */
  105484. private _easingFunction;
  105485. /**
  105486. * @hidden Internal use only
  105487. */
  105488. _runtimeAnimations: RuntimeAnimation[];
  105489. /**
  105490. * The set of event that will be linked to this animation
  105491. */
  105492. private _events;
  105493. /**
  105494. * Stores an array of target property paths
  105495. */
  105496. targetPropertyPath: string[];
  105497. /**
  105498. * Stores the blending speed of the animation
  105499. */
  105500. blendingSpeed: number;
  105501. /**
  105502. * Stores the animation ranges for the animation
  105503. */
  105504. private _ranges;
  105505. /**
  105506. * @hidden Internal use
  105507. */
  105508. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  105509. /**
  105510. * Sets up an animation
  105511. * @param property The property to animate
  105512. * @param animationType The animation type to apply
  105513. * @param framePerSecond The frames per second of the animation
  105514. * @param easingFunction The easing function used in the animation
  105515. * @returns The created animation
  105516. */
  105517. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  105518. /**
  105519. * Create and start an animation on a node
  105520. * @param name defines the name of the global animation that will be run on all nodes
  105521. * @param node defines the root node where the animation will take place
  105522. * @param targetProperty defines property to animate
  105523. * @param framePerSecond defines the number of frame per second yo use
  105524. * @param totalFrame defines the number of frames in total
  105525. * @param from defines the initial value
  105526. * @param to defines the final value
  105527. * @param loopMode defines which loop mode you want to use (off by default)
  105528. * @param easingFunction defines the easing function to use (linear by default)
  105529. * @param onAnimationEnd defines the callback to call when animation end
  105530. * @returns the animatable created for this animation
  105531. */
  105532. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105533. /**
  105534. * Create and start an animation on a node and its descendants
  105535. * @param name defines the name of the global animation that will be run on all nodes
  105536. * @param node defines the root node where the animation will take place
  105537. * @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
  105538. * @param targetProperty defines property to animate
  105539. * @param framePerSecond defines the number of frame per second to use
  105540. * @param totalFrame defines the number of frames in total
  105541. * @param from defines the initial value
  105542. * @param to defines the final value
  105543. * @param loopMode defines which loop mode you want to use (off by default)
  105544. * @param easingFunction defines the easing function to use (linear by default)
  105545. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  105546. * @returns the list of animatables created for all nodes
  105547. * @example https://www.babylonjs-playground.com/#MH0VLI
  105548. */
  105549. 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[]>;
  105550. /**
  105551. * Creates a new animation, merges it with the existing animations and starts it
  105552. * @param name Name of the animation
  105553. * @param node Node which contains the scene that begins the animations
  105554. * @param targetProperty Specifies which property to animate
  105555. * @param framePerSecond The frames per second of the animation
  105556. * @param totalFrame The total number of frames
  105557. * @param from The frame at the beginning of the animation
  105558. * @param to The frame at the end of the animation
  105559. * @param loopMode Specifies the loop mode of the animation
  105560. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  105561. * @param onAnimationEnd Callback to run once the animation is complete
  105562. * @returns Nullable animation
  105563. */
  105564. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  105565. /**
  105566. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  105567. * @param sourceAnimation defines the Animation containing keyframes to convert
  105568. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  105569. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  105570. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  105571. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  105572. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  105573. */
  105574. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  105575. /**
  105576. * Transition property of an host to the target Value
  105577. * @param property The property to transition
  105578. * @param targetValue The target Value of the property
  105579. * @param host The object where the property to animate belongs
  105580. * @param scene Scene used to run the animation
  105581. * @param frameRate Framerate (in frame/s) to use
  105582. * @param transition The transition type we want to use
  105583. * @param duration The duration of the animation, in milliseconds
  105584. * @param onAnimationEnd Callback trigger at the end of the animation
  105585. * @returns Nullable animation
  105586. */
  105587. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  105588. /**
  105589. * Return the array of runtime animations currently using this animation
  105590. */
  105591. get runtimeAnimations(): RuntimeAnimation[];
  105592. /**
  105593. * Specifies if any of the runtime animations are currently running
  105594. */
  105595. get hasRunningRuntimeAnimations(): boolean;
  105596. /**
  105597. * Initializes the animation
  105598. * @param name Name of the animation
  105599. * @param targetProperty Property to animate
  105600. * @param framePerSecond The frames per second of the animation
  105601. * @param dataType The data type of the animation
  105602. * @param loopMode The loop mode of the animation
  105603. * @param enableBlending Specifies if blending should be enabled
  105604. */
  105605. constructor(
  105606. /**Name of the animation */
  105607. name: string,
  105608. /**Property to animate */
  105609. targetProperty: string,
  105610. /**The frames per second of the animation */
  105611. framePerSecond: number,
  105612. /**The data type of the animation */
  105613. dataType: number,
  105614. /**The loop mode of the animation */
  105615. loopMode?: number | undefined,
  105616. /**Specifies if blending should be enabled */
  105617. enableBlending?: boolean | undefined);
  105618. /**
  105619. * Converts the animation to a string
  105620. * @param fullDetails support for multiple levels of logging within scene loading
  105621. * @returns String form of the animation
  105622. */
  105623. toString(fullDetails?: boolean): string;
  105624. /**
  105625. * Add an event to this animation
  105626. * @param event Event to add
  105627. */
  105628. addEvent(event: AnimationEvent): void;
  105629. /**
  105630. * Remove all events found at the given frame
  105631. * @param frame The frame to remove events from
  105632. */
  105633. removeEvents(frame: number): void;
  105634. /**
  105635. * Retrieves all the events from the animation
  105636. * @returns Events from the animation
  105637. */
  105638. getEvents(): AnimationEvent[];
  105639. /**
  105640. * Creates an animation range
  105641. * @param name Name of the animation range
  105642. * @param from Starting frame of the animation range
  105643. * @param to Ending frame of the animation
  105644. */
  105645. createRange(name: string, from: number, to: number): void;
  105646. /**
  105647. * Deletes an animation range by name
  105648. * @param name Name of the animation range to delete
  105649. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  105650. */
  105651. deleteRange(name: string, deleteFrames?: boolean): void;
  105652. /**
  105653. * Gets the animation range by name, or null if not defined
  105654. * @param name Name of the animation range
  105655. * @returns Nullable animation range
  105656. */
  105657. getRange(name: string): Nullable<AnimationRange>;
  105658. /**
  105659. * Gets the key frames from the animation
  105660. * @returns The key frames of the animation
  105661. */
  105662. getKeys(): Array<IAnimationKey>;
  105663. /**
  105664. * Gets the highest frame rate of the animation
  105665. * @returns Highest frame rate of the animation
  105666. */
  105667. getHighestFrame(): number;
  105668. /**
  105669. * Gets the easing function of the animation
  105670. * @returns Easing function of the animation
  105671. */
  105672. getEasingFunction(): IEasingFunction;
  105673. /**
  105674. * Sets the easing function of the animation
  105675. * @param easingFunction A custom mathematical formula for animation
  105676. */
  105677. setEasingFunction(easingFunction: EasingFunction): void;
  105678. /**
  105679. * Interpolates a scalar linearly
  105680. * @param startValue Start value of the animation curve
  105681. * @param endValue End value of the animation curve
  105682. * @param gradient Scalar amount to interpolate
  105683. * @returns Interpolated scalar value
  105684. */
  105685. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  105686. /**
  105687. * Interpolates a scalar cubically
  105688. * @param startValue Start value of the animation curve
  105689. * @param outTangent End tangent of the animation
  105690. * @param endValue End value of the animation curve
  105691. * @param inTangent Start tangent of the animation curve
  105692. * @param gradient Scalar amount to interpolate
  105693. * @returns Interpolated scalar value
  105694. */
  105695. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  105696. /**
  105697. * Interpolates a quaternion using a spherical linear interpolation
  105698. * @param startValue Start value of the animation curve
  105699. * @param endValue End value of the animation curve
  105700. * @param gradient Scalar amount to interpolate
  105701. * @returns Interpolated quaternion value
  105702. */
  105703. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  105704. /**
  105705. * Interpolates a quaternion cubically
  105706. * @param startValue Start value of the animation curve
  105707. * @param outTangent End tangent of the animation curve
  105708. * @param endValue End value of the animation curve
  105709. * @param inTangent Start tangent of the animation curve
  105710. * @param gradient Scalar amount to interpolate
  105711. * @returns Interpolated quaternion value
  105712. */
  105713. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  105714. /**
  105715. * Interpolates a Vector3 linearl
  105716. * @param startValue Start value of the animation curve
  105717. * @param endValue End value of the animation curve
  105718. * @param gradient Scalar amount to interpolate
  105719. * @returns Interpolated scalar value
  105720. */
  105721. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  105722. /**
  105723. * Interpolates a Vector3 cubically
  105724. * @param startValue Start value of the animation curve
  105725. * @param outTangent End tangent of the animation
  105726. * @param endValue End value of the animation curve
  105727. * @param inTangent Start tangent of the animation curve
  105728. * @param gradient Scalar amount to interpolate
  105729. * @returns InterpolatedVector3 value
  105730. */
  105731. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  105732. /**
  105733. * Interpolates a Vector2 linearly
  105734. * @param startValue Start value of the animation curve
  105735. * @param endValue End value of the animation curve
  105736. * @param gradient Scalar amount to interpolate
  105737. * @returns Interpolated Vector2 value
  105738. */
  105739. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  105740. /**
  105741. * Interpolates a Vector2 cubically
  105742. * @param startValue Start value of the animation curve
  105743. * @param outTangent End tangent of the animation
  105744. * @param endValue End value of the animation curve
  105745. * @param inTangent Start tangent of the animation curve
  105746. * @param gradient Scalar amount to interpolate
  105747. * @returns Interpolated Vector2 value
  105748. */
  105749. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  105750. /**
  105751. * Interpolates a size linearly
  105752. * @param startValue Start value of the animation curve
  105753. * @param endValue End value of the animation curve
  105754. * @param gradient Scalar amount to interpolate
  105755. * @returns Interpolated Size value
  105756. */
  105757. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  105758. /**
  105759. * Interpolates a Color3 linearly
  105760. * @param startValue Start value of the animation curve
  105761. * @param endValue End value of the animation curve
  105762. * @param gradient Scalar amount to interpolate
  105763. * @returns Interpolated Color3 value
  105764. */
  105765. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  105766. /**
  105767. * Interpolates a Color4 linearly
  105768. * @param startValue Start value of the animation curve
  105769. * @param endValue End value of the animation curve
  105770. * @param gradient Scalar amount to interpolate
  105771. * @returns Interpolated Color3 value
  105772. */
  105773. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  105774. /**
  105775. * @hidden Internal use only
  105776. */
  105777. _getKeyValue(value: any): any;
  105778. /**
  105779. * @hidden Internal use only
  105780. */
  105781. _interpolate(currentFrame: number, state: _IAnimationState): any;
  105782. /**
  105783. * Defines the function to use to interpolate matrices
  105784. * @param startValue defines the start matrix
  105785. * @param endValue defines the end matrix
  105786. * @param gradient defines the gradient between both matrices
  105787. * @param result defines an optional target matrix where to store the interpolation
  105788. * @returns the interpolated matrix
  105789. */
  105790. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  105791. /**
  105792. * Makes a copy of the animation
  105793. * @returns Cloned animation
  105794. */
  105795. clone(): Animation;
  105796. /**
  105797. * Sets the key frames of the animation
  105798. * @param values The animation key frames to set
  105799. */
  105800. setKeys(values: Array<IAnimationKey>): void;
  105801. /**
  105802. * Serializes the animation to an object
  105803. * @returns Serialized object
  105804. */
  105805. serialize(): any;
  105806. /**
  105807. * Float animation type
  105808. */
  105809. static readonly ANIMATIONTYPE_FLOAT: number;
  105810. /**
  105811. * Vector3 animation type
  105812. */
  105813. static readonly ANIMATIONTYPE_VECTOR3: number;
  105814. /**
  105815. * Quaternion animation type
  105816. */
  105817. static readonly ANIMATIONTYPE_QUATERNION: number;
  105818. /**
  105819. * Matrix animation type
  105820. */
  105821. static readonly ANIMATIONTYPE_MATRIX: number;
  105822. /**
  105823. * Color3 animation type
  105824. */
  105825. static readonly ANIMATIONTYPE_COLOR3: number;
  105826. /**
  105827. * Color3 animation type
  105828. */
  105829. static readonly ANIMATIONTYPE_COLOR4: number;
  105830. /**
  105831. * Vector2 animation type
  105832. */
  105833. static readonly ANIMATIONTYPE_VECTOR2: number;
  105834. /**
  105835. * Size animation type
  105836. */
  105837. static readonly ANIMATIONTYPE_SIZE: number;
  105838. /**
  105839. * Relative Loop Mode
  105840. */
  105841. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  105842. /**
  105843. * Cycle Loop Mode
  105844. */
  105845. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  105846. /**
  105847. * Constant Loop Mode
  105848. */
  105849. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  105850. /** @hidden */
  105851. static _UniversalLerp(left: any, right: any, amount: number): any;
  105852. /**
  105853. * Parses an animation object and creates an animation
  105854. * @param parsedAnimation Parsed animation object
  105855. * @returns Animation object
  105856. */
  105857. static Parse(parsedAnimation: any): Animation;
  105858. /**
  105859. * Appends the serialized animations from the source animations
  105860. * @param source Source containing the animations
  105861. * @param destination Target to store the animations
  105862. */
  105863. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  105864. }
  105865. }
  105866. declare module BABYLON {
  105867. /**
  105868. * Interface containing an array of animations
  105869. */
  105870. export interface IAnimatable {
  105871. /**
  105872. * Array of animations
  105873. */
  105874. animations: Nullable<Array<Animation>>;
  105875. }
  105876. }
  105877. declare module BABYLON {
  105878. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  105879. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105880. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105881. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105882. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105883. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105884. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105885. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105886. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105887. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105888. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105889. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105890. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105891. /**
  105892. * Decorator used to define property that can be serialized as reference to a camera
  105893. * @param sourceName defines the name of the property to decorate
  105894. */
  105895. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  105896. /**
  105897. * Class used to help serialization objects
  105898. */
  105899. export class SerializationHelper {
  105900. /** @hidden */
  105901. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  105902. /** @hidden */
  105903. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  105904. /** @hidden */
  105905. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  105906. /** @hidden */
  105907. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  105908. /**
  105909. * Appends the serialized animations from the source animations
  105910. * @param source Source containing the animations
  105911. * @param destination Target to store the animations
  105912. */
  105913. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  105914. /**
  105915. * Static function used to serialized a specific entity
  105916. * @param entity defines the entity to serialize
  105917. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  105918. * @returns a JSON compatible object representing the serialization of the entity
  105919. */
  105920. static Serialize<T>(entity: T, serializationObject?: any): any;
  105921. /**
  105922. * Creates a new entity from a serialization data object
  105923. * @param creationFunction defines a function used to instanciated the new entity
  105924. * @param source defines the source serialization data
  105925. * @param scene defines the hosting scene
  105926. * @param rootUrl defines the root url for resources
  105927. * @returns a new entity
  105928. */
  105929. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  105930. /**
  105931. * Clones an object
  105932. * @param creationFunction defines the function used to instanciate the new object
  105933. * @param source defines the source object
  105934. * @returns the cloned object
  105935. */
  105936. static Clone<T>(creationFunction: () => T, source: T): T;
  105937. /**
  105938. * Instanciates a new object based on a source one (some data will be shared between both object)
  105939. * @param creationFunction defines the function used to instanciate the new object
  105940. * @param source defines the source object
  105941. * @returns the new object
  105942. */
  105943. static Instanciate<T>(creationFunction: () => T, source: T): T;
  105944. }
  105945. }
  105946. declare module BABYLON {
  105947. /**
  105948. * Base class of all the textures in babylon.
  105949. * It groups all the common properties the materials, post process, lights... might need
  105950. * in order to make a correct use of the texture.
  105951. */
  105952. export class BaseTexture implements IAnimatable {
  105953. /**
  105954. * Default anisotropic filtering level for the application.
  105955. * It is set to 4 as a good tradeoff between perf and quality.
  105956. */
  105957. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  105958. /**
  105959. * Gets or sets the unique id of the texture
  105960. */
  105961. uniqueId: number;
  105962. /**
  105963. * Define the name of the texture.
  105964. */
  105965. name: string;
  105966. /**
  105967. * Gets or sets an object used to store user defined information.
  105968. */
  105969. metadata: any;
  105970. /**
  105971. * For internal use only. Please do not use.
  105972. */
  105973. reservedDataStore: any;
  105974. private _hasAlpha;
  105975. /**
  105976. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  105977. */
  105978. set hasAlpha(value: boolean);
  105979. get hasAlpha(): boolean;
  105980. /**
  105981. * Defines if the alpha value should be determined via the rgb values.
  105982. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  105983. */
  105984. getAlphaFromRGB: boolean;
  105985. /**
  105986. * Intensity or strength of the texture.
  105987. * It is commonly used by materials to fine tune the intensity of the texture
  105988. */
  105989. level: number;
  105990. /**
  105991. * Define the UV chanel to use starting from 0 and defaulting to 0.
  105992. * This is part of the texture as textures usually maps to one uv set.
  105993. */
  105994. coordinatesIndex: number;
  105995. private _coordinatesMode;
  105996. /**
  105997. * How a texture is mapped.
  105998. *
  105999. * | Value | Type | Description |
  106000. * | ----- | ----------------------------------- | ----------- |
  106001. * | 0 | EXPLICIT_MODE | |
  106002. * | 1 | SPHERICAL_MODE | |
  106003. * | 2 | PLANAR_MODE | |
  106004. * | 3 | CUBIC_MODE | |
  106005. * | 4 | PROJECTION_MODE | |
  106006. * | 5 | SKYBOX_MODE | |
  106007. * | 6 | INVCUBIC_MODE | |
  106008. * | 7 | EQUIRECTANGULAR_MODE | |
  106009. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  106010. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  106011. */
  106012. set coordinatesMode(value: number);
  106013. get coordinatesMode(): number;
  106014. /**
  106015. * | Value | Type | Description |
  106016. * | ----- | ------------------ | ----------- |
  106017. * | 0 | CLAMP_ADDRESSMODE | |
  106018. * | 1 | WRAP_ADDRESSMODE | |
  106019. * | 2 | MIRROR_ADDRESSMODE | |
  106020. */
  106021. wrapU: number;
  106022. /**
  106023. * | Value | Type | Description |
  106024. * | ----- | ------------------ | ----------- |
  106025. * | 0 | CLAMP_ADDRESSMODE | |
  106026. * | 1 | WRAP_ADDRESSMODE | |
  106027. * | 2 | MIRROR_ADDRESSMODE | |
  106028. */
  106029. wrapV: number;
  106030. /**
  106031. * | Value | Type | Description |
  106032. * | ----- | ------------------ | ----------- |
  106033. * | 0 | CLAMP_ADDRESSMODE | |
  106034. * | 1 | WRAP_ADDRESSMODE | |
  106035. * | 2 | MIRROR_ADDRESSMODE | |
  106036. */
  106037. wrapR: number;
  106038. /**
  106039. * With compliant hardware and browser (supporting anisotropic filtering)
  106040. * this defines the level of anisotropic filtering in the texture.
  106041. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  106042. */
  106043. anisotropicFilteringLevel: number;
  106044. /**
  106045. * Define if the texture is a cube texture or if false a 2d texture.
  106046. */
  106047. get isCube(): boolean;
  106048. set isCube(value: boolean);
  106049. /**
  106050. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  106051. */
  106052. get is3D(): boolean;
  106053. set is3D(value: boolean);
  106054. /**
  106055. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  106056. */
  106057. get is2DArray(): boolean;
  106058. set is2DArray(value: boolean);
  106059. /**
  106060. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  106061. * HDR texture are usually stored in linear space.
  106062. * This only impacts the PBR and Background materials
  106063. */
  106064. gammaSpace: boolean;
  106065. /**
  106066. * Gets or sets whether or not the texture contains RGBD data.
  106067. */
  106068. get isRGBD(): boolean;
  106069. set isRGBD(value: boolean);
  106070. /**
  106071. * Is Z inverted in the texture (useful in a cube texture).
  106072. */
  106073. invertZ: boolean;
  106074. /**
  106075. * Are mip maps generated for this texture or not.
  106076. */
  106077. get noMipmap(): boolean;
  106078. /**
  106079. * @hidden
  106080. */
  106081. lodLevelInAlpha: boolean;
  106082. /**
  106083. * With prefiltered texture, defined the offset used during the prefiltering steps.
  106084. */
  106085. get lodGenerationOffset(): number;
  106086. set lodGenerationOffset(value: number);
  106087. /**
  106088. * With prefiltered texture, defined the scale used during the prefiltering steps.
  106089. */
  106090. get lodGenerationScale(): number;
  106091. set lodGenerationScale(value: number);
  106092. /**
  106093. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  106094. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  106095. * average roughness values.
  106096. */
  106097. get linearSpecularLOD(): boolean;
  106098. set linearSpecularLOD(value: boolean);
  106099. /**
  106100. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  106101. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  106102. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  106103. */
  106104. get irradianceTexture(): Nullable<BaseTexture>;
  106105. set irradianceTexture(value: Nullable<BaseTexture>);
  106106. /**
  106107. * Define if the texture is a render target.
  106108. */
  106109. isRenderTarget: boolean;
  106110. /**
  106111. * Define the unique id of the texture in the scene.
  106112. */
  106113. get uid(): string;
  106114. /**
  106115. * Return a string representation of the texture.
  106116. * @returns the texture as a string
  106117. */
  106118. toString(): string;
  106119. /**
  106120. * Get the class name of the texture.
  106121. * @returns "BaseTexture"
  106122. */
  106123. getClassName(): string;
  106124. /**
  106125. * Define the list of animation attached to the texture.
  106126. */
  106127. animations: Animation[];
  106128. /**
  106129. * An event triggered when the texture is disposed.
  106130. */
  106131. onDisposeObservable: Observable<BaseTexture>;
  106132. private _onDisposeObserver;
  106133. /**
  106134. * Callback triggered when the texture has been disposed.
  106135. * Kept for back compatibility, you can use the onDisposeObservable instead.
  106136. */
  106137. set onDispose(callback: () => void);
  106138. /**
  106139. * Define the current state of the loading sequence when in delayed load mode.
  106140. */
  106141. delayLoadState: number;
  106142. private _scene;
  106143. /** @hidden */
  106144. _texture: Nullable<InternalTexture>;
  106145. private _uid;
  106146. /**
  106147. * Define if the texture is preventinga material to render or not.
  106148. * If not and the texture is not ready, the engine will use a default black texture instead.
  106149. */
  106150. get isBlocking(): boolean;
  106151. /**
  106152. * Instantiates a new BaseTexture.
  106153. * Base class of all the textures in babylon.
  106154. * It groups all the common properties the materials, post process, lights... might need
  106155. * in order to make a correct use of the texture.
  106156. * @param scene Define the scene the texture blongs to
  106157. */
  106158. constructor(scene: Nullable<Scene>);
  106159. /**
  106160. * Get the scene the texture belongs to.
  106161. * @returns the scene or null if undefined
  106162. */
  106163. getScene(): Nullable<Scene>;
  106164. /**
  106165. * Get the texture transform matrix used to offset tile the texture for istance.
  106166. * @returns the transformation matrix
  106167. */
  106168. getTextureMatrix(): Matrix;
  106169. /**
  106170. * Get the texture reflection matrix used to rotate/transform the reflection.
  106171. * @returns the reflection matrix
  106172. */
  106173. getReflectionTextureMatrix(): Matrix;
  106174. /**
  106175. * Get the underlying lower level texture from Babylon.
  106176. * @returns the insternal texture
  106177. */
  106178. getInternalTexture(): Nullable<InternalTexture>;
  106179. /**
  106180. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  106181. * @returns true if ready or not blocking
  106182. */
  106183. isReadyOrNotBlocking(): boolean;
  106184. /**
  106185. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  106186. * @returns true if fully ready
  106187. */
  106188. isReady(): boolean;
  106189. private _cachedSize;
  106190. /**
  106191. * Get the size of the texture.
  106192. * @returns the texture size.
  106193. */
  106194. getSize(): ISize;
  106195. /**
  106196. * Get the base size of the texture.
  106197. * It can be different from the size if the texture has been resized for POT for instance
  106198. * @returns the base size
  106199. */
  106200. getBaseSize(): ISize;
  106201. /**
  106202. * Update the sampling mode of the texture.
  106203. * Default is Trilinear mode.
  106204. *
  106205. * | Value | Type | Description |
  106206. * | ----- | ------------------ | ----------- |
  106207. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  106208. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  106209. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  106210. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  106211. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  106212. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  106213. * | 7 | NEAREST_LINEAR | |
  106214. * | 8 | NEAREST_NEAREST | |
  106215. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  106216. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  106217. * | 11 | LINEAR_LINEAR | |
  106218. * | 12 | LINEAR_NEAREST | |
  106219. *
  106220. * > _mag_: magnification filter (close to the viewer)
  106221. * > _min_: minification filter (far from the viewer)
  106222. * > _mip_: filter used between mip map levels
  106223. *@param samplingMode Define the new sampling mode of the texture
  106224. */
  106225. updateSamplingMode(samplingMode: number): void;
  106226. /**
  106227. * Scales the texture if is `canRescale()`
  106228. * @param ratio the resize factor we want to use to rescale
  106229. */
  106230. scale(ratio: number): void;
  106231. /**
  106232. * Get if the texture can rescale.
  106233. */
  106234. get canRescale(): boolean;
  106235. /** @hidden */
  106236. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  106237. /** @hidden */
  106238. _rebuild(): void;
  106239. /**
  106240. * Triggers the load sequence in delayed load mode.
  106241. */
  106242. delayLoad(): void;
  106243. /**
  106244. * Clones the texture.
  106245. * @returns the cloned texture
  106246. */
  106247. clone(): Nullable<BaseTexture>;
  106248. /**
  106249. * Get the texture underlying type (INT, FLOAT...)
  106250. */
  106251. get textureType(): number;
  106252. /**
  106253. * Get the texture underlying format (RGB, RGBA...)
  106254. */
  106255. get textureFormat(): number;
  106256. /**
  106257. * Indicates that textures need to be re-calculated for all materials
  106258. */
  106259. protected _markAllSubMeshesAsTexturesDirty(): void;
  106260. /**
  106261. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  106262. * This will returns an RGBA array buffer containing either in values (0-255) or
  106263. * float values (0-1) depending of the underlying buffer type.
  106264. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  106265. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  106266. * @param buffer defines a user defined buffer to fill with data (can be null)
  106267. * @returns The Array buffer containing the pixels data.
  106268. */
  106269. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  106270. /**
  106271. * Release and destroy the underlying lower level texture aka internalTexture.
  106272. */
  106273. releaseInternalTexture(): void;
  106274. /** @hidden */
  106275. get _lodTextureHigh(): Nullable<BaseTexture>;
  106276. /** @hidden */
  106277. get _lodTextureMid(): Nullable<BaseTexture>;
  106278. /** @hidden */
  106279. get _lodTextureLow(): Nullable<BaseTexture>;
  106280. /**
  106281. * Dispose the texture and release its associated resources.
  106282. */
  106283. dispose(): void;
  106284. /**
  106285. * Serialize the texture into a JSON representation that can be parsed later on.
  106286. * @returns the JSON representation of the texture
  106287. */
  106288. serialize(): any;
  106289. /**
  106290. * Helper function to be called back once a list of texture contains only ready textures.
  106291. * @param textures Define the list of textures to wait for
  106292. * @param callback Define the callback triggered once the entire list will be ready
  106293. */
  106294. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  106295. }
  106296. }
  106297. declare module BABYLON {
  106298. /**
  106299. * Options to be used when creating an effect.
  106300. */
  106301. export interface IEffectCreationOptions {
  106302. /**
  106303. * Atrributes that will be used in the shader.
  106304. */
  106305. attributes: string[];
  106306. /**
  106307. * Uniform varible names that will be set in the shader.
  106308. */
  106309. uniformsNames: string[];
  106310. /**
  106311. * Uniform buffer variable names that will be set in the shader.
  106312. */
  106313. uniformBuffersNames: string[];
  106314. /**
  106315. * Sampler texture variable names that will be set in the shader.
  106316. */
  106317. samplers: string[];
  106318. /**
  106319. * Define statements that will be set in the shader.
  106320. */
  106321. defines: any;
  106322. /**
  106323. * Possible fallbacks for this effect to improve performance when needed.
  106324. */
  106325. fallbacks: Nullable<IEffectFallbacks>;
  106326. /**
  106327. * Callback that will be called when the shader is compiled.
  106328. */
  106329. onCompiled: Nullable<(effect: Effect) => void>;
  106330. /**
  106331. * Callback that will be called if an error occurs during shader compilation.
  106332. */
  106333. onError: Nullable<(effect: Effect, errors: string) => void>;
  106334. /**
  106335. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106336. */
  106337. indexParameters?: any;
  106338. /**
  106339. * Max number of lights that can be used in the shader.
  106340. */
  106341. maxSimultaneousLights?: number;
  106342. /**
  106343. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  106344. */
  106345. transformFeedbackVaryings?: Nullable<string[]>;
  106346. }
  106347. /**
  106348. * Effect containing vertex and fragment shader that can be executed on an object.
  106349. */
  106350. export class Effect implements IDisposable {
  106351. /**
  106352. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  106353. */
  106354. static ShadersRepository: string;
  106355. /**
  106356. * Enable logging of the shader code when a compilation error occurs
  106357. */
  106358. static LogShaderCodeOnCompilationError: boolean;
  106359. /**
  106360. * Name of the effect.
  106361. */
  106362. name: any;
  106363. /**
  106364. * String container all the define statements that should be set on the shader.
  106365. */
  106366. defines: string;
  106367. /**
  106368. * Callback that will be called when the shader is compiled.
  106369. */
  106370. onCompiled: Nullable<(effect: Effect) => void>;
  106371. /**
  106372. * Callback that will be called if an error occurs during shader compilation.
  106373. */
  106374. onError: Nullable<(effect: Effect, errors: string) => void>;
  106375. /**
  106376. * Callback that will be called when effect is bound.
  106377. */
  106378. onBind: Nullable<(effect: Effect) => void>;
  106379. /**
  106380. * Unique ID of the effect.
  106381. */
  106382. uniqueId: number;
  106383. /**
  106384. * Observable that will be called when the shader is compiled.
  106385. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  106386. */
  106387. onCompileObservable: Observable<Effect>;
  106388. /**
  106389. * Observable that will be called if an error occurs during shader compilation.
  106390. */
  106391. onErrorObservable: Observable<Effect>;
  106392. /** @hidden */
  106393. _onBindObservable: Nullable<Observable<Effect>>;
  106394. /**
  106395. * @hidden
  106396. * Specifies if the effect was previously ready
  106397. */
  106398. _wasPreviouslyReady: boolean;
  106399. /**
  106400. * Observable that will be called when effect is bound.
  106401. */
  106402. get onBindObservable(): Observable<Effect>;
  106403. /** @hidden */
  106404. _bonesComputationForcedToCPU: boolean;
  106405. private static _uniqueIdSeed;
  106406. private _engine;
  106407. private _uniformBuffersNames;
  106408. private _uniformBuffersNamesList;
  106409. private _uniformsNames;
  106410. private _samplerList;
  106411. private _samplers;
  106412. private _isReady;
  106413. private _compilationError;
  106414. private _allFallbacksProcessed;
  106415. private _attributesNames;
  106416. private _attributes;
  106417. private _attributeLocationByName;
  106418. private _uniforms;
  106419. /**
  106420. * Key for the effect.
  106421. * @hidden
  106422. */
  106423. _key: string;
  106424. private _indexParameters;
  106425. private _fallbacks;
  106426. private _vertexSourceCode;
  106427. private _fragmentSourceCode;
  106428. private _vertexSourceCodeOverride;
  106429. private _fragmentSourceCodeOverride;
  106430. private _transformFeedbackVaryings;
  106431. /**
  106432. * Compiled shader to webGL program.
  106433. * @hidden
  106434. */
  106435. _pipelineContext: Nullable<IPipelineContext>;
  106436. private _valueCache;
  106437. private static _baseCache;
  106438. /**
  106439. * Instantiates an effect.
  106440. * An effect can be used to create/manage/execute vertex and fragment shaders.
  106441. * @param baseName Name of the effect.
  106442. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  106443. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  106444. * @param samplers List of sampler variables that will be passed to the shader.
  106445. * @param engine Engine to be used to render the effect
  106446. * @param defines Define statements to be added to the shader.
  106447. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  106448. * @param onCompiled Callback that will be called when the shader is compiled.
  106449. * @param onError Callback that will be called if an error occurs during shader compilation.
  106450. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  106451. */
  106452. 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);
  106453. private _useFinalCode;
  106454. /**
  106455. * Unique key for this effect
  106456. */
  106457. get key(): string;
  106458. /**
  106459. * If the effect has been compiled and prepared.
  106460. * @returns if the effect is compiled and prepared.
  106461. */
  106462. isReady(): boolean;
  106463. private _isReadyInternal;
  106464. /**
  106465. * The engine the effect was initialized with.
  106466. * @returns the engine.
  106467. */
  106468. getEngine(): Engine;
  106469. /**
  106470. * The pipeline context for this effect
  106471. * @returns the associated pipeline context
  106472. */
  106473. getPipelineContext(): Nullable<IPipelineContext>;
  106474. /**
  106475. * The set of names of attribute variables for the shader.
  106476. * @returns An array of attribute names.
  106477. */
  106478. getAttributesNames(): string[];
  106479. /**
  106480. * Returns the attribute at the given index.
  106481. * @param index The index of the attribute.
  106482. * @returns The location of the attribute.
  106483. */
  106484. getAttributeLocation(index: number): number;
  106485. /**
  106486. * Returns the attribute based on the name of the variable.
  106487. * @param name of the attribute to look up.
  106488. * @returns the attribute location.
  106489. */
  106490. getAttributeLocationByName(name: string): number;
  106491. /**
  106492. * The number of attributes.
  106493. * @returns the numnber of attributes.
  106494. */
  106495. getAttributesCount(): number;
  106496. /**
  106497. * Gets the index of a uniform variable.
  106498. * @param uniformName of the uniform to look up.
  106499. * @returns the index.
  106500. */
  106501. getUniformIndex(uniformName: string): number;
  106502. /**
  106503. * Returns the attribute based on the name of the variable.
  106504. * @param uniformName of the uniform to look up.
  106505. * @returns the location of the uniform.
  106506. */
  106507. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  106508. /**
  106509. * Returns an array of sampler variable names
  106510. * @returns The array of sampler variable names.
  106511. */
  106512. getSamplers(): string[];
  106513. /**
  106514. * Returns an array of uniform variable names
  106515. * @returns The array of uniform variable names.
  106516. */
  106517. getUniformNames(): string[];
  106518. /**
  106519. * Returns an array of uniform buffer variable names
  106520. * @returns The array of uniform buffer variable names.
  106521. */
  106522. getUniformBuffersNames(): string[];
  106523. /**
  106524. * Returns the index parameters used to create the effect
  106525. * @returns The index parameters object
  106526. */
  106527. getIndexParameters(): any;
  106528. /**
  106529. * The error from the last compilation.
  106530. * @returns the error string.
  106531. */
  106532. getCompilationError(): string;
  106533. /**
  106534. * Gets a boolean indicating that all fallbacks were used during compilation
  106535. * @returns true if all fallbacks were used
  106536. */
  106537. allFallbacksProcessed(): boolean;
  106538. /**
  106539. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  106540. * @param func The callback to be used.
  106541. */
  106542. executeWhenCompiled(func: (effect: Effect) => void): void;
  106543. private _checkIsReady;
  106544. private _loadShader;
  106545. /**
  106546. * Gets the vertex shader source code of this effect
  106547. */
  106548. get vertexSourceCode(): string;
  106549. /**
  106550. * Gets the fragment shader source code of this effect
  106551. */
  106552. get fragmentSourceCode(): string;
  106553. /**
  106554. * Recompiles the webGL program
  106555. * @param vertexSourceCode The source code for the vertex shader.
  106556. * @param fragmentSourceCode The source code for the fragment shader.
  106557. * @param onCompiled Callback called when completed.
  106558. * @param onError Callback called on error.
  106559. * @hidden
  106560. */
  106561. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  106562. /**
  106563. * Prepares the effect
  106564. * @hidden
  106565. */
  106566. _prepareEffect(): void;
  106567. private _getShaderCodeAndErrorLine;
  106568. private _processCompilationErrors;
  106569. /**
  106570. * Checks if the effect is supported. (Must be called after compilation)
  106571. */
  106572. get isSupported(): boolean;
  106573. /**
  106574. * Binds a texture to the engine to be used as output of the shader.
  106575. * @param channel Name of the output variable.
  106576. * @param texture Texture to bind.
  106577. * @hidden
  106578. */
  106579. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  106580. /**
  106581. * Sets a texture on the engine to be used in the shader.
  106582. * @param channel Name of the sampler variable.
  106583. * @param texture Texture to set.
  106584. */
  106585. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  106586. /**
  106587. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  106588. * @param channel Name of the sampler variable.
  106589. * @param texture Texture to set.
  106590. */
  106591. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  106592. /**
  106593. * Sets an array of textures on the engine to be used in the shader.
  106594. * @param channel Name of the variable.
  106595. * @param textures Textures to set.
  106596. */
  106597. setTextureArray(channel: string, textures: BaseTexture[]): void;
  106598. /**
  106599. * 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)
  106600. * @param channel Name of the sampler variable.
  106601. * @param postProcess Post process to get the input texture from.
  106602. */
  106603. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  106604. /**
  106605. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  106606. * 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)
  106607. * @param channel Name of the sampler variable.
  106608. * @param postProcess Post process to get the output texture from.
  106609. */
  106610. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  106611. /** @hidden */
  106612. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  106613. /** @hidden */
  106614. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  106615. /** @hidden */
  106616. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  106617. /** @hidden */
  106618. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  106619. /**
  106620. * Binds a buffer to a uniform.
  106621. * @param buffer Buffer to bind.
  106622. * @param name Name of the uniform variable to bind to.
  106623. */
  106624. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  106625. /**
  106626. * Binds block to a uniform.
  106627. * @param blockName Name of the block to bind.
  106628. * @param index Index to bind.
  106629. */
  106630. bindUniformBlock(blockName: string, index: number): void;
  106631. /**
  106632. * Sets an interger value on a uniform variable.
  106633. * @param uniformName Name of the variable.
  106634. * @param value Value to be set.
  106635. * @returns this effect.
  106636. */
  106637. setInt(uniformName: string, value: number): Effect;
  106638. /**
  106639. * Sets an int array on a uniform variable.
  106640. * @param uniformName Name of the variable.
  106641. * @param array array to be set.
  106642. * @returns this effect.
  106643. */
  106644. setIntArray(uniformName: string, array: Int32Array): Effect;
  106645. /**
  106646. * 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)
  106647. * @param uniformName Name of the variable.
  106648. * @param array array to be set.
  106649. * @returns this effect.
  106650. */
  106651. setIntArray2(uniformName: string, array: Int32Array): Effect;
  106652. /**
  106653. * 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)
  106654. * @param uniformName Name of the variable.
  106655. * @param array array to be set.
  106656. * @returns this effect.
  106657. */
  106658. setIntArray3(uniformName: string, array: Int32Array): Effect;
  106659. /**
  106660. * 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)
  106661. * @param uniformName Name of the variable.
  106662. * @param array array to be set.
  106663. * @returns this effect.
  106664. */
  106665. setIntArray4(uniformName: string, array: Int32Array): Effect;
  106666. /**
  106667. * Sets an float array on a uniform variable.
  106668. * @param uniformName Name of the variable.
  106669. * @param array array to be set.
  106670. * @returns this effect.
  106671. */
  106672. setFloatArray(uniformName: string, array: Float32Array): Effect;
  106673. /**
  106674. * 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)
  106675. * @param uniformName Name of the variable.
  106676. * @param array array to be set.
  106677. * @returns this effect.
  106678. */
  106679. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  106680. /**
  106681. * 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)
  106682. * @param uniformName Name of the variable.
  106683. * @param array array to be set.
  106684. * @returns this effect.
  106685. */
  106686. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  106687. /**
  106688. * 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)
  106689. * @param uniformName Name of the variable.
  106690. * @param array array to be set.
  106691. * @returns this effect.
  106692. */
  106693. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  106694. /**
  106695. * Sets an array on a uniform variable.
  106696. * @param uniformName Name of the variable.
  106697. * @param array array to be set.
  106698. * @returns this effect.
  106699. */
  106700. setArray(uniformName: string, array: number[]): Effect;
  106701. /**
  106702. * 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)
  106703. * @param uniformName Name of the variable.
  106704. * @param array array to be set.
  106705. * @returns this effect.
  106706. */
  106707. setArray2(uniformName: string, array: number[]): Effect;
  106708. /**
  106709. * 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)
  106710. * @param uniformName Name of the variable.
  106711. * @param array array to be set.
  106712. * @returns this effect.
  106713. */
  106714. setArray3(uniformName: string, array: number[]): Effect;
  106715. /**
  106716. * 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)
  106717. * @param uniformName Name of the variable.
  106718. * @param array array to be set.
  106719. * @returns this effect.
  106720. */
  106721. setArray4(uniformName: string, array: number[]): Effect;
  106722. /**
  106723. * Sets matrices on a uniform variable.
  106724. * @param uniformName Name of the variable.
  106725. * @param matrices matrices to be set.
  106726. * @returns this effect.
  106727. */
  106728. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  106729. /**
  106730. * Sets matrix on a uniform variable.
  106731. * @param uniformName Name of the variable.
  106732. * @param matrix matrix to be set.
  106733. * @returns this effect.
  106734. */
  106735. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  106736. /**
  106737. * 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)
  106738. * @param uniformName Name of the variable.
  106739. * @param matrix matrix to be set.
  106740. * @returns this effect.
  106741. */
  106742. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  106743. /**
  106744. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  106745. * @param uniformName Name of the variable.
  106746. * @param matrix matrix to be set.
  106747. * @returns this effect.
  106748. */
  106749. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  106750. /**
  106751. * Sets a float on a uniform variable.
  106752. * @param uniformName Name of the variable.
  106753. * @param value value to be set.
  106754. * @returns this effect.
  106755. */
  106756. setFloat(uniformName: string, value: number): Effect;
  106757. /**
  106758. * Sets a boolean on a uniform variable.
  106759. * @param uniformName Name of the variable.
  106760. * @param bool value to be set.
  106761. * @returns this effect.
  106762. */
  106763. setBool(uniformName: string, bool: boolean): Effect;
  106764. /**
  106765. * Sets a Vector2 on a uniform variable.
  106766. * @param uniformName Name of the variable.
  106767. * @param vector2 vector2 to be set.
  106768. * @returns this effect.
  106769. */
  106770. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  106771. /**
  106772. * Sets a float2 on a uniform variable.
  106773. * @param uniformName Name of the variable.
  106774. * @param x First float in float2.
  106775. * @param y Second float in float2.
  106776. * @returns this effect.
  106777. */
  106778. setFloat2(uniformName: string, x: number, y: number): Effect;
  106779. /**
  106780. * Sets a Vector3 on a uniform variable.
  106781. * @param uniformName Name of the variable.
  106782. * @param vector3 Value to be set.
  106783. * @returns this effect.
  106784. */
  106785. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  106786. /**
  106787. * Sets a float3 on a uniform variable.
  106788. * @param uniformName Name of the variable.
  106789. * @param x First float in float3.
  106790. * @param y Second float in float3.
  106791. * @param z Third float in float3.
  106792. * @returns this effect.
  106793. */
  106794. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  106795. /**
  106796. * Sets a Vector4 on a uniform variable.
  106797. * @param uniformName Name of the variable.
  106798. * @param vector4 Value to be set.
  106799. * @returns this effect.
  106800. */
  106801. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  106802. /**
  106803. * Sets a float4 on a uniform variable.
  106804. * @param uniformName Name of the variable.
  106805. * @param x First float in float4.
  106806. * @param y Second float in float4.
  106807. * @param z Third float in float4.
  106808. * @param w Fourth float in float4.
  106809. * @returns this effect.
  106810. */
  106811. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  106812. /**
  106813. * Sets a Color3 on a uniform variable.
  106814. * @param uniformName Name of the variable.
  106815. * @param color3 Value to be set.
  106816. * @returns this effect.
  106817. */
  106818. setColor3(uniformName: string, color3: IColor3Like): Effect;
  106819. /**
  106820. * Sets a Color4 on a uniform variable.
  106821. * @param uniformName Name of the variable.
  106822. * @param color3 Value to be set.
  106823. * @param alpha Alpha value to be set.
  106824. * @returns this effect.
  106825. */
  106826. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  106827. /**
  106828. * Sets a Color4 on a uniform variable
  106829. * @param uniformName defines the name of the variable
  106830. * @param color4 defines the value to be set
  106831. * @returns this effect.
  106832. */
  106833. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  106834. /** Release all associated resources */
  106835. dispose(): void;
  106836. /**
  106837. * This function will add a new shader to the shader store
  106838. * @param name the name of the shader
  106839. * @param pixelShader optional pixel shader content
  106840. * @param vertexShader optional vertex shader content
  106841. */
  106842. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  106843. /**
  106844. * Store of each shader (The can be looked up using effect.key)
  106845. */
  106846. static ShadersStore: {
  106847. [key: string]: string;
  106848. };
  106849. /**
  106850. * Store of each included file for a shader (The can be looked up using effect.key)
  106851. */
  106852. static IncludesShadersStore: {
  106853. [key: string]: string;
  106854. };
  106855. /**
  106856. * Resets the cache of effects.
  106857. */
  106858. static ResetCache(): void;
  106859. }
  106860. }
  106861. declare module BABYLON {
  106862. /**
  106863. * Interface used to describe the capabilities of the engine relatively to the current browser
  106864. */
  106865. export interface EngineCapabilities {
  106866. /** Maximum textures units per fragment shader */
  106867. maxTexturesImageUnits: number;
  106868. /** Maximum texture units per vertex shader */
  106869. maxVertexTextureImageUnits: number;
  106870. /** Maximum textures units in the entire pipeline */
  106871. maxCombinedTexturesImageUnits: number;
  106872. /** Maximum texture size */
  106873. maxTextureSize: number;
  106874. /** Maximum texture samples */
  106875. maxSamples?: number;
  106876. /** Maximum cube texture size */
  106877. maxCubemapTextureSize: number;
  106878. /** Maximum render texture size */
  106879. maxRenderTextureSize: number;
  106880. /** Maximum number of vertex attributes */
  106881. maxVertexAttribs: number;
  106882. /** Maximum number of varyings */
  106883. maxVaryingVectors: number;
  106884. /** Maximum number of uniforms per vertex shader */
  106885. maxVertexUniformVectors: number;
  106886. /** Maximum number of uniforms per fragment shader */
  106887. maxFragmentUniformVectors: number;
  106888. /** Defines if standard derivates (dx/dy) are supported */
  106889. standardDerivatives: boolean;
  106890. /** Defines if s3tc texture compression is supported */
  106891. s3tc?: WEBGL_compressed_texture_s3tc;
  106892. /** Defines if pvrtc texture compression is supported */
  106893. pvrtc: any;
  106894. /** Defines if etc1 texture compression is supported */
  106895. etc1: any;
  106896. /** Defines if etc2 texture compression is supported */
  106897. etc2: any;
  106898. /** Defines if astc texture compression is supported */
  106899. astc: any;
  106900. /** Defines if float textures are supported */
  106901. textureFloat: boolean;
  106902. /** Defines if vertex array objects are supported */
  106903. vertexArrayObject: boolean;
  106904. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  106905. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  106906. /** Gets the maximum level of anisotropy supported */
  106907. maxAnisotropy: number;
  106908. /** Defines if instancing is supported */
  106909. instancedArrays: boolean;
  106910. /** Defines if 32 bits indices are supported */
  106911. uintIndices: boolean;
  106912. /** Defines if high precision shaders are supported */
  106913. highPrecisionShaderSupported: boolean;
  106914. /** Defines if depth reading in the fragment shader is supported */
  106915. fragmentDepthSupported: boolean;
  106916. /** Defines if float texture linear filtering is supported*/
  106917. textureFloatLinearFiltering: boolean;
  106918. /** Defines if rendering to float textures is supported */
  106919. textureFloatRender: boolean;
  106920. /** Defines if half float textures are supported*/
  106921. textureHalfFloat: boolean;
  106922. /** Defines if half float texture linear filtering is supported*/
  106923. textureHalfFloatLinearFiltering: boolean;
  106924. /** Defines if rendering to half float textures is supported */
  106925. textureHalfFloatRender: boolean;
  106926. /** Defines if textureLOD shader command is supported */
  106927. textureLOD: boolean;
  106928. /** Defines if draw buffers extension is supported */
  106929. drawBuffersExtension: boolean;
  106930. /** Defines if depth textures are supported */
  106931. depthTextureExtension: boolean;
  106932. /** Defines if float color buffer are supported */
  106933. colorBufferFloat: boolean;
  106934. /** Gets disjoint timer query extension (null if not supported) */
  106935. timerQuery?: EXT_disjoint_timer_query;
  106936. /** Defines if timestamp can be used with timer query */
  106937. canUseTimestampForTimerQuery: boolean;
  106938. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  106939. multiview?: any;
  106940. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  106941. oculusMultiview?: any;
  106942. /** Function used to let the system compiles shaders in background */
  106943. parallelShaderCompile?: {
  106944. COMPLETION_STATUS_KHR: number;
  106945. };
  106946. /** Max number of texture samples for MSAA */
  106947. maxMSAASamples: number;
  106948. /** Defines if the blend min max extension is supported */
  106949. blendMinMax: boolean;
  106950. }
  106951. }
  106952. declare module BABYLON {
  106953. /**
  106954. * @hidden
  106955. **/
  106956. export class DepthCullingState {
  106957. private _isDepthTestDirty;
  106958. private _isDepthMaskDirty;
  106959. private _isDepthFuncDirty;
  106960. private _isCullFaceDirty;
  106961. private _isCullDirty;
  106962. private _isZOffsetDirty;
  106963. private _isFrontFaceDirty;
  106964. private _depthTest;
  106965. private _depthMask;
  106966. private _depthFunc;
  106967. private _cull;
  106968. private _cullFace;
  106969. private _zOffset;
  106970. private _frontFace;
  106971. /**
  106972. * Initializes the state.
  106973. */
  106974. constructor();
  106975. get isDirty(): boolean;
  106976. get zOffset(): number;
  106977. set zOffset(value: number);
  106978. get cullFace(): Nullable<number>;
  106979. set cullFace(value: Nullable<number>);
  106980. get cull(): Nullable<boolean>;
  106981. set cull(value: Nullable<boolean>);
  106982. get depthFunc(): Nullable<number>;
  106983. set depthFunc(value: Nullable<number>);
  106984. get depthMask(): boolean;
  106985. set depthMask(value: boolean);
  106986. get depthTest(): boolean;
  106987. set depthTest(value: boolean);
  106988. get frontFace(): Nullable<number>;
  106989. set frontFace(value: Nullable<number>);
  106990. reset(): void;
  106991. apply(gl: WebGLRenderingContext): void;
  106992. }
  106993. }
  106994. declare module BABYLON {
  106995. /**
  106996. * @hidden
  106997. **/
  106998. export class StencilState {
  106999. /** 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 */
  107000. static readonly ALWAYS: number;
  107001. /** Passed to stencilOperation to specify that stencil value must be kept */
  107002. static readonly KEEP: number;
  107003. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107004. static readonly REPLACE: number;
  107005. private _isStencilTestDirty;
  107006. private _isStencilMaskDirty;
  107007. private _isStencilFuncDirty;
  107008. private _isStencilOpDirty;
  107009. private _stencilTest;
  107010. private _stencilMask;
  107011. private _stencilFunc;
  107012. private _stencilFuncRef;
  107013. private _stencilFuncMask;
  107014. private _stencilOpStencilFail;
  107015. private _stencilOpDepthFail;
  107016. private _stencilOpStencilDepthPass;
  107017. get isDirty(): boolean;
  107018. get stencilFunc(): number;
  107019. set stencilFunc(value: number);
  107020. get stencilFuncRef(): number;
  107021. set stencilFuncRef(value: number);
  107022. get stencilFuncMask(): number;
  107023. set stencilFuncMask(value: number);
  107024. get stencilOpStencilFail(): number;
  107025. set stencilOpStencilFail(value: number);
  107026. get stencilOpDepthFail(): number;
  107027. set stencilOpDepthFail(value: number);
  107028. get stencilOpStencilDepthPass(): number;
  107029. set stencilOpStencilDepthPass(value: number);
  107030. get stencilMask(): number;
  107031. set stencilMask(value: number);
  107032. get stencilTest(): boolean;
  107033. set stencilTest(value: boolean);
  107034. constructor();
  107035. reset(): void;
  107036. apply(gl: WebGLRenderingContext): void;
  107037. }
  107038. }
  107039. declare module BABYLON {
  107040. /**
  107041. * @hidden
  107042. **/
  107043. export class AlphaState {
  107044. private _isAlphaBlendDirty;
  107045. private _isBlendFunctionParametersDirty;
  107046. private _isBlendEquationParametersDirty;
  107047. private _isBlendConstantsDirty;
  107048. private _alphaBlend;
  107049. private _blendFunctionParameters;
  107050. private _blendEquationParameters;
  107051. private _blendConstants;
  107052. /**
  107053. * Initializes the state.
  107054. */
  107055. constructor();
  107056. get isDirty(): boolean;
  107057. get alphaBlend(): boolean;
  107058. set alphaBlend(value: boolean);
  107059. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  107060. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  107061. setAlphaEquationParameters(rgb: number, alpha: number): void;
  107062. reset(): void;
  107063. apply(gl: WebGLRenderingContext): void;
  107064. }
  107065. }
  107066. declare module BABYLON {
  107067. /** @hidden */
  107068. export class WebGL2ShaderProcessor implements IShaderProcessor {
  107069. attributeProcessor(attribute: string): string;
  107070. varyingProcessor(varying: string, isFragment: boolean): string;
  107071. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  107072. }
  107073. }
  107074. declare module BABYLON {
  107075. /**
  107076. * Interface for attribute information associated with buffer instanciation
  107077. */
  107078. export interface InstancingAttributeInfo {
  107079. /**
  107080. * Name of the GLSL attribute
  107081. * if attribute index is not specified, this is used to retrieve the index from the effect
  107082. */
  107083. attributeName: string;
  107084. /**
  107085. * Index/offset of the attribute in the vertex shader
  107086. * if not specified, this will be computes from the name.
  107087. */
  107088. index?: number;
  107089. /**
  107090. * size of the attribute, 1, 2, 3 or 4
  107091. */
  107092. attributeSize: number;
  107093. /**
  107094. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  107095. */
  107096. offset: number;
  107097. /**
  107098. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  107099. * default to 1
  107100. */
  107101. divisor?: number;
  107102. /**
  107103. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  107104. * default is FLOAT
  107105. */
  107106. attributeType?: number;
  107107. /**
  107108. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  107109. */
  107110. normalized?: boolean;
  107111. }
  107112. }
  107113. declare module BABYLON {
  107114. interface ThinEngine {
  107115. /**
  107116. * Update a video texture
  107117. * @param texture defines the texture to update
  107118. * @param video defines the video element to use
  107119. * @param invertY defines if data must be stored with Y axis inverted
  107120. */
  107121. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  107122. }
  107123. }
  107124. declare module BABYLON {
  107125. /**
  107126. * Settings for finer control over video usage
  107127. */
  107128. export interface VideoTextureSettings {
  107129. /**
  107130. * Applies `autoplay` to video, if specified
  107131. */
  107132. autoPlay?: boolean;
  107133. /**
  107134. * Applies `loop` to video, if specified
  107135. */
  107136. loop?: boolean;
  107137. /**
  107138. * Automatically updates internal texture from video at every frame in the render loop
  107139. */
  107140. autoUpdateTexture: boolean;
  107141. /**
  107142. * Image src displayed during the video loading or until the user interacts with the video.
  107143. */
  107144. poster?: string;
  107145. }
  107146. /**
  107147. * If you want to display a video in your scene, this is the special texture for that.
  107148. * This special texture works similar to other textures, with the exception of a few parameters.
  107149. * @see https://doc.babylonjs.com/how_to/video_texture
  107150. */
  107151. export class VideoTexture extends Texture {
  107152. /**
  107153. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  107154. */
  107155. readonly autoUpdateTexture: boolean;
  107156. /**
  107157. * The video instance used by the texture internally
  107158. */
  107159. readonly video: HTMLVideoElement;
  107160. private _onUserActionRequestedObservable;
  107161. /**
  107162. * Event triggerd when a dom action is required by the user to play the video.
  107163. * This happens due to recent changes in browser policies preventing video to auto start.
  107164. */
  107165. get onUserActionRequestedObservable(): Observable<Texture>;
  107166. private _generateMipMaps;
  107167. private _engine;
  107168. private _stillImageCaptured;
  107169. private _displayingPosterTexture;
  107170. private _settings;
  107171. private _createInternalTextureOnEvent;
  107172. private _frameId;
  107173. private _currentSrc;
  107174. /**
  107175. * Creates a video texture.
  107176. * If you want to display a video in your scene, this is the special texture for that.
  107177. * This special texture works similar to other textures, with the exception of a few parameters.
  107178. * @see https://doc.babylonjs.com/how_to/video_texture
  107179. * @param name optional name, will detect from video source, if not defined
  107180. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  107181. * @param scene is obviously the current scene.
  107182. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  107183. * @param invertY is false by default but can be used to invert video on Y axis
  107184. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  107185. * @param settings allows finer control over video usage
  107186. */
  107187. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  107188. private _getName;
  107189. private _getVideo;
  107190. private _createInternalTexture;
  107191. private reset;
  107192. /**
  107193. * @hidden Internal method to initiate `update`.
  107194. */
  107195. _rebuild(): void;
  107196. /**
  107197. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  107198. */
  107199. update(): void;
  107200. /**
  107201. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  107202. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  107203. */
  107204. updateTexture(isVisible: boolean): void;
  107205. protected _updateInternalTexture: () => void;
  107206. /**
  107207. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  107208. * @param url New url.
  107209. */
  107210. updateURL(url: string): void;
  107211. /**
  107212. * Clones the texture.
  107213. * @returns the cloned texture
  107214. */
  107215. clone(): VideoTexture;
  107216. /**
  107217. * Dispose the texture and release its associated resources.
  107218. */
  107219. dispose(): void;
  107220. /**
  107221. * Creates a video texture straight from a stream.
  107222. * @param scene Define the scene the texture should be created in
  107223. * @param stream Define the stream the texture should be created from
  107224. * @returns The created video texture as a promise
  107225. */
  107226. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  107227. /**
  107228. * Creates a video texture straight from your WebCam video feed.
  107229. * @param scene Define the scene the texture should be created in
  107230. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107231. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107232. * @returns The created video texture as a promise
  107233. */
  107234. static CreateFromWebCamAsync(scene: Scene, constraints: {
  107235. minWidth: number;
  107236. maxWidth: number;
  107237. minHeight: number;
  107238. maxHeight: number;
  107239. deviceId: string;
  107240. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  107241. /**
  107242. * Creates a video texture straight from your WebCam video feed.
  107243. * @param scene Define the scene the texture should be created in
  107244. * @param onReady Define a callback to triggered once the texture will be ready
  107245. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  107246. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  107247. */
  107248. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  107249. minWidth: number;
  107250. maxWidth: number;
  107251. minHeight: number;
  107252. maxHeight: number;
  107253. deviceId: string;
  107254. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  107255. }
  107256. }
  107257. declare module BABYLON {
  107258. /**
  107259. * Defines the interface used by objects working like Scene
  107260. * @hidden
  107261. */
  107262. export interface ISceneLike {
  107263. _addPendingData(data: any): void;
  107264. _removePendingData(data: any): void;
  107265. offlineProvider: IOfflineProvider;
  107266. }
  107267. /** Interface defining initialization parameters for Engine class */
  107268. export interface EngineOptions extends WebGLContextAttributes {
  107269. /**
  107270. * Defines if the engine should no exceed a specified device ratio
  107271. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  107272. */
  107273. limitDeviceRatio?: number;
  107274. /**
  107275. * Defines if webvr should be enabled automatically
  107276. * @see http://doc.babylonjs.com/how_to/webvr_camera
  107277. */
  107278. autoEnableWebVR?: boolean;
  107279. /**
  107280. * Defines if webgl2 should be turned off even if supported
  107281. * @see http://doc.babylonjs.com/features/webgl2
  107282. */
  107283. disableWebGL2Support?: boolean;
  107284. /**
  107285. * Defines if webaudio should be initialized as well
  107286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107287. */
  107288. audioEngine?: boolean;
  107289. /**
  107290. * Defines if animations should run using a deterministic lock step
  107291. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107292. */
  107293. deterministicLockstep?: boolean;
  107294. /** Defines the maximum steps to use with deterministic lock step mode */
  107295. lockstepMaxSteps?: number;
  107296. /** Defines the seconds between each deterministic lock step */
  107297. timeStep?: number;
  107298. /**
  107299. * Defines that engine should ignore context lost events
  107300. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  107301. */
  107302. doNotHandleContextLost?: boolean;
  107303. /**
  107304. * Defines that engine should ignore modifying touch action attribute and style
  107305. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  107306. */
  107307. doNotHandleTouchAction?: boolean;
  107308. /**
  107309. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  107310. */
  107311. useHighPrecisionFloats?: boolean;
  107312. }
  107313. /**
  107314. * The base engine class (root of all engines)
  107315. */
  107316. export class ThinEngine {
  107317. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  107318. static ExceptionList: ({
  107319. key: string;
  107320. capture: string;
  107321. captureConstraint: number;
  107322. targets: string[];
  107323. } | {
  107324. key: string;
  107325. capture: null;
  107326. captureConstraint: null;
  107327. targets: string[];
  107328. })[];
  107329. /** @hidden */
  107330. static _TextureLoaders: IInternalTextureLoader[];
  107331. /**
  107332. * Returns the current npm package of the sdk
  107333. */
  107334. static get NpmPackage(): string;
  107335. /**
  107336. * Returns the current version of the framework
  107337. */
  107338. static get Version(): string;
  107339. /**
  107340. * Returns a string describing the current engine
  107341. */
  107342. get description(): string;
  107343. /**
  107344. * Gets or sets the epsilon value used by collision engine
  107345. */
  107346. static CollisionsEpsilon: number;
  107347. /**
  107348. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  107349. */
  107350. static get ShadersRepository(): string;
  107351. static set ShadersRepository(value: string);
  107352. /** @hidden */
  107353. _shaderProcessor: IShaderProcessor;
  107354. /**
  107355. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  107356. */
  107357. forcePOTTextures: boolean;
  107358. /**
  107359. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  107360. */
  107361. isFullscreen: boolean;
  107362. /**
  107363. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  107364. */
  107365. cullBackFaces: boolean;
  107366. /**
  107367. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  107368. */
  107369. renderEvenInBackground: boolean;
  107370. /**
  107371. * Gets or sets a boolean indicating that cache can be kept between frames
  107372. */
  107373. preventCacheWipeBetweenFrames: boolean;
  107374. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  107375. validateShaderPrograms: boolean;
  107376. /**
  107377. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  107378. * This can provide greater z depth for distant objects.
  107379. */
  107380. useReverseDepthBuffer: boolean;
  107381. /**
  107382. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  107383. */
  107384. disableUniformBuffers: boolean;
  107385. /** @hidden */
  107386. _uniformBuffers: UniformBuffer[];
  107387. /**
  107388. * Gets a boolean indicating that the engine supports uniform buffers
  107389. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  107390. */
  107391. get supportsUniformBuffers(): boolean;
  107392. /** @hidden */
  107393. _gl: WebGLRenderingContext;
  107394. /** @hidden */
  107395. _webGLVersion: number;
  107396. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  107397. protected _windowIsBackground: boolean;
  107398. protected _creationOptions: EngineOptions;
  107399. protected _highPrecisionShadersAllowed: boolean;
  107400. /** @hidden */
  107401. get _shouldUseHighPrecisionShader(): boolean;
  107402. /**
  107403. * Gets a boolean indicating that only power of 2 textures are supported
  107404. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  107405. */
  107406. get needPOTTextures(): boolean;
  107407. /** @hidden */
  107408. _badOS: boolean;
  107409. /** @hidden */
  107410. _badDesktopOS: boolean;
  107411. private _hardwareScalingLevel;
  107412. /** @hidden */
  107413. _caps: EngineCapabilities;
  107414. private _isStencilEnable;
  107415. private _glVersion;
  107416. private _glRenderer;
  107417. private _glVendor;
  107418. /** @hidden */
  107419. _videoTextureSupported: boolean;
  107420. protected _renderingQueueLaunched: boolean;
  107421. protected _activeRenderLoops: (() => void)[];
  107422. /**
  107423. * Observable signaled when a context lost event is raised
  107424. */
  107425. onContextLostObservable: Observable<ThinEngine>;
  107426. /**
  107427. * Observable signaled when a context restored event is raised
  107428. */
  107429. onContextRestoredObservable: Observable<ThinEngine>;
  107430. private _onContextLost;
  107431. private _onContextRestored;
  107432. protected _contextWasLost: boolean;
  107433. /** @hidden */
  107434. _doNotHandleContextLost: boolean;
  107435. /**
  107436. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  107437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  107438. */
  107439. get doNotHandleContextLost(): boolean;
  107440. set doNotHandleContextLost(value: boolean);
  107441. /**
  107442. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  107443. */
  107444. disableVertexArrayObjects: boolean;
  107445. /** @hidden */
  107446. protected _colorWrite: boolean;
  107447. /** @hidden */
  107448. protected _colorWriteChanged: boolean;
  107449. /** @hidden */
  107450. protected _depthCullingState: DepthCullingState;
  107451. /** @hidden */
  107452. protected _stencilState: StencilState;
  107453. /** @hidden */
  107454. _alphaState: AlphaState;
  107455. /** @hidden */
  107456. _alphaMode: number;
  107457. /** @hidden */
  107458. _alphaEquation: number;
  107459. /** @hidden */
  107460. _internalTexturesCache: InternalTexture[];
  107461. /** @hidden */
  107462. protected _activeChannel: number;
  107463. private _currentTextureChannel;
  107464. /** @hidden */
  107465. protected _boundTexturesCache: {
  107466. [key: string]: Nullable<InternalTexture>;
  107467. };
  107468. /** @hidden */
  107469. protected _currentEffect: Nullable<Effect>;
  107470. /** @hidden */
  107471. protected _currentProgram: Nullable<WebGLProgram>;
  107472. private _compiledEffects;
  107473. private _vertexAttribArraysEnabled;
  107474. /** @hidden */
  107475. protected _cachedViewport: Nullable<IViewportLike>;
  107476. private _cachedVertexArrayObject;
  107477. /** @hidden */
  107478. protected _cachedVertexBuffers: any;
  107479. /** @hidden */
  107480. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  107481. /** @hidden */
  107482. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  107483. /** @hidden */
  107484. _currentRenderTarget: Nullable<InternalTexture>;
  107485. private _uintIndicesCurrentlySet;
  107486. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  107487. /** @hidden */
  107488. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  107489. private _currentBufferPointers;
  107490. private _currentInstanceLocations;
  107491. private _currentInstanceBuffers;
  107492. private _textureUnits;
  107493. /** @hidden */
  107494. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107495. /** @hidden */
  107496. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107497. /** @hidden */
  107498. _boundRenderFunction: any;
  107499. private _vaoRecordInProgress;
  107500. private _mustWipeVertexAttributes;
  107501. private _emptyTexture;
  107502. private _emptyCubeTexture;
  107503. private _emptyTexture3D;
  107504. private _emptyTexture2DArray;
  107505. /** @hidden */
  107506. _frameHandler: number;
  107507. private _nextFreeTextureSlots;
  107508. private _maxSimultaneousTextures;
  107509. private _activeRequests;
  107510. /** @hidden */
  107511. _transformTextureUrl: Nullable<(url: string) => string>;
  107512. protected get _supportsHardwareTextureRescaling(): boolean;
  107513. private _framebufferDimensionsObject;
  107514. /**
  107515. * sets the object from which width and height will be taken from when getting render width and height
  107516. * Will fallback to the gl object
  107517. * @param dimensions the framebuffer width and height that will be used.
  107518. */
  107519. set framebufferDimensionsObject(dimensions: Nullable<{
  107520. framebufferWidth: number;
  107521. framebufferHeight: number;
  107522. }>);
  107523. /**
  107524. * Gets the current viewport
  107525. */
  107526. get currentViewport(): Nullable<IViewportLike>;
  107527. /**
  107528. * Gets the default empty texture
  107529. */
  107530. get emptyTexture(): InternalTexture;
  107531. /**
  107532. * Gets the default empty 3D texture
  107533. */
  107534. get emptyTexture3D(): InternalTexture;
  107535. /**
  107536. * Gets the default empty 2D array texture
  107537. */
  107538. get emptyTexture2DArray(): InternalTexture;
  107539. /**
  107540. * Gets the default empty cube texture
  107541. */
  107542. get emptyCubeTexture(): InternalTexture;
  107543. /**
  107544. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  107545. */
  107546. readonly premultipliedAlpha: boolean;
  107547. /**
  107548. * Observable event triggered before each texture is initialized
  107549. */
  107550. onBeforeTextureInitObservable: Observable<Texture>;
  107551. /**
  107552. * Creates a new engine
  107553. * @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
  107554. * @param antialias defines enable antialiasing (default: false)
  107555. * @param options defines further options to be sent to the getContext() function
  107556. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107557. */
  107558. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107559. private _rebuildInternalTextures;
  107560. private _rebuildEffects;
  107561. /**
  107562. * Gets a boolean indicating if all created effects are ready
  107563. * @returns true if all effects are ready
  107564. */
  107565. areAllEffectsReady(): boolean;
  107566. protected _rebuildBuffers(): void;
  107567. protected _initGLContext(): void;
  107568. /**
  107569. * Gets version of the current webGL context
  107570. */
  107571. get webGLVersion(): number;
  107572. /**
  107573. * Gets a string idenfifying the name of the class
  107574. * @returns "Engine" string
  107575. */
  107576. getClassName(): string;
  107577. /**
  107578. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  107579. */
  107580. get isStencilEnable(): boolean;
  107581. /** @hidden */
  107582. _prepareWorkingCanvas(): void;
  107583. /**
  107584. * Reset the texture cache to empty state
  107585. */
  107586. resetTextureCache(): void;
  107587. /**
  107588. * Gets an object containing information about the current webGL context
  107589. * @returns an object containing the vender, the renderer and the version of the current webGL context
  107590. */
  107591. getGlInfo(): {
  107592. vendor: string;
  107593. renderer: string;
  107594. version: string;
  107595. };
  107596. /**
  107597. * Defines the hardware scaling level.
  107598. * By default the hardware scaling level is computed from the window device ratio.
  107599. * 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.
  107600. * @param level defines the level to use
  107601. */
  107602. setHardwareScalingLevel(level: number): void;
  107603. /**
  107604. * Gets the current hardware scaling level.
  107605. * By default the hardware scaling level is computed from the window device ratio.
  107606. * 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.
  107607. * @returns a number indicating the current hardware scaling level
  107608. */
  107609. getHardwareScalingLevel(): number;
  107610. /**
  107611. * Gets the list of loaded textures
  107612. * @returns an array containing all loaded textures
  107613. */
  107614. getLoadedTexturesCache(): InternalTexture[];
  107615. /**
  107616. * Gets the object containing all engine capabilities
  107617. * @returns the EngineCapabilities object
  107618. */
  107619. getCaps(): EngineCapabilities;
  107620. /**
  107621. * stop executing a render loop function and remove it from the execution array
  107622. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  107623. */
  107624. stopRenderLoop(renderFunction?: () => void): void;
  107625. /** @hidden */
  107626. _renderLoop(): void;
  107627. /**
  107628. * Gets the HTML canvas attached with the current webGL context
  107629. * @returns a HTML canvas
  107630. */
  107631. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  107632. /**
  107633. * Gets host window
  107634. * @returns the host window object
  107635. */
  107636. getHostWindow(): Nullable<Window>;
  107637. /**
  107638. * Gets the current render width
  107639. * @param useScreen defines if screen size must be used (or the current render target if any)
  107640. * @returns a number defining the current render width
  107641. */
  107642. getRenderWidth(useScreen?: boolean): number;
  107643. /**
  107644. * Gets the current render height
  107645. * @param useScreen defines if screen size must be used (or the current render target if any)
  107646. * @returns a number defining the current render height
  107647. */
  107648. getRenderHeight(useScreen?: boolean): number;
  107649. /**
  107650. * Can be used to override the current requestAnimationFrame requester.
  107651. * @hidden
  107652. */
  107653. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  107654. /**
  107655. * Register and execute a render loop. The engine can have more than one render function
  107656. * @param renderFunction defines the function to continuously execute
  107657. */
  107658. runRenderLoop(renderFunction: () => void): void;
  107659. /**
  107660. * Clear the current render buffer or the current render target (if any is set up)
  107661. * @param color defines the color to use
  107662. * @param backBuffer defines if the back buffer must be cleared
  107663. * @param depth defines if the depth buffer must be cleared
  107664. * @param stencil defines if the stencil buffer must be cleared
  107665. */
  107666. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107667. private _viewportCached;
  107668. /** @hidden */
  107669. _viewport(x: number, y: number, width: number, height: number): void;
  107670. /**
  107671. * Set the WebGL's viewport
  107672. * @param viewport defines the viewport element to be used
  107673. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  107674. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  107675. */
  107676. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107677. /**
  107678. * Begin a new frame
  107679. */
  107680. beginFrame(): void;
  107681. /**
  107682. * Enf the current frame
  107683. */
  107684. endFrame(): void;
  107685. /**
  107686. * Resize the view according to the canvas' size
  107687. */
  107688. resize(): void;
  107689. /**
  107690. * Force a specific size of the canvas
  107691. * @param width defines the new canvas' width
  107692. * @param height defines the new canvas' height
  107693. */
  107694. setSize(width: number, height: number): void;
  107695. /**
  107696. * Binds the frame buffer to the specified texture.
  107697. * @param texture The texture to render to or null for the default canvas
  107698. * @param faceIndex The face of the texture to render to in case of cube texture
  107699. * @param requiredWidth The width of the target to render to
  107700. * @param requiredHeight The height of the target to render to
  107701. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  107702. * @param lodLevel defines the lod level to bind to the frame buffer
  107703. * @param layer defines the 2d array index to bind to frame buffer to
  107704. */
  107705. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  107706. /** @hidden */
  107707. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  107708. /**
  107709. * Unbind the current render target texture from the webGL context
  107710. * @param texture defines the render target texture to unbind
  107711. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107712. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107713. */
  107714. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107715. /**
  107716. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  107717. */
  107718. flushFramebuffer(): void;
  107719. /**
  107720. * Unbind the current render target and bind the default framebuffer
  107721. */
  107722. restoreDefaultFramebuffer(): void;
  107723. /** @hidden */
  107724. protected _resetVertexBufferBinding(): void;
  107725. /**
  107726. * Creates a vertex buffer
  107727. * @param data the data for the vertex buffer
  107728. * @returns the new WebGL static buffer
  107729. */
  107730. createVertexBuffer(data: DataArray): DataBuffer;
  107731. private _createVertexBuffer;
  107732. /**
  107733. * Creates a dynamic vertex buffer
  107734. * @param data the data for the dynamic vertex buffer
  107735. * @returns the new WebGL dynamic buffer
  107736. */
  107737. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  107738. protected _resetIndexBufferBinding(): void;
  107739. /**
  107740. * Creates a new index buffer
  107741. * @param indices defines the content of the index buffer
  107742. * @param updatable defines if the index buffer must be updatable
  107743. * @returns a new webGL buffer
  107744. */
  107745. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  107746. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  107747. /**
  107748. * Bind a webGL buffer to the webGL context
  107749. * @param buffer defines the buffer to bind
  107750. */
  107751. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  107752. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  107753. private bindBuffer;
  107754. /**
  107755. * update the bound buffer with the given data
  107756. * @param data defines the data to update
  107757. */
  107758. updateArrayBuffer(data: Float32Array): void;
  107759. private _vertexAttribPointer;
  107760. /** @hidden */
  107761. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  107762. private _bindVertexBuffersAttributes;
  107763. /**
  107764. * Records a vertex array object
  107765. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107766. * @param vertexBuffers defines the list of vertex buffers to store
  107767. * @param indexBuffer defines the index buffer to store
  107768. * @param effect defines the effect to store
  107769. * @returns the new vertex array object
  107770. */
  107771. recordVertexArrayObject(vertexBuffers: {
  107772. [key: string]: VertexBuffer;
  107773. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  107774. /**
  107775. * Bind a specific vertex array object
  107776. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  107777. * @param vertexArrayObject defines the vertex array object to bind
  107778. * @param indexBuffer defines the index buffer to bind
  107779. */
  107780. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  107781. /**
  107782. * Bind webGl buffers directly to the webGL context
  107783. * @param vertexBuffer defines the vertex buffer to bind
  107784. * @param indexBuffer defines the index buffer to bind
  107785. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  107786. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  107787. * @param effect defines the effect associated with the vertex buffer
  107788. */
  107789. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  107790. private _unbindVertexArrayObject;
  107791. /**
  107792. * Bind a list of vertex buffers to the webGL context
  107793. * @param vertexBuffers defines the list of vertex buffers to bind
  107794. * @param indexBuffer defines the index buffer to bind
  107795. * @param effect defines the effect associated with the vertex buffers
  107796. */
  107797. bindBuffers(vertexBuffers: {
  107798. [key: string]: Nullable<VertexBuffer>;
  107799. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  107800. /**
  107801. * Unbind all instance attributes
  107802. */
  107803. unbindInstanceAttributes(): void;
  107804. /**
  107805. * Release and free the memory of a vertex array object
  107806. * @param vao defines the vertex array object to delete
  107807. */
  107808. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  107809. /** @hidden */
  107810. _releaseBuffer(buffer: DataBuffer): boolean;
  107811. protected _deleteBuffer(buffer: DataBuffer): void;
  107812. /**
  107813. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  107814. * @param instancesBuffer defines the webGL buffer to update and bind
  107815. * @param data defines the data to store in the buffer
  107816. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  107817. */
  107818. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  107819. /**
  107820. * Bind the content of a webGL buffer used with instantiation
  107821. * @param instancesBuffer defines the webGL buffer to bind
  107822. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  107823. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  107824. */
  107825. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  107826. /**
  107827. * Disable the instance attribute corresponding to the name in parameter
  107828. * @param name defines the name of the attribute to disable
  107829. */
  107830. disableInstanceAttributeByName(name: string): void;
  107831. /**
  107832. * Disable the instance attribute corresponding to the location in parameter
  107833. * @param attributeLocation defines the attribute location of the attribute to disable
  107834. */
  107835. disableInstanceAttribute(attributeLocation: number): void;
  107836. /**
  107837. * Disable the attribute corresponding to the location in parameter
  107838. * @param attributeLocation defines the attribute location of the attribute to disable
  107839. */
  107840. disableAttributeByIndex(attributeLocation: number): void;
  107841. /**
  107842. * Send a draw order
  107843. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  107844. * @param indexStart defines the starting index
  107845. * @param indexCount defines the number of index to draw
  107846. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107847. */
  107848. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107849. /**
  107850. * Draw a list of points
  107851. * @param verticesStart defines the index of first vertex to draw
  107852. * @param verticesCount defines the count of vertices to draw
  107853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107854. */
  107855. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107856. /**
  107857. * Draw a list of unindexed primitives
  107858. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  107859. * @param verticesStart defines the index of first vertex to draw
  107860. * @param verticesCount defines the count of vertices to draw
  107861. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107862. */
  107863. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107864. /**
  107865. * Draw a list of indexed primitives
  107866. * @param fillMode defines the primitive to use
  107867. * @param indexStart defines the starting index
  107868. * @param indexCount defines the number of index to draw
  107869. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107870. */
  107871. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107872. /**
  107873. * Draw a list of unindexed primitives
  107874. * @param fillMode defines the primitive to use
  107875. * @param verticesStart defines the index of first vertex to draw
  107876. * @param verticesCount defines the count of vertices to draw
  107877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  107878. */
  107879. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107880. private _drawMode;
  107881. /** @hidden */
  107882. protected _reportDrawCall(): void;
  107883. /** @hidden */
  107884. _releaseEffect(effect: Effect): void;
  107885. /** @hidden */
  107886. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107887. /**
  107888. * Create a new effect (used to store vertex/fragment shaders)
  107889. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  107890. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  107891. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  107892. * @param samplers defines an array of string used to represent textures
  107893. * @param defines defines the string containing the defines to use to compile the shaders
  107894. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107895. * @param onCompiled defines a function to call when the effect creation is successful
  107896. * @param onError defines a function to call when the effect creation has failed
  107897. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  107898. * @returns the new Effect
  107899. */
  107900. 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;
  107901. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  107902. private _compileShader;
  107903. private _compileRawShader;
  107904. /** @hidden */
  107905. _getShaderSource(shader: WebGLShader): Nullable<string>;
  107906. /**
  107907. * Directly creates a webGL program
  107908. * @param pipelineContext defines the pipeline context to attach to
  107909. * @param vertexCode defines the vertex shader code to use
  107910. * @param fragmentCode defines the fragment shader code to use
  107911. * @param context defines the webGL context to use (if not set, the current one will be used)
  107912. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  107913. * @returns the new webGL program
  107914. */
  107915. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107916. /**
  107917. * Creates a webGL program
  107918. * @param pipelineContext defines the pipeline context to attach to
  107919. * @param vertexCode defines the vertex shader code to use
  107920. * @param fragmentCode defines the fragment shader code to use
  107921. * @param defines defines the string containing the defines to use to compile the shaders
  107922. * @param context defines the webGL context to use (if not set, the current one will be used)
  107923. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  107924. * @returns the new webGL program
  107925. */
  107926. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107927. /**
  107928. * Creates a new pipeline context
  107929. * @returns the new pipeline
  107930. */
  107931. createPipelineContext(): IPipelineContext;
  107932. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107933. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  107934. /** @hidden */
  107935. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  107936. /** @hidden */
  107937. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  107938. /** @hidden */
  107939. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  107940. /**
  107941. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  107942. * @param pipelineContext defines the pipeline context to use
  107943. * @param uniformsNames defines the list of uniform names
  107944. * @returns an array of webGL uniform locations
  107945. */
  107946. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  107947. /**
  107948. * Gets the lsit of active attributes for a given webGL program
  107949. * @param pipelineContext defines the pipeline context to use
  107950. * @param attributesNames defines the list of attribute names to get
  107951. * @returns an array of indices indicating the offset of each attribute
  107952. */
  107953. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  107954. /**
  107955. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  107956. * @param effect defines the effect to activate
  107957. */
  107958. enableEffect(effect: Nullable<Effect>): void;
  107959. /**
  107960. * Set the value of an uniform to a number (int)
  107961. * @param uniform defines the webGL uniform location where to store the value
  107962. * @param value defines the int number to store
  107963. */
  107964. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  107965. /**
  107966. * Set the value of an uniform to an array of int32
  107967. * @param uniform defines the webGL uniform location where to store the value
  107968. * @param array defines the array of int32 to store
  107969. */
  107970. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107971. /**
  107972. * Set the value of an uniform to an array of int32 (stored as vec2)
  107973. * @param uniform defines the webGL uniform location where to store the value
  107974. * @param array defines the array of int32 to store
  107975. */
  107976. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107977. /**
  107978. * Set the value of an uniform to an array of int32 (stored as vec3)
  107979. * @param uniform defines the webGL uniform location where to store the value
  107980. * @param array defines the array of int32 to store
  107981. */
  107982. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107983. /**
  107984. * Set the value of an uniform to an array of int32 (stored as vec4)
  107985. * @param uniform defines the webGL uniform location where to store the value
  107986. * @param array defines the array of int32 to store
  107987. */
  107988. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  107989. /**
  107990. * Set the value of an uniform to an array of number
  107991. * @param uniform defines the webGL uniform location where to store the value
  107992. * @param array defines the array of number to store
  107993. */
  107994. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  107995. /**
  107996. * Set the value of an uniform to an array of number (stored as vec2)
  107997. * @param uniform defines the webGL uniform location where to store the value
  107998. * @param array defines the array of number to store
  107999. */
  108000. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108001. /**
  108002. * Set the value of an uniform to an array of number (stored as vec3)
  108003. * @param uniform defines the webGL uniform location where to store the value
  108004. * @param array defines the array of number to store
  108005. */
  108006. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108007. /**
  108008. * Set the value of an uniform to an array of number (stored as vec4)
  108009. * @param uniform defines the webGL uniform location where to store the value
  108010. * @param array defines the array of number to store
  108011. */
  108012. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  108013. /**
  108014. * Set the value of an uniform to an array of float32 (stored as matrices)
  108015. * @param uniform defines the webGL uniform location where to store the value
  108016. * @param matrices defines the array of float32 to store
  108017. */
  108018. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  108019. /**
  108020. * Set the value of an uniform to a matrix (3x3)
  108021. * @param uniform defines the webGL uniform location where to store the value
  108022. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  108023. */
  108024. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108025. /**
  108026. * Set the value of an uniform to a matrix (2x2)
  108027. * @param uniform defines the webGL uniform location where to store the value
  108028. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  108029. */
  108030. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  108031. /**
  108032. * Set the value of an uniform to a number (float)
  108033. * @param uniform defines the webGL uniform location where to store the value
  108034. * @param value defines the float number to store
  108035. */
  108036. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  108037. /**
  108038. * Set the value of an uniform to a vec2
  108039. * @param uniform defines the webGL uniform location where to store the value
  108040. * @param x defines the 1st component of the value
  108041. * @param y defines the 2nd component of the value
  108042. */
  108043. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  108044. /**
  108045. * Set the value of an uniform to a vec3
  108046. * @param uniform defines the webGL uniform location where to store the value
  108047. * @param x defines the 1st component of the value
  108048. * @param y defines the 2nd component of the value
  108049. * @param z defines the 3rd component of the value
  108050. */
  108051. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  108052. /**
  108053. * Set the value of an uniform to a vec4
  108054. * @param uniform defines the webGL uniform location where to store the value
  108055. * @param x defines the 1st component of the value
  108056. * @param y defines the 2nd component of the value
  108057. * @param z defines the 3rd component of the value
  108058. * @param w defines the 4th component of the value
  108059. */
  108060. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  108061. /**
  108062. * Apply all cached states (depth, culling, stencil and alpha)
  108063. */
  108064. applyStates(): void;
  108065. /**
  108066. * Enable or disable color writing
  108067. * @param enable defines the state to set
  108068. */
  108069. setColorWrite(enable: boolean): void;
  108070. /**
  108071. * Gets a boolean indicating if color writing is enabled
  108072. * @returns the current color writing state
  108073. */
  108074. getColorWrite(): boolean;
  108075. /**
  108076. * Gets the depth culling state manager
  108077. */
  108078. get depthCullingState(): DepthCullingState;
  108079. /**
  108080. * Gets the alpha state manager
  108081. */
  108082. get alphaState(): AlphaState;
  108083. /**
  108084. * Gets the stencil state manager
  108085. */
  108086. get stencilState(): StencilState;
  108087. /**
  108088. * Clears the list of texture accessible through engine.
  108089. * This can help preventing texture load conflict due to name collision.
  108090. */
  108091. clearInternalTexturesCache(): void;
  108092. /**
  108093. * Force the entire cache to be cleared
  108094. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  108095. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  108096. */
  108097. wipeCaches(bruteForce?: boolean): void;
  108098. /** @hidden */
  108099. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  108100. min: number;
  108101. mag: number;
  108102. };
  108103. /** @hidden */
  108104. _createTexture(): WebGLTexture;
  108105. /**
  108106. * Usually called from Texture.ts.
  108107. * Passed information to create a WebGLTexture
  108108. * @param url defines a value which contains one of the following:
  108109. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  108110. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  108111. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  108112. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  108113. * @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)
  108114. * @param scene needed for loading to the correct scene
  108115. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  108116. * @param onLoad optional callback to be called upon successful completion
  108117. * @param onError optional callback to be called upon failure
  108118. * @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
  108119. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  108120. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  108121. * @param forcedExtension defines the extension to use to pick the right loader
  108122. * @param mimeType defines an optional mime type
  108123. * @returns a InternalTexture for assignment back into BABYLON.Texture
  108124. */
  108125. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  108126. /**
  108127. * Loads an image as an HTMLImageElement.
  108128. * @param input url string, ArrayBuffer, or Blob to load
  108129. * @param onLoad callback called when the image successfully loads
  108130. * @param onError callback called when the image fails to load
  108131. * @param offlineProvider offline provider for caching
  108132. * @param mimeType optional mime type
  108133. * @returns the HTMLImageElement of the loaded image
  108134. * @hidden
  108135. */
  108136. 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>;
  108137. /**
  108138. * @hidden
  108139. */
  108140. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108141. private _unpackFlipYCached;
  108142. /**
  108143. * In case you are sharing the context with other applications, it might
  108144. * be interested to not cache the unpack flip y state to ensure a consistent
  108145. * value would be set.
  108146. */
  108147. enableUnpackFlipYCached: boolean;
  108148. /** @hidden */
  108149. _unpackFlipY(value: boolean): void;
  108150. /** @hidden */
  108151. _getUnpackAlignement(): number;
  108152. private _getTextureTarget;
  108153. /**
  108154. * Update the sampling mode of a given texture
  108155. * @param samplingMode defines the required sampling mode
  108156. * @param texture defines the texture to update
  108157. * @param generateMipMaps defines whether to generate mipmaps for the texture
  108158. */
  108159. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  108160. /**
  108161. * Update the sampling mode of a given texture
  108162. * @param texture defines the texture to update
  108163. * @param wrapU defines the texture wrap mode of the u coordinates
  108164. * @param wrapV defines the texture wrap mode of the v coordinates
  108165. * @param wrapR defines the texture wrap mode of the r coordinates
  108166. */
  108167. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  108168. /** @hidden */
  108169. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  108170. width: number;
  108171. height: number;
  108172. layers?: number;
  108173. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  108174. /** @hidden */
  108175. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108176. /** @hidden */
  108177. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  108178. /**
  108179. * Update a portion of an internal texture
  108180. * @param texture defines the texture to update
  108181. * @param imageData defines the data to store into the texture
  108182. * @param xOffset defines the x coordinates of the update rectangle
  108183. * @param yOffset defines the y coordinates of the update rectangle
  108184. * @param width defines the width of the update rectangle
  108185. * @param height defines the height of the update rectangle
  108186. * @param faceIndex defines the face index if texture is a cube (0 by default)
  108187. * @param lod defines the lod level to update (0 by default)
  108188. */
  108189. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  108190. /** @hidden */
  108191. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108192. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  108193. private _prepareWebGLTexture;
  108194. /** @hidden */
  108195. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  108196. private _getDepthStencilBuffer;
  108197. /** @hidden */
  108198. _releaseFramebufferObjects(texture: InternalTexture): void;
  108199. /** @hidden */
  108200. _releaseTexture(texture: InternalTexture): void;
  108201. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  108202. protected _setProgram(program: WebGLProgram): void;
  108203. protected _boundUniforms: {
  108204. [key: number]: WebGLUniformLocation;
  108205. };
  108206. /**
  108207. * Binds an effect to the webGL context
  108208. * @param effect defines the effect to bind
  108209. */
  108210. bindSamplers(effect: Effect): void;
  108211. private _activateCurrentTexture;
  108212. /** @hidden */
  108213. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  108214. /** @hidden */
  108215. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  108216. /**
  108217. * Unbind all textures from the webGL context
  108218. */
  108219. unbindAllTextures(): void;
  108220. /**
  108221. * Sets a texture to the according uniform.
  108222. * @param channel The texture channel
  108223. * @param uniform The uniform to set
  108224. * @param texture The texture to apply
  108225. */
  108226. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  108227. private _bindSamplerUniformToChannel;
  108228. private _getTextureWrapMode;
  108229. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  108230. /**
  108231. * Sets an array of texture to the webGL context
  108232. * @param channel defines the channel where the texture array must be set
  108233. * @param uniform defines the associated uniform location
  108234. * @param textures defines the array of textures to bind
  108235. */
  108236. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  108237. /** @hidden */
  108238. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  108239. private _setTextureParameterFloat;
  108240. private _setTextureParameterInteger;
  108241. /**
  108242. * Unbind all vertex attributes from the webGL context
  108243. */
  108244. unbindAllAttributes(): void;
  108245. /**
  108246. * 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
  108247. */
  108248. releaseEffects(): void;
  108249. /**
  108250. * Dispose and release all associated resources
  108251. */
  108252. dispose(): void;
  108253. /**
  108254. * Attach a new callback raised when context lost event is fired
  108255. * @param callback defines the callback to call
  108256. */
  108257. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108258. /**
  108259. * Attach a new callback raised when context restored event is fired
  108260. * @param callback defines the callback to call
  108261. */
  108262. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  108263. /**
  108264. * Get the current error code of the webGL context
  108265. * @returns the error code
  108266. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108267. */
  108268. getError(): number;
  108269. private _canRenderToFloatFramebuffer;
  108270. private _canRenderToHalfFloatFramebuffer;
  108271. private _canRenderToFramebuffer;
  108272. /** @hidden */
  108273. _getWebGLTextureType(type: number): number;
  108274. /** @hidden */
  108275. _getInternalFormat(format: number): number;
  108276. /** @hidden */
  108277. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  108278. /** @hidden */
  108279. _getRGBAMultiSampleBufferFormat(type: number): number;
  108280. /** @hidden */
  108281. _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;
  108282. /**
  108283. * Loads a file from a url
  108284. * @param url url to load
  108285. * @param onSuccess callback called when the file successfully loads
  108286. * @param onProgress callback called while file is loading (if the server supports this mode)
  108287. * @param offlineProvider defines the offline provider for caching
  108288. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108289. * @param onError callback called when the file fails to load
  108290. * @returns a file request object
  108291. * @hidden
  108292. */
  108293. 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;
  108294. /**
  108295. * Reads pixels from the current frame buffer. Please note that this function can be slow
  108296. * @param x defines the x coordinate of the rectangle where pixels must be read
  108297. * @param y defines the y coordinate of the rectangle where pixels must be read
  108298. * @param width defines the width of the rectangle where pixels must be read
  108299. * @param height defines the height of the rectangle where pixels must be read
  108300. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  108301. * @returns a Uint8Array containing RGBA colors
  108302. */
  108303. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  108304. private static _isSupported;
  108305. /**
  108306. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  108307. * @returns true if the engine can be created
  108308. * @ignorenaming
  108309. */
  108310. static isSupported(): boolean;
  108311. /**
  108312. * Find the next highest power of two.
  108313. * @param x Number to start search from.
  108314. * @return Next highest power of two.
  108315. */
  108316. static CeilingPOT(x: number): number;
  108317. /**
  108318. * Find the next lowest power of two.
  108319. * @param x Number to start search from.
  108320. * @return Next lowest power of two.
  108321. */
  108322. static FloorPOT(x: number): number;
  108323. /**
  108324. * Find the nearest power of two.
  108325. * @param x Number to start search from.
  108326. * @return Next nearest power of two.
  108327. */
  108328. static NearestPOT(x: number): number;
  108329. /**
  108330. * Get the closest exponent of two
  108331. * @param value defines the value to approximate
  108332. * @param max defines the maximum value to return
  108333. * @param mode defines how to define the closest value
  108334. * @returns closest exponent of two of the given value
  108335. */
  108336. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  108337. /**
  108338. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  108339. * @param func - the function to be called
  108340. * @param requester - the object that will request the next frame. Falls back to window.
  108341. * @returns frame number
  108342. */
  108343. static QueueNewFrame(func: () => void, requester?: any): number;
  108344. /**
  108345. * Gets host document
  108346. * @returns the host document object
  108347. */
  108348. getHostDocument(): Nullable<Document>;
  108349. }
  108350. }
  108351. declare module BABYLON {
  108352. /**
  108353. * Class representing spherical harmonics coefficients to the 3rd degree
  108354. */
  108355. export class SphericalHarmonics {
  108356. /**
  108357. * Defines whether or not the harmonics have been prescaled for rendering.
  108358. */
  108359. preScaled: boolean;
  108360. /**
  108361. * The l0,0 coefficients of the spherical harmonics
  108362. */
  108363. l00: Vector3;
  108364. /**
  108365. * The l1,-1 coefficients of the spherical harmonics
  108366. */
  108367. l1_1: Vector3;
  108368. /**
  108369. * The l1,0 coefficients of the spherical harmonics
  108370. */
  108371. l10: Vector3;
  108372. /**
  108373. * The l1,1 coefficients of the spherical harmonics
  108374. */
  108375. l11: Vector3;
  108376. /**
  108377. * The l2,-2 coefficients of the spherical harmonics
  108378. */
  108379. l2_2: Vector3;
  108380. /**
  108381. * The l2,-1 coefficients of the spherical harmonics
  108382. */
  108383. l2_1: Vector3;
  108384. /**
  108385. * The l2,0 coefficients of the spherical harmonics
  108386. */
  108387. l20: Vector3;
  108388. /**
  108389. * The l2,1 coefficients of the spherical harmonics
  108390. */
  108391. l21: Vector3;
  108392. /**
  108393. * The l2,2 coefficients of the spherical harmonics
  108394. */
  108395. l22: Vector3;
  108396. /**
  108397. * Adds a light to the spherical harmonics
  108398. * @param direction the direction of the light
  108399. * @param color the color of the light
  108400. * @param deltaSolidAngle the delta solid angle of the light
  108401. */
  108402. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  108403. /**
  108404. * Scales the spherical harmonics by the given amount
  108405. * @param scale the amount to scale
  108406. */
  108407. scaleInPlace(scale: number): void;
  108408. /**
  108409. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  108410. *
  108411. * ```
  108412. * E_lm = A_l * L_lm
  108413. * ```
  108414. *
  108415. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  108416. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  108417. * the scaling factors are given in equation 9.
  108418. */
  108419. convertIncidentRadianceToIrradiance(): void;
  108420. /**
  108421. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  108422. *
  108423. * ```
  108424. * L = (1/pi) * E * rho
  108425. * ```
  108426. *
  108427. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  108428. */
  108429. convertIrradianceToLambertianRadiance(): void;
  108430. /**
  108431. * Integrates the reconstruction coefficients directly in to the SH preventing further
  108432. * required operations at run time.
  108433. *
  108434. * This is simply done by scaling back the SH with Ylm constants parameter.
  108435. * The trigonometric part being applied by the shader at run time.
  108436. */
  108437. preScaleForRendering(): void;
  108438. /**
  108439. * Constructs a spherical harmonics from an array.
  108440. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  108441. * @returns the spherical harmonics
  108442. */
  108443. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  108444. /**
  108445. * Gets the spherical harmonics from polynomial
  108446. * @param polynomial the spherical polynomial
  108447. * @returns the spherical harmonics
  108448. */
  108449. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  108450. }
  108451. /**
  108452. * Class representing spherical polynomial coefficients to the 3rd degree
  108453. */
  108454. export class SphericalPolynomial {
  108455. private _harmonics;
  108456. /**
  108457. * The spherical harmonics used to create the polynomials.
  108458. */
  108459. get preScaledHarmonics(): SphericalHarmonics;
  108460. /**
  108461. * The x coefficients of the spherical polynomial
  108462. */
  108463. x: Vector3;
  108464. /**
  108465. * The y coefficients of the spherical polynomial
  108466. */
  108467. y: Vector3;
  108468. /**
  108469. * The z coefficients of the spherical polynomial
  108470. */
  108471. z: Vector3;
  108472. /**
  108473. * The xx coefficients of the spherical polynomial
  108474. */
  108475. xx: Vector3;
  108476. /**
  108477. * The yy coefficients of the spherical polynomial
  108478. */
  108479. yy: Vector3;
  108480. /**
  108481. * The zz coefficients of the spherical polynomial
  108482. */
  108483. zz: Vector3;
  108484. /**
  108485. * The xy coefficients of the spherical polynomial
  108486. */
  108487. xy: Vector3;
  108488. /**
  108489. * The yz coefficients of the spherical polynomial
  108490. */
  108491. yz: Vector3;
  108492. /**
  108493. * The zx coefficients of the spherical polynomial
  108494. */
  108495. zx: Vector3;
  108496. /**
  108497. * Adds an ambient color to the spherical polynomial
  108498. * @param color the color to add
  108499. */
  108500. addAmbient(color: Color3): void;
  108501. /**
  108502. * Scales the spherical polynomial by the given amount
  108503. * @param scale the amount to scale
  108504. */
  108505. scaleInPlace(scale: number): void;
  108506. /**
  108507. * Gets the spherical polynomial from harmonics
  108508. * @param harmonics the spherical harmonics
  108509. * @returns the spherical polynomial
  108510. */
  108511. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  108512. /**
  108513. * Constructs a spherical polynomial from an array.
  108514. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  108515. * @returns the spherical polynomial
  108516. */
  108517. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  108518. }
  108519. }
  108520. declare module BABYLON {
  108521. /**
  108522. * Defines the source of the internal texture
  108523. */
  108524. export enum InternalTextureSource {
  108525. /**
  108526. * The source of the texture data is unknown
  108527. */
  108528. Unknown = 0,
  108529. /**
  108530. * Texture data comes from an URL
  108531. */
  108532. Url = 1,
  108533. /**
  108534. * Texture data is only used for temporary storage
  108535. */
  108536. Temp = 2,
  108537. /**
  108538. * Texture data comes from raw data (ArrayBuffer)
  108539. */
  108540. Raw = 3,
  108541. /**
  108542. * Texture content is dynamic (video or dynamic texture)
  108543. */
  108544. Dynamic = 4,
  108545. /**
  108546. * Texture content is generated by rendering to it
  108547. */
  108548. RenderTarget = 5,
  108549. /**
  108550. * Texture content is part of a multi render target process
  108551. */
  108552. MultiRenderTarget = 6,
  108553. /**
  108554. * Texture data comes from a cube data file
  108555. */
  108556. Cube = 7,
  108557. /**
  108558. * Texture data comes from a raw cube data
  108559. */
  108560. CubeRaw = 8,
  108561. /**
  108562. * Texture data come from a prefiltered cube data file
  108563. */
  108564. CubePrefiltered = 9,
  108565. /**
  108566. * Texture content is raw 3D data
  108567. */
  108568. Raw3D = 10,
  108569. /**
  108570. * Texture content is raw 2D array data
  108571. */
  108572. Raw2DArray = 11,
  108573. /**
  108574. * Texture content is a depth texture
  108575. */
  108576. Depth = 12,
  108577. /**
  108578. * Texture data comes from a raw cube data encoded with RGBD
  108579. */
  108580. CubeRawRGBD = 13
  108581. }
  108582. /**
  108583. * Class used to store data associated with WebGL texture data for the engine
  108584. * This class should not be used directly
  108585. */
  108586. export class InternalTexture {
  108587. /** @hidden */
  108588. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  108589. /**
  108590. * Defines if the texture is ready
  108591. */
  108592. isReady: boolean;
  108593. /**
  108594. * Defines if the texture is a cube texture
  108595. */
  108596. isCube: boolean;
  108597. /**
  108598. * Defines if the texture contains 3D data
  108599. */
  108600. is3D: boolean;
  108601. /**
  108602. * Defines if the texture contains 2D array data
  108603. */
  108604. is2DArray: boolean;
  108605. /**
  108606. * Defines if the texture contains multiview data
  108607. */
  108608. isMultiview: boolean;
  108609. /**
  108610. * Gets the URL used to load this texture
  108611. */
  108612. url: string;
  108613. /**
  108614. * Gets the sampling mode of the texture
  108615. */
  108616. samplingMode: number;
  108617. /**
  108618. * Gets a boolean indicating if the texture needs mipmaps generation
  108619. */
  108620. generateMipMaps: boolean;
  108621. /**
  108622. * Gets the number of samples used by the texture (WebGL2+ only)
  108623. */
  108624. samples: number;
  108625. /**
  108626. * Gets the type of the texture (int, float...)
  108627. */
  108628. type: number;
  108629. /**
  108630. * Gets the format of the texture (RGB, RGBA...)
  108631. */
  108632. format: number;
  108633. /**
  108634. * Observable called when the texture is loaded
  108635. */
  108636. onLoadedObservable: Observable<InternalTexture>;
  108637. /**
  108638. * Gets the width of the texture
  108639. */
  108640. width: number;
  108641. /**
  108642. * Gets the height of the texture
  108643. */
  108644. height: number;
  108645. /**
  108646. * Gets the depth of the texture
  108647. */
  108648. depth: number;
  108649. /**
  108650. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  108651. */
  108652. baseWidth: number;
  108653. /**
  108654. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  108655. */
  108656. baseHeight: number;
  108657. /**
  108658. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  108659. */
  108660. baseDepth: number;
  108661. /**
  108662. * Gets a boolean indicating if the texture is inverted on Y axis
  108663. */
  108664. invertY: boolean;
  108665. /** @hidden */
  108666. _invertVScale: boolean;
  108667. /** @hidden */
  108668. _associatedChannel: number;
  108669. /** @hidden */
  108670. _source: InternalTextureSource;
  108671. /** @hidden */
  108672. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108673. /** @hidden */
  108674. _bufferView: Nullable<ArrayBufferView>;
  108675. /** @hidden */
  108676. _bufferViewArray: Nullable<ArrayBufferView[]>;
  108677. /** @hidden */
  108678. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  108679. /** @hidden */
  108680. _size: number;
  108681. /** @hidden */
  108682. _extension: string;
  108683. /** @hidden */
  108684. _files: Nullable<string[]>;
  108685. /** @hidden */
  108686. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  108687. /** @hidden */
  108688. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  108689. /** @hidden */
  108690. _framebuffer: Nullable<WebGLFramebuffer>;
  108691. /** @hidden */
  108692. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  108693. /** @hidden */
  108694. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  108695. /** @hidden */
  108696. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  108697. /** @hidden */
  108698. _attachments: Nullable<number[]>;
  108699. /** @hidden */
  108700. _cachedCoordinatesMode: Nullable<number>;
  108701. /** @hidden */
  108702. _cachedWrapU: Nullable<number>;
  108703. /** @hidden */
  108704. _cachedWrapV: Nullable<number>;
  108705. /** @hidden */
  108706. _cachedWrapR: Nullable<number>;
  108707. /** @hidden */
  108708. _cachedAnisotropicFilteringLevel: Nullable<number>;
  108709. /** @hidden */
  108710. _isDisabled: boolean;
  108711. /** @hidden */
  108712. _compression: Nullable<string>;
  108713. /** @hidden */
  108714. _generateStencilBuffer: boolean;
  108715. /** @hidden */
  108716. _generateDepthBuffer: boolean;
  108717. /** @hidden */
  108718. _comparisonFunction: number;
  108719. /** @hidden */
  108720. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  108721. /** @hidden */
  108722. _lodGenerationScale: number;
  108723. /** @hidden */
  108724. _lodGenerationOffset: number;
  108725. /** @hidden */
  108726. _depthStencilTexture: Nullable<InternalTexture>;
  108727. /** @hidden */
  108728. _colorTextureArray: Nullable<WebGLTexture>;
  108729. /** @hidden */
  108730. _depthStencilTextureArray: Nullable<WebGLTexture>;
  108731. /** @hidden */
  108732. _lodTextureHigh: Nullable<BaseTexture>;
  108733. /** @hidden */
  108734. _lodTextureMid: Nullable<BaseTexture>;
  108735. /** @hidden */
  108736. _lodTextureLow: Nullable<BaseTexture>;
  108737. /** @hidden */
  108738. _isRGBD: boolean;
  108739. /** @hidden */
  108740. _linearSpecularLOD: boolean;
  108741. /** @hidden */
  108742. _irradianceTexture: Nullable<BaseTexture>;
  108743. /** @hidden */
  108744. _webGLTexture: Nullable<WebGLTexture>;
  108745. /** @hidden */
  108746. _references: number;
  108747. private _engine;
  108748. /**
  108749. * Gets the Engine the texture belongs to.
  108750. * @returns The babylon engine
  108751. */
  108752. getEngine(): ThinEngine;
  108753. /**
  108754. * Gets the data source type of the texture
  108755. */
  108756. get source(): InternalTextureSource;
  108757. /**
  108758. * Creates a new InternalTexture
  108759. * @param engine defines the engine to use
  108760. * @param source defines the type of data that will be used
  108761. * @param delayAllocation if the texture allocation should be delayed (default: false)
  108762. */
  108763. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  108764. /**
  108765. * Increments the number of references (ie. the number of Texture that point to it)
  108766. */
  108767. incrementReferences(): void;
  108768. /**
  108769. * Change the size of the texture (not the size of the content)
  108770. * @param width defines the new width
  108771. * @param height defines the new height
  108772. * @param depth defines the new depth (1 by default)
  108773. */
  108774. updateSize(width: int, height: int, depth?: int): void;
  108775. /** @hidden */
  108776. _rebuild(): void;
  108777. /** @hidden */
  108778. _swapAndDie(target: InternalTexture): void;
  108779. /**
  108780. * Dispose the current allocated resources
  108781. */
  108782. dispose(): void;
  108783. }
  108784. }
  108785. declare module BABYLON {
  108786. /**
  108787. * Class used to work with sound analyzer using fast fourier transform (FFT)
  108788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108789. */
  108790. export class Analyser {
  108791. /**
  108792. * Gets or sets the smoothing
  108793. * @ignorenaming
  108794. */
  108795. SMOOTHING: number;
  108796. /**
  108797. * Gets or sets the FFT table size
  108798. * @ignorenaming
  108799. */
  108800. FFT_SIZE: number;
  108801. /**
  108802. * Gets or sets the bar graph amplitude
  108803. * @ignorenaming
  108804. */
  108805. BARGRAPHAMPLITUDE: number;
  108806. /**
  108807. * Gets or sets the position of the debug canvas
  108808. * @ignorenaming
  108809. */
  108810. DEBUGCANVASPOS: {
  108811. x: number;
  108812. y: number;
  108813. };
  108814. /**
  108815. * Gets or sets the debug canvas size
  108816. * @ignorenaming
  108817. */
  108818. DEBUGCANVASSIZE: {
  108819. width: number;
  108820. height: number;
  108821. };
  108822. private _byteFreqs;
  108823. private _byteTime;
  108824. private _floatFreqs;
  108825. private _webAudioAnalyser;
  108826. private _debugCanvas;
  108827. private _debugCanvasContext;
  108828. private _scene;
  108829. private _registerFunc;
  108830. private _audioEngine;
  108831. /**
  108832. * Creates a new analyser
  108833. * @param scene defines hosting scene
  108834. */
  108835. constructor(scene: Scene);
  108836. /**
  108837. * Get the number of data values you will have to play with for the visualization
  108838. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  108839. * @returns a number
  108840. */
  108841. getFrequencyBinCount(): number;
  108842. /**
  108843. * Gets the current frequency data as a byte array
  108844. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  108845. * @returns a Uint8Array
  108846. */
  108847. getByteFrequencyData(): Uint8Array;
  108848. /**
  108849. * Gets the current waveform as a byte array
  108850. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  108851. * @returns a Uint8Array
  108852. */
  108853. getByteTimeDomainData(): Uint8Array;
  108854. /**
  108855. * Gets the current frequency data as a float array
  108856. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  108857. * @returns a Float32Array
  108858. */
  108859. getFloatFrequencyData(): Float32Array;
  108860. /**
  108861. * Renders the debug canvas
  108862. */
  108863. drawDebugCanvas(): void;
  108864. /**
  108865. * Stops rendering the debug canvas and removes it
  108866. */
  108867. stopDebugCanvas(): void;
  108868. /**
  108869. * Connects two audio nodes
  108870. * @param inputAudioNode defines first node to connect
  108871. * @param outputAudioNode defines second node to connect
  108872. */
  108873. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  108874. /**
  108875. * Releases all associated resources
  108876. */
  108877. dispose(): void;
  108878. }
  108879. }
  108880. declare module BABYLON {
  108881. /**
  108882. * This represents an audio engine and it is responsible
  108883. * to play, synchronize and analyse sounds throughout the application.
  108884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108885. */
  108886. export interface IAudioEngine extends IDisposable {
  108887. /**
  108888. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  108889. */
  108890. readonly canUseWebAudio: boolean;
  108891. /**
  108892. * Gets the current AudioContext if available.
  108893. */
  108894. readonly audioContext: Nullable<AudioContext>;
  108895. /**
  108896. * The master gain node defines the global audio volume of your audio engine.
  108897. */
  108898. readonly masterGain: GainNode;
  108899. /**
  108900. * Gets whether or not mp3 are supported by your browser.
  108901. */
  108902. readonly isMP3supported: boolean;
  108903. /**
  108904. * Gets whether or not ogg are supported by your browser.
  108905. */
  108906. readonly isOGGsupported: boolean;
  108907. /**
  108908. * Defines if Babylon should emit a warning if WebAudio is not supported.
  108909. * @ignoreNaming
  108910. */
  108911. WarnedWebAudioUnsupported: boolean;
  108912. /**
  108913. * Defines if the audio engine relies on a custom unlocked button.
  108914. * In this case, the embedded button will not be displayed.
  108915. */
  108916. useCustomUnlockedButton: boolean;
  108917. /**
  108918. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  108919. */
  108920. readonly unlocked: boolean;
  108921. /**
  108922. * Event raised when audio has been unlocked on the browser.
  108923. */
  108924. onAudioUnlockedObservable: Observable<AudioEngine>;
  108925. /**
  108926. * Event raised when audio has been locked on the browser.
  108927. */
  108928. onAudioLockedObservable: Observable<AudioEngine>;
  108929. /**
  108930. * Flags the audio engine in Locked state.
  108931. * This happens due to new browser policies preventing audio to autoplay.
  108932. */
  108933. lock(): void;
  108934. /**
  108935. * Unlocks the audio engine once a user action has been done on the dom.
  108936. * This is helpful to resume play once browser policies have been satisfied.
  108937. */
  108938. unlock(): void;
  108939. /**
  108940. * Gets the global volume sets on the master gain.
  108941. * @returns the global volume if set or -1 otherwise
  108942. */
  108943. getGlobalVolume(): number;
  108944. /**
  108945. * Sets the global volume of your experience (sets on the master gain).
  108946. * @param newVolume Defines the new global volume of the application
  108947. */
  108948. setGlobalVolume(newVolume: number): void;
  108949. /**
  108950. * Connect the audio engine to an audio analyser allowing some amazing
  108951. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108953. * @param analyser The analyser to connect to the engine
  108954. */
  108955. connectToAnalyser(analyser: Analyser): void;
  108956. }
  108957. /**
  108958. * This represents the default audio engine used in babylon.
  108959. * It is responsible to play, synchronize and analyse sounds throughout the application.
  108960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108961. */
  108962. export class AudioEngine implements IAudioEngine {
  108963. private _audioContext;
  108964. private _audioContextInitialized;
  108965. private _muteButton;
  108966. private _hostElement;
  108967. /**
  108968. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  108969. */
  108970. canUseWebAudio: boolean;
  108971. /**
  108972. * The master gain node defines the global audio volume of your audio engine.
  108973. */
  108974. masterGain: GainNode;
  108975. /**
  108976. * Defines if Babylon should emit a warning if WebAudio is not supported.
  108977. * @ignoreNaming
  108978. */
  108979. WarnedWebAudioUnsupported: boolean;
  108980. /**
  108981. * Gets whether or not mp3 are supported by your browser.
  108982. */
  108983. isMP3supported: boolean;
  108984. /**
  108985. * Gets whether or not ogg are supported by your browser.
  108986. */
  108987. isOGGsupported: boolean;
  108988. /**
  108989. * Gets whether audio has been unlocked on the device.
  108990. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  108991. * a user interaction has happened.
  108992. */
  108993. unlocked: boolean;
  108994. /**
  108995. * Defines if the audio engine relies on a custom unlocked button.
  108996. * In this case, the embedded button will not be displayed.
  108997. */
  108998. useCustomUnlockedButton: boolean;
  108999. /**
  109000. * Event raised when audio has been unlocked on the browser.
  109001. */
  109002. onAudioUnlockedObservable: Observable<AudioEngine>;
  109003. /**
  109004. * Event raised when audio has been locked on the browser.
  109005. */
  109006. onAudioLockedObservable: Observable<AudioEngine>;
  109007. /**
  109008. * Gets the current AudioContext if available.
  109009. */
  109010. get audioContext(): Nullable<AudioContext>;
  109011. private _connectedAnalyser;
  109012. /**
  109013. * Instantiates a new audio engine.
  109014. *
  109015. * There should be only one per page as some browsers restrict the number
  109016. * of audio contexts you can create.
  109017. * @param hostElement defines the host element where to display the mute icon if necessary
  109018. */
  109019. constructor(hostElement?: Nullable<HTMLElement>);
  109020. /**
  109021. * Flags the audio engine in Locked state.
  109022. * This happens due to new browser policies preventing audio to autoplay.
  109023. */
  109024. lock(): void;
  109025. /**
  109026. * Unlocks the audio engine once a user action has been done on the dom.
  109027. * This is helpful to resume play once browser policies have been satisfied.
  109028. */
  109029. unlock(): void;
  109030. private _resumeAudioContext;
  109031. private _initializeAudioContext;
  109032. private _tryToRun;
  109033. private _triggerRunningState;
  109034. private _triggerSuspendedState;
  109035. private _displayMuteButton;
  109036. private _moveButtonToTopLeft;
  109037. private _onResize;
  109038. private _hideMuteButton;
  109039. /**
  109040. * Destroy and release the resources associated with the audio ccontext.
  109041. */
  109042. dispose(): void;
  109043. /**
  109044. * Gets the global volume sets on the master gain.
  109045. * @returns the global volume if set or -1 otherwise
  109046. */
  109047. getGlobalVolume(): number;
  109048. /**
  109049. * Sets the global volume of your experience (sets on the master gain).
  109050. * @param newVolume Defines the new global volume of the application
  109051. */
  109052. setGlobalVolume(newVolume: number): void;
  109053. /**
  109054. * Connect the audio engine to an audio analyser allowing some amazing
  109055. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  109056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  109057. * @param analyser The analyser to connect to the engine
  109058. */
  109059. connectToAnalyser(analyser: Analyser): void;
  109060. }
  109061. }
  109062. declare module BABYLON {
  109063. /**
  109064. * Interface used to present a loading screen while loading a scene
  109065. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109066. */
  109067. export interface ILoadingScreen {
  109068. /**
  109069. * Function called to display the loading screen
  109070. */
  109071. displayLoadingUI: () => void;
  109072. /**
  109073. * Function called to hide the loading screen
  109074. */
  109075. hideLoadingUI: () => void;
  109076. /**
  109077. * Gets or sets the color to use for the background
  109078. */
  109079. loadingUIBackgroundColor: string;
  109080. /**
  109081. * Gets or sets the text to display while loading
  109082. */
  109083. loadingUIText: string;
  109084. }
  109085. /**
  109086. * Class used for the default loading screen
  109087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109088. */
  109089. export class DefaultLoadingScreen implements ILoadingScreen {
  109090. private _renderingCanvas;
  109091. private _loadingText;
  109092. private _loadingDivBackgroundColor;
  109093. private _loadingDiv;
  109094. private _loadingTextDiv;
  109095. /** Gets or sets the logo url to use for the default loading screen */
  109096. static DefaultLogoUrl: string;
  109097. /** Gets or sets the spinner url to use for the default loading screen */
  109098. static DefaultSpinnerUrl: string;
  109099. /**
  109100. * Creates a new default loading screen
  109101. * @param _renderingCanvas defines the canvas used to render the scene
  109102. * @param _loadingText defines the default text to display
  109103. * @param _loadingDivBackgroundColor defines the default background color
  109104. */
  109105. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  109106. /**
  109107. * Function called to display the loading screen
  109108. */
  109109. displayLoadingUI(): void;
  109110. /**
  109111. * Function called to hide the loading screen
  109112. */
  109113. hideLoadingUI(): void;
  109114. /**
  109115. * Gets or sets the text to display while loading
  109116. */
  109117. set loadingUIText(text: string);
  109118. get loadingUIText(): string;
  109119. /**
  109120. * Gets or sets the color to use for the background
  109121. */
  109122. get loadingUIBackgroundColor(): string;
  109123. set loadingUIBackgroundColor(color: string);
  109124. private _resizeLoadingUI;
  109125. }
  109126. }
  109127. declare module BABYLON {
  109128. /**
  109129. * Interface for any object that can request an animation frame
  109130. */
  109131. export interface ICustomAnimationFrameRequester {
  109132. /**
  109133. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  109134. */
  109135. renderFunction?: Function;
  109136. /**
  109137. * Called to request the next frame to render to
  109138. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  109139. */
  109140. requestAnimationFrame: Function;
  109141. /**
  109142. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  109143. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  109144. */
  109145. requestID?: number;
  109146. }
  109147. }
  109148. declare module BABYLON {
  109149. /**
  109150. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  109151. */
  109152. export class PerformanceMonitor {
  109153. private _enabled;
  109154. private _rollingFrameTime;
  109155. private _lastFrameTimeMs;
  109156. /**
  109157. * constructor
  109158. * @param frameSampleSize The number of samples required to saturate the sliding window
  109159. */
  109160. constructor(frameSampleSize?: number);
  109161. /**
  109162. * Samples current frame
  109163. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  109164. */
  109165. sampleFrame(timeMs?: number): void;
  109166. /**
  109167. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109168. */
  109169. get averageFrameTime(): number;
  109170. /**
  109171. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  109172. */
  109173. get averageFrameTimeVariance(): number;
  109174. /**
  109175. * Returns the frame time of the most recent frame
  109176. */
  109177. get instantaneousFrameTime(): number;
  109178. /**
  109179. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  109180. */
  109181. get averageFPS(): number;
  109182. /**
  109183. * Returns the average framerate in frames per second using the most recent frame time
  109184. */
  109185. get instantaneousFPS(): number;
  109186. /**
  109187. * Returns true if enough samples have been taken to completely fill the sliding window
  109188. */
  109189. get isSaturated(): boolean;
  109190. /**
  109191. * Enables contributions to the sliding window sample set
  109192. */
  109193. enable(): void;
  109194. /**
  109195. * Disables contributions to the sliding window sample set
  109196. * Samples will not be interpolated over the disabled period
  109197. */
  109198. disable(): void;
  109199. /**
  109200. * Returns true if sampling is enabled
  109201. */
  109202. get isEnabled(): boolean;
  109203. /**
  109204. * Resets performance monitor
  109205. */
  109206. reset(): void;
  109207. }
  109208. /**
  109209. * RollingAverage
  109210. *
  109211. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  109212. */
  109213. export class RollingAverage {
  109214. /**
  109215. * Current average
  109216. */
  109217. average: number;
  109218. /**
  109219. * Current variance
  109220. */
  109221. variance: number;
  109222. protected _samples: Array<number>;
  109223. protected _sampleCount: number;
  109224. protected _pos: number;
  109225. protected _m2: number;
  109226. /**
  109227. * constructor
  109228. * @param length The number of samples required to saturate the sliding window
  109229. */
  109230. constructor(length: number);
  109231. /**
  109232. * Adds a sample to the sample set
  109233. * @param v The sample value
  109234. */
  109235. add(v: number): void;
  109236. /**
  109237. * Returns previously added values or null if outside of history or outside the sliding window domain
  109238. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  109239. * @return Value previously recorded with add() or null if outside of range
  109240. */
  109241. history(i: number): number;
  109242. /**
  109243. * Returns true if enough samples have been taken to completely fill the sliding window
  109244. * @return true if sample-set saturated
  109245. */
  109246. isSaturated(): boolean;
  109247. /**
  109248. * Resets the rolling average (equivalent to 0 samples taken so far)
  109249. */
  109250. reset(): void;
  109251. /**
  109252. * Wraps a value around the sample range boundaries
  109253. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  109254. * @return Wrapped position in sample range
  109255. */
  109256. protected _wrapPosition(i: number): number;
  109257. }
  109258. }
  109259. declare module BABYLON {
  109260. /**
  109261. * This class is used to track a performance counter which is number based.
  109262. * The user has access to many properties which give statistics of different nature.
  109263. *
  109264. * The implementer can track two kinds of Performance Counter: time and count.
  109265. * 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.
  109266. * 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.
  109267. */
  109268. export class PerfCounter {
  109269. /**
  109270. * Gets or sets a global boolean to turn on and off all the counters
  109271. */
  109272. static Enabled: boolean;
  109273. /**
  109274. * Returns the smallest value ever
  109275. */
  109276. get min(): number;
  109277. /**
  109278. * Returns the biggest value ever
  109279. */
  109280. get max(): number;
  109281. /**
  109282. * Returns the average value since the performance counter is running
  109283. */
  109284. get average(): number;
  109285. /**
  109286. * Returns the average value of the last second the counter was monitored
  109287. */
  109288. get lastSecAverage(): number;
  109289. /**
  109290. * Returns the current value
  109291. */
  109292. get current(): number;
  109293. /**
  109294. * Gets the accumulated total
  109295. */
  109296. get total(): number;
  109297. /**
  109298. * Gets the total value count
  109299. */
  109300. get count(): number;
  109301. /**
  109302. * Creates a new counter
  109303. */
  109304. constructor();
  109305. /**
  109306. * Call this method to start monitoring a new frame.
  109307. * 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.
  109308. */
  109309. fetchNewFrame(): void;
  109310. /**
  109311. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  109312. * @param newCount the count value to add to the monitored count
  109313. * @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.
  109314. */
  109315. addCount(newCount: number, fetchResult: boolean): void;
  109316. /**
  109317. * Start monitoring this performance counter
  109318. */
  109319. beginMonitoring(): void;
  109320. /**
  109321. * Compute the time lapsed since the previous beginMonitoring() call.
  109322. * @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
  109323. */
  109324. endMonitoring(newFrame?: boolean): void;
  109325. private _fetchResult;
  109326. private _startMonitoringTime;
  109327. private _min;
  109328. private _max;
  109329. private _average;
  109330. private _current;
  109331. private _totalValueCount;
  109332. private _totalAccumulated;
  109333. private _lastSecAverage;
  109334. private _lastSecAccumulated;
  109335. private _lastSecTime;
  109336. private _lastSecValueCount;
  109337. }
  109338. }
  109339. declare module BABYLON {
  109340. interface ThinEngine {
  109341. /**
  109342. * Sets alpha constants used by some alpha blending modes
  109343. * @param r defines the red component
  109344. * @param g defines the green component
  109345. * @param b defines the blue component
  109346. * @param a defines the alpha component
  109347. */
  109348. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109349. /**
  109350. * Sets the current alpha mode
  109351. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  109352. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109353. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109354. */
  109355. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109356. /**
  109357. * Gets the current alpha mode
  109358. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109359. * @returns the current alpha mode
  109360. */
  109361. getAlphaMode(): number;
  109362. /**
  109363. * Sets the current alpha equation
  109364. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  109365. */
  109366. setAlphaEquation(equation: number): void;
  109367. /**
  109368. * Gets the current alpha equation.
  109369. * @returns the current alpha equation
  109370. */
  109371. getAlphaEquation(): number;
  109372. }
  109373. }
  109374. declare module BABYLON {
  109375. /**
  109376. * Defines the interface used by display changed events
  109377. */
  109378. export interface IDisplayChangedEventArgs {
  109379. /** Gets the vrDisplay object (if any) */
  109380. vrDisplay: Nullable<any>;
  109381. /** Gets a boolean indicating if webVR is supported */
  109382. vrSupported: boolean;
  109383. }
  109384. /**
  109385. * Defines the interface used by objects containing a viewport (like a camera)
  109386. */
  109387. interface IViewportOwnerLike {
  109388. /**
  109389. * Gets or sets the viewport
  109390. */
  109391. viewport: IViewportLike;
  109392. }
  109393. /**
  109394. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  109395. */
  109396. export class Engine extends ThinEngine {
  109397. /** Defines that alpha blending is disabled */
  109398. static readonly ALPHA_DISABLE: number;
  109399. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  109400. static readonly ALPHA_ADD: number;
  109401. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  109402. static readonly ALPHA_COMBINE: number;
  109403. /** Defines that alpha blending to DEST - SRC * DEST */
  109404. static readonly ALPHA_SUBTRACT: number;
  109405. /** Defines that alpha blending to SRC * DEST */
  109406. static readonly ALPHA_MULTIPLY: number;
  109407. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  109408. static readonly ALPHA_MAXIMIZED: number;
  109409. /** Defines that alpha blending to SRC + DEST */
  109410. static readonly ALPHA_ONEONE: number;
  109411. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  109412. static readonly ALPHA_PREMULTIPLIED: number;
  109413. /**
  109414. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  109415. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  109416. */
  109417. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  109418. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  109419. static readonly ALPHA_INTERPOLATE: number;
  109420. /**
  109421. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  109422. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  109423. */
  109424. static readonly ALPHA_SCREENMODE: number;
  109425. /** Defines that the ressource is not delayed*/
  109426. static readonly DELAYLOADSTATE_NONE: number;
  109427. /** Defines that the ressource was successfully delay loaded */
  109428. static readonly DELAYLOADSTATE_LOADED: number;
  109429. /** Defines that the ressource is currently delay loading */
  109430. static readonly DELAYLOADSTATE_LOADING: number;
  109431. /** Defines that the ressource is delayed and has not started loading */
  109432. static readonly DELAYLOADSTATE_NOTLOADED: number;
  109433. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  109434. static readonly NEVER: number;
  109435. /** 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 */
  109436. static readonly ALWAYS: number;
  109437. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  109438. static readonly LESS: number;
  109439. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  109440. static readonly EQUAL: number;
  109441. /** 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 */
  109442. static readonly LEQUAL: number;
  109443. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  109444. static readonly GREATER: number;
  109445. /** 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 */
  109446. static readonly GEQUAL: number;
  109447. /** 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 */
  109448. static readonly NOTEQUAL: number;
  109449. /** Passed to stencilOperation to specify that stencil value must be kept */
  109450. static readonly KEEP: number;
  109451. /** Passed to stencilOperation to specify that stencil value must be replaced */
  109452. static readonly REPLACE: number;
  109453. /** Passed to stencilOperation to specify that stencil value must be incremented */
  109454. static readonly INCR: number;
  109455. /** Passed to stencilOperation to specify that stencil value must be decremented */
  109456. static readonly DECR: number;
  109457. /** Passed to stencilOperation to specify that stencil value must be inverted */
  109458. static readonly INVERT: number;
  109459. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  109460. static readonly INCR_WRAP: number;
  109461. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  109462. static readonly DECR_WRAP: number;
  109463. /** Texture is not repeating outside of 0..1 UVs */
  109464. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  109465. /** Texture is repeating outside of 0..1 UVs */
  109466. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  109467. /** Texture is repeating and mirrored */
  109468. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  109469. /** ALPHA */
  109470. static readonly TEXTUREFORMAT_ALPHA: number;
  109471. /** LUMINANCE */
  109472. static readonly TEXTUREFORMAT_LUMINANCE: number;
  109473. /** LUMINANCE_ALPHA */
  109474. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  109475. /** RGB */
  109476. static readonly TEXTUREFORMAT_RGB: number;
  109477. /** RGBA */
  109478. static readonly TEXTUREFORMAT_RGBA: number;
  109479. /** RED */
  109480. static readonly TEXTUREFORMAT_RED: number;
  109481. /** RED (2nd reference) */
  109482. static readonly TEXTUREFORMAT_R: number;
  109483. /** RG */
  109484. static readonly TEXTUREFORMAT_RG: number;
  109485. /** RED_INTEGER */
  109486. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  109487. /** RED_INTEGER (2nd reference) */
  109488. static readonly TEXTUREFORMAT_R_INTEGER: number;
  109489. /** RG_INTEGER */
  109490. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  109491. /** RGB_INTEGER */
  109492. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  109493. /** RGBA_INTEGER */
  109494. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  109495. /** UNSIGNED_BYTE */
  109496. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  109497. /** UNSIGNED_BYTE (2nd reference) */
  109498. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  109499. /** FLOAT */
  109500. static readonly TEXTURETYPE_FLOAT: number;
  109501. /** HALF_FLOAT */
  109502. static readonly TEXTURETYPE_HALF_FLOAT: number;
  109503. /** BYTE */
  109504. static readonly TEXTURETYPE_BYTE: number;
  109505. /** SHORT */
  109506. static readonly TEXTURETYPE_SHORT: number;
  109507. /** UNSIGNED_SHORT */
  109508. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  109509. /** INT */
  109510. static readonly TEXTURETYPE_INT: number;
  109511. /** UNSIGNED_INT */
  109512. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  109513. /** UNSIGNED_SHORT_4_4_4_4 */
  109514. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  109515. /** UNSIGNED_SHORT_5_5_5_1 */
  109516. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  109517. /** UNSIGNED_SHORT_5_6_5 */
  109518. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  109519. /** UNSIGNED_INT_2_10_10_10_REV */
  109520. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  109521. /** UNSIGNED_INT_24_8 */
  109522. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  109523. /** UNSIGNED_INT_10F_11F_11F_REV */
  109524. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  109525. /** UNSIGNED_INT_5_9_9_9_REV */
  109526. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  109527. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  109528. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109529. /** nearest is mag = nearest and min = nearest and mip = linear */
  109530. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  109531. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109532. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  109533. /** Trilinear is mag = linear and min = linear and mip = linear */
  109534. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  109535. /** nearest is mag = nearest and min = nearest and mip = linear */
  109536. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  109537. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109538. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  109539. /** Trilinear is mag = linear and min = linear and mip = linear */
  109540. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  109541. /** mag = nearest and min = nearest and mip = nearest */
  109542. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  109543. /** mag = nearest and min = linear and mip = nearest */
  109544. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  109545. /** mag = nearest and min = linear and mip = linear */
  109546. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  109547. /** mag = nearest and min = linear and mip = none */
  109548. static readonly TEXTURE_NEAREST_LINEAR: number;
  109549. /** mag = nearest and min = nearest and mip = none */
  109550. static readonly TEXTURE_NEAREST_NEAREST: number;
  109551. /** mag = linear and min = nearest and mip = nearest */
  109552. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  109553. /** mag = linear and min = nearest and mip = linear */
  109554. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  109555. /** mag = linear and min = linear and mip = none */
  109556. static readonly TEXTURE_LINEAR_LINEAR: number;
  109557. /** mag = linear and min = nearest and mip = none */
  109558. static readonly TEXTURE_LINEAR_NEAREST: number;
  109559. /** Explicit coordinates mode */
  109560. static readonly TEXTURE_EXPLICIT_MODE: number;
  109561. /** Spherical coordinates mode */
  109562. static readonly TEXTURE_SPHERICAL_MODE: number;
  109563. /** Planar coordinates mode */
  109564. static readonly TEXTURE_PLANAR_MODE: number;
  109565. /** Cubic coordinates mode */
  109566. static readonly TEXTURE_CUBIC_MODE: number;
  109567. /** Projection coordinates mode */
  109568. static readonly TEXTURE_PROJECTION_MODE: number;
  109569. /** Skybox coordinates mode */
  109570. static readonly TEXTURE_SKYBOX_MODE: number;
  109571. /** Inverse Cubic coordinates mode */
  109572. static readonly TEXTURE_INVCUBIC_MODE: number;
  109573. /** Equirectangular coordinates mode */
  109574. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  109575. /** Equirectangular Fixed coordinates mode */
  109576. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  109577. /** Equirectangular Fixed Mirrored coordinates mode */
  109578. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109579. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  109580. static readonly SCALEMODE_FLOOR: number;
  109581. /** Defines that texture rescaling will look for the nearest power of 2 size */
  109582. static readonly SCALEMODE_NEAREST: number;
  109583. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  109584. static readonly SCALEMODE_CEILING: number;
  109585. /**
  109586. * Returns the current npm package of the sdk
  109587. */
  109588. static get NpmPackage(): string;
  109589. /**
  109590. * Returns the current version of the framework
  109591. */
  109592. static get Version(): string;
  109593. /** Gets the list of created engines */
  109594. static get Instances(): Engine[];
  109595. /**
  109596. * Gets the latest created engine
  109597. */
  109598. static get LastCreatedEngine(): Nullable<Engine>;
  109599. /**
  109600. * Gets the latest created scene
  109601. */
  109602. static get LastCreatedScene(): Nullable<Scene>;
  109603. /**
  109604. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  109605. * @param flag defines which part of the materials must be marked as dirty
  109606. * @param predicate defines a predicate used to filter which materials should be affected
  109607. */
  109608. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109609. /**
  109610. * Method called to create the default loading screen.
  109611. * This can be overriden in your own app.
  109612. * @param canvas The rendering canvas element
  109613. * @returns The loading screen
  109614. */
  109615. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  109616. /**
  109617. * Method called to create the default rescale post process on each engine.
  109618. */
  109619. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  109620. /**
  109621. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  109622. **/
  109623. enableOfflineSupport: boolean;
  109624. /**
  109625. * 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)
  109626. **/
  109627. disableManifestCheck: boolean;
  109628. /**
  109629. * Gets the list of created scenes
  109630. */
  109631. scenes: Scene[];
  109632. /**
  109633. * Event raised when a new scene is created
  109634. */
  109635. onNewSceneAddedObservable: Observable<Scene>;
  109636. /**
  109637. * Gets the list of created postprocesses
  109638. */
  109639. postProcesses: PostProcess[];
  109640. /**
  109641. * Gets a boolean indicating if the pointer is currently locked
  109642. */
  109643. isPointerLock: boolean;
  109644. /**
  109645. * Observable event triggered each time the rendering canvas is resized
  109646. */
  109647. onResizeObservable: Observable<Engine>;
  109648. /**
  109649. * Observable event triggered each time the canvas loses focus
  109650. */
  109651. onCanvasBlurObservable: Observable<Engine>;
  109652. /**
  109653. * Observable event triggered each time the canvas gains focus
  109654. */
  109655. onCanvasFocusObservable: Observable<Engine>;
  109656. /**
  109657. * Observable event triggered each time the canvas receives pointerout event
  109658. */
  109659. onCanvasPointerOutObservable: Observable<PointerEvent>;
  109660. /**
  109661. * Observable raised when the engine begins a new frame
  109662. */
  109663. onBeginFrameObservable: Observable<Engine>;
  109664. /**
  109665. * If set, will be used to request the next animation frame for the render loop
  109666. */
  109667. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  109668. /**
  109669. * Observable raised when the engine ends the current frame
  109670. */
  109671. onEndFrameObservable: Observable<Engine>;
  109672. /**
  109673. * Observable raised when the engine is about to compile a shader
  109674. */
  109675. onBeforeShaderCompilationObservable: Observable<Engine>;
  109676. /**
  109677. * Observable raised when the engine has jsut compiled a shader
  109678. */
  109679. onAfterShaderCompilationObservable: Observable<Engine>;
  109680. /**
  109681. * Gets the audio engine
  109682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109683. * @ignorenaming
  109684. */
  109685. static audioEngine: IAudioEngine;
  109686. /**
  109687. * Default AudioEngine factory responsible of creating the Audio Engine.
  109688. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  109689. */
  109690. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  109691. /**
  109692. * Default offline support factory responsible of creating a tool used to store data locally.
  109693. * By default, this will create a Database object if the workload has been embedded.
  109694. */
  109695. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  109696. private _loadingScreen;
  109697. private _pointerLockRequested;
  109698. private _dummyFramebuffer;
  109699. private _rescalePostProcess;
  109700. private _deterministicLockstep;
  109701. private _lockstepMaxSteps;
  109702. private _timeStep;
  109703. protected get _supportsHardwareTextureRescaling(): boolean;
  109704. private _fps;
  109705. private _deltaTime;
  109706. /** @hidden */
  109707. _drawCalls: PerfCounter;
  109708. /** 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 */
  109709. canvasTabIndex: number;
  109710. /**
  109711. * Turn this value on if you want to pause FPS computation when in background
  109712. */
  109713. disablePerformanceMonitorInBackground: boolean;
  109714. private _performanceMonitor;
  109715. /**
  109716. * Gets the performance monitor attached to this engine
  109717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109718. */
  109719. get performanceMonitor(): PerformanceMonitor;
  109720. private _onFocus;
  109721. private _onBlur;
  109722. private _onCanvasPointerOut;
  109723. private _onCanvasBlur;
  109724. private _onCanvasFocus;
  109725. private _onFullscreenChange;
  109726. private _onPointerLockChange;
  109727. /**
  109728. * Gets the HTML element used to attach event listeners
  109729. * @returns a HTML element
  109730. */
  109731. getInputElement(): Nullable<HTMLElement>;
  109732. /**
  109733. * Creates a new engine
  109734. * @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
  109735. * @param antialias defines enable antialiasing (default: false)
  109736. * @param options defines further options to be sent to the getContext() function
  109737. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  109738. */
  109739. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  109740. /**
  109741. * Gets current aspect ratio
  109742. * @param viewportOwner defines the camera to use to get the aspect ratio
  109743. * @param useScreen defines if screen size must be used (or the current render target if any)
  109744. * @returns a number defining the aspect ratio
  109745. */
  109746. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  109747. /**
  109748. * Gets current screen aspect ratio
  109749. * @returns a number defining the aspect ratio
  109750. */
  109751. getScreenAspectRatio(): number;
  109752. /**
  109753. * Gets the client rect of the HTML canvas attached with the current webGL context
  109754. * @returns a client rectanglee
  109755. */
  109756. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  109757. /**
  109758. * Gets the client rect of the HTML element used for events
  109759. * @returns a client rectanglee
  109760. */
  109761. getInputElementClientRect(): Nullable<ClientRect>;
  109762. /**
  109763. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  109764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109765. * @returns true if engine is in deterministic lock step mode
  109766. */
  109767. isDeterministicLockStep(): boolean;
  109768. /**
  109769. * Gets the max steps when engine is running in deterministic lock step
  109770. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109771. * @returns the max steps
  109772. */
  109773. getLockstepMaxSteps(): number;
  109774. /**
  109775. * Returns the time in ms between steps when using deterministic lock step.
  109776. * @returns time step in (ms)
  109777. */
  109778. getTimeStep(): number;
  109779. /**
  109780. * Force the mipmap generation for the given render target texture
  109781. * @param texture defines the render target texture to use
  109782. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  109783. */
  109784. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  109785. /** States */
  109786. /**
  109787. * Set various states to the webGL context
  109788. * @param culling defines backface culling state
  109789. * @param zOffset defines the value to apply to zOffset (0 by default)
  109790. * @param force defines if states must be applied even if cache is up to date
  109791. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  109792. */
  109793. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109794. /**
  109795. * Set the z offset to apply to current rendering
  109796. * @param value defines the offset to apply
  109797. */
  109798. setZOffset(value: number): void;
  109799. /**
  109800. * Gets the current value of the zOffset
  109801. * @returns the current zOffset state
  109802. */
  109803. getZOffset(): number;
  109804. /**
  109805. * Enable or disable depth buffering
  109806. * @param enable defines the state to set
  109807. */
  109808. setDepthBuffer(enable: boolean): void;
  109809. /**
  109810. * Gets a boolean indicating if depth writing is enabled
  109811. * @returns the current depth writing state
  109812. */
  109813. getDepthWrite(): boolean;
  109814. /**
  109815. * Enable or disable depth writing
  109816. * @param enable defines the state to set
  109817. */
  109818. setDepthWrite(enable: boolean): void;
  109819. /**
  109820. * Gets a boolean indicating if stencil buffer is enabled
  109821. * @returns the current stencil buffer state
  109822. */
  109823. getStencilBuffer(): boolean;
  109824. /**
  109825. * Enable or disable the stencil buffer
  109826. * @param enable defines if the stencil buffer must be enabled or disabled
  109827. */
  109828. setStencilBuffer(enable: boolean): void;
  109829. /**
  109830. * Gets the current stencil mask
  109831. * @returns a number defining the new stencil mask to use
  109832. */
  109833. getStencilMask(): number;
  109834. /**
  109835. * Sets the current stencil mask
  109836. * @param mask defines the new stencil mask to use
  109837. */
  109838. setStencilMask(mask: number): void;
  109839. /**
  109840. * Gets the current stencil function
  109841. * @returns a number defining the stencil function to use
  109842. */
  109843. getStencilFunction(): number;
  109844. /**
  109845. * Gets the current stencil reference value
  109846. * @returns a number defining the stencil reference value to use
  109847. */
  109848. getStencilFunctionReference(): number;
  109849. /**
  109850. * Gets the current stencil mask
  109851. * @returns a number defining the stencil mask to use
  109852. */
  109853. getStencilFunctionMask(): number;
  109854. /**
  109855. * Sets the current stencil function
  109856. * @param stencilFunc defines the new stencil function to use
  109857. */
  109858. setStencilFunction(stencilFunc: number): void;
  109859. /**
  109860. * Sets the current stencil reference
  109861. * @param reference defines the new stencil reference to use
  109862. */
  109863. setStencilFunctionReference(reference: number): void;
  109864. /**
  109865. * Sets the current stencil mask
  109866. * @param mask defines the new stencil mask to use
  109867. */
  109868. setStencilFunctionMask(mask: number): void;
  109869. /**
  109870. * Gets the current stencil operation when stencil fails
  109871. * @returns a number defining stencil operation to use when stencil fails
  109872. */
  109873. getStencilOperationFail(): number;
  109874. /**
  109875. * Gets the current stencil operation when depth fails
  109876. * @returns a number defining stencil operation to use when depth fails
  109877. */
  109878. getStencilOperationDepthFail(): number;
  109879. /**
  109880. * Gets the current stencil operation when stencil passes
  109881. * @returns a number defining stencil operation to use when stencil passes
  109882. */
  109883. getStencilOperationPass(): number;
  109884. /**
  109885. * Sets the stencil operation to use when stencil fails
  109886. * @param operation defines the stencil operation to use when stencil fails
  109887. */
  109888. setStencilOperationFail(operation: number): void;
  109889. /**
  109890. * Sets the stencil operation to use when depth fails
  109891. * @param operation defines the stencil operation to use when depth fails
  109892. */
  109893. setStencilOperationDepthFail(operation: number): void;
  109894. /**
  109895. * Sets the stencil operation to use when stencil passes
  109896. * @param operation defines the stencil operation to use when stencil passes
  109897. */
  109898. setStencilOperationPass(operation: number): void;
  109899. /**
  109900. * Sets a boolean indicating if the dithering state is enabled or disabled
  109901. * @param value defines the dithering state
  109902. */
  109903. setDitheringState(value: boolean): void;
  109904. /**
  109905. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  109906. * @param value defines the rasterizer state
  109907. */
  109908. setRasterizerState(value: boolean): void;
  109909. /**
  109910. * Gets the current depth function
  109911. * @returns a number defining the depth function
  109912. */
  109913. getDepthFunction(): Nullable<number>;
  109914. /**
  109915. * Sets the current depth function
  109916. * @param depthFunc defines the function to use
  109917. */
  109918. setDepthFunction(depthFunc: number): void;
  109919. /**
  109920. * Sets the current depth function to GREATER
  109921. */
  109922. setDepthFunctionToGreater(): void;
  109923. /**
  109924. * Sets the current depth function to GEQUAL
  109925. */
  109926. setDepthFunctionToGreaterOrEqual(): void;
  109927. /**
  109928. * Sets the current depth function to LESS
  109929. */
  109930. setDepthFunctionToLess(): void;
  109931. /**
  109932. * Sets the current depth function to LEQUAL
  109933. */
  109934. setDepthFunctionToLessOrEqual(): void;
  109935. private _cachedStencilBuffer;
  109936. private _cachedStencilFunction;
  109937. private _cachedStencilMask;
  109938. private _cachedStencilOperationPass;
  109939. private _cachedStencilOperationFail;
  109940. private _cachedStencilOperationDepthFail;
  109941. private _cachedStencilReference;
  109942. /**
  109943. * Caches the the state of the stencil buffer
  109944. */
  109945. cacheStencilState(): void;
  109946. /**
  109947. * Restores the state of the stencil buffer
  109948. */
  109949. restoreStencilState(): void;
  109950. /**
  109951. * Directly set the WebGL Viewport
  109952. * @param x defines the x coordinate of the viewport (in screen space)
  109953. * @param y defines the y coordinate of the viewport (in screen space)
  109954. * @param width defines the width of the viewport (in screen space)
  109955. * @param height defines the height of the viewport (in screen space)
  109956. * @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
  109957. */
  109958. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  109959. /**
  109960. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  109961. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  109962. * @param y defines the y-coordinate of the corner of the clear rectangle
  109963. * @param width defines the width of the clear rectangle
  109964. * @param height defines the height of the clear rectangle
  109965. * @param clearColor defines the clear color
  109966. */
  109967. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  109968. /**
  109969. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  109970. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  109971. * @param y defines the y-coordinate of the corner of the clear rectangle
  109972. * @param width defines the width of the clear rectangle
  109973. * @param height defines the height of the clear rectangle
  109974. */
  109975. enableScissor(x: number, y: number, width: number, height: number): void;
  109976. /**
  109977. * Disable previously set scissor test rectangle
  109978. */
  109979. disableScissor(): void;
  109980. protected _reportDrawCall(): void;
  109981. /**
  109982. * Initializes a webVR display and starts listening to display change events
  109983. * The onVRDisplayChangedObservable will be notified upon these changes
  109984. * @returns The onVRDisplayChangedObservable
  109985. */
  109986. initWebVR(): Observable<IDisplayChangedEventArgs>;
  109987. /** @hidden */
  109988. _prepareVRComponent(): void;
  109989. /** @hidden */
  109990. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  109991. /** @hidden */
  109992. _submitVRFrame(): void;
  109993. /**
  109994. * Call this function to leave webVR mode
  109995. * Will do nothing if webVR is not supported or if there is no webVR device
  109996. * @see http://doc.babylonjs.com/how_to/webvr_camera
  109997. */
  109998. disableVR(): void;
  109999. /**
  110000. * Gets a boolean indicating that the system is in VR mode and is presenting
  110001. * @returns true if VR mode is engaged
  110002. */
  110003. isVRPresenting(): boolean;
  110004. /** @hidden */
  110005. _requestVRFrame(): void;
  110006. /** @hidden */
  110007. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110008. /**
  110009. * Gets the source code of the vertex shader associated with a specific webGL program
  110010. * @param program defines the program to use
  110011. * @returns a string containing the source code of the vertex shader associated with the program
  110012. */
  110013. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  110014. /**
  110015. * Gets the source code of the fragment shader associated with a specific webGL program
  110016. * @param program defines the program to use
  110017. * @returns a string containing the source code of the fragment shader associated with the program
  110018. */
  110019. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  110020. /**
  110021. * Sets a depth stencil texture from a render target to the according uniform.
  110022. * @param channel The texture channel
  110023. * @param uniform The uniform to set
  110024. * @param texture The render target texture containing the depth stencil texture to apply
  110025. */
  110026. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  110027. /**
  110028. * Sets a texture to the webGL context from a postprocess
  110029. * @param channel defines the channel to use
  110030. * @param postProcess defines the source postprocess
  110031. */
  110032. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  110033. /**
  110034. * Binds the output of the passed in post process to the texture channel specified
  110035. * @param channel The channel the texture should be bound to
  110036. * @param postProcess The post process which's output should be bound
  110037. */
  110038. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  110039. protected _rebuildBuffers(): void;
  110040. /** @hidden */
  110041. _renderFrame(): void;
  110042. _renderLoop(): void;
  110043. /** @hidden */
  110044. _renderViews(): boolean;
  110045. /**
  110046. * Toggle full screen mode
  110047. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110048. */
  110049. switchFullscreen(requestPointerLock: boolean): void;
  110050. /**
  110051. * Enters full screen mode
  110052. * @param requestPointerLock defines if a pointer lock should be requested from the user
  110053. */
  110054. enterFullscreen(requestPointerLock: boolean): void;
  110055. /**
  110056. * Exits full screen mode
  110057. */
  110058. exitFullscreen(): void;
  110059. /**
  110060. * Enters Pointerlock mode
  110061. */
  110062. enterPointerlock(): void;
  110063. /**
  110064. * Exits Pointerlock mode
  110065. */
  110066. exitPointerlock(): void;
  110067. /**
  110068. * Begin a new frame
  110069. */
  110070. beginFrame(): void;
  110071. /**
  110072. * Enf the current frame
  110073. */
  110074. endFrame(): void;
  110075. resize(): void;
  110076. /**
  110077. * Force a specific size of the canvas
  110078. * @param width defines the new canvas' width
  110079. * @param height defines the new canvas' height
  110080. */
  110081. setSize(width: number, height: number): void;
  110082. /**
  110083. * Updates a dynamic vertex buffer.
  110084. * @param vertexBuffer the vertex buffer to update
  110085. * @param data the data used to update the vertex buffer
  110086. * @param byteOffset the byte offset of the data
  110087. * @param byteLength the byte length of the data
  110088. */
  110089. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110090. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110091. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110092. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  110093. _releaseTexture(texture: InternalTexture): void;
  110094. /**
  110095. * @hidden
  110096. * Rescales a texture
  110097. * @param source input texutre
  110098. * @param destination destination texture
  110099. * @param scene scene to use to render the resize
  110100. * @param internalFormat format to use when resizing
  110101. * @param onComplete callback to be called when resize has completed
  110102. */
  110103. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  110104. /**
  110105. * Gets the current framerate
  110106. * @returns a number representing the framerate
  110107. */
  110108. getFps(): number;
  110109. /**
  110110. * Gets the time spent between current and previous frame
  110111. * @returns a number representing the delta time in ms
  110112. */
  110113. getDeltaTime(): number;
  110114. private _measureFps;
  110115. /** @hidden */
  110116. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  110117. /**
  110118. * Update a dynamic index buffer
  110119. * @param indexBuffer defines the target index buffer
  110120. * @param indices defines the data to update
  110121. * @param offset defines the offset in the target index buffer where update should start
  110122. */
  110123. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110124. /**
  110125. * Updates the sample count of a render target texture
  110126. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110127. * @param texture defines the texture to update
  110128. * @param samples defines the sample count to set
  110129. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110130. */
  110131. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  110132. /**
  110133. * Updates a depth texture Comparison Mode and Function.
  110134. * If the comparison Function is equal to 0, the mode will be set to none.
  110135. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  110136. * @param texture The texture to set the comparison function for
  110137. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  110138. */
  110139. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  110140. /**
  110141. * Creates a webGL buffer to use with instanciation
  110142. * @param capacity defines the size of the buffer
  110143. * @returns the webGL buffer
  110144. */
  110145. createInstancesBuffer(capacity: number): DataBuffer;
  110146. /**
  110147. * Delete a webGL buffer used with instanciation
  110148. * @param buffer defines the webGL buffer to delete
  110149. */
  110150. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  110151. private _clientWaitAsync;
  110152. /** @hidden */
  110153. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  110154. /** @hidden */
  110155. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  110156. dispose(): void;
  110157. private _disableTouchAction;
  110158. /**
  110159. * Display the loading screen
  110160. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110161. */
  110162. displayLoadingUI(): void;
  110163. /**
  110164. * Hide the loading screen
  110165. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110166. */
  110167. hideLoadingUI(): void;
  110168. /**
  110169. * Gets the current loading screen object
  110170. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110171. */
  110172. get loadingScreen(): ILoadingScreen;
  110173. /**
  110174. * Sets the current loading screen object
  110175. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110176. */
  110177. set loadingScreen(loadingScreen: ILoadingScreen);
  110178. /**
  110179. * Sets the current loading screen text
  110180. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110181. */
  110182. set loadingUIText(text: string);
  110183. /**
  110184. * Sets the current loading screen background color
  110185. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110186. */
  110187. set loadingUIBackgroundColor(color: string);
  110188. /** Pointerlock and fullscreen */
  110189. /**
  110190. * Ask the browser to promote the current element to pointerlock mode
  110191. * @param element defines the DOM element to promote
  110192. */
  110193. static _RequestPointerlock(element: HTMLElement): void;
  110194. /**
  110195. * Asks the browser to exit pointerlock mode
  110196. */
  110197. static _ExitPointerlock(): void;
  110198. /**
  110199. * Ask the browser to promote the current element to fullscreen rendering mode
  110200. * @param element defines the DOM element to promote
  110201. */
  110202. static _RequestFullscreen(element: HTMLElement): void;
  110203. /**
  110204. * Asks the browser to exit fullscreen mode
  110205. */
  110206. static _ExitFullscreen(): void;
  110207. }
  110208. }
  110209. declare module BABYLON {
  110210. /**
  110211. * The engine store class is responsible to hold all the instances of Engine and Scene created
  110212. * during the life time of the application.
  110213. */
  110214. export class EngineStore {
  110215. /** Gets the list of created engines */
  110216. static Instances: Engine[];
  110217. /** @hidden */
  110218. static _LastCreatedScene: Nullable<Scene>;
  110219. /**
  110220. * Gets the latest created engine
  110221. */
  110222. static get LastCreatedEngine(): Nullable<Engine>;
  110223. /**
  110224. * Gets the latest created scene
  110225. */
  110226. static get LastCreatedScene(): Nullable<Scene>;
  110227. /**
  110228. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110229. * @ignorenaming
  110230. */
  110231. static UseFallbackTexture: boolean;
  110232. /**
  110233. * Texture content used if a texture cannot loaded
  110234. * @ignorenaming
  110235. */
  110236. static FallbackTexture: string;
  110237. }
  110238. }
  110239. declare module BABYLON {
  110240. /**
  110241. * Helper class that provides a small promise polyfill
  110242. */
  110243. export class PromisePolyfill {
  110244. /**
  110245. * Static function used to check if the polyfill is required
  110246. * If this is the case then the function will inject the polyfill to window.Promise
  110247. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  110248. */
  110249. static Apply(force?: boolean): void;
  110250. }
  110251. }
  110252. declare module BABYLON {
  110253. /**
  110254. * Interface for screenshot methods with describe argument called `size` as object with options
  110255. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  110256. */
  110257. export interface IScreenshotSize {
  110258. /**
  110259. * number in pixels for canvas height
  110260. */
  110261. height?: number;
  110262. /**
  110263. * multiplier allowing render at a higher or lower resolution
  110264. * If value is defined then height and width will be ignored and taken from camera
  110265. */
  110266. precision?: number;
  110267. /**
  110268. * number in pixels for canvas width
  110269. */
  110270. width?: number;
  110271. }
  110272. }
  110273. declare module BABYLON {
  110274. interface IColor4Like {
  110275. r: float;
  110276. g: float;
  110277. b: float;
  110278. a: float;
  110279. }
  110280. /**
  110281. * Class containing a set of static utilities functions
  110282. */
  110283. export class Tools {
  110284. /**
  110285. * Gets or sets the base URL to use to load assets
  110286. */
  110287. static get BaseUrl(): string;
  110288. static set BaseUrl(value: string);
  110289. /**
  110290. * Enable/Disable Custom HTTP Request Headers globally.
  110291. * default = false
  110292. * @see CustomRequestHeaders
  110293. */
  110294. static UseCustomRequestHeaders: boolean;
  110295. /**
  110296. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  110297. * i.e. when loading files, where the server/service expects an Authorization header
  110298. */
  110299. static CustomRequestHeaders: {
  110300. [key: string]: string;
  110301. };
  110302. /**
  110303. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  110304. */
  110305. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  110306. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  110307. /**
  110308. * Default behaviour for cors in the application.
  110309. * It can be a string if the expected behavior is identical in the entire app.
  110310. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  110311. */
  110312. static get CorsBehavior(): string | ((url: string | string[]) => string);
  110313. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  110314. /**
  110315. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  110316. * @ignorenaming
  110317. */
  110318. static get UseFallbackTexture(): boolean;
  110319. static set UseFallbackTexture(value: boolean);
  110320. /**
  110321. * Use this object to register external classes like custom textures or material
  110322. * to allow the laoders to instantiate them
  110323. */
  110324. static get RegisteredExternalClasses(): {
  110325. [key: string]: Object;
  110326. };
  110327. static set RegisteredExternalClasses(classes: {
  110328. [key: string]: Object;
  110329. });
  110330. /**
  110331. * Texture content used if a texture cannot loaded
  110332. * @ignorenaming
  110333. */
  110334. static get fallbackTexture(): string;
  110335. static set fallbackTexture(value: string);
  110336. /**
  110337. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  110338. * @param u defines the coordinate on X axis
  110339. * @param v defines the coordinate on Y axis
  110340. * @param width defines the width of the source data
  110341. * @param height defines the height of the source data
  110342. * @param pixels defines the source byte array
  110343. * @param color defines the output color
  110344. */
  110345. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  110346. /**
  110347. * Interpolates between a and b via alpha
  110348. * @param a The lower value (returned when alpha = 0)
  110349. * @param b The upper value (returned when alpha = 1)
  110350. * @param alpha The interpolation-factor
  110351. * @return The mixed value
  110352. */
  110353. static Mix(a: number, b: number, alpha: number): number;
  110354. /**
  110355. * Tries to instantiate a new object from a given class name
  110356. * @param className defines the class name to instantiate
  110357. * @returns the new object or null if the system was not able to do the instantiation
  110358. */
  110359. static Instantiate(className: string): any;
  110360. /**
  110361. * Provides a slice function that will work even on IE
  110362. * @param data defines the array to slice
  110363. * @param start defines the start of the data (optional)
  110364. * @param end defines the end of the data (optional)
  110365. * @returns the new sliced array
  110366. */
  110367. static Slice<T>(data: T, start?: number, end?: number): T;
  110368. /**
  110369. * Polyfill for setImmediate
  110370. * @param action defines the action to execute after the current execution block
  110371. */
  110372. static SetImmediate(action: () => void): void;
  110373. /**
  110374. * Function indicating if a number is an exponent of 2
  110375. * @param value defines the value to test
  110376. * @returns true if the value is an exponent of 2
  110377. */
  110378. static IsExponentOfTwo(value: number): boolean;
  110379. private static _tmpFloatArray;
  110380. /**
  110381. * Returns the nearest 32-bit single precision float representation of a Number
  110382. * @param value A Number. If the parameter is of a different type, it will get converted
  110383. * to a number or to NaN if it cannot be converted
  110384. * @returns number
  110385. */
  110386. static FloatRound(value: number): number;
  110387. /**
  110388. * Extracts the filename from a path
  110389. * @param path defines the path to use
  110390. * @returns the filename
  110391. */
  110392. static GetFilename(path: string): string;
  110393. /**
  110394. * Extracts the "folder" part of a path (everything before the filename).
  110395. * @param uri The URI to extract the info from
  110396. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  110397. * @returns The "folder" part of the path
  110398. */
  110399. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  110400. /**
  110401. * Extracts text content from a DOM element hierarchy
  110402. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  110403. */
  110404. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  110405. /**
  110406. * Convert an angle in radians to degrees
  110407. * @param angle defines the angle to convert
  110408. * @returns the angle in degrees
  110409. */
  110410. static ToDegrees(angle: number): number;
  110411. /**
  110412. * Convert an angle in degrees to radians
  110413. * @param angle defines the angle to convert
  110414. * @returns the angle in radians
  110415. */
  110416. static ToRadians(angle: number): number;
  110417. /**
  110418. * Returns an array if obj is not an array
  110419. * @param obj defines the object to evaluate as an array
  110420. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  110421. * @returns either obj directly if obj is an array or a new array containing obj
  110422. */
  110423. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  110424. /**
  110425. * Gets the pointer prefix to use
  110426. * @returns "pointer" if touch is enabled. Else returns "mouse"
  110427. */
  110428. static GetPointerPrefix(): string;
  110429. /**
  110430. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  110431. * @param url define the url we are trying
  110432. * @param element define the dom element where to configure the cors policy
  110433. */
  110434. static SetCorsBehavior(url: string | string[], element: {
  110435. crossOrigin: string | null;
  110436. }): void;
  110437. /**
  110438. * Removes unwanted characters from an url
  110439. * @param url defines the url to clean
  110440. * @returns the cleaned url
  110441. */
  110442. static CleanUrl(url: string): string;
  110443. /**
  110444. * Gets or sets a function used to pre-process url before using them to load assets
  110445. */
  110446. static get PreprocessUrl(): (url: string) => string;
  110447. static set PreprocessUrl(processor: (url: string) => string);
  110448. /**
  110449. * Loads an image as an HTMLImageElement.
  110450. * @param input url string, ArrayBuffer, or Blob to load
  110451. * @param onLoad callback called when the image successfully loads
  110452. * @param onError callback called when the image fails to load
  110453. * @param offlineProvider offline provider for caching
  110454. * @param mimeType optional mime type
  110455. * @returns the HTMLImageElement of the loaded image
  110456. */
  110457. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  110458. /**
  110459. * Loads a file from a url
  110460. * @param url url string, ArrayBuffer, or Blob to load
  110461. * @param onSuccess callback called when the file successfully loads
  110462. * @param onProgress callback called while file is loading (if the server supports this mode)
  110463. * @param offlineProvider defines the offline provider for caching
  110464. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110465. * @param onError callback called when the file fails to load
  110466. * @returns a file request object
  110467. */
  110468. 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;
  110469. /**
  110470. * Loads a file from a url
  110471. * @param url the file url to load
  110472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110473. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  110474. */
  110475. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  110476. /**
  110477. * Load a script (identified by an url). When the url returns, the
  110478. * content of this file is added into a new script element, attached to the DOM (body element)
  110479. * @param scriptUrl defines the url of the script to laod
  110480. * @param onSuccess defines the callback called when the script is loaded
  110481. * @param onError defines the callback to call if an error occurs
  110482. * @param scriptId defines the id of the script element
  110483. */
  110484. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  110485. /**
  110486. * Load an asynchronous script (identified by an url). When the url returns, the
  110487. * content of this file is added into a new script element, attached to the DOM (body element)
  110488. * @param scriptUrl defines the url of the script to laod
  110489. * @param scriptId defines the id of the script element
  110490. * @returns a promise request object
  110491. */
  110492. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  110493. /**
  110494. * Loads a file from a blob
  110495. * @param fileToLoad defines the blob to use
  110496. * @param callback defines the callback to call when data is loaded
  110497. * @param progressCallback defines the callback to call during loading process
  110498. * @returns a file request object
  110499. */
  110500. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  110501. /**
  110502. * Reads a file from a File object
  110503. * @param file defines the file to load
  110504. * @param onSuccess defines the callback to call when data is loaded
  110505. * @param onProgress defines the callback to call during loading process
  110506. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110507. * @param onError defines the callback to call when an error occurs
  110508. * @returns a file request object
  110509. */
  110510. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110511. /**
  110512. * Creates a data url from a given string content
  110513. * @param content defines the content to convert
  110514. * @returns the new data url link
  110515. */
  110516. static FileAsURL(content: string): string;
  110517. /**
  110518. * Format the given number to a specific decimal format
  110519. * @param value defines the number to format
  110520. * @param decimals defines the number of decimals to use
  110521. * @returns the formatted string
  110522. */
  110523. static Format(value: number, decimals?: number): string;
  110524. /**
  110525. * Tries to copy an object by duplicating every property
  110526. * @param source defines the source object
  110527. * @param destination defines the target object
  110528. * @param doNotCopyList defines a list of properties to avoid
  110529. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  110530. */
  110531. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  110532. /**
  110533. * Gets a boolean indicating if the given object has no own property
  110534. * @param obj defines the object to test
  110535. * @returns true if object has no own property
  110536. */
  110537. static IsEmpty(obj: any): boolean;
  110538. /**
  110539. * Function used to register events at window level
  110540. * @param windowElement defines the Window object to use
  110541. * @param events defines the events to register
  110542. */
  110543. static RegisterTopRootEvents(windowElement: Window, events: {
  110544. name: string;
  110545. handler: Nullable<(e: FocusEvent) => any>;
  110546. }[]): void;
  110547. /**
  110548. * Function used to unregister events from window level
  110549. * @param windowElement defines the Window object to use
  110550. * @param events defines the events to unregister
  110551. */
  110552. static UnregisterTopRootEvents(windowElement: Window, events: {
  110553. name: string;
  110554. handler: Nullable<(e: FocusEvent) => any>;
  110555. }[]): void;
  110556. /**
  110557. * @ignore
  110558. */
  110559. static _ScreenshotCanvas: HTMLCanvasElement;
  110560. /**
  110561. * Dumps the current bound framebuffer
  110562. * @param width defines the rendering width
  110563. * @param height defines the rendering height
  110564. * @param engine defines the hosting engine
  110565. * @param successCallback defines the callback triggered once the data are available
  110566. * @param mimeType defines the mime type of the result
  110567. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  110568. */
  110569. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110570. /**
  110571. * Converts the canvas data to blob.
  110572. * This acts as a polyfill for browsers not supporting the to blob function.
  110573. * @param canvas Defines the canvas to extract the data from
  110574. * @param successCallback Defines the callback triggered once the data are available
  110575. * @param mimeType Defines the mime type of the result
  110576. */
  110577. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  110578. /**
  110579. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  110580. * @param successCallback defines the callback triggered once the data are available
  110581. * @param mimeType defines the mime type of the result
  110582. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  110583. */
  110584. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  110585. /**
  110586. * Downloads a blob in the browser
  110587. * @param blob defines the blob to download
  110588. * @param fileName defines the name of the downloaded file
  110589. */
  110590. static Download(blob: Blob, fileName: string): void;
  110591. /**
  110592. * Captures a screenshot of the current rendering
  110593. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110594. * @param engine defines the rendering engine
  110595. * @param camera defines the source camera
  110596. * @param size This parameter can be set to a single number or to an object with the
  110597. * following (optional) properties: precision, width, height. If a single number is passed,
  110598. * it will be used for both width and height. If an object is passed, the screenshot size
  110599. * will be derived from the parameters. The precision property is a multiplier allowing
  110600. * rendering at a higher or lower resolution
  110601. * @param successCallback defines the callback receives a single parameter which contains the
  110602. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110603. * src parameter of an <img> to display it
  110604. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110605. * Check your browser for supported MIME types
  110606. */
  110607. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  110608. /**
  110609. * Captures a screenshot of the current rendering
  110610. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110611. * @param engine defines the rendering engine
  110612. * @param camera defines the source camera
  110613. * @param size This parameter can be set to a single number or to an object with the
  110614. * following (optional) properties: precision, width, height. If a single number is passed,
  110615. * it will be used for both width and height. If an object is passed, the screenshot size
  110616. * will be derived from the parameters. The precision property is a multiplier allowing
  110617. * rendering at a higher or lower resolution
  110618. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110619. * Check your browser for supported MIME types
  110620. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110621. * to the src parameter of an <img> to display it
  110622. */
  110623. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  110624. /**
  110625. * Generates an image screenshot from the specified camera.
  110626. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110627. * @param engine The engine to use for rendering
  110628. * @param camera The camera to use for rendering
  110629. * @param size This parameter can be set to a single number or to an object with the
  110630. * following (optional) properties: precision, width, height. If a single number is passed,
  110631. * it will be used for both width and height. If an object is passed, the screenshot size
  110632. * will be derived from the parameters. The precision property is a multiplier allowing
  110633. * rendering at a higher or lower resolution
  110634. * @param successCallback The callback receives a single parameter which contains the
  110635. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110636. * src parameter of an <img> to display it
  110637. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110638. * Check your browser for supported MIME types
  110639. * @param samples Texture samples (default: 1)
  110640. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110641. * @param fileName A name for for the downloaded file.
  110642. */
  110643. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110644. /**
  110645. * Generates an image screenshot from the specified camera.
  110646. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110647. * @param engine The engine to use for rendering
  110648. * @param camera The camera to use for rendering
  110649. * @param size This parameter can be set to a single number or to an object with the
  110650. * following (optional) properties: precision, width, height. If a single number is passed,
  110651. * it will be used for both width and height. If an object is passed, the screenshot size
  110652. * will be derived from the parameters. The precision property is a multiplier allowing
  110653. * rendering at a higher or lower resolution
  110654. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110655. * Check your browser for supported MIME types
  110656. * @param samples Texture samples (default: 1)
  110657. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110658. * @param fileName A name for for the downloaded file.
  110659. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  110660. * to the src parameter of an <img> to display it
  110661. */
  110662. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  110663. /**
  110664. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110665. * Be aware Math.random() could cause collisions, but:
  110666. * "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"
  110667. * @returns a pseudo random id
  110668. */
  110669. static RandomId(): string;
  110670. /**
  110671. * Test if the given uri is a base64 string
  110672. * @param uri The uri to test
  110673. * @return True if the uri is a base64 string or false otherwise
  110674. */
  110675. static IsBase64(uri: string): boolean;
  110676. /**
  110677. * Decode the given base64 uri.
  110678. * @param uri The uri to decode
  110679. * @return The decoded base64 data.
  110680. */
  110681. static DecodeBase64(uri: string): ArrayBuffer;
  110682. /**
  110683. * Gets the absolute url.
  110684. * @param url the input url
  110685. * @return the absolute url
  110686. */
  110687. static GetAbsoluteUrl(url: string): string;
  110688. /**
  110689. * No log
  110690. */
  110691. static readonly NoneLogLevel: number;
  110692. /**
  110693. * Only message logs
  110694. */
  110695. static readonly MessageLogLevel: number;
  110696. /**
  110697. * Only warning logs
  110698. */
  110699. static readonly WarningLogLevel: number;
  110700. /**
  110701. * Only error logs
  110702. */
  110703. static readonly ErrorLogLevel: number;
  110704. /**
  110705. * All logs
  110706. */
  110707. static readonly AllLogLevel: number;
  110708. /**
  110709. * Gets a value indicating the number of loading errors
  110710. * @ignorenaming
  110711. */
  110712. static get errorsCount(): number;
  110713. /**
  110714. * Callback called when a new log is added
  110715. */
  110716. static OnNewCacheEntry: (entry: string) => void;
  110717. /**
  110718. * Log a message to the console
  110719. * @param message defines the message to log
  110720. */
  110721. static Log(message: string): void;
  110722. /**
  110723. * Write a warning message to the console
  110724. * @param message defines the message to log
  110725. */
  110726. static Warn(message: string): void;
  110727. /**
  110728. * Write an error message to the console
  110729. * @param message defines the message to log
  110730. */
  110731. static Error(message: string): void;
  110732. /**
  110733. * Gets current log cache (list of logs)
  110734. */
  110735. static get LogCache(): string;
  110736. /**
  110737. * Clears the log cache
  110738. */
  110739. static ClearLogCache(): void;
  110740. /**
  110741. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  110742. */
  110743. static set LogLevels(level: number);
  110744. /**
  110745. * Checks if the window object exists
  110746. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  110747. */
  110748. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  110749. /**
  110750. * No performance log
  110751. */
  110752. static readonly PerformanceNoneLogLevel: number;
  110753. /**
  110754. * Use user marks to log performance
  110755. */
  110756. static readonly PerformanceUserMarkLogLevel: number;
  110757. /**
  110758. * Log performance to the console
  110759. */
  110760. static readonly PerformanceConsoleLogLevel: number;
  110761. private static _performance;
  110762. /**
  110763. * Sets the current performance log level
  110764. */
  110765. static set PerformanceLogLevel(level: number);
  110766. private static _StartPerformanceCounterDisabled;
  110767. private static _EndPerformanceCounterDisabled;
  110768. private static _StartUserMark;
  110769. private static _EndUserMark;
  110770. private static _StartPerformanceConsole;
  110771. private static _EndPerformanceConsole;
  110772. /**
  110773. * Starts a performance counter
  110774. */
  110775. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  110776. /**
  110777. * Ends a specific performance coutner
  110778. */
  110779. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  110780. /**
  110781. * Gets either window.performance.now() if supported or Date.now() else
  110782. */
  110783. static get Now(): number;
  110784. /**
  110785. * This method will return the name of the class used to create the instance of the given object.
  110786. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  110787. * @param object the object to get the class name from
  110788. * @param isType defines if the object is actually a type
  110789. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  110790. */
  110791. static GetClassName(object: any, isType?: boolean): string;
  110792. /**
  110793. * Gets the first element of an array satisfying a given predicate
  110794. * @param array defines the array to browse
  110795. * @param predicate defines the predicate to use
  110796. * @returns null if not found or the element
  110797. */
  110798. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  110799. /**
  110800. * This method will return the name of the full name of the class, including its owning module (if any).
  110801. * 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).
  110802. * @param object the object to get the class name from
  110803. * @param isType defines if the object is actually a type
  110804. * @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.
  110805. * @ignorenaming
  110806. */
  110807. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  110808. /**
  110809. * Returns a promise that resolves after the given amount of time.
  110810. * @param delay Number of milliseconds to delay
  110811. * @returns Promise that resolves after the given amount of time
  110812. */
  110813. static DelayAsync(delay: number): Promise<void>;
  110814. /**
  110815. * Utility function to detect if the current user agent is Safari
  110816. * @returns whether or not the current user agent is safari
  110817. */
  110818. static IsSafari(): boolean;
  110819. }
  110820. /**
  110821. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  110822. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  110823. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  110824. * @param name The name of the class, case should be preserved
  110825. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  110826. */
  110827. export function className(name: string, module?: string): (target: Object) => void;
  110828. /**
  110829. * An implementation of a loop for asynchronous functions.
  110830. */
  110831. export class AsyncLoop {
  110832. /**
  110833. * Defines the number of iterations for the loop
  110834. */
  110835. iterations: number;
  110836. /**
  110837. * Defines the current index of the loop.
  110838. */
  110839. index: number;
  110840. private _done;
  110841. private _fn;
  110842. private _successCallback;
  110843. /**
  110844. * Constructor.
  110845. * @param iterations the number of iterations.
  110846. * @param func the function to run each iteration
  110847. * @param successCallback the callback that will be called upon succesful execution
  110848. * @param offset starting offset.
  110849. */
  110850. constructor(
  110851. /**
  110852. * Defines the number of iterations for the loop
  110853. */
  110854. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  110855. /**
  110856. * Execute the next iteration. Must be called after the last iteration was finished.
  110857. */
  110858. executeNext(): void;
  110859. /**
  110860. * Break the loop and run the success callback.
  110861. */
  110862. breakLoop(): void;
  110863. /**
  110864. * Create and run an async loop.
  110865. * @param iterations the number of iterations.
  110866. * @param fn the function to run each iteration
  110867. * @param successCallback the callback that will be called upon succesful execution
  110868. * @param offset starting offset.
  110869. * @returns the created async loop object
  110870. */
  110871. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  110872. /**
  110873. * A for-loop that will run a given number of iterations synchronous and the rest async.
  110874. * @param iterations total number of iterations
  110875. * @param syncedIterations number of synchronous iterations in each async iteration.
  110876. * @param fn the function to call each iteration.
  110877. * @param callback a success call back that will be called when iterating stops.
  110878. * @param breakFunction a break condition (optional)
  110879. * @param timeout timeout settings for the setTimeout function. default - 0.
  110880. * @returns the created async loop object
  110881. */
  110882. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  110883. }
  110884. }
  110885. declare module BABYLON {
  110886. /**
  110887. * This class implement a typical dictionary using a string as key and the generic type T as value.
  110888. * The underlying implementation relies on an associative array to ensure the best performances.
  110889. * The value can be anything including 'null' but except 'undefined'
  110890. */
  110891. export class StringDictionary<T> {
  110892. /**
  110893. * This will clear this dictionary and copy the content from the 'source' one.
  110894. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  110895. * @param source the dictionary to take the content from and copy to this dictionary
  110896. */
  110897. copyFrom(source: StringDictionary<T>): void;
  110898. /**
  110899. * Get a value based from its key
  110900. * @param key the given key to get the matching value from
  110901. * @return the value if found, otherwise undefined is returned
  110902. */
  110903. get(key: string): T | undefined;
  110904. /**
  110905. * Get a value from its key or add it if it doesn't exist.
  110906. * This method will ensure you that a given key/data will be present in the dictionary.
  110907. * @param key the given key to get the matching value from
  110908. * @param factory the factory that will create the value if the key is not present in the dictionary.
  110909. * The factory will only be invoked if there's no data for the given key.
  110910. * @return the value corresponding to the key.
  110911. */
  110912. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  110913. /**
  110914. * Get a value from its key if present in the dictionary otherwise add it
  110915. * @param key the key to get the value from
  110916. * @param val if there's no such key/value pair in the dictionary add it with this value
  110917. * @return the value corresponding to the key
  110918. */
  110919. getOrAdd(key: string, val: T): T;
  110920. /**
  110921. * Check if there's a given key in the dictionary
  110922. * @param key the key to check for
  110923. * @return true if the key is present, false otherwise
  110924. */
  110925. contains(key: string): boolean;
  110926. /**
  110927. * Add a new key and its corresponding value
  110928. * @param key the key to add
  110929. * @param value the value corresponding to the key
  110930. * @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
  110931. */
  110932. add(key: string, value: T): boolean;
  110933. /**
  110934. * Update a specific value associated to a key
  110935. * @param key defines the key to use
  110936. * @param value defines the value to store
  110937. * @returns true if the value was updated (or false if the key was not found)
  110938. */
  110939. set(key: string, value: T): boolean;
  110940. /**
  110941. * Get the element of the given key and remove it from the dictionary
  110942. * @param key defines the key to search
  110943. * @returns the value associated with the key or null if not found
  110944. */
  110945. getAndRemove(key: string): Nullable<T>;
  110946. /**
  110947. * Remove a key/value from the dictionary.
  110948. * @param key the key to remove
  110949. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  110950. */
  110951. remove(key: string): boolean;
  110952. /**
  110953. * Clear the whole content of the dictionary
  110954. */
  110955. clear(): void;
  110956. /**
  110957. * Gets the current count
  110958. */
  110959. get count(): number;
  110960. /**
  110961. * Execute a callback on each key/val of the dictionary.
  110962. * Note that you can remove any element in this dictionary in the callback implementation
  110963. * @param callback the callback to execute on a given key/value pair
  110964. */
  110965. forEach(callback: (key: string, val: T) => void): void;
  110966. /**
  110967. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  110968. * If the callback returns null or undefined the method will iterate to the next key/value pair
  110969. * Note that you can remove any element in this dictionary in the callback implementation
  110970. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  110971. * @returns the first item
  110972. */
  110973. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  110974. private _count;
  110975. private _data;
  110976. }
  110977. }
  110978. declare module BABYLON {
  110979. /** @hidden */
  110980. export interface ICollisionCoordinator {
  110981. createCollider(): Collider;
  110982. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  110983. init(scene: Scene): void;
  110984. }
  110985. /** @hidden */
  110986. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  110987. private _scene;
  110988. private _scaledPosition;
  110989. private _scaledVelocity;
  110990. private _finalPosition;
  110991. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  110992. createCollider(): Collider;
  110993. init(scene: Scene): void;
  110994. private _collideWithWorld;
  110995. }
  110996. }
  110997. declare module BABYLON {
  110998. /**
  110999. * Class used to manage all inputs for the scene.
  111000. */
  111001. export class InputManager {
  111002. /** The distance in pixel that you have to move to prevent some events */
  111003. static DragMovementThreshold: number;
  111004. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  111005. static LongPressDelay: number;
  111006. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  111007. static DoubleClickDelay: number;
  111008. /** If you need to check double click without raising a single click at first click, enable this flag */
  111009. static ExclusiveDoubleClickMode: boolean;
  111010. private _wheelEventName;
  111011. private _onPointerMove;
  111012. private _onPointerDown;
  111013. private _onPointerUp;
  111014. private _initClickEvent;
  111015. private _initActionManager;
  111016. private _delayedSimpleClick;
  111017. private _delayedSimpleClickTimeout;
  111018. private _previousDelayedSimpleClickTimeout;
  111019. private _meshPickProceed;
  111020. private _previousButtonPressed;
  111021. private _currentPickResult;
  111022. private _previousPickResult;
  111023. private _totalPointersPressed;
  111024. private _doubleClickOccured;
  111025. private _pointerOverMesh;
  111026. private _pickedDownMesh;
  111027. private _pickedUpMesh;
  111028. private _pointerX;
  111029. private _pointerY;
  111030. private _unTranslatedPointerX;
  111031. private _unTranslatedPointerY;
  111032. private _startingPointerPosition;
  111033. private _previousStartingPointerPosition;
  111034. private _startingPointerTime;
  111035. private _previousStartingPointerTime;
  111036. private _pointerCaptures;
  111037. private _onKeyDown;
  111038. private _onKeyUp;
  111039. private _onCanvasFocusObserver;
  111040. private _onCanvasBlurObserver;
  111041. private _scene;
  111042. /**
  111043. * Creates a new InputManager
  111044. * @param scene defines the hosting scene
  111045. */
  111046. constructor(scene: Scene);
  111047. /**
  111048. * Gets the mesh that is currently under the pointer
  111049. */
  111050. get meshUnderPointer(): Nullable<AbstractMesh>;
  111051. /**
  111052. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  111053. */
  111054. get unTranslatedPointer(): Vector2;
  111055. /**
  111056. * Gets or sets the current on-screen X position of the pointer
  111057. */
  111058. get pointerX(): number;
  111059. set pointerX(value: number);
  111060. /**
  111061. * Gets or sets the current on-screen Y position of the pointer
  111062. */
  111063. get pointerY(): number;
  111064. set pointerY(value: number);
  111065. private _updatePointerPosition;
  111066. private _processPointerMove;
  111067. private _setRayOnPointerInfo;
  111068. private _checkPrePointerObservable;
  111069. /**
  111070. * Use this method to simulate a pointer move on a mesh
  111071. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111072. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111073. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111074. */
  111075. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111076. /**
  111077. * Use this method to simulate a pointer down on a mesh
  111078. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111079. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111080. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111081. */
  111082. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  111083. private _processPointerDown;
  111084. /** @hidden */
  111085. _isPointerSwiping(): boolean;
  111086. /**
  111087. * Use this method to simulate a pointer up on a mesh
  111088. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  111089. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  111090. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  111091. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  111092. */
  111093. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  111094. private _processPointerUp;
  111095. /**
  111096. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  111097. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  111098. * @returns true if the pointer was captured
  111099. */
  111100. isPointerCaptured(pointerId?: number): boolean;
  111101. /**
  111102. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  111103. * @param attachUp defines if you want to attach events to pointerup
  111104. * @param attachDown defines if you want to attach events to pointerdown
  111105. * @param attachMove defines if you want to attach events to pointermove
  111106. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  111107. */
  111108. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  111109. /**
  111110. * Detaches all event handlers
  111111. */
  111112. detachControl(): void;
  111113. /**
  111114. * Force the value of meshUnderPointer
  111115. * @param mesh defines the mesh to use
  111116. */
  111117. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111118. /**
  111119. * Gets the mesh under the pointer
  111120. * @returns a Mesh or null if no mesh is under the pointer
  111121. */
  111122. getPointerOverMesh(): Nullable<AbstractMesh>;
  111123. }
  111124. }
  111125. declare module BABYLON {
  111126. /**
  111127. * Helper class used to generate session unique ID
  111128. */
  111129. export class UniqueIdGenerator {
  111130. private static _UniqueIdCounter;
  111131. /**
  111132. * Gets an unique (relatively to the current scene) Id
  111133. */
  111134. static get UniqueId(): number;
  111135. }
  111136. }
  111137. declare module BABYLON {
  111138. /**
  111139. * This class defines the direct association between an animation and a target
  111140. */
  111141. export class TargetedAnimation {
  111142. /**
  111143. * Animation to perform
  111144. */
  111145. animation: Animation;
  111146. /**
  111147. * Target to animate
  111148. */
  111149. target: any;
  111150. /**
  111151. * Serialize the object
  111152. * @returns the JSON object representing the current entity
  111153. */
  111154. serialize(): any;
  111155. }
  111156. /**
  111157. * Use this class to create coordinated animations on multiple targets
  111158. */
  111159. export class AnimationGroup implements IDisposable {
  111160. /** The name of the animation group */
  111161. name: string;
  111162. private _scene;
  111163. private _targetedAnimations;
  111164. private _animatables;
  111165. private _from;
  111166. private _to;
  111167. private _isStarted;
  111168. private _isPaused;
  111169. private _speedRatio;
  111170. private _loopAnimation;
  111171. private _isAdditive;
  111172. /**
  111173. * Gets or sets the unique id of the node
  111174. */
  111175. uniqueId: number;
  111176. /**
  111177. * This observable will notify when one animation have ended
  111178. */
  111179. onAnimationEndObservable: Observable<TargetedAnimation>;
  111180. /**
  111181. * Observer raised when one animation loops
  111182. */
  111183. onAnimationLoopObservable: Observable<TargetedAnimation>;
  111184. /**
  111185. * Observer raised when all animations have looped
  111186. */
  111187. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  111188. /**
  111189. * This observable will notify when all animations have ended.
  111190. */
  111191. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  111192. /**
  111193. * This observable will notify when all animations have paused.
  111194. */
  111195. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  111196. /**
  111197. * This observable will notify when all animations are playing.
  111198. */
  111199. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  111200. /**
  111201. * Gets the first frame
  111202. */
  111203. get from(): number;
  111204. /**
  111205. * Gets the last frame
  111206. */
  111207. get to(): number;
  111208. /**
  111209. * Define if the animations are started
  111210. */
  111211. get isStarted(): boolean;
  111212. /**
  111213. * Gets a value indicating that the current group is playing
  111214. */
  111215. get isPlaying(): boolean;
  111216. /**
  111217. * Gets or sets the speed ratio to use for all animations
  111218. */
  111219. get speedRatio(): number;
  111220. /**
  111221. * Gets or sets the speed ratio to use for all animations
  111222. */
  111223. set speedRatio(value: number);
  111224. /**
  111225. * Gets or sets if all animations should loop or not
  111226. */
  111227. get loopAnimation(): boolean;
  111228. set loopAnimation(value: boolean);
  111229. /**
  111230. * Gets or sets if all animations should be evaluated additively
  111231. */
  111232. get isAdditive(): boolean;
  111233. set isAdditive(value: boolean);
  111234. /**
  111235. * Gets the targeted animations for this animation group
  111236. */
  111237. get targetedAnimations(): Array<TargetedAnimation>;
  111238. /**
  111239. * returning the list of animatables controlled by this animation group.
  111240. */
  111241. get animatables(): Array<Animatable>;
  111242. /**
  111243. * Instantiates a new Animation Group.
  111244. * This helps managing several animations at once.
  111245. * @see http://doc.babylonjs.com/how_to/group
  111246. * @param name Defines the name of the group
  111247. * @param scene Defines the scene the group belongs to
  111248. */
  111249. constructor(
  111250. /** The name of the animation group */
  111251. name: string, scene?: Nullable<Scene>);
  111252. /**
  111253. * Add an animation (with its target) in the group
  111254. * @param animation defines the animation we want to add
  111255. * @param target defines the target of the animation
  111256. * @returns the TargetedAnimation object
  111257. */
  111258. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  111259. /**
  111260. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  111261. * It can add constant keys at begin or end
  111262. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  111263. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  111264. * @returns the animation group
  111265. */
  111266. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  111267. private _animationLoopCount;
  111268. private _animationLoopFlags;
  111269. private _processLoop;
  111270. /**
  111271. * Start all animations on given targets
  111272. * @param loop defines if animations must loop
  111273. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  111274. * @param from defines the from key (optional)
  111275. * @param to defines the to key (optional)
  111276. * @param isAdditive defines the additive state for the resulting animatables (optional)
  111277. * @returns the current animation group
  111278. */
  111279. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  111280. /**
  111281. * Pause all animations
  111282. * @returns the animation group
  111283. */
  111284. pause(): AnimationGroup;
  111285. /**
  111286. * Play all animations to initial state
  111287. * This function will start() the animations if they were not started or will restart() them if they were paused
  111288. * @param loop defines if animations must loop
  111289. * @returns the animation group
  111290. */
  111291. play(loop?: boolean): AnimationGroup;
  111292. /**
  111293. * Reset all animations to initial state
  111294. * @returns the animation group
  111295. */
  111296. reset(): AnimationGroup;
  111297. /**
  111298. * Restart animations from key 0
  111299. * @returns the animation group
  111300. */
  111301. restart(): AnimationGroup;
  111302. /**
  111303. * Stop all animations
  111304. * @returns the animation group
  111305. */
  111306. stop(): AnimationGroup;
  111307. /**
  111308. * Set animation weight for all animatables
  111309. * @param weight defines the weight to use
  111310. * @return the animationGroup
  111311. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111312. */
  111313. setWeightForAllAnimatables(weight: number): AnimationGroup;
  111314. /**
  111315. * Synchronize and normalize all animatables with a source animatable
  111316. * @param root defines the root animatable to synchronize with
  111317. * @return the animationGroup
  111318. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  111319. */
  111320. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  111321. /**
  111322. * Goes to a specific frame in this animation group
  111323. * @param frame the frame number to go to
  111324. * @return the animationGroup
  111325. */
  111326. goToFrame(frame: number): AnimationGroup;
  111327. /**
  111328. * Dispose all associated resources
  111329. */
  111330. dispose(): void;
  111331. private _checkAnimationGroupEnded;
  111332. /**
  111333. * Clone the current animation group and returns a copy
  111334. * @param newName defines the name of the new group
  111335. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  111336. * @returns the new aniamtion group
  111337. */
  111338. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  111339. /**
  111340. * Serializes the animationGroup to an object
  111341. * @returns Serialized object
  111342. */
  111343. serialize(): any;
  111344. /**
  111345. * Returns a new AnimationGroup object parsed from the source provided.
  111346. * @param parsedAnimationGroup defines the source
  111347. * @param scene defines the scene that will receive the animationGroup
  111348. * @returns a new AnimationGroup
  111349. */
  111350. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  111351. /**
  111352. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  111353. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  111354. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  111355. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  111356. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  111357. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  111358. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  111359. */
  111360. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  111361. /**
  111362. * Returns the string "AnimationGroup"
  111363. * @returns "AnimationGroup"
  111364. */
  111365. getClassName(): string;
  111366. /**
  111367. * Creates a detailled string about the object
  111368. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  111369. * @returns a string representing the object
  111370. */
  111371. toString(fullDetails?: boolean): string;
  111372. }
  111373. }
  111374. declare module BABYLON {
  111375. /**
  111376. * Define an interface for all classes that will hold resources
  111377. */
  111378. export interface IDisposable {
  111379. /**
  111380. * Releases all held resources
  111381. */
  111382. dispose(): void;
  111383. }
  111384. /** Interface defining initialization parameters for Scene class */
  111385. export interface SceneOptions {
  111386. /**
  111387. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  111388. * It will improve performance when the number of geometries becomes important.
  111389. */
  111390. useGeometryUniqueIdsMap?: boolean;
  111391. /**
  111392. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  111393. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111394. */
  111395. useMaterialMeshMap?: boolean;
  111396. /**
  111397. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  111398. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  111399. */
  111400. useClonedMeshMap?: boolean;
  111401. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  111402. virtual?: boolean;
  111403. }
  111404. /**
  111405. * Represents a scene to be rendered by the engine.
  111406. * @see http://doc.babylonjs.com/features/scene
  111407. */
  111408. export class Scene extends AbstractScene implements IAnimatable {
  111409. /** The fog is deactivated */
  111410. static readonly FOGMODE_NONE: number;
  111411. /** The fog density is following an exponential function */
  111412. static readonly FOGMODE_EXP: number;
  111413. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  111414. static readonly FOGMODE_EXP2: number;
  111415. /** The fog density is following a linear function. */
  111416. static readonly FOGMODE_LINEAR: number;
  111417. /**
  111418. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  111419. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111420. */
  111421. static MinDeltaTime: number;
  111422. /**
  111423. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  111424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111425. */
  111426. static MaxDeltaTime: number;
  111427. /**
  111428. * Factory used to create the default material.
  111429. * @param name The name of the material to create
  111430. * @param scene The scene to create the material for
  111431. * @returns The default material
  111432. */
  111433. static DefaultMaterialFactory(scene: Scene): Material;
  111434. /**
  111435. * Factory used to create the a collision coordinator.
  111436. * @returns The collision coordinator
  111437. */
  111438. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  111439. /** @hidden */
  111440. _inputManager: InputManager;
  111441. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  111442. cameraToUseForPointers: Nullable<Camera>;
  111443. /** @hidden */
  111444. readonly _isScene: boolean;
  111445. /** @hidden */
  111446. _blockEntityCollection: boolean;
  111447. /**
  111448. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  111449. */
  111450. autoClear: boolean;
  111451. /**
  111452. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  111453. */
  111454. autoClearDepthAndStencil: boolean;
  111455. /**
  111456. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  111457. */
  111458. clearColor: Color4;
  111459. /**
  111460. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  111461. */
  111462. ambientColor: Color3;
  111463. /**
  111464. * This is use to store the default BRDF lookup for PBR materials in your scene.
  111465. * It should only be one of the following (if not the default embedded one):
  111466. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111467. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  111468. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111469. * The material properties need to be setup according to the type of texture in use.
  111470. */
  111471. environmentBRDFTexture: BaseTexture;
  111472. /** @hidden */
  111473. protected _environmentTexture: Nullable<BaseTexture>;
  111474. /**
  111475. * Texture used in all pbr material as the reflection texture.
  111476. * As in the majority of the scene they are the same (exception for multi room and so on),
  111477. * this is easier to reference from here than from all the materials.
  111478. */
  111479. get environmentTexture(): Nullable<BaseTexture>;
  111480. /**
  111481. * Texture used in all pbr material as the reflection texture.
  111482. * As in the majority of the scene they are the same (exception for multi room and so on),
  111483. * this is easier to set here than in all the materials.
  111484. */
  111485. set environmentTexture(value: Nullable<BaseTexture>);
  111486. /** @hidden */
  111487. protected _environmentIntensity: number;
  111488. /**
  111489. * Intensity of the environment in all pbr material.
  111490. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111491. * As in the majority of the scene they are the same (exception for multi room and so on),
  111492. * this is easier to reference from here than from all the materials.
  111493. */
  111494. get environmentIntensity(): number;
  111495. /**
  111496. * Intensity of the environment in all pbr material.
  111497. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  111498. * As in the majority of the scene they are the same (exception for multi room and so on),
  111499. * this is easier to set here than in all the materials.
  111500. */
  111501. set environmentIntensity(value: number);
  111502. /** @hidden */
  111503. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111504. /**
  111505. * Default image processing configuration used either in the rendering
  111506. * Forward main pass or through the imageProcessingPostProcess if present.
  111507. * As in the majority of the scene they are the same (exception for multi camera),
  111508. * this is easier to reference from here than from all the materials and post process.
  111509. *
  111510. * No setter as we it is a shared configuration, you can set the values instead.
  111511. */
  111512. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111513. private _forceWireframe;
  111514. /**
  111515. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  111516. */
  111517. set forceWireframe(value: boolean);
  111518. get forceWireframe(): boolean;
  111519. private _skipFrustumClipping;
  111520. /**
  111521. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  111522. */
  111523. set skipFrustumClipping(value: boolean);
  111524. get skipFrustumClipping(): boolean;
  111525. private _forcePointsCloud;
  111526. /**
  111527. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  111528. */
  111529. set forcePointsCloud(value: boolean);
  111530. get forcePointsCloud(): boolean;
  111531. /**
  111532. * Gets or sets the active clipplane 1
  111533. */
  111534. clipPlane: Nullable<Plane>;
  111535. /**
  111536. * Gets or sets the active clipplane 2
  111537. */
  111538. clipPlane2: Nullable<Plane>;
  111539. /**
  111540. * Gets or sets the active clipplane 3
  111541. */
  111542. clipPlane3: Nullable<Plane>;
  111543. /**
  111544. * Gets or sets the active clipplane 4
  111545. */
  111546. clipPlane4: Nullable<Plane>;
  111547. /**
  111548. * Gets or sets the active clipplane 5
  111549. */
  111550. clipPlane5: Nullable<Plane>;
  111551. /**
  111552. * Gets or sets the active clipplane 6
  111553. */
  111554. clipPlane6: Nullable<Plane>;
  111555. /**
  111556. * Gets or sets a boolean indicating if animations are enabled
  111557. */
  111558. animationsEnabled: boolean;
  111559. private _animationPropertiesOverride;
  111560. /**
  111561. * Gets or sets the animation properties override
  111562. */
  111563. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111564. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111565. /**
  111566. * Gets or sets a boolean indicating if a constant deltatime has to be used
  111567. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  111568. */
  111569. useConstantAnimationDeltaTime: boolean;
  111570. /**
  111571. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  111572. * Please note that it requires to run a ray cast through the scene on every frame
  111573. */
  111574. constantlyUpdateMeshUnderPointer: boolean;
  111575. /**
  111576. * Defines the HTML cursor to use when hovering over interactive elements
  111577. */
  111578. hoverCursor: string;
  111579. /**
  111580. * Defines the HTML default cursor to use (empty by default)
  111581. */
  111582. defaultCursor: string;
  111583. /**
  111584. * Defines whether cursors are handled by the scene.
  111585. */
  111586. doNotHandleCursors: boolean;
  111587. /**
  111588. * This is used to call preventDefault() on pointer down
  111589. * in order to block unwanted artifacts like system double clicks
  111590. */
  111591. preventDefaultOnPointerDown: boolean;
  111592. /**
  111593. * This is used to call preventDefault() on pointer up
  111594. * in order to block unwanted artifacts like system double clicks
  111595. */
  111596. preventDefaultOnPointerUp: boolean;
  111597. /**
  111598. * Gets or sets user defined metadata
  111599. */
  111600. metadata: any;
  111601. /**
  111602. * For internal use only. Please do not use.
  111603. */
  111604. reservedDataStore: any;
  111605. /**
  111606. * Gets the name of the plugin used to load this scene (null by default)
  111607. */
  111608. loadingPluginName: string;
  111609. /**
  111610. * Use this array to add regular expressions used to disable offline support for specific urls
  111611. */
  111612. disableOfflineSupportExceptionRules: RegExp[];
  111613. /**
  111614. * An event triggered when the scene is disposed.
  111615. */
  111616. onDisposeObservable: Observable<Scene>;
  111617. private _onDisposeObserver;
  111618. /** Sets a function to be executed when this scene is disposed. */
  111619. set onDispose(callback: () => void);
  111620. /**
  111621. * An event triggered before rendering the scene (right after animations and physics)
  111622. */
  111623. onBeforeRenderObservable: Observable<Scene>;
  111624. private _onBeforeRenderObserver;
  111625. /** Sets a function to be executed before rendering this scene */
  111626. set beforeRender(callback: Nullable<() => void>);
  111627. /**
  111628. * An event triggered after rendering the scene
  111629. */
  111630. onAfterRenderObservable: Observable<Scene>;
  111631. /**
  111632. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  111633. */
  111634. onAfterRenderCameraObservable: Observable<Camera>;
  111635. private _onAfterRenderObserver;
  111636. /** Sets a function to be executed after rendering this scene */
  111637. set afterRender(callback: Nullable<() => void>);
  111638. /**
  111639. * An event triggered before animating the scene
  111640. */
  111641. onBeforeAnimationsObservable: Observable<Scene>;
  111642. /**
  111643. * An event triggered after animations processing
  111644. */
  111645. onAfterAnimationsObservable: Observable<Scene>;
  111646. /**
  111647. * An event triggered before draw calls are ready to be sent
  111648. */
  111649. onBeforeDrawPhaseObservable: Observable<Scene>;
  111650. /**
  111651. * An event triggered after draw calls have been sent
  111652. */
  111653. onAfterDrawPhaseObservable: Observable<Scene>;
  111654. /**
  111655. * An event triggered when the scene is ready
  111656. */
  111657. onReadyObservable: Observable<Scene>;
  111658. /**
  111659. * An event triggered before rendering a camera
  111660. */
  111661. onBeforeCameraRenderObservable: Observable<Camera>;
  111662. private _onBeforeCameraRenderObserver;
  111663. /** Sets a function to be executed before rendering a camera*/
  111664. set beforeCameraRender(callback: () => void);
  111665. /**
  111666. * An event triggered after rendering a camera
  111667. */
  111668. onAfterCameraRenderObservable: Observable<Camera>;
  111669. private _onAfterCameraRenderObserver;
  111670. /** Sets a function to be executed after rendering a camera*/
  111671. set afterCameraRender(callback: () => void);
  111672. /**
  111673. * An event triggered when active meshes evaluation is about to start
  111674. */
  111675. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  111676. /**
  111677. * An event triggered when active meshes evaluation is done
  111678. */
  111679. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  111680. /**
  111681. * An event triggered when particles rendering is about to start
  111682. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111683. */
  111684. onBeforeParticlesRenderingObservable: Observable<Scene>;
  111685. /**
  111686. * An event triggered when particles rendering is done
  111687. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  111688. */
  111689. onAfterParticlesRenderingObservable: Observable<Scene>;
  111690. /**
  111691. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  111692. */
  111693. onDataLoadedObservable: Observable<Scene>;
  111694. /**
  111695. * An event triggered when a camera is created
  111696. */
  111697. onNewCameraAddedObservable: Observable<Camera>;
  111698. /**
  111699. * An event triggered when a camera is removed
  111700. */
  111701. onCameraRemovedObservable: Observable<Camera>;
  111702. /**
  111703. * An event triggered when a light is created
  111704. */
  111705. onNewLightAddedObservable: Observable<Light>;
  111706. /**
  111707. * An event triggered when a light is removed
  111708. */
  111709. onLightRemovedObservable: Observable<Light>;
  111710. /**
  111711. * An event triggered when a geometry is created
  111712. */
  111713. onNewGeometryAddedObservable: Observable<Geometry>;
  111714. /**
  111715. * An event triggered when a geometry is removed
  111716. */
  111717. onGeometryRemovedObservable: Observable<Geometry>;
  111718. /**
  111719. * An event triggered when a transform node is created
  111720. */
  111721. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  111722. /**
  111723. * An event triggered when a transform node is removed
  111724. */
  111725. onTransformNodeRemovedObservable: Observable<TransformNode>;
  111726. /**
  111727. * An event triggered when a mesh is created
  111728. */
  111729. onNewMeshAddedObservable: Observable<AbstractMesh>;
  111730. /**
  111731. * An event triggered when a mesh is removed
  111732. */
  111733. onMeshRemovedObservable: Observable<AbstractMesh>;
  111734. /**
  111735. * An event triggered when a skeleton is created
  111736. */
  111737. onNewSkeletonAddedObservable: Observable<Skeleton>;
  111738. /**
  111739. * An event triggered when a skeleton is removed
  111740. */
  111741. onSkeletonRemovedObservable: Observable<Skeleton>;
  111742. /**
  111743. * An event triggered when a material is created
  111744. */
  111745. onNewMaterialAddedObservable: Observable<Material>;
  111746. /**
  111747. * An event triggered when a material is removed
  111748. */
  111749. onMaterialRemovedObservable: Observable<Material>;
  111750. /**
  111751. * An event triggered when a texture is created
  111752. */
  111753. onNewTextureAddedObservable: Observable<BaseTexture>;
  111754. /**
  111755. * An event triggered when a texture is removed
  111756. */
  111757. onTextureRemovedObservable: Observable<BaseTexture>;
  111758. /**
  111759. * An event triggered when render targets are about to be rendered
  111760. * Can happen multiple times per frame.
  111761. */
  111762. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  111763. /**
  111764. * An event triggered when render targets were rendered.
  111765. * Can happen multiple times per frame.
  111766. */
  111767. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  111768. /**
  111769. * An event triggered before calculating deterministic simulation step
  111770. */
  111771. onBeforeStepObservable: Observable<Scene>;
  111772. /**
  111773. * An event triggered after calculating deterministic simulation step
  111774. */
  111775. onAfterStepObservable: Observable<Scene>;
  111776. /**
  111777. * An event triggered when the activeCamera property is updated
  111778. */
  111779. onActiveCameraChanged: Observable<Scene>;
  111780. /**
  111781. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  111782. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  111783. * 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)
  111784. */
  111785. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  111786. /**
  111787. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  111788. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  111789. * 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)
  111790. */
  111791. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  111792. /**
  111793. * This Observable will when a mesh has been imported into the scene.
  111794. */
  111795. onMeshImportedObservable: Observable<AbstractMesh>;
  111796. /**
  111797. * This Observable will when an animation file has been imported into the scene.
  111798. */
  111799. onAnimationFileImportedObservable: Observable<Scene>;
  111800. /**
  111801. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  111802. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  111803. */
  111804. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  111805. /** @hidden */
  111806. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  111807. /**
  111808. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  111809. */
  111810. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  111811. /**
  111812. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  111813. */
  111814. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  111815. /**
  111816. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  111817. */
  111818. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  111819. /** Callback called when a pointer move is detected */
  111820. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  111821. /** Callback called when a pointer down is detected */
  111822. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  111823. /** Callback called when a pointer up is detected */
  111824. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  111825. /** Callback called when a pointer pick is detected */
  111826. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  111827. /**
  111828. * 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).
  111829. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  111830. */
  111831. onPrePointerObservable: Observable<PointerInfoPre>;
  111832. /**
  111833. * Observable event triggered each time an input event is received from the rendering canvas
  111834. */
  111835. onPointerObservable: Observable<PointerInfo>;
  111836. /**
  111837. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  111838. */
  111839. get unTranslatedPointer(): Vector2;
  111840. /**
  111841. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  111842. */
  111843. static get DragMovementThreshold(): number;
  111844. static set DragMovementThreshold(value: number);
  111845. /**
  111846. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  111847. */
  111848. static get LongPressDelay(): number;
  111849. static set LongPressDelay(value: number);
  111850. /**
  111851. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  111852. */
  111853. static get DoubleClickDelay(): number;
  111854. static set DoubleClickDelay(value: number);
  111855. /** If you need to check double click without raising a single click at first click, enable this flag */
  111856. static get ExclusiveDoubleClickMode(): boolean;
  111857. static set ExclusiveDoubleClickMode(value: boolean);
  111858. /** @hidden */
  111859. _mirroredCameraPosition: Nullable<Vector3>;
  111860. /**
  111861. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  111862. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  111863. */
  111864. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  111865. /**
  111866. * Observable event triggered each time an keyboard event is received from the hosting window
  111867. */
  111868. onKeyboardObservable: Observable<KeyboardInfo>;
  111869. private _useRightHandedSystem;
  111870. /**
  111871. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  111872. */
  111873. set useRightHandedSystem(value: boolean);
  111874. get useRightHandedSystem(): boolean;
  111875. private _timeAccumulator;
  111876. private _currentStepId;
  111877. private _currentInternalStep;
  111878. /**
  111879. * Sets the step Id used by deterministic lock step
  111880. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111881. * @param newStepId defines the step Id
  111882. */
  111883. setStepId(newStepId: number): void;
  111884. /**
  111885. * Gets the step Id used by deterministic lock step
  111886. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111887. * @returns the step Id
  111888. */
  111889. getStepId(): number;
  111890. /**
  111891. * Gets the internal step used by deterministic lock step
  111892. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111893. * @returns the internal step
  111894. */
  111895. getInternalStep(): number;
  111896. private _fogEnabled;
  111897. /**
  111898. * Gets or sets a boolean indicating if fog is enabled on this scene
  111899. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111900. * (Default is true)
  111901. */
  111902. set fogEnabled(value: boolean);
  111903. get fogEnabled(): boolean;
  111904. private _fogMode;
  111905. /**
  111906. * Gets or sets the fog mode to use
  111907. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111908. * | mode | value |
  111909. * | --- | --- |
  111910. * | FOGMODE_NONE | 0 |
  111911. * | FOGMODE_EXP | 1 |
  111912. * | FOGMODE_EXP2 | 2 |
  111913. * | FOGMODE_LINEAR | 3 |
  111914. */
  111915. set fogMode(value: number);
  111916. get fogMode(): number;
  111917. /**
  111918. * Gets or sets the fog color to use
  111919. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111920. * (Default is Color3(0.2, 0.2, 0.3))
  111921. */
  111922. fogColor: Color3;
  111923. /**
  111924. * Gets or sets the fog density to use
  111925. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111926. * (Default is 0.1)
  111927. */
  111928. fogDensity: number;
  111929. /**
  111930. * Gets or sets the fog start distance to use
  111931. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111932. * (Default is 0)
  111933. */
  111934. fogStart: number;
  111935. /**
  111936. * Gets or sets the fog end distance to use
  111937. * @see http://doc.babylonjs.com/babylon101/environment#fog
  111938. * (Default is 1000)
  111939. */
  111940. fogEnd: number;
  111941. private _shadowsEnabled;
  111942. /**
  111943. * Gets or sets a boolean indicating if shadows are enabled on this scene
  111944. */
  111945. set shadowsEnabled(value: boolean);
  111946. get shadowsEnabled(): boolean;
  111947. private _lightsEnabled;
  111948. /**
  111949. * Gets or sets a boolean indicating if lights are enabled on this scene
  111950. */
  111951. set lightsEnabled(value: boolean);
  111952. get lightsEnabled(): boolean;
  111953. /** All of the active cameras added to this scene. */
  111954. activeCameras: Camera[];
  111955. /** @hidden */
  111956. _activeCamera: Nullable<Camera>;
  111957. /** Gets or sets the current active camera */
  111958. get activeCamera(): Nullable<Camera>;
  111959. set activeCamera(value: Nullable<Camera>);
  111960. private _defaultMaterial;
  111961. /** The default material used on meshes when no material is affected */
  111962. get defaultMaterial(): Material;
  111963. /** The default material used on meshes when no material is affected */
  111964. set defaultMaterial(value: Material);
  111965. private _texturesEnabled;
  111966. /**
  111967. * Gets or sets a boolean indicating if textures are enabled on this scene
  111968. */
  111969. set texturesEnabled(value: boolean);
  111970. get texturesEnabled(): boolean;
  111971. /**
  111972. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  111973. */
  111974. physicsEnabled: boolean;
  111975. /**
  111976. * Gets or sets a boolean indicating if particles are enabled on this scene
  111977. */
  111978. particlesEnabled: boolean;
  111979. /**
  111980. * Gets or sets a boolean indicating if sprites are enabled on this scene
  111981. */
  111982. spritesEnabled: boolean;
  111983. private _skeletonsEnabled;
  111984. /**
  111985. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  111986. */
  111987. set skeletonsEnabled(value: boolean);
  111988. get skeletonsEnabled(): boolean;
  111989. /**
  111990. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  111991. */
  111992. lensFlaresEnabled: boolean;
  111993. /**
  111994. * Gets or sets a boolean indicating if collisions are enabled on this scene
  111995. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111996. */
  111997. collisionsEnabled: boolean;
  111998. private _collisionCoordinator;
  111999. /** @hidden */
  112000. get collisionCoordinator(): ICollisionCoordinator;
  112001. /**
  112002. * Defines the gravity applied to this scene (used only for collisions)
  112003. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112004. */
  112005. gravity: Vector3;
  112006. /**
  112007. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  112008. */
  112009. postProcessesEnabled: boolean;
  112010. /**
  112011. * The list of postprocesses added to the scene
  112012. */
  112013. postProcesses: PostProcess[];
  112014. /**
  112015. * Gets the current postprocess manager
  112016. */
  112017. postProcessManager: PostProcessManager;
  112018. /**
  112019. * Gets or sets a boolean indicating if render targets are enabled on this scene
  112020. */
  112021. renderTargetsEnabled: boolean;
  112022. /**
  112023. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  112024. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  112025. */
  112026. dumpNextRenderTargets: boolean;
  112027. /**
  112028. * The list of user defined render targets added to the scene
  112029. */
  112030. customRenderTargets: RenderTargetTexture[];
  112031. /**
  112032. * Defines if texture loading must be delayed
  112033. * If true, textures will only be loaded when they need to be rendered
  112034. */
  112035. useDelayedTextureLoading: boolean;
  112036. /**
  112037. * Gets the list of meshes imported to the scene through SceneLoader
  112038. */
  112039. importedMeshesFiles: String[];
  112040. /**
  112041. * Gets or sets a boolean indicating if probes are enabled on this scene
  112042. */
  112043. probesEnabled: boolean;
  112044. /**
  112045. * Gets or sets the current offline provider to use to store scene data
  112046. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  112047. */
  112048. offlineProvider: IOfflineProvider;
  112049. /**
  112050. * Gets or sets the action manager associated with the scene
  112051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112052. */
  112053. actionManager: AbstractActionManager;
  112054. private _meshesForIntersections;
  112055. /**
  112056. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  112057. */
  112058. proceduralTexturesEnabled: boolean;
  112059. private _engine;
  112060. private _totalVertices;
  112061. /** @hidden */
  112062. _activeIndices: PerfCounter;
  112063. /** @hidden */
  112064. _activeParticles: PerfCounter;
  112065. /** @hidden */
  112066. _activeBones: PerfCounter;
  112067. private _animationRatio;
  112068. /** @hidden */
  112069. _animationTimeLast: number;
  112070. /** @hidden */
  112071. _animationTime: number;
  112072. /**
  112073. * Gets or sets a general scale for animation speed
  112074. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  112075. */
  112076. animationTimeScale: number;
  112077. /** @hidden */
  112078. _cachedMaterial: Nullable<Material>;
  112079. /** @hidden */
  112080. _cachedEffect: Nullable<Effect>;
  112081. /** @hidden */
  112082. _cachedVisibility: Nullable<number>;
  112083. private _renderId;
  112084. private _frameId;
  112085. private _executeWhenReadyTimeoutId;
  112086. private _intermediateRendering;
  112087. private _viewUpdateFlag;
  112088. private _projectionUpdateFlag;
  112089. /** @hidden */
  112090. _toBeDisposed: Nullable<IDisposable>[];
  112091. private _activeRequests;
  112092. /** @hidden */
  112093. _pendingData: any[];
  112094. private _isDisposed;
  112095. /**
  112096. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  112097. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  112098. */
  112099. dispatchAllSubMeshesOfActiveMeshes: boolean;
  112100. private _activeMeshes;
  112101. private _processedMaterials;
  112102. private _renderTargets;
  112103. /** @hidden */
  112104. _activeParticleSystems: SmartArray<IParticleSystem>;
  112105. private _activeSkeletons;
  112106. private _softwareSkinnedMeshes;
  112107. private _renderingManager;
  112108. /** @hidden */
  112109. _activeAnimatables: Animatable[];
  112110. private _transformMatrix;
  112111. private _sceneUbo;
  112112. /** @hidden */
  112113. _viewMatrix: Matrix;
  112114. private _projectionMatrix;
  112115. /** @hidden */
  112116. _forcedViewPosition: Nullable<Vector3>;
  112117. /** @hidden */
  112118. _frustumPlanes: Plane[];
  112119. /**
  112120. * Gets the list of frustum planes (built from the active camera)
  112121. */
  112122. get frustumPlanes(): Plane[];
  112123. /**
  112124. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  112125. * This is useful if there are more lights that the maximum simulteanous authorized
  112126. */
  112127. requireLightSorting: boolean;
  112128. /** @hidden */
  112129. readonly useMaterialMeshMap: boolean;
  112130. /** @hidden */
  112131. readonly useClonedMeshMap: boolean;
  112132. private _externalData;
  112133. private _uid;
  112134. /**
  112135. * @hidden
  112136. * Backing store of defined scene components.
  112137. */
  112138. _components: ISceneComponent[];
  112139. /**
  112140. * @hidden
  112141. * Backing store of defined scene components.
  112142. */
  112143. _serializableComponents: ISceneSerializableComponent[];
  112144. /**
  112145. * List of components to register on the next registration step.
  112146. */
  112147. private _transientComponents;
  112148. /**
  112149. * Registers the transient components if needed.
  112150. */
  112151. private _registerTransientComponents;
  112152. /**
  112153. * @hidden
  112154. * Add a component to the scene.
  112155. * Note that the ccomponent could be registered on th next frame if this is called after
  112156. * the register component stage.
  112157. * @param component Defines the component to add to the scene
  112158. */
  112159. _addComponent(component: ISceneComponent): void;
  112160. /**
  112161. * @hidden
  112162. * Gets a component from the scene.
  112163. * @param name defines the name of the component to retrieve
  112164. * @returns the component or null if not present
  112165. */
  112166. _getComponent(name: string): Nullable<ISceneComponent>;
  112167. /**
  112168. * @hidden
  112169. * Defines the actions happening before camera updates.
  112170. */
  112171. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  112172. /**
  112173. * @hidden
  112174. * Defines the actions happening before clear the canvas.
  112175. */
  112176. _beforeClearStage: Stage<SimpleStageAction>;
  112177. /**
  112178. * @hidden
  112179. * Defines the actions when collecting render targets for the frame.
  112180. */
  112181. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112182. /**
  112183. * @hidden
  112184. * Defines the actions happening for one camera in the frame.
  112185. */
  112186. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  112187. /**
  112188. * @hidden
  112189. * Defines the actions happening during the per mesh ready checks.
  112190. */
  112191. _isReadyForMeshStage: Stage<MeshStageAction>;
  112192. /**
  112193. * @hidden
  112194. * Defines the actions happening before evaluate active mesh checks.
  112195. */
  112196. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  112197. /**
  112198. * @hidden
  112199. * Defines the actions happening during the evaluate sub mesh checks.
  112200. */
  112201. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  112202. /**
  112203. * @hidden
  112204. * Defines the actions happening during the active mesh stage.
  112205. */
  112206. _activeMeshStage: Stage<ActiveMeshStageAction>;
  112207. /**
  112208. * @hidden
  112209. * Defines the actions happening during the per camera render target step.
  112210. */
  112211. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  112212. /**
  112213. * @hidden
  112214. * Defines the actions happening just before the active camera is drawing.
  112215. */
  112216. _beforeCameraDrawStage: Stage<CameraStageAction>;
  112217. /**
  112218. * @hidden
  112219. * Defines the actions happening just before a render target is drawing.
  112220. */
  112221. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112222. /**
  112223. * @hidden
  112224. * Defines the actions happening just before a rendering group is drawing.
  112225. */
  112226. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112227. /**
  112228. * @hidden
  112229. * Defines the actions happening just before a mesh is drawing.
  112230. */
  112231. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112232. /**
  112233. * @hidden
  112234. * Defines the actions happening just after a mesh has been drawn.
  112235. */
  112236. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  112237. /**
  112238. * @hidden
  112239. * Defines the actions happening just after a rendering group has been drawn.
  112240. */
  112241. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  112242. /**
  112243. * @hidden
  112244. * Defines the actions happening just after the active camera has been drawn.
  112245. */
  112246. _afterCameraDrawStage: Stage<CameraStageAction>;
  112247. /**
  112248. * @hidden
  112249. * Defines the actions happening just after a render target has been drawn.
  112250. */
  112251. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  112252. /**
  112253. * @hidden
  112254. * Defines the actions happening just after rendering all cameras and computing intersections.
  112255. */
  112256. _afterRenderStage: Stage<SimpleStageAction>;
  112257. /**
  112258. * @hidden
  112259. * Defines the actions happening when a pointer move event happens.
  112260. */
  112261. _pointerMoveStage: Stage<PointerMoveStageAction>;
  112262. /**
  112263. * @hidden
  112264. * Defines the actions happening when a pointer down event happens.
  112265. */
  112266. _pointerDownStage: Stage<PointerUpDownStageAction>;
  112267. /**
  112268. * @hidden
  112269. * Defines the actions happening when a pointer up event happens.
  112270. */
  112271. _pointerUpStage: Stage<PointerUpDownStageAction>;
  112272. /**
  112273. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  112274. */
  112275. private geometriesByUniqueId;
  112276. /**
  112277. * Creates a new Scene
  112278. * @param engine defines the engine to use to render this scene
  112279. * @param options defines the scene options
  112280. */
  112281. constructor(engine: Engine, options?: SceneOptions);
  112282. /**
  112283. * Gets a string idenfifying the name of the class
  112284. * @returns "Scene" string
  112285. */
  112286. getClassName(): string;
  112287. private _defaultMeshCandidates;
  112288. /**
  112289. * @hidden
  112290. */
  112291. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112292. private _defaultSubMeshCandidates;
  112293. /**
  112294. * @hidden
  112295. */
  112296. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112297. /**
  112298. * Sets the default candidate providers for the scene.
  112299. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  112300. * and getCollidingSubMeshCandidates to their default function
  112301. */
  112302. setDefaultCandidateProviders(): void;
  112303. /**
  112304. * Gets the mesh that is currently under the pointer
  112305. */
  112306. get meshUnderPointer(): Nullable<AbstractMesh>;
  112307. /**
  112308. * Gets or sets the current on-screen X position of the pointer
  112309. */
  112310. get pointerX(): number;
  112311. set pointerX(value: number);
  112312. /**
  112313. * Gets or sets the current on-screen Y position of the pointer
  112314. */
  112315. get pointerY(): number;
  112316. set pointerY(value: number);
  112317. /**
  112318. * Gets the cached material (ie. the latest rendered one)
  112319. * @returns the cached material
  112320. */
  112321. getCachedMaterial(): Nullable<Material>;
  112322. /**
  112323. * Gets the cached effect (ie. the latest rendered one)
  112324. * @returns the cached effect
  112325. */
  112326. getCachedEffect(): Nullable<Effect>;
  112327. /**
  112328. * Gets the cached visibility state (ie. the latest rendered one)
  112329. * @returns the cached visibility state
  112330. */
  112331. getCachedVisibility(): Nullable<number>;
  112332. /**
  112333. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  112334. * @param material defines the current material
  112335. * @param effect defines the current effect
  112336. * @param visibility defines the current visibility state
  112337. * @returns true if one parameter is not cached
  112338. */
  112339. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  112340. /**
  112341. * Gets the engine associated with the scene
  112342. * @returns an Engine
  112343. */
  112344. getEngine(): Engine;
  112345. /**
  112346. * Gets the total number of vertices rendered per frame
  112347. * @returns the total number of vertices rendered per frame
  112348. */
  112349. getTotalVertices(): number;
  112350. /**
  112351. * Gets the performance counter for total vertices
  112352. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112353. */
  112354. get totalVerticesPerfCounter(): PerfCounter;
  112355. /**
  112356. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  112357. * @returns the total number of active indices rendered per frame
  112358. */
  112359. getActiveIndices(): number;
  112360. /**
  112361. * Gets the performance counter for active indices
  112362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112363. */
  112364. get totalActiveIndicesPerfCounter(): PerfCounter;
  112365. /**
  112366. * Gets the total number of active particles rendered per frame
  112367. * @returns the total number of active particles rendered per frame
  112368. */
  112369. getActiveParticles(): number;
  112370. /**
  112371. * Gets the performance counter for active particles
  112372. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112373. */
  112374. get activeParticlesPerfCounter(): PerfCounter;
  112375. /**
  112376. * Gets the total number of active bones rendered per frame
  112377. * @returns the total number of active bones rendered per frame
  112378. */
  112379. getActiveBones(): number;
  112380. /**
  112381. * Gets the performance counter for active bones
  112382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  112383. */
  112384. get activeBonesPerfCounter(): PerfCounter;
  112385. /**
  112386. * Gets the array of active meshes
  112387. * @returns an array of AbstractMesh
  112388. */
  112389. getActiveMeshes(): SmartArray<AbstractMesh>;
  112390. /**
  112391. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  112392. * @returns a number
  112393. */
  112394. getAnimationRatio(): number;
  112395. /**
  112396. * Gets an unique Id for the current render phase
  112397. * @returns a number
  112398. */
  112399. getRenderId(): number;
  112400. /**
  112401. * Gets an unique Id for the current frame
  112402. * @returns a number
  112403. */
  112404. getFrameId(): number;
  112405. /** Call this function if you want to manually increment the render Id*/
  112406. incrementRenderId(): void;
  112407. private _createUbo;
  112408. /**
  112409. * Use this method to simulate a pointer move on a mesh
  112410. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112411. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112412. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112413. * @returns the current scene
  112414. */
  112415. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112416. /**
  112417. * Use this method to simulate a pointer down on a mesh
  112418. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112419. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112420. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112421. * @returns the current scene
  112422. */
  112423. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  112424. /**
  112425. * Use this method to simulate a pointer up on a mesh
  112426. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  112427. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  112428. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  112429. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  112430. * @returns the current scene
  112431. */
  112432. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  112433. /**
  112434. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  112435. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  112436. * @returns true if the pointer was captured
  112437. */
  112438. isPointerCaptured(pointerId?: number): boolean;
  112439. /**
  112440. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  112441. * @param attachUp defines if you want to attach events to pointerup
  112442. * @param attachDown defines if you want to attach events to pointerdown
  112443. * @param attachMove defines if you want to attach events to pointermove
  112444. */
  112445. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  112446. /** Detaches all event handlers*/
  112447. detachControl(): void;
  112448. /**
  112449. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  112450. * Delay loaded resources are not taking in account
  112451. * @return true if all required resources are ready
  112452. */
  112453. isReady(): boolean;
  112454. /** Resets all cached information relative to material (including effect and visibility) */
  112455. resetCachedMaterial(): void;
  112456. /**
  112457. * Registers a function to be called before every frame render
  112458. * @param func defines the function to register
  112459. */
  112460. registerBeforeRender(func: () => void): void;
  112461. /**
  112462. * Unregisters a function called before every frame render
  112463. * @param func defines the function to unregister
  112464. */
  112465. unregisterBeforeRender(func: () => void): void;
  112466. /**
  112467. * Registers a function to be called after every frame render
  112468. * @param func defines the function to register
  112469. */
  112470. registerAfterRender(func: () => void): void;
  112471. /**
  112472. * Unregisters a function called after every frame render
  112473. * @param func defines the function to unregister
  112474. */
  112475. unregisterAfterRender(func: () => void): void;
  112476. private _executeOnceBeforeRender;
  112477. /**
  112478. * The provided function will run before render once and will be disposed afterwards.
  112479. * A timeout delay can be provided so that the function will be executed in N ms.
  112480. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  112481. * @param func The function to be executed.
  112482. * @param timeout optional delay in ms
  112483. */
  112484. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  112485. /** @hidden */
  112486. _addPendingData(data: any): void;
  112487. /** @hidden */
  112488. _removePendingData(data: any): void;
  112489. /**
  112490. * Returns the number of items waiting to be loaded
  112491. * @returns the number of items waiting to be loaded
  112492. */
  112493. getWaitingItemsCount(): number;
  112494. /**
  112495. * Returns a boolean indicating if the scene is still loading data
  112496. */
  112497. get isLoading(): boolean;
  112498. /**
  112499. * Registers a function to be executed when the scene is ready
  112500. * @param {Function} func - the function to be executed
  112501. */
  112502. executeWhenReady(func: () => void): void;
  112503. /**
  112504. * Returns a promise that resolves when the scene is ready
  112505. * @returns A promise that resolves when the scene is ready
  112506. */
  112507. whenReadyAsync(): Promise<void>;
  112508. /** @hidden */
  112509. _checkIsReady(): void;
  112510. /**
  112511. * Gets all animatable attached to the scene
  112512. */
  112513. get animatables(): Animatable[];
  112514. /**
  112515. * Resets the last animation time frame.
  112516. * Useful to override when animations start running when loading a scene for the first time.
  112517. */
  112518. resetLastAnimationTimeFrame(): void;
  112519. /**
  112520. * Gets the current view matrix
  112521. * @returns a Matrix
  112522. */
  112523. getViewMatrix(): Matrix;
  112524. /**
  112525. * Gets the current projection matrix
  112526. * @returns a Matrix
  112527. */
  112528. getProjectionMatrix(): Matrix;
  112529. /**
  112530. * Gets the current transform matrix
  112531. * @returns a Matrix made of View * Projection
  112532. */
  112533. getTransformMatrix(): Matrix;
  112534. /**
  112535. * Sets the current transform matrix
  112536. * @param viewL defines the View matrix to use
  112537. * @param projectionL defines the Projection matrix to use
  112538. * @param viewR defines the right View matrix to use (if provided)
  112539. * @param projectionR defines the right Projection matrix to use (if provided)
  112540. */
  112541. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  112542. /**
  112543. * Gets the uniform buffer used to store scene data
  112544. * @returns a UniformBuffer
  112545. */
  112546. getSceneUniformBuffer(): UniformBuffer;
  112547. /**
  112548. * Gets an unique (relatively to the current scene) Id
  112549. * @returns an unique number for the scene
  112550. */
  112551. getUniqueId(): number;
  112552. /**
  112553. * Add a mesh to the list of scene's meshes
  112554. * @param newMesh defines the mesh to add
  112555. * @param recursive if all child meshes should also be added to the scene
  112556. */
  112557. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  112558. /**
  112559. * Remove a mesh for the list of scene's meshes
  112560. * @param toRemove defines the mesh to remove
  112561. * @param recursive if all child meshes should also be removed from the scene
  112562. * @returns the index where the mesh was in the mesh list
  112563. */
  112564. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  112565. /**
  112566. * Add a transform node to the list of scene's transform nodes
  112567. * @param newTransformNode defines the transform node to add
  112568. */
  112569. addTransformNode(newTransformNode: TransformNode): void;
  112570. /**
  112571. * Remove a transform node for the list of scene's transform nodes
  112572. * @param toRemove defines the transform node to remove
  112573. * @returns the index where the transform node was in the transform node list
  112574. */
  112575. removeTransformNode(toRemove: TransformNode): number;
  112576. /**
  112577. * Remove a skeleton for the list of scene's skeletons
  112578. * @param toRemove defines the skeleton to remove
  112579. * @returns the index where the skeleton was in the skeleton list
  112580. */
  112581. removeSkeleton(toRemove: Skeleton): number;
  112582. /**
  112583. * Remove a morph target for the list of scene's morph targets
  112584. * @param toRemove defines the morph target to remove
  112585. * @returns the index where the morph target was in the morph target list
  112586. */
  112587. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  112588. /**
  112589. * Remove a light for the list of scene's lights
  112590. * @param toRemove defines the light to remove
  112591. * @returns the index where the light was in the light list
  112592. */
  112593. removeLight(toRemove: Light): number;
  112594. /**
  112595. * Remove a camera for the list of scene's cameras
  112596. * @param toRemove defines the camera to remove
  112597. * @returns the index where the camera was in the camera list
  112598. */
  112599. removeCamera(toRemove: Camera): number;
  112600. /**
  112601. * Remove a particle system for the list of scene's particle systems
  112602. * @param toRemove defines the particle system to remove
  112603. * @returns the index where the particle system was in the particle system list
  112604. */
  112605. removeParticleSystem(toRemove: IParticleSystem): number;
  112606. /**
  112607. * Remove a animation for the list of scene's animations
  112608. * @param toRemove defines the animation to remove
  112609. * @returns the index where the animation was in the animation list
  112610. */
  112611. removeAnimation(toRemove: Animation): number;
  112612. /**
  112613. * Will stop the animation of the given target
  112614. * @param target - the target
  112615. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  112616. * @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)
  112617. */
  112618. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  112619. /**
  112620. * Removes the given animation group from this scene.
  112621. * @param toRemove The animation group to remove
  112622. * @returns The index of the removed animation group
  112623. */
  112624. removeAnimationGroup(toRemove: AnimationGroup): number;
  112625. /**
  112626. * Removes the given multi-material from this scene.
  112627. * @param toRemove The multi-material to remove
  112628. * @returns The index of the removed multi-material
  112629. */
  112630. removeMultiMaterial(toRemove: MultiMaterial): number;
  112631. /**
  112632. * Removes the given material from this scene.
  112633. * @param toRemove The material to remove
  112634. * @returns The index of the removed material
  112635. */
  112636. removeMaterial(toRemove: Material): number;
  112637. /**
  112638. * Removes the given action manager from this scene.
  112639. * @param toRemove The action manager to remove
  112640. * @returns The index of the removed action manager
  112641. */
  112642. removeActionManager(toRemove: AbstractActionManager): number;
  112643. /**
  112644. * Removes the given texture from this scene.
  112645. * @param toRemove The texture to remove
  112646. * @returns The index of the removed texture
  112647. */
  112648. removeTexture(toRemove: BaseTexture): number;
  112649. /**
  112650. * Adds the given light to this scene
  112651. * @param newLight The light to add
  112652. */
  112653. addLight(newLight: Light): void;
  112654. /**
  112655. * Sorts the list list based on light priorities
  112656. */
  112657. sortLightsByPriority(): void;
  112658. /**
  112659. * Adds the given camera to this scene
  112660. * @param newCamera The camera to add
  112661. */
  112662. addCamera(newCamera: Camera): void;
  112663. /**
  112664. * Adds the given skeleton to this scene
  112665. * @param newSkeleton The skeleton to add
  112666. */
  112667. addSkeleton(newSkeleton: Skeleton): void;
  112668. /**
  112669. * Adds the given particle system to this scene
  112670. * @param newParticleSystem The particle system to add
  112671. */
  112672. addParticleSystem(newParticleSystem: IParticleSystem): void;
  112673. /**
  112674. * Adds the given animation to this scene
  112675. * @param newAnimation The animation to add
  112676. */
  112677. addAnimation(newAnimation: Animation): void;
  112678. /**
  112679. * Adds the given animation group to this scene.
  112680. * @param newAnimationGroup The animation group to add
  112681. */
  112682. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  112683. /**
  112684. * Adds the given multi-material to this scene
  112685. * @param newMultiMaterial The multi-material to add
  112686. */
  112687. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  112688. /**
  112689. * Adds the given material to this scene
  112690. * @param newMaterial The material to add
  112691. */
  112692. addMaterial(newMaterial: Material): void;
  112693. /**
  112694. * Adds the given morph target to this scene
  112695. * @param newMorphTargetManager The morph target to add
  112696. */
  112697. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  112698. /**
  112699. * Adds the given geometry to this scene
  112700. * @param newGeometry The geometry to add
  112701. */
  112702. addGeometry(newGeometry: Geometry): void;
  112703. /**
  112704. * Adds the given action manager to this scene
  112705. * @param newActionManager The action manager to add
  112706. */
  112707. addActionManager(newActionManager: AbstractActionManager): void;
  112708. /**
  112709. * Adds the given texture to this scene.
  112710. * @param newTexture The texture to add
  112711. */
  112712. addTexture(newTexture: BaseTexture): void;
  112713. /**
  112714. * Switch active camera
  112715. * @param newCamera defines the new active camera
  112716. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  112717. */
  112718. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  112719. /**
  112720. * sets the active camera of the scene using its ID
  112721. * @param id defines the camera's ID
  112722. * @return the new active camera or null if none found.
  112723. */
  112724. setActiveCameraByID(id: string): Nullable<Camera>;
  112725. /**
  112726. * sets the active camera of the scene using its name
  112727. * @param name defines the camera's name
  112728. * @returns the new active camera or null if none found.
  112729. */
  112730. setActiveCameraByName(name: string): Nullable<Camera>;
  112731. /**
  112732. * get an animation group using its name
  112733. * @param name defines the material's name
  112734. * @return the animation group or null if none found.
  112735. */
  112736. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  112737. /**
  112738. * Get a material using its unique id
  112739. * @param uniqueId defines the material's unique id
  112740. * @return the material or null if none found.
  112741. */
  112742. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  112743. /**
  112744. * get a material using its id
  112745. * @param id defines the material's ID
  112746. * @return the material or null if none found.
  112747. */
  112748. getMaterialByID(id: string): Nullable<Material>;
  112749. /**
  112750. * Gets a the last added material using a given id
  112751. * @param id defines the material's ID
  112752. * @return the last material with the given id or null if none found.
  112753. */
  112754. getLastMaterialByID(id: string): Nullable<Material>;
  112755. /**
  112756. * Gets a material using its name
  112757. * @param name defines the material's name
  112758. * @return the material or null if none found.
  112759. */
  112760. getMaterialByName(name: string): Nullable<Material>;
  112761. /**
  112762. * Get a texture using its unique id
  112763. * @param uniqueId defines the texture's unique id
  112764. * @return the texture or null if none found.
  112765. */
  112766. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  112767. /**
  112768. * Gets a camera using its id
  112769. * @param id defines the id to look for
  112770. * @returns the camera or null if not found
  112771. */
  112772. getCameraByID(id: string): Nullable<Camera>;
  112773. /**
  112774. * Gets a camera using its unique id
  112775. * @param uniqueId defines the unique id to look for
  112776. * @returns the camera or null if not found
  112777. */
  112778. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  112779. /**
  112780. * Gets a camera using its name
  112781. * @param name defines the camera's name
  112782. * @return the camera or null if none found.
  112783. */
  112784. getCameraByName(name: string): Nullable<Camera>;
  112785. /**
  112786. * Gets a bone using its id
  112787. * @param id defines the bone's id
  112788. * @return the bone or null if not found
  112789. */
  112790. getBoneByID(id: string): Nullable<Bone>;
  112791. /**
  112792. * Gets a bone using its id
  112793. * @param name defines the bone's name
  112794. * @return the bone or null if not found
  112795. */
  112796. getBoneByName(name: string): Nullable<Bone>;
  112797. /**
  112798. * Gets a light node using its name
  112799. * @param name defines the the light's name
  112800. * @return the light or null if none found.
  112801. */
  112802. getLightByName(name: string): Nullable<Light>;
  112803. /**
  112804. * Gets a light node using its id
  112805. * @param id defines the light's id
  112806. * @return the light or null if none found.
  112807. */
  112808. getLightByID(id: string): Nullable<Light>;
  112809. /**
  112810. * Gets a light node using its scene-generated unique ID
  112811. * @param uniqueId defines the light's unique id
  112812. * @return the light or null if none found.
  112813. */
  112814. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  112815. /**
  112816. * Gets a particle system by id
  112817. * @param id defines the particle system id
  112818. * @return the corresponding system or null if none found
  112819. */
  112820. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  112821. /**
  112822. * Gets a geometry using its ID
  112823. * @param id defines the geometry's id
  112824. * @return the geometry or null if none found.
  112825. */
  112826. getGeometryByID(id: string): Nullable<Geometry>;
  112827. private _getGeometryByUniqueID;
  112828. /**
  112829. * Add a new geometry to this scene
  112830. * @param geometry defines the geometry to be added to the scene.
  112831. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  112832. * @return a boolean defining if the geometry was added or not
  112833. */
  112834. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  112835. /**
  112836. * Removes an existing geometry
  112837. * @param geometry defines the geometry to be removed from the scene
  112838. * @return a boolean defining if the geometry was removed or not
  112839. */
  112840. removeGeometry(geometry: Geometry): boolean;
  112841. /**
  112842. * Gets the list of geometries attached to the scene
  112843. * @returns an array of Geometry
  112844. */
  112845. getGeometries(): Geometry[];
  112846. /**
  112847. * Gets the first added mesh found of a given ID
  112848. * @param id defines the id to search for
  112849. * @return the mesh found or null if not found at all
  112850. */
  112851. getMeshByID(id: string): Nullable<AbstractMesh>;
  112852. /**
  112853. * Gets a list of meshes using their id
  112854. * @param id defines the id to search for
  112855. * @returns a list of meshes
  112856. */
  112857. getMeshesByID(id: string): Array<AbstractMesh>;
  112858. /**
  112859. * Gets the first added transform node found of a given ID
  112860. * @param id defines the id to search for
  112861. * @return the found transform node or null if not found at all.
  112862. */
  112863. getTransformNodeByID(id: string): Nullable<TransformNode>;
  112864. /**
  112865. * Gets a transform node with its auto-generated unique id
  112866. * @param uniqueId efines the unique id to search for
  112867. * @return the found transform node or null if not found at all.
  112868. */
  112869. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  112870. /**
  112871. * Gets a list of transform nodes using their id
  112872. * @param id defines the id to search for
  112873. * @returns a list of transform nodes
  112874. */
  112875. getTransformNodesByID(id: string): Array<TransformNode>;
  112876. /**
  112877. * Gets a mesh with its auto-generated unique id
  112878. * @param uniqueId defines the unique id to search for
  112879. * @return the found mesh or null if not found at all.
  112880. */
  112881. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  112882. /**
  112883. * Gets a the last added mesh using a given id
  112884. * @param id defines the id to search for
  112885. * @return the found mesh or null if not found at all.
  112886. */
  112887. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  112888. /**
  112889. * Gets a the last added node (Mesh, Camera, Light) using a given id
  112890. * @param id defines the id to search for
  112891. * @return the found node or null if not found at all
  112892. */
  112893. getLastEntryByID(id: string): Nullable<Node>;
  112894. /**
  112895. * Gets a node (Mesh, Camera, Light) using a given id
  112896. * @param id defines the id to search for
  112897. * @return the found node or null if not found at all
  112898. */
  112899. getNodeByID(id: string): Nullable<Node>;
  112900. /**
  112901. * Gets a node (Mesh, Camera, Light) using a given name
  112902. * @param name defines the name to search for
  112903. * @return the found node or null if not found at all.
  112904. */
  112905. getNodeByName(name: string): Nullable<Node>;
  112906. /**
  112907. * Gets a mesh using a given name
  112908. * @param name defines the name to search for
  112909. * @return the found mesh or null if not found at all.
  112910. */
  112911. getMeshByName(name: string): Nullable<AbstractMesh>;
  112912. /**
  112913. * Gets a transform node using a given name
  112914. * @param name defines the name to search for
  112915. * @return the found transform node or null if not found at all.
  112916. */
  112917. getTransformNodeByName(name: string): Nullable<TransformNode>;
  112918. /**
  112919. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  112920. * @param id defines the id to search for
  112921. * @return the found skeleton or null if not found at all.
  112922. */
  112923. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  112924. /**
  112925. * Gets a skeleton using a given auto generated unique id
  112926. * @param uniqueId defines the unique id to search for
  112927. * @return the found skeleton or null if not found at all.
  112928. */
  112929. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  112930. /**
  112931. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  112932. * @param id defines the id to search for
  112933. * @return the found skeleton or null if not found at all.
  112934. */
  112935. getSkeletonById(id: string): Nullable<Skeleton>;
  112936. /**
  112937. * Gets a skeleton using a given name
  112938. * @param name defines the name to search for
  112939. * @return the found skeleton or null if not found at all.
  112940. */
  112941. getSkeletonByName(name: string): Nullable<Skeleton>;
  112942. /**
  112943. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  112944. * @param id defines the id to search for
  112945. * @return the found morph target manager or null if not found at all.
  112946. */
  112947. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  112948. /**
  112949. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  112950. * @param id defines the id to search for
  112951. * @return the found morph target or null if not found at all.
  112952. */
  112953. getMorphTargetById(id: string): Nullable<MorphTarget>;
  112954. /**
  112955. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  112956. * @param name defines the name to search for
  112957. * @return the found morph target or null if not found at all.
  112958. */
  112959. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  112960. /**
  112961. * Gets a boolean indicating if the given mesh is active
  112962. * @param mesh defines the mesh to look for
  112963. * @returns true if the mesh is in the active list
  112964. */
  112965. isActiveMesh(mesh: AbstractMesh): boolean;
  112966. /**
  112967. * Return a unique id as a string which can serve as an identifier for the scene
  112968. */
  112969. get uid(): string;
  112970. /**
  112971. * Add an externaly attached data from its key.
  112972. * This method call will fail and return false, if such key already exists.
  112973. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  112974. * @param key the unique key that identifies the data
  112975. * @param data the data object to associate to the key for this Engine instance
  112976. * @return true if no such key were already present and the data was added successfully, false otherwise
  112977. */
  112978. addExternalData<T>(key: string, data: T): boolean;
  112979. /**
  112980. * Get an externaly attached data from its key
  112981. * @param key the unique key that identifies the data
  112982. * @return the associated data, if present (can be null), or undefined if not present
  112983. */
  112984. getExternalData<T>(key: string): Nullable<T>;
  112985. /**
  112986. * Get an externaly attached data from its key, create it using a factory if it's not already present
  112987. * @param key the unique key that identifies the data
  112988. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  112989. * @return the associated data, can be null if the factory returned null.
  112990. */
  112991. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  112992. /**
  112993. * Remove an externaly attached data from the Engine instance
  112994. * @param key the unique key that identifies the data
  112995. * @return true if the data was successfully removed, false if it doesn't exist
  112996. */
  112997. removeExternalData(key: string): boolean;
  112998. private _evaluateSubMesh;
  112999. /**
  113000. * Clear the processed materials smart array preventing retention point in material dispose.
  113001. */
  113002. freeProcessedMaterials(): void;
  113003. private _preventFreeActiveMeshesAndRenderingGroups;
  113004. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  113005. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  113006. * when disposing several meshes in a row or a hierarchy of meshes.
  113007. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  113008. */
  113009. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  113010. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  113011. /**
  113012. * Clear the active meshes smart array preventing retention point in mesh dispose.
  113013. */
  113014. freeActiveMeshes(): void;
  113015. /**
  113016. * Clear the info related to rendering groups preventing retention points during dispose.
  113017. */
  113018. freeRenderingGroups(): void;
  113019. /** @hidden */
  113020. _isInIntermediateRendering(): boolean;
  113021. /**
  113022. * Lambda returning the list of potentially active meshes.
  113023. */
  113024. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  113025. /**
  113026. * Lambda returning the list of potentially active sub meshes.
  113027. */
  113028. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  113029. /**
  113030. * Lambda returning the list of potentially intersecting sub meshes.
  113031. */
  113032. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  113033. /**
  113034. * Lambda returning the list of potentially colliding sub meshes.
  113035. */
  113036. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  113037. private _activeMeshesFrozen;
  113038. private _skipEvaluateActiveMeshesCompletely;
  113039. /**
  113040. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  113041. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  113042. * @returns the current scene
  113043. */
  113044. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  113045. /**
  113046. * Use this function to restart evaluating active meshes on every frame
  113047. * @returns the current scene
  113048. */
  113049. unfreezeActiveMeshes(): Scene;
  113050. private _evaluateActiveMeshes;
  113051. private _activeMesh;
  113052. /**
  113053. * Update the transform matrix to update from the current active camera
  113054. * @param force defines a boolean used to force the update even if cache is up to date
  113055. */
  113056. updateTransformMatrix(force?: boolean): void;
  113057. private _bindFrameBuffer;
  113058. /** @hidden */
  113059. _allowPostProcessClearColor: boolean;
  113060. /** @hidden */
  113061. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  113062. private _processSubCameras;
  113063. private _checkIntersections;
  113064. /** @hidden */
  113065. _advancePhysicsEngineStep(step: number): void;
  113066. /**
  113067. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  113068. */
  113069. getDeterministicFrameTime: () => number;
  113070. /** @hidden */
  113071. _animate(): void;
  113072. /** Execute all animations (for a frame) */
  113073. animate(): void;
  113074. /**
  113075. * Render the scene
  113076. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  113077. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  113078. */
  113079. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  113080. /**
  113081. * Freeze all materials
  113082. * A frozen material will not be updatable but should be faster to render
  113083. */
  113084. freezeMaterials(): void;
  113085. /**
  113086. * Unfreeze all materials
  113087. * A frozen material will not be updatable but should be faster to render
  113088. */
  113089. unfreezeMaterials(): void;
  113090. /**
  113091. * Releases all held ressources
  113092. */
  113093. dispose(): void;
  113094. /**
  113095. * Gets if the scene is already disposed
  113096. */
  113097. get isDisposed(): boolean;
  113098. /**
  113099. * Call this function to reduce memory footprint of the scene.
  113100. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  113101. */
  113102. clearCachedVertexData(): void;
  113103. /**
  113104. * This function will remove the local cached buffer data from texture.
  113105. * It will save memory but will prevent the texture from being rebuilt
  113106. */
  113107. cleanCachedTextureBuffer(): void;
  113108. /**
  113109. * Get the world extend vectors with an optional filter
  113110. *
  113111. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  113112. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  113113. */
  113114. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  113115. min: Vector3;
  113116. max: Vector3;
  113117. };
  113118. /**
  113119. * Creates a ray that can be used to pick in the scene
  113120. * @param x defines the x coordinate of the origin (on-screen)
  113121. * @param y defines the y coordinate of the origin (on-screen)
  113122. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113123. * @param camera defines the camera to use for the picking
  113124. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113125. * @returns a Ray
  113126. */
  113127. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  113128. /**
  113129. * Creates a ray that can be used to pick in the scene
  113130. * @param x defines the x coordinate of the origin (on-screen)
  113131. * @param y defines the y coordinate of the origin (on-screen)
  113132. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  113133. * @param result defines the ray where to store the picking ray
  113134. * @param camera defines the camera to use for the picking
  113135. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  113136. * @returns the current scene
  113137. */
  113138. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  113139. /**
  113140. * Creates a ray that can be used to pick in the scene
  113141. * @param x defines the x coordinate of the origin (on-screen)
  113142. * @param y defines the y coordinate of the origin (on-screen)
  113143. * @param camera defines the camera to use for the picking
  113144. * @returns a Ray
  113145. */
  113146. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  113147. /**
  113148. * Creates a ray that can be used to pick in the scene
  113149. * @param x defines the x coordinate of the origin (on-screen)
  113150. * @param y defines the y coordinate of the origin (on-screen)
  113151. * @param result defines the ray where to store the picking ray
  113152. * @param camera defines the camera to use for the picking
  113153. * @returns the current scene
  113154. */
  113155. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  113156. /** Launch a ray to try to pick a mesh in the scene
  113157. * @param x position on screen
  113158. * @param y position on screen
  113159. * @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
  113160. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113161. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113162. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113163. * @returns a PickingInfo
  113164. */
  113165. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113166. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  113167. * @param x position on screen
  113168. * @param y position on screen
  113169. * @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
  113170. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113171. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113172. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  113173. */
  113174. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  113175. /** Use the given ray to pick a mesh in the scene
  113176. * @param ray The ray to use to pick meshes
  113177. * @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
  113178. * @param fastCheck defines if the first intersection will be used (and not the closest)
  113179. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113180. * @returns a PickingInfo
  113181. */
  113182. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  113183. /**
  113184. * Launch a ray to try to pick a mesh in the scene
  113185. * @param x X position on screen
  113186. * @param y Y position on screen
  113187. * @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
  113188. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  113189. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113190. * @returns an array of PickingInfo
  113191. */
  113192. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113193. /**
  113194. * Launch a ray to try to pick a mesh in the scene
  113195. * @param ray Ray to use
  113196. * @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
  113197. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113198. * @returns an array of PickingInfo
  113199. */
  113200. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  113201. /**
  113202. * Force the value of meshUnderPointer
  113203. * @param mesh defines the mesh to use
  113204. */
  113205. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  113206. /**
  113207. * Gets the mesh under the pointer
  113208. * @returns a Mesh or null if no mesh is under the pointer
  113209. */
  113210. getPointerOverMesh(): Nullable<AbstractMesh>;
  113211. /** @hidden */
  113212. _rebuildGeometries(): void;
  113213. /** @hidden */
  113214. _rebuildTextures(): void;
  113215. private _getByTags;
  113216. /**
  113217. * Get a list of meshes by tags
  113218. * @param tagsQuery defines the tags query to use
  113219. * @param forEach defines a predicate used to filter results
  113220. * @returns an array of Mesh
  113221. */
  113222. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  113223. /**
  113224. * Get a list of cameras by tags
  113225. * @param tagsQuery defines the tags query to use
  113226. * @param forEach defines a predicate used to filter results
  113227. * @returns an array of Camera
  113228. */
  113229. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  113230. /**
  113231. * Get a list of lights by tags
  113232. * @param tagsQuery defines the tags query to use
  113233. * @param forEach defines a predicate used to filter results
  113234. * @returns an array of Light
  113235. */
  113236. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  113237. /**
  113238. * Get a list of materials by tags
  113239. * @param tagsQuery defines the tags query to use
  113240. * @param forEach defines a predicate used to filter results
  113241. * @returns an array of Material
  113242. */
  113243. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  113244. /**
  113245. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  113246. * This allowed control for front to back rendering or reversly depending of the special needs.
  113247. *
  113248. * @param renderingGroupId The rendering group id corresponding to its index
  113249. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  113250. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  113251. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  113252. */
  113253. 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;
  113254. /**
  113255. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  113256. *
  113257. * @param renderingGroupId The rendering group id corresponding to its index
  113258. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113259. * @param depth Automatically clears depth between groups if true and autoClear is true.
  113260. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  113261. */
  113262. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  113263. /**
  113264. * Gets the current auto clear configuration for one rendering group of the rendering
  113265. * manager.
  113266. * @param index the rendering group index to get the information for
  113267. * @returns The auto clear setup for the requested rendering group
  113268. */
  113269. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  113270. private _blockMaterialDirtyMechanism;
  113271. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  113272. get blockMaterialDirtyMechanism(): boolean;
  113273. set blockMaterialDirtyMechanism(value: boolean);
  113274. /**
  113275. * Will flag all materials as dirty to trigger new shader compilation
  113276. * @param flag defines the flag used to specify which material part must be marked as dirty
  113277. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  113278. */
  113279. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113280. /** @hidden */
  113281. _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;
  113282. /** @hidden */
  113283. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113284. /** @hidden */
  113285. _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;
  113286. /** @hidden */
  113287. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  113288. /** @hidden */
  113289. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  113290. /** @hidden */
  113291. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  113292. }
  113293. }
  113294. declare module BABYLON {
  113295. /**
  113296. * Set of assets to keep when moving a scene into an asset container.
  113297. */
  113298. export class KeepAssets extends AbstractScene {
  113299. }
  113300. /**
  113301. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  113302. */
  113303. export class InstantiatedEntries {
  113304. /**
  113305. * List of new root nodes (eg. nodes with no parent)
  113306. */
  113307. rootNodes: TransformNode[];
  113308. /**
  113309. * List of new skeletons
  113310. */
  113311. skeletons: Skeleton[];
  113312. /**
  113313. * List of new animation groups
  113314. */
  113315. animationGroups: AnimationGroup[];
  113316. }
  113317. /**
  113318. * Container with a set of assets that can be added or removed from a scene.
  113319. */
  113320. export class AssetContainer extends AbstractScene {
  113321. private _wasAddedToScene;
  113322. /**
  113323. * The scene the AssetContainer belongs to.
  113324. */
  113325. scene: Scene;
  113326. /**
  113327. * Instantiates an AssetContainer.
  113328. * @param scene The scene the AssetContainer belongs to.
  113329. */
  113330. constructor(scene: Scene);
  113331. /**
  113332. * Instantiate or clone all meshes and add the new ones to the scene.
  113333. * Skeletons and animation groups will all be cloned
  113334. * @param nameFunction defines an optional function used to get new names for clones
  113335. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  113336. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  113337. */
  113338. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  113339. /**
  113340. * Adds all the assets from the container to the scene.
  113341. */
  113342. addAllToScene(): void;
  113343. /**
  113344. * Removes all the assets in the container from the scene
  113345. */
  113346. removeAllFromScene(): void;
  113347. /**
  113348. * Disposes all the assets in the container
  113349. */
  113350. dispose(): void;
  113351. private _moveAssets;
  113352. /**
  113353. * Removes all the assets contained in the scene and adds them to the container.
  113354. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  113355. */
  113356. moveAllFromScene(keepAssets?: KeepAssets): void;
  113357. /**
  113358. * 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.
  113359. * @returns the root mesh
  113360. */
  113361. createRootMesh(): Mesh;
  113362. /**
  113363. * Merge animations (direct and animation groups) from this asset container into a scene
  113364. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113365. * @param animatables set of animatables to retarget to a node from the scene
  113366. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  113367. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  113368. */
  113369. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  113370. }
  113371. }
  113372. declare module BABYLON {
  113373. /**
  113374. * Defines how the parser contract is defined.
  113375. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  113376. */
  113377. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  113378. /**
  113379. * Defines how the individual parser contract is defined.
  113380. * These parser can parse an individual asset
  113381. */
  113382. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  113383. /**
  113384. * Base class of the scene acting as a container for the different elements composing a scene.
  113385. * This class is dynamically extended by the different components of the scene increasing
  113386. * flexibility and reducing coupling
  113387. */
  113388. export abstract class AbstractScene {
  113389. /**
  113390. * Stores the list of available parsers in the application.
  113391. */
  113392. private static _BabylonFileParsers;
  113393. /**
  113394. * Stores the list of available individual parsers in the application.
  113395. */
  113396. private static _IndividualBabylonFileParsers;
  113397. /**
  113398. * Adds a parser in the list of available ones
  113399. * @param name Defines the name of the parser
  113400. * @param parser Defines the parser to add
  113401. */
  113402. static AddParser(name: string, parser: BabylonFileParser): void;
  113403. /**
  113404. * Gets a general parser from the list of avaialble ones
  113405. * @param name Defines the name of the parser
  113406. * @returns the requested parser or null
  113407. */
  113408. static GetParser(name: string): Nullable<BabylonFileParser>;
  113409. /**
  113410. * Adds n individual parser in the list of available ones
  113411. * @param name Defines the name of the parser
  113412. * @param parser Defines the parser to add
  113413. */
  113414. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  113415. /**
  113416. * Gets an individual parser from the list of avaialble ones
  113417. * @param name Defines the name of the parser
  113418. * @returns the requested parser or null
  113419. */
  113420. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  113421. /**
  113422. * Parser json data and populate both a scene and its associated container object
  113423. * @param jsonData Defines the data to parse
  113424. * @param scene Defines the scene to parse the data for
  113425. * @param container Defines the container attached to the parsing sequence
  113426. * @param rootUrl Defines the root url of the data
  113427. */
  113428. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  113429. /**
  113430. * Gets the list of root nodes (ie. nodes with no parent)
  113431. */
  113432. rootNodes: Node[];
  113433. /** All of the cameras added to this scene
  113434. * @see http://doc.babylonjs.com/babylon101/cameras
  113435. */
  113436. cameras: Camera[];
  113437. /**
  113438. * All of the lights added to this scene
  113439. * @see http://doc.babylonjs.com/babylon101/lights
  113440. */
  113441. lights: Light[];
  113442. /**
  113443. * All of the (abstract) meshes added to this scene
  113444. */
  113445. meshes: AbstractMesh[];
  113446. /**
  113447. * The list of skeletons added to the scene
  113448. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  113449. */
  113450. skeletons: Skeleton[];
  113451. /**
  113452. * All of the particle systems added to this scene
  113453. * @see http://doc.babylonjs.com/babylon101/particles
  113454. */
  113455. particleSystems: IParticleSystem[];
  113456. /**
  113457. * Gets a list of Animations associated with the scene
  113458. */
  113459. animations: Animation[];
  113460. /**
  113461. * All of the animation groups added to this scene
  113462. * @see http://doc.babylonjs.com/how_to/group
  113463. */
  113464. animationGroups: AnimationGroup[];
  113465. /**
  113466. * All of the multi-materials added to this scene
  113467. * @see http://doc.babylonjs.com/how_to/multi_materials
  113468. */
  113469. multiMaterials: MultiMaterial[];
  113470. /**
  113471. * All of the materials added to this scene
  113472. * In the context of a Scene, it is not supposed to be modified manually.
  113473. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  113474. * Note also that the order of the Material within the array is not significant and might change.
  113475. * @see http://doc.babylonjs.com/babylon101/materials
  113476. */
  113477. materials: Material[];
  113478. /**
  113479. * The list of morph target managers added to the scene
  113480. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113481. */
  113482. morphTargetManagers: MorphTargetManager[];
  113483. /**
  113484. * The list of geometries used in the scene.
  113485. */
  113486. geometries: Geometry[];
  113487. /**
  113488. * All of the tranform nodes added to this scene
  113489. * In the context of a Scene, it is not supposed to be modified manually.
  113490. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  113491. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  113492. * @see http://doc.babylonjs.com/how_to/transformnode
  113493. */
  113494. transformNodes: TransformNode[];
  113495. /**
  113496. * ActionManagers available on the scene.
  113497. */
  113498. actionManagers: AbstractActionManager[];
  113499. /**
  113500. * Textures to keep.
  113501. */
  113502. textures: BaseTexture[];
  113503. /**
  113504. * Environment texture for the scene
  113505. */
  113506. environmentTexture: Nullable<BaseTexture>;
  113507. /**
  113508. * @returns all meshes, lights, cameras, transformNodes and bones
  113509. */
  113510. getNodes(): Array<Node>;
  113511. }
  113512. }
  113513. declare module BABYLON {
  113514. /**
  113515. * Interface used to define options for Sound class
  113516. */
  113517. export interface ISoundOptions {
  113518. /**
  113519. * Does the sound autoplay once loaded.
  113520. */
  113521. autoplay?: boolean;
  113522. /**
  113523. * Does the sound loop after it finishes playing once.
  113524. */
  113525. loop?: boolean;
  113526. /**
  113527. * Sound's volume
  113528. */
  113529. volume?: number;
  113530. /**
  113531. * Is it a spatial sound?
  113532. */
  113533. spatialSound?: boolean;
  113534. /**
  113535. * Maximum distance to hear that sound
  113536. */
  113537. maxDistance?: number;
  113538. /**
  113539. * Uses user defined attenuation function
  113540. */
  113541. useCustomAttenuation?: boolean;
  113542. /**
  113543. * Define the roll off factor of spatial sounds.
  113544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113545. */
  113546. rolloffFactor?: number;
  113547. /**
  113548. * Define the reference distance the sound should be heard perfectly.
  113549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113550. */
  113551. refDistance?: number;
  113552. /**
  113553. * Define the distance attenuation model the sound will follow.
  113554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113555. */
  113556. distanceModel?: string;
  113557. /**
  113558. * Defines the playback speed (1 by default)
  113559. */
  113560. playbackRate?: number;
  113561. /**
  113562. * Defines if the sound is from a streaming source
  113563. */
  113564. streaming?: boolean;
  113565. /**
  113566. * Defines an optional length (in seconds) inside the sound file
  113567. */
  113568. length?: number;
  113569. /**
  113570. * Defines an optional offset (in seconds) inside the sound file
  113571. */
  113572. offset?: number;
  113573. /**
  113574. * If true, URLs will not be required to state the audio file codec to use.
  113575. */
  113576. skipCodecCheck?: boolean;
  113577. }
  113578. /**
  113579. * Defines a sound that can be played in the application.
  113580. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  113581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113582. */
  113583. export class Sound {
  113584. /**
  113585. * The name of the sound in the scene.
  113586. */
  113587. name: string;
  113588. /**
  113589. * Does the sound autoplay once loaded.
  113590. */
  113591. autoplay: boolean;
  113592. /**
  113593. * Does the sound loop after it finishes playing once.
  113594. */
  113595. loop: boolean;
  113596. /**
  113597. * Does the sound use a custom attenuation curve to simulate the falloff
  113598. * happening when the source gets further away from the camera.
  113599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113600. */
  113601. useCustomAttenuation: boolean;
  113602. /**
  113603. * The sound track id this sound belongs to.
  113604. */
  113605. soundTrackId: number;
  113606. /**
  113607. * Is this sound currently played.
  113608. */
  113609. isPlaying: boolean;
  113610. /**
  113611. * Is this sound currently paused.
  113612. */
  113613. isPaused: boolean;
  113614. /**
  113615. * Does this sound enables spatial sound.
  113616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113617. */
  113618. spatialSound: boolean;
  113619. /**
  113620. * Define the reference distance the sound should be heard perfectly.
  113621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113622. */
  113623. refDistance: number;
  113624. /**
  113625. * Define the roll off factor of spatial sounds.
  113626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113627. */
  113628. rolloffFactor: number;
  113629. /**
  113630. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  113631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113632. */
  113633. maxDistance: number;
  113634. /**
  113635. * Define the distance attenuation model the sound will follow.
  113636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113637. */
  113638. distanceModel: string;
  113639. /**
  113640. * @hidden
  113641. * Back Compat
  113642. **/
  113643. onended: () => any;
  113644. /**
  113645. * Observable event when the current playing sound finishes.
  113646. */
  113647. onEndedObservable: Observable<Sound>;
  113648. private _panningModel;
  113649. private _playbackRate;
  113650. private _streaming;
  113651. private _startTime;
  113652. private _startOffset;
  113653. private _position;
  113654. /** @hidden */
  113655. _positionInEmitterSpace: boolean;
  113656. private _localDirection;
  113657. private _volume;
  113658. private _isReadyToPlay;
  113659. private _isDirectional;
  113660. private _readyToPlayCallback;
  113661. private _audioBuffer;
  113662. private _soundSource;
  113663. private _streamingSource;
  113664. private _soundPanner;
  113665. private _soundGain;
  113666. private _inputAudioNode;
  113667. private _outputAudioNode;
  113668. private _coneInnerAngle;
  113669. private _coneOuterAngle;
  113670. private _coneOuterGain;
  113671. private _scene;
  113672. private _connectedTransformNode;
  113673. private _customAttenuationFunction;
  113674. private _registerFunc;
  113675. private _isOutputConnected;
  113676. private _htmlAudioElement;
  113677. private _urlType;
  113678. private _length?;
  113679. private _offset?;
  113680. /** @hidden */
  113681. static _SceneComponentInitialization: (scene: Scene) => void;
  113682. /**
  113683. * Create a sound and attach it to a scene
  113684. * @param name Name of your sound
  113685. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  113686. * @param scene defines the scene the sound belongs to
  113687. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  113688. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  113689. */
  113690. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  113691. /**
  113692. * Release the sound and its associated resources
  113693. */
  113694. dispose(): void;
  113695. /**
  113696. * Gets if the sounds is ready to be played or not.
  113697. * @returns true if ready, otherwise false
  113698. */
  113699. isReady(): boolean;
  113700. private _soundLoaded;
  113701. /**
  113702. * Sets the data of the sound from an audiobuffer
  113703. * @param audioBuffer The audioBuffer containing the data
  113704. */
  113705. setAudioBuffer(audioBuffer: AudioBuffer): void;
  113706. /**
  113707. * Updates the current sounds options such as maxdistance, loop...
  113708. * @param options A JSON object containing values named as the object properties
  113709. */
  113710. updateOptions(options: ISoundOptions): void;
  113711. private _createSpatialParameters;
  113712. private _updateSpatialParameters;
  113713. /**
  113714. * Switch the panning model to HRTF:
  113715. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  113716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113717. */
  113718. switchPanningModelToHRTF(): void;
  113719. /**
  113720. * Switch the panning model to Equal Power:
  113721. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  113722. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  113723. */
  113724. switchPanningModelToEqualPower(): void;
  113725. private _switchPanningModel;
  113726. /**
  113727. * Connect this sound to a sound track audio node like gain...
  113728. * @param soundTrackAudioNode the sound track audio node to connect to
  113729. */
  113730. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  113731. /**
  113732. * Transform this sound into a directional source
  113733. * @param coneInnerAngle Size of the inner cone in degree
  113734. * @param coneOuterAngle Size of the outer cone in degree
  113735. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  113736. */
  113737. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  113738. /**
  113739. * Gets or sets the inner angle for the directional cone.
  113740. */
  113741. get directionalConeInnerAngle(): number;
  113742. /**
  113743. * Gets or sets the inner angle for the directional cone.
  113744. */
  113745. set directionalConeInnerAngle(value: number);
  113746. /**
  113747. * Gets or sets the outer angle for the directional cone.
  113748. */
  113749. get directionalConeOuterAngle(): number;
  113750. /**
  113751. * Gets or sets the outer angle for the directional cone.
  113752. */
  113753. set directionalConeOuterAngle(value: number);
  113754. /**
  113755. * Sets the position of the emitter if spatial sound is enabled
  113756. * @param newPosition Defines the new posisiton
  113757. */
  113758. setPosition(newPosition: Vector3): void;
  113759. /**
  113760. * Sets the local direction of the emitter if spatial sound is enabled
  113761. * @param newLocalDirection Defines the new local direction
  113762. */
  113763. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  113764. private _updateDirection;
  113765. /** @hidden */
  113766. updateDistanceFromListener(): void;
  113767. /**
  113768. * Sets a new custom attenuation function for the sound.
  113769. * @param callback Defines the function used for the attenuation
  113770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  113771. */
  113772. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  113773. /**
  113774. * Play the sound
  113775. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  113776. * @param offset (optional) Start the sound at a specific time in seconds
  113777. * @param length (optional) Sound duration (in seconds)
  113778. */
  113779. play(time?: number, offset?: number, length?: number): void;
  113780. private _onended;
  113781. /**
  113782. * Stop the sound
  113783. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  113784. */
  113785. stop(time?: number): void;
  113786. /**
  113787. * Put the sound in pause
  113788. */
  113789. pause(): void;
  113790. /**
  113791. * Sets a dedicated volume for this sounds
  113792. * @param newVolume Define the new volume of the sound
  113793. * @param time Define time for gradual change to new volume
  113794. */
  113795. setVolume(newVolume: number, time?: number): void;
  113796. /**
  113797. * Set the sound play back rate
  113798. * @param newPlaybackRate Define the playback rate the sound should be played at
  113799. */
  113800. setPlaybackRate(newPlaybackRate: number): void;
  113801. /**
  113802. * Gets the volume of the sound.
  113803. * @returns the volume of the sound
  113804. */
  113805. getVolume(): number;
  113806. /**
  113807. * Attach the sound to a dedicated mesh
  113808. * @param transformNode The transform node to connect the sound with
  113809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  113810. */
  113811. attachToMesh(transformNode: TransformNode): void;
  113812. /**
  113813. * Detach the sound from the previously attached mesh
  113814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  113815. */
  113816. detachFromMesh(): void;
  113817. private _onRegisterAfterWorldMatrixUpdate;
  113818. /**
  113819. * Clone the current sound in the scene.
  113820. * @returns the new sound clone
  113821. */
  113822. clone(): Nullable<Sound>;
  113823. /**
  113824. * Gets the current underlying audio buffer containing the data
  113825. * @returns the audio buffer
  113826. */
  113827. getAudioBuffer(): Nullable<AudioBuffer>;
  113828. /**
  113829. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  113830. * @returns the source node
  113831. */
  113832. getSoundSource(): Nullable<AudioBufferSourceNode>;
  113833. /**
  113834. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  113835. * @returns the gain node
  113836. */
  113837. getSoundGain(): Nullable<GainNode>;
  113838. /**
  113839. * Serializes the Sound in a JSON representation
  113840. * @returns the JSON representation of the sound
  113841. */
  113842. serialize(): any;
  113843. /**
  113844. * Parse a JSON representation of a sound to innstantiate in a given scene
  113845. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  113846. * @param scene Define the scene the new parsed sound should be created in
  113847. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  113848. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  113849. * @returns the newly parsed sound
  113850. */
  113851. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  113852. }
  113853. }
  113854. declare module BABYLON {
  113855. /**
  113856. * This defines an action helpful to play a defined sound on a triggered action.
  113857. */
  113858. export class PlaySoundAction extends Action {
  113859. private _sound;
  113860. /**
  113861. * Instantiate the action
  113862. * @param triggerOptions defines the trigger options
  113863. * @param sound defines the sound to play
  113864. * @param condition defines the trigger related conditions
  113865. */
  113866. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  113867. /** @hidden */
  113868. _prepare(): void;
  113869. /**
  113870. * Execute the action and play the sound.
  113871. */
  113872. execute(): void;
  113873. /**
  113874. * Serializes the actions and its related information.
  113875. * @param parent defines the object to serialize in
  113876. * @returns the serialized object
  113877. */
  113878. serialize(parent: any): any;
  113879. }
  113880. /**
  113881. * This defines an action helpful to stop a defined sound on a triggered action.
  113882. */
  113883. export class StopSoundAction extends Action {
  113884. private _sound;
  113885. /**
  113886. * Instantiate the action
  113887. * @param triggerOptions defines the trigger options
  113888. * @param sound defines the sound to stop
  113889. * @param condition defines the trigger related conditions
  113890. */
  113891. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  113892. /** @hidden */
  113893. _prepare(): void;
  113894. /**
  113895. * Execute the action and stop the sound.
  113896. */
  113897. execute(): void;
  113898. /**
  113899. * Serializes the actions and its related information.
  113900. * @param parent defines the object to serialize in
  113901. * @returns the serialized object
  113902. */
  113903. serialize(parent: any): any;
  113904. }
  113905. }
  113906. declare module BABYLON {
  113907. /**
  113908. * This defines an action responsible to change the value of a property
  113909. * by interpolating between its current value and the newly set one once triggered.
  113910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  113911. */
  113912. export class InterpolateValueAction extends Action {
  113913. /**
  113914. * Defines the path of the property where the value should be interpolated
  113915. */
  113916. propertyPath: string;
  113917. /**
  113918. * Defines the target value at the end of the interpolation.
  113919. */
  113920. value: any;
  113921. /**
  113922. * Defines the time it will take for the property to interpolate to the value.
  113923. */
  113924. duration: number;
  113925. /**
  113926. * Defines if the other scene animations should be stopped when the action has been triggered
  113927. */
  113928. stopOtherAnimations?: boolean;
  113929. /**
  113930. * Defines a callback raised once the interpolation animation has been done.
  113931. */
  113932. onInterpolationDone?: () => void;
  113933. /**
  113934. * Observable triggered once the interpolation animation has been done.
  113935. */
  113936. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  113937. private _target;
  113938. private _effectiveTarget;
  113939. private _property;
  113940. /**
  113941. * Instantiate the action
  113942. * @param triggerOptions defines the trigger options
  113943. * @param target defines the object containing the value to interpolate
  113944. * @param propertyPath defines the path to the property in the target object
  113945. * @param value defines the target value at the end of the interpolation
  113946. * @param duration deines the time it will take for the property to interpolate to the value.
  113947. * @param condition defines the trigger related conditions
  113948. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  113949. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  113950. */
  113951. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  113952. /** @hidden */
  113953. _prepare(): void;
  113954. /**
  113955. * Execute the action starts the value interpolation.
  113956. */
  113957. execute(): void;
  113958. /**
  113959. * Serializes the actions and its related information.
  113960. * @param parent defines the object to serialize in
  113961. * @returns the serialized object
  113962. */
  113963. serialize(parent: any): any;
  113964. }
  113965. }
  113966. declare module BABYLON {
  113967. /**
  113968. * Options allowed during the creation of a sound track.
  113969. */
  113970. export interface ISoundTrackOptions {
  113971. /**
  113972. * The volume the sound track should take during creation
  113973. */
  113974. volume?: number;
  113975. /**
  113976. * Define if the sound track is the main sound track of the scene
  113977. */
  113978. mainTrack?: boolean;
  113979. }
  113980. /**
  113981. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  113982. * It will be also used in a future release to apply effects on a specific track.
  113983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  113984. */
  113985. export class SoundTrack {
  113986. /**
  113987. * The unique identifier of the sound track in the scene.
  113988. */
  113989. id: number;
  113990. /**
  113991. * The list of sounds included in the sound track.
  113992. */
  113993. soundCollection: Array<Sound>;
  113994. private _outputAudioNode;
  113995. private _scene;
  113996. private _connectedAnalyser;
  113997. private _options;
  113998. private _isInitialized;
  113999. /**
  114000. * Creates a new sound track.
  114001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  114002. * @param scene Define the scene the sound track belongs to
  114003. * @param options
  114004. */
  114005. constructor(scene: Scene, options?: ISoundTrackOptions);
  114006. private _initializeSoundTrackAudioGraph;
  114007. /**
  114008. * Release the sound track and its associated resources
  114009. */
  114010. dispose(): void;
  114011. /**
  114012. * Adds a sound to this sound track
  114013. * @param sound define the cound to add
  114014. * @ignoreNaming
  114015. */
  114016. AddSound(sound: Sound): void;
  114017. /**
  114018. * Removes a sound to this sound track
  114019. * @param sound define the cound to remove
  114020. * @ignoreNaming
  114021. */
  114022. RemoveSound(sound: Sound): void;
  114023. /**
  114024. * Set a global volume for the full sound track.
  114025. * @param newVolume Define the new volume of the sound track
  114026. */
  114027. setVolume(newVolume: number): void;
  114028. /**
  114029. * Switch the panning model to HRTF:
  114030. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  114031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114032. */
  114033. switchPanningModelToHRTF(): void;
  114034. /**
  114035. * Switch the panning model to Equal Power:
  114036. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  114037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  114038. */
  114039. switchPanningModelToEqualPower(): void;
  114040. /**
  114041. * Connect the sound track to an audio analyser allowing some amazing
  114042. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114044. * @param analyser The analyser to connect to the engine
  114045. */
  114046. connectToAnalyser(analyser: Analyser): void;
  114047. }
  114048. }
  114049. declare module BABYLON {
  114050. interface AbstractScene {
  114051. /**
  114052. * The list of sounds used in the scene.
  114053. */
  114054. sounds: Nullable<Array<Sound>>;
  114055. }
  114056. interface Scene {
  114057. /**
  114058. * @hidden
  114059. * Backing field
  114060. */
  114061. _mainSoundTrack: SoundTrack;
  114062. /**
  114063. * The main sound track played by the scene.
  114064. * It cotains your primary collection of sounds.
  114065. */
  114066. mainSoundTrack: SoundTrack;
  114067. /**
  114068. * The list of sound tracks added to the scene
  114069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114070. */
  114071. soundTracks: Nullable<Array<SoundTrack>>;
  114072. /**
  114073. * Gets a sound using a given name
  114074. * @param name defines the name to search for
  114075. * @return the found sound or null if not found at all.
  114076. */
  114077. getSoundByName(name: string): Nullable<Sound>;
  114078. /**
  114079. * Gets or sets if audio support is enabled
  114080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114081. */
  114082. audioEnabled: boolean;
  114083. /**
  114084. * Gets or sets if audio will be output to headphones
  114085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114086. */
  114087. headphone: boolean;
  114088. /**
  114089. * Gets or sets custom audio listener position provider
  114090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114091. */
  114092. audioListenerPositionProvider: Nullable<() => Vector3>;
  114093. /**
  114094. * Gets or sets a refresh rate when using 3D audio positioning
  114095. */
  114096. audioPositioningRefreshRate: number;
  114097. }
  114098. /**
  114099. * Defines the sound scene component responsible to manage any sounds
  114100. * in a given scene.
  114101. */
  114102. export class AudioSceneComponent implements ISceneSerializableComponent {
  114103. /**
  114104. * The component name helpfull to identify the component in the list of scene components.
  114105. */
  114106. readonly name: string;
  114107. /**
  114108. * The scene the component belongs to.
  114109. */
  114110. scene: Scene;
  114111. private _audioEnabled;
  114112. /**
  114113. * Gets whether audio is enabled or not.
  114114. * Please use related enable/disable method to switch state.
  114115. */
  114116. get audioEnabled(): boolean;
  114117. private _headphone;
  114118. /**
  114119. * Gets whether audio is outputing to headphone or not.
  114120. * Please use the according Switch methods to change output.
  114121. */
  114122. get headphone(): boolean;
  114123. /**
  114124. * Gets or sets a refresh rate when using 3D audio positioning
  114125. */
  114126. audioPositioningRefreshRate: number;
  114127. private _audioListenerPositionProvider;
  114128. /**
  114129. * Gets the current audio listener position provider
  114130. */
  114131. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  114132. /**
  114133. * Sets a custom listener position for all sounds in the scene
  114134. * By default, this is the position of the first active camera
  114135. */
  114136. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  114137. /**
  114138. * Creates a new instance of the component for the given scene
  114139. * @param scene Defines the scene to register the component in
  114140. */
  114141. constructor(scene: Scene);
  114142. /**
  114143. * Registers the component in a given scene
  114144. */
  114145. register(): void;
  114146. /**
  114147. * Rebuilds the elements related to this component in case of
  114148. * context lost for instance.
  114149. */
  114150. rebuild(): void;
  114151. /**
  114152. * Serializes the component data to the specified json object
  114153. * @param serializationObject The object to serialize to
  114154. */
  114155. serialize(serializationObject: any): void;
  114156. /**
  114157. * Adds all the elements from the container to the scene
  114158. * @param container the container holding the elements
  114159. */
  114160. addFromContainer(container: AbstractScene): void;
  114161. /**
  114162. * Removes all the elements in the container from the scene
  114163. * @param container contains the elements to remove
  114164. * @param dispose if the removed element should be disposed (default: false)
  114165. */
  114166. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114167. /**
  114168. * Disposes the component and the associated ressources.
  114169. */
  114170. dispose(): void;
  114171. /**
  114172. * Disables audio in the associated scene.
  114173. */
  114174. disableAudio(): void;
  114175. /**
  114176. * Enables audio in the associated scene.
  114177. */
  114178. enableAudio(): void;
  114179. /**
  114180. * Switch audio to headphone output.
  114181. */
  114182. switchAudioModeForHeadphones(): void;
  114183. /**
  114184. * Switch audio to normal speakers.
  114185. */
  114186. switchAudioModeForNormalSpeakers(): void;
  114187. private _cachedCameraDirection;
  114188. private _cachedCameraPosition;
  114189. private _lastCheck;
  114190. private _afterRender;
  114191. }
  114192. }
  114193. declare module BABYLON {
  114194. /**
  114195. * Wraps one or more Sound objects and selects one with random weight for playback.
  114196. */
  114197. export class WeightedSound {
  114198. /** When true a Sound will be selected and played when the current playing Sound completes. */
  114199. loop: boolean;
  114200. private _coneInnerAngle;
  114201. private _coneOuterAngle;
  114202. private _volume;
  114203. /** A Sound is currently playing. */
  114204. isPlaying: boolean;
  114205. /** A Sound is currently paused. */
  114206. isPaused: boolean;
  114207. private _sounds;
  114208. private _weights;
  114209. private _currentIndex?;
  114210. /**
  114211. * Creates a new WeightedSound from the list of sounds given.
  114212. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  114213. * @param sounds Array of Sounds that will be selected from.
  114214. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  114215. */
  114216. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  114217. /**
  114218. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  114219. */
  114220. get directionalConeInnerAngle(): number;
  114221. /**
  114222. * The size of cone in degress for a directional sound in which there will be no attenuation.
  114223. */
  114224. set directionalConeInnerAngle(value: number);
  114225. /**
  114226. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114227. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114228. */
  114229. get directionalConeOuterAngle(): number;
  114230. /**
  114231. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  114232. * Listener angles between innerAngle and outerAngle will falloff linearly.
  114233. */
  114234. set directionalConeOuterAngle(value: number);
  114235. /**
  114236. * Playback volume.
  114237. */
  114238. get volume(): number;
  114239. /**
  114240. * Playback volume.
  114241. */
  114242. set volume(value: number);
  114243. private _onended;
  114244. /**
  114245. * Suspend playback
  114246. */
  114247. pause(): void;
  114248. /**
  114249. * Stop playback
  114250. */
  114251. stop(): void;
  114252. /**
  114253. * Start playback.
  114254. * @param startOffset Position the clip head at a specific time in seconds.
  114255. */
  114256. play(startOffset?: number): void;
  114257. }
  114258. }
  114259. declare module BABYLON {
  114260. /**
  114261. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  114262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  114263. */
  114264. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  114265. /**
  114266. * Gets the name of the behavior.
  114267. */
  114268. get name(): string;
  114269. /**
  114270. * The easing function used by animations
  114271. */
  114272. static EasingFunction: BackEase;
  114273. /**
  114274. * The easing mode used by animations
  114275. */
  114276. static EasingMode: number;
  114277. /**
  114278. * The duration of the animation, in milliseconds
  114279. */
  114280. transitionDuration: number;
  114281. /**
  114282. * Length of the distance animated by the transition when lower radius is reached
  114283. */
  114284. lowerRadiusTransitionRange: number;
  114285. /**
  114286. * Length of the distance animated by the transition when upper radius is reached
  114287. */
  114288. upperRadiusTransitionRange: number;
  114289. private _autoTransitionRange;
  114290. /**
  114291. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114292. */
  114293. get autoTransitionRange(): boolean;
  114294. /**
  114295. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  114296. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  114297. */
  114298. set autoTransitionRange(value: boolean);
  114299. private _attachedCamera;
  114300. private _onAfterCheckInputsObserver;
  114301. private _onMeshTargetChangedObserver;
  114302. /**
  114303. * Initializes the behavior.
  114304. */
  114305. init(): void;
  114306. /**
  114307. * Attaches the behavior to its arc rotate camera.
  114308. * @param camera Defines the camera to attach the behavior to
  114309. */
  114310. attach(camera: ArcRotateCamera): void;
  114311. /**
  114312. * Detaches the behavior from its current arc rotate camera.
  114313. */
  114314. detach(): void;
  114315. private _radiusIsAnimating;
  114316. private _radiusBounceTransition;
  114317. private _animatables;
  114318. private _cachedWheelPrecision;
  114319. /**
  114320. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  114321. * @param radiusLimit The limit to check against.
  114322. * @return Bool to indicate if at limit.
  114323. */
  114324. private _isRadiusAtLimit;
  114325. /**
  114326. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  114327. * @param radiusDelta The delta by which to animate to. Can be negative.
  114328. */
  114329. private _applyBoundRadiusAnimation;
  114330. /**
  114331. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  114332. */
  114333. protected _clearAnimationLocks(): void;
  114334. /**
  114335. * Stops and removes all animations that have been applied to the camera
  114336. */
  114337. stopAllAnimations(): void;
  114338. }
  114339. }
  114340. declare module BABYLON {
  114341. /**
  114342. * 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.
  114343. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  114344. */
  114345. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  114346. /**
  114347. * Gets the name of the behavior.
  114348. */
  114349. get name(): string;
  114350. private _mode;
  114351. private _radiusScale;
  114352. private _positionScale;
  114353. private _defaultElevation;
  114354. private _elevationReturnTime;
  114355. private _elevationReturnWaitTime;
  114356. private _zoomStopsAnimation;
  114357. private _framingTime;
  114358. /**
  114359. * The easing function used by animations
  114360. */
  114361. static EasingFunction: ExponentialEase;
  114362. /**
  114363. * The easing mode used by animations
  114364. */
  114365. static EasingMode: number;
  114366. /**
  114367. * Sets the current mode used by the behavior
  114368. */
  114369. set mode(mode: number);
  114370. /**
  114371. * Gets current mode used by the behavior.
  114372. */
  114373. get mode(): number;
  114374. /**
  114375. * Sets the scale applied to the radius (1 by default)
  114376. */
  114377. set radiusScale(radius: number);
  114378. /**
  114379. * Gets the scale applied to the radius
  114380. */
  114381. get radiusScale(): number;
  114382. /**
  114383. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114384. */
  114385. set positionScale(scale: number);
  114386. /**
  114387. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  114388. */
  114389. get positionScale(): number;
  114390. /**
  114391. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114392. * behaviour is triggered, in radians.
  114393. */
  114394. set defaultElevation(elevation: number);
  114395. /**
  114396. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  114397. * behaviour is triggered, in radians.
  114398. */
  114399. get defaultElevation(): number;
  114400. /**
  114401. * Sets the time (in milliseconds) taken to return to the default beta position.
  114402. * Negative value indicates camera should not return to default.
  114403. */
  114404. set elevationReturnTime(speed: number);
  114405. /**
  114406. * Gets the time (in milliseconds) taken to return to the default beta position.
  114407. * Negative value indicates camera should not return to default.
  114408. */
  114409. get elevationReturnTime(): number;
  114410. /**
  114411. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114412. */
  114413. set elevationReturnWaitTime(time: number);
  114414. /**
  114415. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  114416. */
  114417. get elevationReturnWaitTime(): number;
  114418. /**
  114419. * Sets the flag that indicates if user zooming should stop animation.
  114420. */
  114421. set zoomStopsAnimation(flag: boolean);
  114422. /**
  114423. * Gets the flag that indicates if user zooming should stop animation.
  114424. */
  114425. get zoomStopsAnimation(): boolean;
  114426. /**
  114427. * Sets the transition time when framing the mesh, in milliseconds
  114428. */
  114429. set framingTime(time: number);
  114430. /**
  114431. * Gets the transition time when framing the mesh, in milliseconds
  114432. */
  114433. get framingTime(): number;
  114434. /**
  114435. * Define if the behavior should automatically change the configured
  114436. * camera limits and sensibilities.
  114437. */
  114438. autoCorrectCameraLimitsAndSensibility: boolean;
  114439. private _onPrePointerObservableObserver;
  114440. private _onAfterCheckInputsObserver;
  114441. private _onMeshTargetChangedObserver;
  114442. private _attachedCamera;
  114443. private _isPointerDown;
  114444. private _lastInteractionTime;
  114445. /**
  114446. * Initializes the behavior.
  114447. */
  114448. init(): void;
  114449. /**
  114450. * Attaches the behavior to its arc rotate camera.
  114451. * @param camera Defines the camera to attach the behavior to
  114452. */
  114453. attach(camera: ArcRotateCamera): void;
  114454. /**
  114455. * Detaches the behavior from its current arc rotate camera.
  114456. */
  114457. detach(): void;
  114458. private _animatables;
  114459. private _betaIsAnimating;
  114460. private _betaTransition;
  114461. private _radiusTransition;
  114462. private _vectorTransition;
  114463. /**
  114464. * Targets the given mesh and updates zoom level accordingly.
  114465. * @param mesh The mesh to target.
  114466. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114467. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114468. */
  114469. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114470. /**
  114471. * Targets the given mesh with its children and updates zoom level accordingly.
  114472. * @param mesh The mesh to target.
  114473. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114474. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114475. */
  114476. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114477. /**
  114478. * Targets the given meshes with their children and updates zoom level accordingly.
  114479. * @param meshes The mesh to target.
  114480. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114481. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114482. */
  114483. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114484. /**
  114485. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  114486. * @param minimumWorld Determines the smaller position of the bounding box extend
  114487. * @param maximumWorld Determines the bigger position of the bounding box extend
  114488. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  114489. * @param onAnimationEnd Callback triggered at the end of the framing animation
  114490. */
  114491. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  114492. /**
  114493. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  114494. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  114495. * frustum width.
  114496. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  114497. * to fully enclose the mesh in the viewing frustum.
  114498. */
  114499. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  114500. /**
  114501. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  114502. * is automatically returned to its default position (expected to be above ground plane).
  114503. */
  114504. private _maintainCameraAboveGround;
  114505. /**
  114506. * Returns the frustum slope based on the canvas ratio and camera FOV
  114507. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  114508. */
  114509. private _getFrustumSlope;
  114510. /**
  114511. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  114512. */
  114513. private _clearAnimationLocks;
  114514. /**
  114515. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  114516. */
  114517. private _applyUserInteraction;
  114518. /**
  114519. * Stops and removes all animations that have been applied to the camera
  114520. */
  114521. stopAllAnimations(): void;
  114522. /**
  114523. * Gets a value indicating if the user is moving the camera
  114524. */
  114525. get isUserIsMoving(): boolean;
  114526. /**
  114527. * The camera can move all the way towards the mesh.
  114528. */
  114529. static IgnoreBoundsSizeMode: number;
  114530. /**
  114531. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  114532. */
  114533. static FitFrustumSidesMode: number;
  114534. }
  114535. }
  114536. declare module BABYLON {
  114537. /**
  114538. * Base class for Camera Pointer Inputs.
  114539. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  114540. * for example usage.
  114541. */
  114542. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  114543. /**
  114544. * Defines the camera the input is attached to.
  114545. */
  114546. abstract camera: Camera;
  114547. /**
  114548. * Whether keyboard modifier keys are pressed at time of last mouse event.
  114549. */
  114550. protected _altKey: boolean;
  114551. protected _ctrlKey: boolean;
  114552. protected _metaKey: boolean;
  114553. protected _shiftKey: boolean;
  114554. /**
  114555. * Which mouse buttons were pressed at time of last mouse event.
  114556. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  114557. */
  114558. protected _buttonsPressed: number;
  114559. /**
  114560. * Defines the buttons associated with the input to handle camera move.
  114561. */
  114562. buttons: number[];
  114563. /**
  114564. * Attach the input controls to a specific dom element to get the input from.
  114565. * @param element Defines the element the controls should be listened from
  114566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114567. */
  114568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114569. /**
  114570. * Detach the current controls from the specified dom element.
  114571. * @param element Defines the element to stop listening the inputs from
  114572. */
  114573. detachControl(element: Nullable<HTMLElement>): void;
  114574. /**
  114575. * Gets the class name of the current input.
  114576. * @returns the class name
  114577. */
  114578. getClassName(): string;
  114579. /**
  114580. * Get the friendly name associated with the input class.
  114581. * @returns the input friendly name
  114582. */
  114583. getSimpleName(): string;
  114584. /**
  114585. * Called on pointer POINTERDOUBLETAP event.
  114586. * Override this method to provide functionality on POINTERDOUBLETAP event.
  114587. */
  114588. protected onDoubleTap(type: string): void;
  114589. /**
  114590. * Called on pointer POINTERMOVE event if only a single touch is active.
  114591. * Override this method to provide functionality.
  114592. */
  114593. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114594. /**
  114595. * Called on pointer POINTERMOVE event if multiple touches are active.
  114596. * Override this method to provide functionality.
  114597. */
  114598. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114599. /**
  114600. * Called on JS contextmenu event.
  114601. * Override this method to provide functionality.
  114602. */
  114603. protected onContextMenu(evt: PointerEvent): void;
  114604. /**
  114605. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114606. * press.
  114607. * Override this method to provide functionality.
  114608. */
  114609. protected onButtonDown(evt: PointerEvent): void;
  114610. /**
  114611. * Called each time a new POINTERUP event occurs. Ie, for each button
  114612. * release.
  114613. * Override this method to provide functionality.
  114614. */
  114615. protected onButtonUp(evt: PointerEvent): void;
  114616. /**
  114617. * Called when window becomes inactive.
  114618. * Override this method to provide functionality.
  114619. */
  114620. protected onLostFocus(): void;
  114621. private _pointerInput;
  114622. private _observer;
  114623. private _onLostFocus;
  114624. private pointA;
  114625. private pointB;
  114626. }
  114627. }
  114628. declare module BABYLON {
  114629. /**
  114630. * Manage the pointers inputs to control an arc rotate camera.
  114631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114632. */
  114633. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  114634. /**
  114635. * Defines the camera the input is attached to.
  114636. */
  114637. camera: ArcRotateCamera;
  114638. /**
  114639. * Gets the class name of the current input.
  114640. * @returns the class name
  114641. */
  114642. getClassName(): string;
  114643. /**
  114644. * Defines the buttons associated with the input to handle camera move.
  114645. */
  114646. buttons: number[];
  114647. /**
  114648. * Defines the pointer angular sensibility along the X axis or how fast is
  114649. * the camera rotating.
  114650. */
  114651. angularSensibilityX: number;
  114652. /**
  114653. * Defines the pointer angular sensibility along the Y axis or how fast is
  114654. * the camera rotating.
  114655. */
  114656. angularSensibilityY: number;
  114657. /**
  114658. * Defines the pointer pinch precision or how fast is the camera zooming.
  114659. */
  114660. pinchPrecision: number;
  114661. /**
  114662. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114663. * from 0.
  114664. * It defines the percentage of current camera.radius to use as delta when
  114665. * pinch zoom is used.
  114666. */
  114667. pinchDeltaPercentage: number;
  114668. /**
  114669. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  114670. * that any object in the plane at the camera's target point will scale
  114671. * perfectly with finger motion.
  114672. * Overrides pinchDeltaPercentage and pinchPrecision.
  114673. */
  114674. useNaturalPinchZoom: boolean;
  114675. /**
  114676. * Defines the pointer panning sensibility or how fast is the camera moving.
  114677. */
  114678. panningSensibility: number;
  114679. /**
  114680. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  114681. */
  114682. multiTouchPanning: boolean;
  114683. /**
  114684. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  114685. * zoom (pinch) through multitouch.
  114686. */
  114687. multiTouchPanAndZoom: boolean;
  114688. /**
  114689. * Revers pinch action direction.
  114690. */
  114691. pinchInwards: boolean;
  114692. private _isPanClick;
  114693. private _twoFingerActivityCount;
  114694. private _isPinching;
  114695. /**
  114696. * Called on pointer POINTERMOVE event if only a single touch is active.
  114697. */
  114698. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114699. /**
  114700. * Called on pointer POINTERDOUBLETAP event.
  114701. */
  114702. protected onDoubleTap(type: string): void;
  114703. /**
  114704. * Called on pointer POINTERMOVE event if multiple touches are active.
  114705. */
  114706. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114707. /**
  114708. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  114709. * press.
  114710. */
  114711. protected onButtonDown(evt: PointerEvent): void;
  114712. /**
  114713. * Called each time a new POINTERUP event occurs. Ie, for each button
  114714. * release.
  114715. */
  114716. protected onButtonUp(evt: PointerEvent): void;
  114717. /**
  114718. * Called when window becomes inactive.
  114719. */
  114720. protected onLostFocus(): void;
  114721. }
  114722. }
  114723. declare module BABYLON {
  114724. /**
  114725. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  114726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114727. */
  114728. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  114729. /**
  114730. * Defines the camera the input is attached to.
  114731. */
  114732. camera: ArcRotateCamera;
  114733. /**
  114734. * Defines the list of key codes associated with the up action (increase alpha)
  114735. */
  114736. keysUp: number[];
  114737. /**
  114738. * Defines the list of key codes associated with the down action (decrease alpha)
  114739. */
  114740. keysDown: number[];
  114741. /**
  114742. * Defines the list of key codes associated with the left action (increase beta)
  114743. */
  114744. keysLeft: number[];
  114745. /**
  114746. * Defines the list of key codes associated with the right action (decrease beta)
  114747. */
  114748. keysRight: number[];
  114749. /**
  114750. * Defines the list of key codes associated with the reset action.
  114751. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  114752. */
  114753. keysReset: number[];
  114754. /**
  114755. * Defines the panning sensibility of the inputs.
  114756. * (How fast is the camera panning)
  114757. */
  114758. panningSensibility: number;
  114759. /**
  114760. * Defines the zooming sensibility of the inputs.
  114761. * (How fast is the camera zooming)
  114762. */
  114763. zoomingSensibility: number;
  114764. /**
  114765. * Defines whether maintaining the alt key down switch the movement mode from
  114766. * orientation to zoom.
  114767. */
  114768. useAltToZoom: boolean;
  114769. /**
  114770. * Rotation speed of the camera
  114771. */
  114772. angularSpeed: number;
  114773. private _keys;
  114774. private _ctrlPressed;
  114775. private _altPressed;
  114776. private _onCanvasBlurObserver;
  114777. private _onKeyboardObserver;
  114778. private _engine;
  114779. private _scene;
  114780. /**
  114781. * Attach the input controls to a specific dom element to get the input from.
  114782. * @param element Defines the element the controls should be listened from
  114783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114784. */
  114785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114786. /**
  114787. * Detach the current controls from the specified dom element.
  114788. * @param element Defines the element to stop listening the inputs from
  114789. */
  114790. detachControl(element: Nullable<HTMLElement>): void;
  114791. /**
  114792. * Update the current camera state depending on the inputs that have been used this frame.
  114793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114794. */
  114795. checkInputs(): void;
  114796. /**
  114797. * Gets the class name of the current intput.
  114798. * @returns the class name
  114799. */
  114800. getClassName(): string;
  114801. /**
  114802. * Get the friendly name associated with the input class.
  114803. * @returns the input friendly name
  114804. */
  114805. getSimpleName(): string;
  114806. }
  114807. }
  114808. declare module BABYLON {
  114809. /**
  114810. * Manage the mouse wheel inputs to control an arc rotate camera.
  114811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114812. */
  114813. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  114814. /**
  114815. * Defines the camera the input is attached to.
  114816. */
  114817. camera: ArcRotateCamera;
  114818. /**
  114819. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  114820. */
  114821. wheelPrecision: number;
  114822. /**
  114823. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114824. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114825. */
  114826. wheelDeltaPercentage: number;
  114827. private _wheel;
  114828. private _observer;
  114829. private computeDeltaFromMouseWheelLegacyEvent;
  114830. /**
  114831. * Attach the input controls to a specific dom element to get the input from.
  114832. * @param element Defines the element the controls should be listened from
  114833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114834. */
  114835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114836. /**
  114837. * Detach the current controls from the specified dom element.
  114838. * @param element Defines the element to stop listening the inputs from
  114839. */
  114840. detachControl(element: Nullable<HTMLElement>): void;
  114841. /**
  114842. * Gets the class name of the current intput.
  114843. * @returns the class name
  114844. */
  114845. getClassName(): string;
  114846. /**
  114847. * Get the friendly name associated with the input class.
  114848. * @returns the input friendly name
  114849. */
  114850. getSimpleName(): string;
  114851. }
  114852. }
  114853. declare module BABYLON {
  114854. /**
  114855. * Default Inputs manager for the ArcRotateCamera.
  114856. * It groups all the default supported inputs for ease of use.
  114857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114858. */
  114859. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  114860. /**
  114861. * Instantiates a new ArcRotateCameraInputsManager.
  114862. * @param camera Defines the camera the inputs belong to
  114863. */
  114864. constructor(camera: ArcRotateCamera);
  114865. /**
  114866. * Add mouse wheel input support to the input manager.
  114867. * @returns the current input manager
  114868. */
  114869. addMouseWheel(): ArcRotateCameraInputsManager;
  114870. /**
  114871. * Add pointers input support to the input manager.
  114872. * @returns the current input manager
  114873. */
  114874. addPointers(): ArcRotateCameraInputsManager;
  114875. /**
  114876. * Add keyboard input support to the input manager.
  114877. * @returns the current input manager
  114878. */
  114879. addKeyboard(): ArcRotateCameraInputsManager;
  114880. }
  114881. }
  114882. declare module BABYLON {
  114883. /**
  114884. * This represents an orbital type of camera.
  114885. *
  114886. * 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.
  114887. * 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.
  114888. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  114889. */
  114890. export class ArcRotateCamera extends TargetCamera {
  114891. /**
  114892. * Defines the rotation angle of the camera along the longitudinal axis.
  114893. */
  114894. alpha: number;
  114895. /**
  114896. * Defines the rotation angle of the camera along the latitudinal axis.
  114897. */
  114898. beta: number;
  114899. /**
  114900. * Defines the radius of the camera from it s target point.
  114901. */
  114902. radius: number;
  114903. protected _target: Vector3;
  114904. protected _targetHost: Nullable<AbstractMesh>;
  114905. /**
  114906. * Defines the target point of the camera.
  114907. * The camera looks towards it form the radius distance.
  114908. */
  114909. get target(): Vector3;
  114910. set target(value: Vector3);
  114911. /**
  114912. * Define the current local position of the camera in the scene
  114913. */
  114914. get position(): Vector3;
  114915. set position(newPosition: Vector3);
  114916. protected _upVector: Vector3;
  114917. protected _upToYMatrix: Matrix;
  114918. protected _YToUpMatrix: Matrix;
  114919. /**
  114920. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  114921. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  114922. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  114923. */
  114924. set upVector(vec: Vector3);
  114925. get upVector(): Vector3;
  114926. /**
  114927. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  114928. */
  114929. setMatUp(): void;
  114930. /**
  114931. * Current inertia value on the longitudinal axis.
  114932. * The bigger this number the longer it will take for the camera to stop.
  114933. */
  114934. inertialAlphaOffset: number;
  114935. /**
  114936. * Current inertia value on the latitudinal axis.
  114937. * The bigger this number the longer it will take for the camera to stop.
  114938. */
  114939. inertialBetaOffset: number;
  114940. /**
  114941. * Current inertia value on the radius axis.
  114942. * The bigger this number the longer it will take for the camera to stop.
  114943. */
  114944. inertialRadiusOffset: number;
  114945. /**
  114946. * Minimum allowed angle on the longitudinal axis.
  114947. * This can help limiting how the Camera is able to move in the scene.
  114948. */
  114949. lowerAlphaLimit: Nullable<number>;
  114950. /**
  114951. * Maximum allowed angle on the longitudinal axis.
  114952. * This can help limiting how the Camera is able to move in the scene.
  114953. */
  114954. upperAlphaLimit: Nullable<number>;
  114955. /**
  114956. * Minimum allowed angle on the latitudinal axis.
  114957. * This can help limiting how the Camera is able to move in the scene.
  114958. */
  114959. lowerBetaLimit: number;
  114960. /**
  114961. * Maximum allowed angle on the latitudinal axis.
  114962. * This can help limiting how the Camera is able to move in the scene.
  114963. */
  114964. upperBetaLimit: number;
  114965. /**
  114966. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  114967. * This can help limiting how the Camera is able to move in the scene.
  114968. */
  114969. lowerRadiusLimit: Nullable<number>;
  114970. /**
  114971. * Maximum allowed distance of the camera to the target (The camera can not get further).
  114972. * This can help limiting how the Camera is able to move in the scene.
  114973. */
  114974. upperRadiusLimit: Nullable<number>;
  114975. /**
  114976. * Defines the current inertia value used during panning of the camera along the X axis.
  114977. */
  114978. inertialPanningX: number;
  114979. /**
  114980. * Defines the current inertia value used during panning of the camera along the Y axis.
  114981. */
  114982. inertialPanningY: number;
  114983. /**
  114984. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  114985. * Basically if your fingers moves away from more than this distance you will be considered
  114986. * in pinch mode.
  114987. */
  114988. pinchToPanMaxDistance: number;
  114989. /**
  114990. * Defines the maximum distance the camera can pan.
  114991. * This could help keeping the cammera always in your scene.
  114992. */
  114993. panningDistanceLimit: Nullable<number>;
  114994. /**
  114995. * Defines the target of the camera before paning.
  114996. */
  114997. panningOriginTarget: Vector3;
  114998. /**
  114999. * Defines the value of the inertia used during panning.
  115000. * 0 would mean stop inertia and one would mean no decelleration at all.
  115001. */
  115002. panningInertia: number;
  115003. /**
  115004. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  115005. */
  115006. get angularSensibilityX(): number;
  115007. set angularSensibilityX(value: number);
  115008. /**
  115009. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  115010. */
  115011. get angularSensibilityY(): number;
  115012. set angularSensibilityY(value: number);
  115013. /**
  115014. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  115015. */
  115016. get pinchPrecision(): number;
  115017. set pinchPrecision(value: number);
  115018. /**
  115019. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  115020. * It will be used instead of pinchDeltaPrecision if different from 0.
  115021. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115022. */
  115023. get pinchDeltaPercentage(): number;
  115024. set pinchDeltaPercentage(value: number);
  115025. /**
  115026. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  115027. * and pinch delta percentage.
  115028. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  115029. * that any object in the plane at the camera's target point will scale
  115030. * perfectly with finger motion.
  115031. */
  115032. get useNaturalPinchZoom(): boolean;
  115033. set useNaturalPinchZoom(value: boolean);
  115034. /**
  115035. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  115036. */
  115037. get panningSensibility(): number;
  115038. set panningSensibility(value: number);
  115039. /**
  115040. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  115041. */
  115042. get keysUp(): number[];
  115043. set keysUp(value: number[]);
  115044. /**
  115045. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  115046. */
  115047. get keysDown(): number[];
  115048. set keysDown(value: number[]);
  115049. /**
  115050. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  115051. */
  115052. get keysLeft(): number[];
  115053. set keysLeft(value: number[]);
  115054. /**
  115055. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  115056. */
  115057. get keysRight(): number[];
  115058. set keysRight(value: number[]);
  115059. /**
  115060. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  115061. */
  115062. get wheelPrecision(): number;
  115063. set wheelPrecision(value: number);
  115064. /**
  115065. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  115066. * It will be used instead of pinchDeltaPrecision if different from 0.
  115067. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  115068. */
  115069. get wheelDeltaPercentage(): number;
  115070. set wheelDeltaPercentage(value: number);
  115071. /**
  115072. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  115073. */
  115074. zoomOnFactor: number;
  115075. /**
  115076. * Defines a screen offset for the camera position.
  115077. */
  115078. targetScreenOffset: Vector2;
  115079. /**
  115080. * Allows the camera to be completely reversed.
  115081. * If false the camera can not arrive upside down.
  115082. */
  115083. allowUpsideDown: boolean;
  115084. /**
  115085. * Define if double tap/click is used to restore the previously saved state of the camera.
  115086. */
  115087. useInputToRestoreState: boolean;
  115088. /** @hidden */
  115089. _viewMatrix: Matrix;
  115090. /** @hidden */
  115091. _useCtrlForPanning: boolean;
  115092. /** @hidden */
  115093. _panningMouseButton: number;
  115094. /**
  115095. * Defines the input associated to the camera.
  115096. */
  115097. inputs: ArcRotateCameraInputsManager;
  115098. /** @hidden */
  115099. _reset: () => void;
  115100. /**
  115101. * Defines the allowed panning axis.
  115102. */
  115103. panningAxis: Vector3;
  115104. protected _localDirection: Vector3;
  115105. protected _transformedDirection: Vector3;
  115106. private _bouncingBehavior;
  115107. /**
  115108. * Gets the bouncing behavior of the camera if it has been enabled.
  115109. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115110. */
  115111. get bouncingBehavior(): Nullable<BouncingBehavior>;
  115112. /**
  115113. * Defines if the bouncing behavior of the camera is enabled on the camera.
  115114. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  115115. */
  115116. get useBouncingBehavior(): boolean;
  115117. set useBouncingBehavior(value: boolean);
  115118. private _framingBehavior;
  115119. /**
  115120. * Gets the framing behavior of the camera if it has been enabled.
  115121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115122. */
  115123. get framingBehavior(): Nullable<FramingBehavior>;
  115124. /**
  115125. * Defines if the framing behavior of the camera is enabled on the camera.
  115126. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  115127. */
  115128. get useFramingBehavior(): boolean;
  115129. set useFramingBehavior(value: boolean);
  115130. private _autoRotationBehavior;
  115131. /**
  115132. * Gets the auto rotation behavior of the camera if it has been enabled.
  115133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115134. */
  115135. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  115136. /**
  115137. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  115138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115139. */
  115140. get useAutoRotationBehavior(): boolean;
  115141. set useAutoRotationBehavior(value: boolean);
  115142. /**
  115143. * Observable triggered when the mesh target has been changed on the camera.
  115144. */
  115145. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  115146. /**
  115147. * Event raised when the camera is colliding with a mesh.
  115148. */
  115149. onCollide: (collidedMesh: AbstractMesh) => void;
  115150. /**
  115151. * Defines whether the camera should check collision with the objects oh the scene.
  115152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  115153. */
  115154. checkCollisions: boolean;
  115155. /**
  115156. * Defines the collision radius of the camera.
  115157. * This simulates a sphere around the camera.
  115158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  115159. */
  115160. collisionRadius: Vector3;
  115161. protected _collider: Collider;
  115162. protected _previousPosition: Vector3;
  115163. protected _collisionVelocity: Vector3;
  115164. protected _newPosition: Vector3;
  115165. protected _previousAlpha: number;
  115166. protected _previousBeta: number;
  115167. protected _previousRadius: number;
  115168. protected _collisionTriggered: boolean;
  115169. protected _targetBoundingCenter: Nullable<Vector3>;
  115170. private _computationVector;
  115171. /**
  115172. * Instantiates a new ArcRotateCamera in a given scene
  115173. * @param name Defines the name of the camera
  115174. * @param alpha Defines the camera rotation along the logitudinal axis
  115175. * @param beta Defines the camera rotation along the latitudinal axis
  115176. * @param radius Defines the camera distance from its target
  115177. * @param target Defines the camera target
  115178. * @param scene Defines the scene the camera belongs to
  115179. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  115180. */
  115181. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115182. /** @hidden */
  115183. _initCache(): void;
  115184. /** @hidden */
  115185. _updateCache(ignoreParentClass?: boolean): void;
  115186. protected _getTargetPosition(): Vector3;
  115187. private _storedAlpha;
  115188. private _storedBeta;
  115189. private _storedRadius;
  115190. private _storedTarget;
  115191. private _storedTargetScreenOffset;
  115192. /**
  115193. * Stores the current state of the camera (alpha, beta, radius and target)
  115194. * @returns the camera itself
  115195. */
  115196. storeState(): Camera;
  115197. /**
  115198. * @hidden
  115199. * Restored camera state. You must call storeState() first
  115200. */
  115201. _restoreStateValues(): boolean;
  115202. /** @hidden */
  115203. _isSynchronizedViewMatrix(): boolean;
  115204. /**
  115205. * Attached controls to the current camera.
  115206. * @param element Defines the element the controls should be listened from
  115207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115208. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  115209. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  115210. */
  115211. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  115212. /**
  115213. * Detach the current controls from the camera.
  115214. * The camera will stop reacting to inputs.
  115215. * @param element Defines the element to stop listening the inputs from
  115216. */
  115217. detachControl(element: HTMLElement): void;
  115218. /** @hidden */
  115219. _checkInputs(): void;
  115220. protected _checkLimits(): void;
  115221. /**
  115222. * Rebuilds angles (alpha, beta) and radius from the give position and target
  115223. */
  115224. rebuildAnglesAndRadius(): void;
  115225. /**
  115226. * Use a position to define the current camera related information like alpha, beta and radius
  115227. * @param position Defines the position to set the camera at
  115228. */
  115229. setPosition(position: Vector3): void;
  115230. /**
  115231. * Defines the target the camera should look at.
  115232. * This will automatically adapt alpha beta and radius to fit within the new target.
  115233. * @param target Defines the new target as a Vector or a mesh
  115234. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  115235. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  115236. */
  115237. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  115238. /** @hidden */
  115239. _getViewMatrix(): Matrix;
  115240. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  115241. /**
  115242. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  115243. * @param meshes Defines the mesh to zoom on
  115244. * @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)
  115245. */
  115246. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  115247. /**
  115248. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  115249. * The target will be changed but the radius
  115250. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  115251. * @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)
  115252. */
  115253. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  115254. min: Vector3;
  115255. max: Vector3;
  115256. distance: number;
  115257. }, doNotUpdateMaxZ?: boolean): void;
  115258. /**
  115259. * @override
  115260. * Override Camera.createRigCamera
  115261. */
  115262. createRigCamera(name: string, cameraIndex: number): Camera;
  115263. /**
  115264. * @hidden
  115265. * @override
  115266. * Override Camera._updateRigCameras
  115267. */
  115268. _updateRigCameras(): void;
  115269. /**
  115270. * Destroy the camera and release the current resources hold by it.
  115271. */
  115272. dispose(): void;
  115273. /**
  115274. * Gets the current object class name.
  115275. * @return the class name
  115276. */
  115277. getClassName(): string;
  115278. }
  115279. }
  115280. declare module BABYLON {
  115281. /**
  115282. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  115283. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  115284. */
  115285. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  115286. /**
  115287. * Gets the name of the behavior.
  115288. */
  115289. get name(): string;
  115290. private _zoomStopsAnimation;
  115291. private _idleRotationSpeed;
  115292. private _idleRotationWaitTime;
  115293. private _idleRotationSpinupTime;
  115294. /**
  115295. * Sets the flag that indicates if user zooming should stop animation.
  115296. */
  115297. set zoomStopsAnimation(flag: boolean);
  115298. /**
  115299. * Gets the flag that indicates if user zooming should stop animation.
  115300. */
  115301. get zoomStopsAnimation(): boolean;
  115302. /**
  115303. * Sets the default speed at which the camera rotates around the model.
  115304. */
  115305. set idleRotationSpeed(speed: number);
  115306. /**
  115307. * Gets the default speed at which the camera rotates around the model.
  115308. */
  115309. get idleRotationSpeed(): number;
  115310. /**
  115311. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  115312. */
  115313. set idleRotationWaitTime(time: number);
  115314. /**
  115315. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  115316. */
  115317. get idleRotationWaitTime(): number;
  115318. /**
  115319. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115320. */
  115321. set idleRotationSpinupTime(time: number);
  115322. /**
  115323. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  115324. */
  115325. get idleRotationSpinupTime(): number;
  115326. /**
  115327. * Gets a value indicating if the camera is currently rotating because of this behavior
  115328. */
  115329. get rotationInProgress(): boolean;
  115330. private _onPrePointerObservableObserver;
  115331. private _onAfterCheckInputsObserver;
  115332. private _attachedCamera;
  115333. private _isPointerDown;
  115334. private _lastFrameTime;
  115335. private _lastInteractionTime;
  115336. private _cameraRotationSpeed;
  115337. /**
  115338. * Initializes the behavior.
  115339. */
  115340. init(): void;
  115341. /**
  115342. * Attaches the behavior to its arc rotate camera.
  115343. * @param camera Defines the camera to attach the behavior to
  115344. */
  115345. attach(camera: ArcRotateCamera): void;
  115346. /**
  115347. * Detaches the behavior from its current arc rotate camera.
  115348. */
  115349. detach(): void;
  115350. /**
  115351. * Returns true if user is scrolling.
  115352. * @return true if user is scrolling.
  115353. */
  115354. private _userIsZooming;
  115355. private _lastFrameRadius;
  115356. private _shouldAnimationStopForInteraction;
  115357. /**
  115358. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  115359. */
  115360. private _applyUserInteraction;
  115361. private _userIsMoving;
  115362. }
  115363. }
  115364. declare module BABYLON {
  115365. /**
  115366. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  115367. */
  115368. export class AttachToBoxBehavior implements Behavior<Mesh> {
  115369. private ui;
  115370. /**
  115371. * The name of the behavior
  115372. */
  115373. name: string;
  115374. /**
  115375. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  115376. */
  115377. distanceAwayFromFace: number;
  115378. /**
  115379. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  115380. */
  115381. distanceAwayFromBottomOfFace: number;
  115382. private _faceVectors;
  115383. private _target;
  115384. private _scene;
  115385. private _onRenderObserver;
  115386. private _tmpMatrix;
  115387. private _tmpVector;
  115388. /**
  115389. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  115390. * @param ui The transform node that should be attched to the mesh
  115391. */
  115392. constructor(ui: TransformNode);
  115393. /**
  115394. * Initializes the behavior
  115395. */
  115396. init(): void;
  115397. private _closestFace;
  115398. private _zeroVector;
  115399. private _lookAtTmpMatrix;
  115400. private _lookAtToRef;
  115401. /**
  115402. * Attaches the AttachToBoxBehavior to the passed in mesh
  115403. * @param target The mesh that the specified node will be attached to
  115404. */
  115405. attach(target: Mesh): void;
  115406. /**
  115407. * Detaches the behavior from the mesh
  115408. */
  115409. detach(): void;
  115410. }
  115411. }
  115412. declare module BABYLON {
  115413. /**
  115414. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  115415. */
  115416. export class FadeInOutBehavior implements Behavior<Mesh> {
  115417. /**
  115418. * Time in milliseconds to delay before fading in (Default: 0)
  115419. */
  115420. delay: number;
  115421. /**
  115422. * Time in milliseconds for the mesh to fade in (Default: 300)
  115423. */
  115424. fadeInTime: number;
  115425. private _millisecondsPerFrame;
  115426. private _hovered;
  115427. private _hoverValue;
  115428. private _ownerNode;
  115429. /**
  115430. * Instatiates the FadeInOutBehavior
  115431. */
  115432. constructor();
  115433. /**
  115434. * The name of the behavior
  115435. */
  115436. get name(): string;
  115437. /**
  115438. * Initializes the behavior
  115439. */
  115440. init(): void;
  115441. /**
  115442. * Attaches the fade behavior on the passed in mesh
  115443. * @param ownerNode The mesh that will be faded in/out once attached
  115444. */
  115445. attach(ownerNode: Mesh): void;
  115446. /**
  115447. * Detaches the behavior from the mesh
  115448. */
  115449. detach(): void;
  115450. /**
  115451. * Triggers the mesh to begin fading in or out
  115452. * @param value if the object should fade in or out (true to fade in)
  115453. */
  115454. fadeIn(value: boolean): void;
  115455. private _update;
  115456. private _setAllVisibility;
  115457. }
  115458. }
  115459. declare module BABYLON {
  115460. /**
  115461. * Class containing a set of static utilities functions for managing Pivots
  115462. * @hidden
  115463. */
  115464. export class PivotTools {
  115465. private static _PivotCached;
  115466. private static _OldPivotPoint;
  115467. private static _PivotTranslation;
  115468. private static _PivotTmpVector;
  115469. /** @hidden */
  115470. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  115471. /** @hidden */
  115472. static _RestorePivotPoint(mesh: AbstractMesh): void;
  115473. }
  115474. }
  115475. declare module BABYLON {
  115476. /**
  115477. * Class containing static functions to help procedurally build meshes
  115478. */
  115479. export class PlaneBuilder {
  115480. /**
  115481. * Creates a plane mesh
  115482. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115483. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115484. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115488. * @param name defines the name of the mesh
  115489. * @param options defines the options used to create the mesh
  115490. * @param scene defines the hosting scene
  115491. * @returns the plane mesh
  115492. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115493. */
  115494. static CreatePlane(name: string, options: {
  115495. size?: number;
  115496. width?: number;
  115497. height?: number;
  115498. sideOrientation?: number;
  115499. frontUVs?: Vector4;
  115500. backUVs?: Vector4;
  115501. updatable?: boolean;
  115502. sourcePlane?: Plane;
  115503. }, scene?: Nullable<Scene>): Mesh;
  115504. }
  115505. }
  115506. declare module BABYLON {
  115507. /**
  115508. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  115509. */
  115510. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  115511. private static _AnyMouseID;
  115512. /**
  115513. * Abstract mesh the behavior is set on
  115514. */
  115515. attachedNode: AbstractMesh;
  115516. private _dragPlane;
  115517. private _scene;
  115518. private _pointerObserver;
  115519. private _beforeRenderObserver;
  115520. private static _planeScene;
  115521. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  115522. /**
  115523. * 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)
  115524. */
  115525. maxDragAngle: number;
  115526. /**
  115527. * @hidden
  115528. */
  115529. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  115530. /**
  115531. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115532. */
  115533. currentDraggingPointerID: number;
  115534. /**
  115535. * The last position where the pointer hit the drag plane in world space
  115536. */
  115537. lastDragPosition: Vector3;
  115538. /**
  115539. * If the behavior is currently in a dragging state
  115540. */
  115541. dragging: boolean;
  115542. /**
  115543. * 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)
  115544. */
  115545. dragDeltaRatio: number;
  115546. /**
  115547. * If the drag plane orientation should be updated during the dragging (Default: true)
  115548. */
  115549. updateDragPlane: boolean;
  115550. private _debugMode;
  115551. private _moving;
  115552. /**
  115553. * Fires each time the attached mesh is dragged with the pointer
  115554. * * delta between last drag position and current drag position in world space
  115555. * * dragDistance along the drag axis
  115556. * * dragPlaneNormal normal of the current drag plane used during the drag
  115557. * * dragPlanePoint in world space where the drag intersects the drag plane
  115558. */
  115559. onDragObservable: Observable<{
  115560. delta: Vector3;
  115561. dragPlanePoint: Vector3;
  115562. dragPlaneNormal: Vector3;
  115563. dragDistance: number;
  115564. pointerId: number;
  115565. }>;
  115566. /**
  115567. * Fires each time a drag begins (eg. mouse down on mesh)
  115568. */
  115569. onDragStartObservable: Observable<{
  115570. dragPlanePoint: Vector3;
  115571. pointerId: number;
  115572. }>;
  115573. /**
  115574. * Fires each time a drag ends (eg. mouse release after drag)
  115575. */
  115576. onDragEndObservable: Observable<{
  115577. dragPlanePoint: Vector3;
  115578. pointerId: number;
  115579. }>;
  115580. /**
  115581. * If the attached mesh should be moved when dragged
  115582. */
  115583. moveAttached: boolean;
  115584. /**
  115585. * If the drag behavior will react to drag events (Default: true)
  115586. */
  115587. enabled: boolean;
  115588. /**
  115589. * If pointer events should start and release the drag (Default: true)
  115590. */
  115591. startAndReleaseDragOnPointerEvents: boolean;
  115592. /**
  115593. * If camera controls should be detached during the drag
  115594. */
  115595. detachCameraControls: boolean;
  115596. /**
  115597. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  115598. */
  115599. useObjectOrientationForDragging: boolean;
  115600. private _options;
  115601. /**
  115602. * Gets the options used by the behavior
  115603. */
  115604. get options(): {
  115605. dragAxis?: Vector3;
  115606. dragPlaneNormal?: Vector3;
  115607. };
  115608. /**
  115609. * Sets the options used by the behavior
  115610. */
  115611. set options(options: {
  115612. dragAxis?: Vector3;
  115613. dragPlaneNormal?: Vector3;
  115614. });
  115615. /**
  115616. * Creates a pointer drag behavior that can be attached to a mesh
  115617. * @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)
  115618. */
  115619. constructor(options?: {
  115620. dragAxis?: Vector3;
  115621. dragPlaneNormal?: Vector3;
  115622. });
  115623. /**
  115624. * Predicate to determine if it is valid to move the object to a new position when it is moved
  115625. */
  115626. validateDrag: (targetPosition: Vector3) => boolean;
  115627. /**
  115628. * The name of the behavior
  115629. */
  115630. get name(): string;
  115631. /**
  115632. * Initializes the behavior
  115633. */
  115634. init(): void;
  115635. private _tmpVector;
  115636. private _alternatePickedPoint;
  115637. private _worldDragAxis;
  115638. private _targetPosition;
  115639. private _attachedElement;
  115640. /**
  115641. * Attaches the drag behavior the passed in mesh
  115642. * @param ownerNode The mesh that will be dragged around once attached
  115643. * @param predicate Predicate to use for pick filtering
  115644. */
  115645. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  115646. /**
  115647. * Force relase the drag action by code.
  115648. */
  115649. releaseDrag(): void;
  115650. private _startDragRay;
  115651. private _lastPointerRay;
  115652. /**
  115653. * Simulates the start of a pointer drag event on the behavior
  115654. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  115655. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  115656. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  115657. */
  115658. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  115659. private _startDrag;
  115660. private _dragDelta;
  115661. private _moveDrag;
  115662. private _pickWithRayOnDragPlane;
  115663. private _pointA;
  115664. private _pointB;
  115665. private _pointC;
  115666. private _lineA;
  115667. private _lineB;
  115668. private _localAxis;
  115669. private _lookAt;
  115670. private _updateDragPlanePosition;
  115671. /**
  115672. * Detaches the behavior from the mesh
  115673. */
  115674. detach(): void;
  115675. }
  115676. }
  115677. declare module BABYLON {
  115678. /**
  115679. * A behavior that when attached to a mesh will allow the mesh to be scaled
  115680. */
  115681. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  115682. private _dragBehaviorA;
  115683. private _dragBehaviorB;
  115684. private _startDistance;
  115685. private _initialScale;
  115686. private _targetScale;
  115687. private _ownerNode;
  115688. private _sceneRenderObserver;
  115689. /**
  115690. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  115691. */
  115692. constructor();
  115693. /**
  115694. * The name of the behavior
  115695. */
  115696. get name(): string;
  115697. /**
  115698. * Initializes the behavior
  115699. */
  115700. init(): void;
  115701. private _getCurrentDistance;
  115702. /**
  115703. * Attaches the scale behavior the passed in mesh
  115704. * @param ownerNode The mesh that will be scaled around once attached
  115705. */
  115706. attach(ownerNode: Mesh): void;
  115707. /**
  115708. * Detaches the behavior from the mesh
  115709. */
  115710. detach(): void;
  115711. }
  115712. }
  115713. declare module BABYLON {
  115714. /**
  115715. * 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
  115716. */
  115717. export class SixDofDragBehavior implements Behavior<Mesh> {
  115718. private static _virtualScene;
  115719. private _ownerNode;
  115720. private _sceneRenderObserver;
  115721. private _scene;
  115722. private _targetPosition;
  115723. private _virtualOriginMesh;
  115724. private _virtualDragMesh;
  115725. private _pointerObserver;
  115726. private _moving;
  115727. private _startingOrientation;
  115728. private _attachedElement;
  115729. /**
  115730. * 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)
  115731. */
  115732. private zDragFactor;
  115733. /**
  115734. * If the object should rotate to face the drag origin
  115735. */
  115736. rotateDraggedObject: boolean;
  115737. /**
  115738. * If the behavior is currently in a dragging state
  115739. */
  115740. dragging: boolean;
  115741. /**
  115742. * 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)
  115743. */
  115744. dragDeltaRatio: number;
  115745. /**
  115746. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  115747. */
  115748. currentDraggingPointerID: number;
  115749. /**
  115750. * If camera controls should be detached during the drag
  115751. */
  115752. detachCameraControls: boolean;
  115753. /**
  115754. * Fires each time a drag starts
  115755. */
  115756. onDragStartObservable: Observable<{}>;
  115757. /**
  115758. * Fires each time a drag ends (eg. mouse release after drag)
  115759. */
  115760. onDragEndObservable: Observable<{}>;
  115761. /**
  115762. * 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
  115763. */
  115764. constructor();
  115765. /**
  115766. * The name of the behavior
  115767. */
  115768. get name(): string;
  115769. /**
  115770. * Initializes the behavior
  115771. */
  115772. init(): void;
  115773. /**
  115774. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  115775. */
  115776. private get _pointerCamera();
  115777. /**
  115778. * Attaches the scale behavior the passed in mesh
  115779. * @param ownerNode The mesh that will be scaled around once attached
  115780. */
  115781. attach(ownerNode: Mesh): void;
  115782. /**
  115783. * Detaches the behavior from the mesh
  115784. */
  115785. detach(): void;
  115786. }
  115787. }
  115788. declare module BABYLON {
  115789. /**
  115790. * Class used to apply inverse kinematics to bones
  115791. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  115792. */
  115793. export class BoneIKController {
  115794. private static _tmpVecs;
  115795. private static _tmpQuat;
  115796. private static _tmpMats;
  115797. /**
  115798. * Gets or sets the target mesh
  115799. */
  115800. targetMesh: AbstractMesh;
  115801. /** Gets or sets the mesh used as pole */
  115802. poleTargetMesh: AbstractMesh;
  115803. /**
  115804. * Gets or sets the bone used as pole
  115805. */
  115806. poleTargetBone: Nullable<Bone>;
  115807. /**
  115808. * Gets or sets the target position
  115809. */
  115810. targetPosition: Vector3;
  115811. /**
  115812. * Gets or sets the pole target position
  115813. */
  115814. poleTargetPosition: Vector3;
  115815. /**
  115816. * Gets or sets the pole target local offset
  115817. */
  115818. poleTargetLocalOffset: Vector3;
  115819. /**
  115820. * Gets or sets the pole angle
  115821. */
  115822. poleAngle: number;
  115823. /**
  115824. * Gets or sets the mesh associated with the controller
  115825. */
  115826. mesh: AbstractMesh;
  115827. /**
  115828. * 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)
  115829. */
  115830. slerpAmount: number;
  115831. private _bone1Quat;
  115832. private _bone1Mat;
  115833. private _bone2Ang;
  115834. private _bone1;
  115835. private _bone2;
  115836. private _bone1Length;
  115837. private _bone2Length;
  115838. private _maxAngle;
  115839. private _maxReach;
  115840. private _rightHandedSystem;
  115841. private _bendAxis;
  115842. private _slerping;
  115843. private _adjustRoll;
  115844. /**
  115845. * Gets or sets maximum allowed angle
  115846. */
  115847. get maxAngle(): number;
  115848. set maxAngle(value: number);
  115849. /**
  115850. * Creates a new BoneIKController
  115851. * @param mesh defines the mesh to control
  115852. * @param bone defines the bone to control
  115853. * @param options defines options to set up the controller
  115854. */
  115855. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  115856. targetMesh?: AbstractMesh;
  115857. poleTargetMesh?: AbstractMesh;
  115858. poleTargetBone?: Bone;
  115859. poleTargetLocalOffset?: Vector3;
  115860. poleAngle?: number;
  115861. bendAxis?: Vector3;
  115862. maxAngle?: number;
  115863. slerpAmount?: number;
  115864. });
  115865. private _setMaxAngle;
  115866. /**
  115867. * Force the controller to update the bones
  115868. */
  115869. update(): void;
  115870. }
  115871. }
  115872. declare module BABYLON {
  115873. /**
  115874. * Class used to make a bone look toward a point in space
  115875. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  115876. */
  115877. export class BoneLookController {
  115878. private static _tmpVecs;
  115879. private static _tmpQuat;
  115880. private static _tmpMats;
  115881. /**
  115882. * The target Vector3 that the bone will look at
  115883. */
  115884. target: Vector3;
  115885. /**
  115886. * The mesh that the bone is attached to
  115887. */
  115888. mesh: AbstractMesh;
  115889. /**
  115890. * The bone that will be looking to the target
  115891. */
  115892. bone: Bone;
  115893. /**
  115894. * The up axis of the coordinate system that is used when the bone is rotated
  115895. */
  115896. upAxis: Vector3;
  115897. /**
  115898. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  115899. */
  115900. upAxisSpace: Space;
  115901. /**
  115902. * Used to make an adjustment to the yaw of the bone
  115903. */
  115904. adjustYaw: number;
  115905. /**
  115906. * Used to make an adjustment to the pitch of the bone
  115907. */
  115908. adjustPitch: number;
  115909. /**
  115910. * Used to make an adjustment to the roll of the bone
  115911. */
  115912. adjustRoll: number;
  115913. /**
  115914. * 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)
  115915. */
  115916. slerpAmount: number;
  115917. private _minYaw;
  115918. private _maxYaw;
  115919. private _minPitch;
  115920. private _maxPitch;
  115921. private _minYawSin;
  115922. private _minYawCos;
  115923. private _maxYawSin;
  115924. private _maxYawCos;
  115925. private _midYawConstraint;
  115926. private _minPitchTan;
  115927. private _maxPitchTan;
  115928. private _boneQuat;
  115929. private _slerping;
  115930. private _transformYawPitch;
  115931. private _transformYawPitchInv;
  115932. private _firstFrameSkipped;
  115933. private _yawRange;
  115934. private _fowardAxis;
  115935. /**
  115936. * Gets or sets the minimum yaw angle that the bone can look to
  115937. */
  115938. get minYaw(): number;
  115939. set minYaw(value: number);
  115940. /**
  115941. * Gets or sets the maximum yaw angle that the bone can look to
  115942. */
  115943. get maxYaw(): number;
  115944. set maxYaw(value: number);
  115945. /**
  115946. * Gets or sets the minimum pitch angle that the bone can look to
  115947. */
  115948. get minPitch(): number;
  115949. set minPitch(value: number);
  115950. /**
  115951. * Gets or sets the maximum pitch angle that the bone can look to
  115952. */
  115953. get maxPitch(): number;
  115954. set maxPitch(value: number);
  115955. /**
  115956. * Create a BoneLookController
  115957. * @param mesh the mesh that the bone belongs to
  115958. * @param bone the bone that will be looking to the target
  115959. * @param target the target Vector3 to look at
  115960. * @param options optional settings:
  115961. * * maxYaw: the maximum angle the bone will yaw to
  115962. * * minYaw: the minimum angle the bone will yaw to
  115963. * * maxPitch: the maximum angle the bone will pitch to
  115964. * * minPitch: the minimum angle the bone will yaw to
  115965. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  115966. * * upAxis: the up axis of the coordinate system
  115967. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  115968. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  115969. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  115970. * * adjustYaw: used to make an adjustment to the yaw of the bone
  115971. * * adjustPitch: used to make an adjustment to the pitch of the bone
  115972. * * adjustRoll: used to make an adjustment to the roll of the bone
  115973. **/
  115974. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  115975. maxYaw?: number;
  115976. minYaw?: number;
  115977. maxPitch?: number;
  115978. minPitch?: number;
  115979. slerpAmount?: number;
  115980. upAxis?: Vector3;
  115981. upAxisSpace?: Space;
  115982. yawAxis?: Vector3;
  115983. pitchAxis?: Vector3;
  115984. adjustYaw?: number;
  115985. adjustPitch?: number;
  115986. adjustRoll?: number;
  115987. });
  115988. /**
  115989. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  115990. */
  115991. update(): void;
  115992. private _getAngleDiff;
  115993. private _getAngleBetween;
  115994. private _isAngleBetween;
  115995. }
  115996. }
  115997. declare module BABYLON {
  115998. /**
  115999. * Manage the gamepad inputs to control an arc rotate camera.
  116000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116001. */
  116002. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  116003. /**
  116004. * Defines the camera the input is attached to.
  116005. */
  116006. camera: ArcRotateCamera;
  116007. /**
  116008. * Defines the gamepad the input is gathering event from.
  116009. */
  116010. gamepad: Nullable<Gamepad>;
  116011. /**
  116012. * Defines the gamepad rotation sensiblity.
  116013. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116014. */
  116015. gamepadRotationSensibility: number;
  116016. /**
  116017. * Defines the gamepad move sensiblity.
  116018. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116019. */
  116020. gamepadMoveSensibility: number;
  116021. private _yAxisScale;
  116022. /**
  116023. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  116024. */
  116025. get invertYAxis(): boolean;
  116026. set invertYAxis(value: boolean);
  116027. private _onGamepadConnectedObserver;
  116028. private _onGamepadDisconnectedObserver;
  116029. /**
  116030. * Attach the input controls to a specific dom element to get the input from.
  116031. * @param element Defines the element the controls should be listened from
  116032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116033. */
  116034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116035. /**
  116036. * Detach the current controls from the specified dom element.
  116037. * @param element Defines the element to stop listening the inputs from
  116038. */
  116039. detachControl(element: Nullable<HTMLElement>): void;
  116040. /**
  116041. * Update the current camera state depending on the inputs that have been used this frame.
  116042. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116043. */
  116044. checkInputs(): void;
  116045. /**
  116046. * Gets the class name of the current intput.
  116047. * @returns the class name
  116048. */
  116049. getClassName(): string;
  116050. /**
  116051. * Get the friendly name associated with the input class.
  116052. * @returns the input friendly name
  116053. */
  116054. getSimpleName(): string;
  116055. }
  116056. }
  116057. declare module BABYLON {
  116058. interface ArcRotateCameraInputsManager {
  116059. /**
  116060. * Add orientation input support to the input manager.
  116061. * @returns the current input manager
  116062. */
  116063. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  116064. }
  116065. /**
  116066. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  116067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116068. */
  116069. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  116070. /**
  116071. * Defines the camera the input is attached to.
  116072. */
  116073. camera: ArcRotateCamera;
  116074. /**
  116075. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  116076. */
  116077. alphaCorrection: number;
  116078. /**
  116079. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  116080. */
  116081. gammaCorrection: number;
  116082. private _alpha;
  116083. private _gamma;
  116084. private _dirty;
  116085. private _deviceOrientationHandler;
  116086. /**
  116087. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  116088. */
  116089. constructor();
  116090. /**
  116091. * Attach the input controls to a specific dom element to get the input from.
  116092. * @param element Defines the element the controls should be listened from
  116093. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116094. */
  116095. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116096. /** @hidden */
  116097. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  116098. /**
  116099. * Update the current camera state depending on the inputs that have been used this frame.
  116100. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116101. */
  116102. checkInputs(): void;
  116103. /**
  116104. * Detach the current controls from the specified dom element.
  116105. * @param element Defines the element to stop listening the inputs from
  116106. */
  116107. detachControl(element: Nullable<HTMLElement>): void;
  116108. /**
  116109. * Gets the class name of the current intput.
  116110. * @returns the class name
  116111. */
  116112. getClassName(): string;
  116113. /**
  116114. * Get the friendly name associated with the input class.
  116115. * @returns the input friendly name
  116116. */
  116117. getSimpleName(): string;
  116118. }
  116119. }
  116120. declare module BABYLON {
  116121. /**
  116122. * Listen to mouse events to control the camera.
  116123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116124. */
  116125. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  116126. /**
  116127. * Defines the camera the input is attached to.
  116128. */
  116129. camera: FlyCamera;
  116130. /**
  116131. * Defines if touch is enabled. (Default is true.)
  116132. */
  116133. touchEnabled: boolean;
  116134. /**
  116135. * Defines the buttons associated with the input to handle camera rotation.
  116136. */
  116137. buttons: number[];
  116138. /**
  116139. * Assign buttons for Yaw control.
  116140. */
  116141. buttonsYaw: number[];
  116142. /**
  116143. * Assign buttons for Pitch control.
  116144. */
  116145. buttonsPitch: number[];
  116146. /**
  116147. * Assign buttons for Roll control.
  116148. */
  116149. buttonsRoll: number[];
  116150. /**
  116151. * Detect if any button is being pressed while mouse is moved.
  116152. * -1 = Mouse locked.
  116153. * 0 = Left button.
  116154. * 1 = Middle Button.
  116155. * 2 = Right Button.
  116156. */
  116157. activeButton: number;
  116158. /**
  116159. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  116160. * Higher values reduce its sensitivity.
  116161. */
  116162. angularSensibility: number;
  116163. private _mousemoveCallback;
  116164. private _observer;
  116165. private _rollObserver;
  116166. private previousPosition;
  116167. private noPreventDefault;
  116168. private element;
  116169. /**
  116170. * Listen to mouse events to control the camera.
  116171. * @param touchEnabled Define if touch is enabled. (Default is true.)
  116172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116173. */
  116174. constructor(touchEnabled?: boolean);
  116175. /**
  116176. * Attach the mouse control to the HTML DOM element.
  116177. * @param element Defines the element that listens to the input events.
  116178. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  116179. */
  116180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116181. /**
  116182. * Detach the current controls from the specified dom element.
  116183. * @param element Defines the element to stop listening the inputs from
  116184. */
  116185. detachControl(element: Nullable<HTMLElement>): void;
  116186. /**
  116187. * Gets the class name of the current input.
  116188. * @returns the class name.
  116189. */
  116190. getClassName(): string;
  116191. /**
  116192. * Get the friendly name associated with the input class.
  116193. * @returns the input's friendly name.
  116194. */
  116195. getSimpleName(): string;
  116196. private _pointerInput;
  116197. private _onMouseMove;
  116198. /**
  116199. * Rotate camera by mouse offset.
  116200. */
  116201. private rotateCamera;
  116202. }
  116203. }
  116204. declare module BABYLON {
  116205. /**
  116206. * Default Inputs manager for the FlyCamera.
  116207. * It groups all the default supported inputs for ease of use.
  116208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116209. */
  116210. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  116211. /**
  116212. * Instantiates a new FlyCameraInputsManager.
  116213. * @param camera Defines the camera the inputs belong to.
  116214. */
  116215. constructor(camera: FlyCamera);
  116216. /**
  116217. * Add keyboard input support to the input manager.
  116218. * @returns the new FlyCameraKeyboardMoveInput().
  116219. */
  116220. addKeyboard(): FlyCameraInputsManager;
  116221. /**
  116222. * Add mouse input support to the input manager.
  116223. * @param touchEnabled Enable touch screen support.
  116224. * @returns the new FlyCameraMouseInput().
  116225. */
  116226. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  116227. }
  116228. }
  116229. declare module BABYLON {
  116230. /**
  116231. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116232. * such as in a 3D Space Shooter or a Flight Simulator.
  116233. */
  116234. export class FlyCamera extends TargetCamera {
  116235. /**
  116236. * Define the collision ellipsoid of the camera.
  116237. * This is helpful for simulating a camera body, like a player's body.
  116238. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  116239. */
  116240. ellipsoid: Vector3;
  116241. /**
  116242. * Define an offset for the position of the ellipsoid around the camera.
  116243. * This can be helpful if the camera is attached away from the player's body center,
  116244. * such as at its head.
  116245. */
  116246. ellipsoidOffset: Vector3;
  116247. /**
  116248. * Enable or disable collisions of the camera with the rest of the scene objects.
  116249. */
  116250. checkCollisions: boolean;
  116251. /**
  116252. * Enable or disable gravity on the camera.
  116253. */
  116254. applyGravity: boolean;
  116255. /**
  116256. * Define the current direction the camera is moving to.
  116257. */
  116258. cameraDirection: Vector3;
  116259. /**
  116260. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  116261. * This overrides and empties cameraRotation.
  116262. */
  116263. rotationQuaternion: Quaternion;
  116264. /**
  116265. * Track Roll to maintain the wanted Rolling when looking around.
  116266. */
  116267. _trackRoll: number;
  116268. /**
  116269. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  116270. */
  116271. rollCorrect: number;
  116272. /**
  116273. * Mimic a banked turn, Rolling the camera when Yawing.
  116274. * It's recommended to use rollCorrect = 10 for faster banking correction.
  116275. */
  116276. bankedTurn: boolean;
  116277. /**
  116278. * Limit in radians for how much Roll banking will add. (Default: 90°)
  116279. */
  116280. bankedTurnLimit: number;
  116281. /**
  116282. * Value of 0 disables the banked Roll.
  116283. * Value of 1 is equal to the Yaw angle in radians.
  116284. */
  116285. bankedTurnMultiplier: number;
  116286. /**
  116287. * The inputs manager loads all the input sources, such as keyboard and mouse.
  116288. */
  116289. inputs: FlyCameraInputsManager;
  116290. /**
  116291. * Gets the input sensibility for mouse input.
  116292. * Higher values reduce sensitivity.
  116293. */
  116294. get angularSensibility(): number;
  116295. /**
  116296. * Sets the input sensibility for a mouse input.
  116297. * Higher values reduce sensitivity.
  116298. */
  116299. set angularSensibility(value: number);
  116300. /**
  116301. * Get the keys for camera movement forward.
  116302. */
  116303. get keysForward(): number[];
  116304. /**
  116305. * Set the keys for camera movement forward.
  116306. */
  116307. set keysForward(value: number[]);
  116308. /**
  116309. * Get the keys for camera movement backward.
  116310. */
  116311. get keysBackward(): number[];
  116312. set keysBackward(value: number[]);
  116313. /**
  116314. * Get the keys for camera movement up.
  116315. */
  116316. get keysUp(): number[];
  116317. /**
  116318. * Set the keys for camera movement up.
  116319. */
  116320. set keysUp(value: number[]);
  116321. /**
  116322. * Get the keys for camera movement down.
  116323. */
  116324. get keysDown(): number[];
  116325. /**
  116326. * Set the keys for camera movement down.
  116327. */
  116328. set keysDown(value: number[]);
  116329. /**
  116330. * Get the keys for camera movement left.
  116331. */
  116332. get keysLeft(): number[];
  116333. /**
  116334. * Set the keys for camera movement left.
  116335. */
  116336. set keysLeft(value: number[]);
  116337. /**
  116338. * Set the keys for camera movement right.
  116339. */
  116340. get keysRight(): number[];
  116341. /**
  116342. * Set the keys for camera movement right.
  116343. */
  116344. set keysRight(value: number[]);
  116345. /**
  116346. * Event raised when the camera collides with a mesh in the scene.
  116347. */
  116348. onCollide: (collidedMesh: AbstractMesh) => void;
  116349. private _collider;
  116350. private _needMoveForGravity;
  116351. private _oldPosition;
  116352. private _diffPosition;
  116353. private _newPosition;
  116354. /** @hidden */
  116355. _localDirection: Vector3;
  116356. /** @hidden */
  116357. _transformedDirection: Vector3;
  116358. /**
  116359. * Instantiates a FlyCamera.
  116360. * This is a flying camera, designed for 3D movement and rotation in all directions,
  116361. * such as in a 3D Space Shooter or a Flight Simulator.
  116362. * @param name Define the name of the camera in the scene.
  116363. * @param position Define the starting position of the camera in the scene.
  116364. * @param scene Define the scene the camera belongs to.
  116365. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  116366. */
  116367. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  116368. /**
  116369. * Attach a control to the HTML DOM element.
  116370. * @param element Defines the element that listens to the input events.
  116371. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  116372. */
  116373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116374. /**
  116375. * Detach a control from the HTML DOM element.
  116376. * The camera will stop reacting to that input.
  116377. * @param element Defines the element that listens to the input events.
  116378. */
  116379. detachControl(element: HTMLElement): void;
  116380. private _collisionMask;
  116381. /**
  116382. * Get the mask that the camera ignores in collision events.
  116383. */
  116384. get collisionMask(): number;
  116385. /**
  116386. * Set the mask that the camera ignores in collision events.
  116387. */
  116388. set collisionMask(mask: number);
  116389. /** @hidden */
  116390. _collideWithWorld(displacement: Vector3): void;
  116391. /** @hidden */
  116392. private _onCollisionPositionChange;
  116393. /** @hidden */
  116394. _checkInputs(): void;
  116395. /** @hidden */
  116396. _decideIfNeedsToMove(): boolean;
  116397. /** @hidden */
  116398. _updatePosition(): void;
  116399. /**
  116400. * Restore the Roll to its target value at the rate specified.
  116401. * @param rate - Higher means slower restoring.
  116402. * @hidden
  116403. */
  116404. restoreRoll(rate: number): void;
  116405. /**
  116406. * Destroy the camera and release the current resources held by it.
  116407. */
  116408. dispose(): void;
  116409. /**
  116410. * Get the current object class name.
  116411. * @returns the class name.
  116412. */
  116413. getClassName(): string;
  116414. }
  116415. }
  116416. declare module BABYLON {
  116417. /**
  116418. * Listen to keyboard events to control the camera.
  116419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116420. */
  116421. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  116422. /**
  116423. * Defines the camera the input is attached to.
  116424. */
  116425. camera: FlyCamera;
  116426. /**
  116427. * The list of keyboard keys used to control the forward move of the camera.
  116428. */
  116429. keysForward: number[];
  116430. /**
  116431. * The list of keyboard keys used to control the backward move of the camera.
  116432. */
  116433. keysBackward: number[];
  116434. /**
  116435. * The list of keyboard keys used to control the forward move of the camera.
  116436. */
  116437. keysUp: number[];
  116438. /**
  116439. * The list of keyboard keys used to control the backward move of the camera.
  116440. */
  116441. keysDown: number[];
  116442. /**
  116443. * The list of keyboard keys used to control the right strafe move of the camera.
  116444. */
  116445. keysRight: number[];
  116446. /**
  116447. * The list of keyboard keys used to control the left strafe move of the camera.
  116448. */
  116449. keysLeft: number[];
  116450. private _keys;
  116451. private _onCanvasBlurObserver;
  116452. private _onKeyboardObserver;
  116453. private _engine;
  116454. private _scene;
  116455. /**
  116456. * Attach the input controls to a specific dom element to get the input from.
  116457. * @param element Defines the element the controls should be listened from
  116458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116459. */
  116460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116461. /**
  116462. * Detach the current controls from the specified dom element.
  116463. * @param element Defines the element to stop listening the inputs from
  116464. */
  116465. detachControl(element: Nullable<HTMLElement>): void;
  116466. /**
  116467. * Gets the class name of the current intput.
  116468. * @returns the class name
  116469. */
  116470. getClassName(): string;
  116471. /** @hidden */
  116472. _onLostFocus(e: FocusEvent): void;
  116473. /**
  116474. * Get the friendly name associated with the input class.
  116475. * @returns the input friendly name
  116476. */
  116477. getSimpleName(): string;
  116478. /**
  116479. * Update the current camera state depending on the inputs that have been used this frame.
  116480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116481. */
  116482. checkInputs(): void;
  116483. }
  116484. }
  116485. declare module BABYLON {
  116486. /**
  116487. * Manage the mouse wheel inputs to control a follow camera.
  116488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116489. */
  116490. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  116491. /**
  116492. * Defines the camera the input is attached to.
  116493. */
  116494. camera: FollowCamera;
  116495. /**
  116496. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  116497. */
  116498. axisControlRadius: boolean;
  116499. /**
  116500. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  116501. */
  116502. axisControlHeight: boolean;
  116503. /**
  116504. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  116505. */
  116506. axisControlRotation: boolean;
  116507. /**
  116508. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  116509. * relation to mouseWheel events.
  116510. */
  116511. wheelPrecision: number;
  116512. /**
  116513. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  116514. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  116515. */
  116516. wheelDeltaPercentage: number;
  116517. private _wheel;
  116518. private _observer;
  116519. /**
  116520. * Attach the input controls to a specific dom element to get the input from.
  116521. * @param element Defines the element the controls should be listened from
  116522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116523. */
  116524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116525. /**
  116526. * Detach the current controls from the specified dom element.
  116527. * @param element Defines the element to stop listening the inputs from
  116528. */
  116529. detachControl(element: Nullable<HTMLElement>): void;
  116530. /**
  116531. * Gets the class name of the current intput.
  116532. * @returns the class name
  116533. */
  116534. getClassName(): string;
  116535. /**
  116536. * Get the friendly name associated with the input class.
  116537. * @returns the input friendly name
  116538. */
  116539. getSimpleName(): string;
  116540. }
  116541. }
  116542. declare module BABYLON {
  116543. /**
  116544. * Manage the pointers inputs to control an follow camera.
  116545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116546. */
  116547. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  116548. /**
  116549. * Defines the camera the input is attached to.
  116550. */
  116551. camera: FollowCamera;
  116552. /**
  116553. * Gets the class name of the current input.
  116554. * @returns the class name
  116555. */
  116556. getClassName(): string;
  116557. /**
  116558. * Defines the pointer angular sensibility along the X axis or how fast is
  116559. * the camera rotating.
  116560. * A negative number will reverse the axis direction.
  116561. */
  116562. angularSensibilityX: number;
  116563. /**
  116564. * Defines the pointer angular sensibility along the Y axis or how fast is
  116565. * the camera rotating.
  116566. * A negative number will reverse the axis direction.
  116567. */
  116568. angularSensibilityY: number;
  116569. /**
  116570. * Defines the pointer pinch precision or how fast is the camera zooming.
  116571. * A negative number will reverse the axis direction.
  116572. */
  116573. pinchPrecision: number;
  116574. /**
  116575. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  116576. * from 0.
  116577. * It defines the percentage of current camera.radius to use as delta when
  116578. * pinch zoom is used.
  116579. */
  116580. pinchDeltaPercentage: number;
  116581. /**
  116582. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  116583. */
  116584. axisXControlRadius: boolean;
  116585. /**
  116586. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  116587. */
  116588. axisXControlHeight: boolean;
  116589. /**
  116590. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  116591. */
  116592. axisXControlRotation: boolean;
  116593. /**
  116594. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  116595. */
  116596. axisYControlRadius: boolean;
  116597. /**
  116598. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  116599. */
  116600. axisYControlHeight: boolean;
  116601. /**
  116602. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  116603. */
  116604. axisYControlRotation: boolean;
  116605. /**
  116606. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  116607. */
  116608. axisPinchControlRadius: boolean;
  116609. /**
  116610. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  116611. */
  116612. axisPinchControlHeight: boolean;
  116613. /**
  116614. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  116615. */
  116616. axisPinchControlRotation: boolean;
  116617. /**
  116618. * Log error messages if basic misconfiguration has occurred.
  116619. */
  116620. warningEnable: boolean;
  116621. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  116622. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  116623. private _warningCounter;
  116624. private _warning;
  116625. }
  116626. }
  116627. declare module BABYLON {
  116628. /**
  116629. * Default Inputs manager for the FollowCamera.
  116630. * It groups all the default supported inputs for ease of use.
  116631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116632. */
  116633. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  116634. /**
  116635. * Instantiates a new FollowCameraInputsManager.
  116636. * @param camera Defines the camera the inputs belong to
  116637. */
  116638. constructor(camera: FollowCamera);
  116639. /**
  116640. * Add keyboard input support to the input manager.
  116641. * @returns the current input manager
  116642. */
  116643. addKeyboard(): FollowCameraInputsManager;
  116644. /**
  116645. * Add mouse wheel input support to the input manager.
  116646. * @returns the current input manager
  116647. */
  116648. addMouseWheel(): FollowCameraInputsManager;
  116649. /**
  116650. * Add pointers input support to the input manager.
  116651. * @returns the current input manager
  116652. */
  116653. addPointers(): FollowCameraInputsManager;
  116654. /**
  116655. * Add orientation input support to the input manager.
  116656. * @returns the current input manager
  116657. */
  116658. addVRDeviceOrientation(): FollowCameraInputsManager;
  116659. }
  116660. }
  116661. declare module BABYLON {
  116662. /**
  116663. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  116664. * an arc rotate version arcFollowCamera are available.
  116665. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116666. */
  116667. export class FollowCamera extends TargetCamera {
  116668. /**
  116669. * Distance the follow camera should follow an object at
  116670. */
  116671. radius: number;
  116672. /**
  116673. * Minimum allowed distance of the camera to the axis of rotation
  116674. * (The camera can not get closer).
  116675. * This can help limiting how the Camera is able to move in the scene.
  116676. */
  116677. lowerRadiusLimit: Nullable<number>;
  116678. /**
  116679. * Maximum allowed distance of the camera to the axis of rotation
  116680. * (The camera can not get further).
  116681. * This can help limiting how the Camera is able to move in the scene.
  116682. */
  116683. upperRadiusLimit: Nullable<number>;
  116684. /**
  116685. * Define a rotation offset between the camera and the object it follows
  116686. */
  116687. rotationOffset: number;
  116688. /**
  116689. * Minimum allowed angle to camera position relative to target object.
  116690. * This can help limiting how the Camera is able to move in the scene.
  116691. */
  116692. lowerRotationOffsetLimit: Nullable<number>;
  116693. /**
  116694. * Maximum allowed angle to camera position relative to target object.
  116695. * This can help limiting how the Camera is able to move in the scene.
  116696. */
  116697. upperRotationOffsetLimit: Nullable<number>;
  116698. /**
  116699. * Define a height offset between the camera and the object it follows.
  116700. * It can help following an object from the top (like a car chaing a plane)
  116701. */
  116702. heightOffset: number;
  116703. /**
  116704. * Minimum allowed height of camera position relative to target object.
  116705. * This can help limiting how the Camera is able to move in the scene.
  116706. */
  116707. lowerHeightOffsetLimit: Nullable<number>;
  116708. /**
  116709. * Maximum allowed height of camera position relative to target object.
  116710. * This can help limiting how the Camera is able to move in the scene.
  116711. */
  116712. upperHeightOffsetLimit: Nullable<number>;
  116713. /**
  116714. * Define how fast the camera can accelerate to follow it s target.
  116715. */
  116716. cameraAcceleration: number;
  116717. /**
  116718. * Define the speed limit of the camera following an object.
  116719. */
  116720. maxCameraSpeed: number;
  116721. /**
  116722. * Define the target of the camera.
  116723. */
  116724. lockedTarget: Nullable<AbstractMesh>;
  116725. /**
  116726. * Defines the input associated with the camera.
  116727. */
  116728. inputs: FollowCameraInputsManager;
  116729. /**
  116730. * Instantiates the follow camera.
  116731. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116732. * @param name Define the name of the camera in the scene
  116733. * @param position Define the position of the camera
  116734. * @param scene Define the scene the camera belong to
  116735. * @param lockedTarget Define the target of the camera
  116736. */
  116737. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  116738. private _follow;
  116739. /**
  116740. * Attached controls to the current camera.
  116741. * @param element Defines the element the controls should be listened from
  116742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116743. */
  116744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116745. /**
  116746. * Detach the current controls from the camera.
  116747. * The camera will stop reacting to inputs.
  116748. * @param element Defines the element to stop listening the inputs from
  116749. */
  116750. detachControl(element: HTMLElement): void;
  116751. /** @hidden */
  116752. _checkInputs(): void;
  116753. private _checkLimits;
  116754. /**
  116755. * Gets the camera class name.
  116756. * @returns the class name
  116757. */
  116758. getClassName(): string;
  116759. }
  116760. /**
  116761. * Arc Rotate version of the follow camera.
  116762. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  116763. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116764. */
  116765. export class ArcFollowCamera extends TargetCamera {
  116766. /** The longitudinal angle of the camera */
  116767. alpha: number;
  116768. /** The latitudinal angle of the camera */
  116769. beta: number;
  116770. /** The radius of the camera from its target */
  116771. radius: number;
  116772. /** Define the camera target (the messh it should follow) */
  116773. target: Nullable<AbstractMesh>;
  116774. private _cartesianCoordinates;
  116775. /**
  116776. * Instantiates a new ArcFollowCamera
  116777. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  116778. * @param name Define the name of the camera
  116779. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  116780. * @param beta Define the rotation angle of the camera around the elevation axis
  116781. * @param radius Define the radius of the camera from its target point
  116782. * @param target Define the target of the camera
  116783. * @param scene Define the scene the camera belongs to
  116784. */
  116785. constructor(name: string,
  116786. /** The longitudinal angle of the camera */
  116787. alpha: number,
  116788. /** The latitudinal angle of the camera */
  116789. beta: number,
  116790. /** The radius of the camera from its target */
  116791. radius: number,
  116792. /** Define the camera target (the messh it should follow) */
  116793. target: Nullable<AbstractMesh>, scene: Scene);
  116794. private _follow;
  116795. /** @hidden */
  116796. _checkInputs(): void;
  116797. /**
  116798. * Returns the class name of the object.
  116799. * It is mostly used internally for serialization purposes.
  116800. */
  116801. getClassName(): string;
  116802. }
  116803. }
  116804. declare module BABYLON {
  116805. /**
  116806. * Manage the keyboard inputs to control the movement of a follow camera.
  116807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116808. */
  116809. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  116810. /**
  116811. * Defines the camera the input is attached to.
  116812. */
  116813. camera: FollowCamera;
  116814. /**
  116815. * Defines the list of key codes associated with the up action (increase heightOffset)
  116816. */
  116817. keysHeightOffsetIncr: number[];
  116818. /**
  116819. * Defines the list of key codes associated with the down action (decrease heightOffset)
  116820. */
  116821. keysHeightOffsetDecr: number[];
  116822. /**
  116823. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  116824. */
  116825. keysHeightOffsetModifierAlt: boolean;
  116826. /**
  116827. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  116828. */
  116829. keysHeightOffsetModifierCtrl: boolean;
  116830. /**
  116831. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  116832. */
  116833. keysHeightOffsetModifierShift: boolean;
  116834. /**
  116835. * Defines the list of key codes associated with the left action (increase rotationOffset)
  116836. */
  116837. keysRotationOffsetIncr: number[];
  116838. /**
  116839. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  116840. */
  116841. keysRotationOffsetDecr: number[];
  116842. /**
  116843. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  116844. */
  116845. keysRotationOffsetModifierAlt: boolean;
  116846. /**
  116847. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  116848. */
  116849. keysRotationOffsetModifierCtrl: boolean;
  116850. /**
  116851. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  116852. */
  116853. keysRotationOffsetModifierShift: boolean;
  116854. /**
  116855. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  116856. */
  116857. keysRadiusIncr: number[];
  116858. /**
  116859. * Defines the list of key codes associated with the zoom-out action (increase radius)
  116860. */
  116861. keysRadiusDecr: number[];
  116862. /**
  116863. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  116864. */
  116865. keysRadiusModifierAlt: boolean;
  116866. /**
  116867. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  116868. */
  116869. keysRadiusModifierCtrl: boolean;
  116870. /**
  116871. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  116872. */
  116873. keysRadiusModifierShift: boolean;
  116874. /**
  116875. * Defines the rate of change of heightOffset.
  116876. */
  116877. heightSensibility: number;
  116878. /**
  116879. * Defines the rate of change of rotationOffset.
  116880. */
  116881. rotationSensibility: number;
  116882. /**
  116883. * Defines the rate of change of radius.
  116884. */
  116885. radiusSensibility: number;
  116886. private _keys;
  116887. private _ctrlPressed;
  116888. private _altPressed;
  116889. private _shiftPressed;
  116890. private _onCanvasBlurObserver;
  116891. private _onKeyboardObserver;
  116892. private _engine;
  116893. private _scene;
  116894. /**
  116895. * Attach the input controls to a specific dom element to get the input from.
  116896. * @param element Defines the element the controls should be listened from
  116897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116898. */
  116899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116900. /**
  116901. * Detach the current controls from the specified dom element.
  116902. * @param element Defines the element to stop listening the inputs from
  116903. */
  116904. detachControl(element: Nullable<HTMLElement>): void;
  116905. /**
  116906. * Update the current camera state depending on the inputs that have been used this frame.
  116907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116908. */
  116909. checkInputs(): void;
  116910. /**
  116911. * Gets the class name of the current input.
  116912. * @returns the class name
  116913. */
  116914. getClassName(): string;
  116915. /**
  116916. * Get the friendly name associated with the input class.
  116917. * @returns the input friendly name
  116918. */
  116919. getSimpleName(): string;
  116920. /**
  116921. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  116922. * allow modification of the heightOffset value.
  116923. */
  116924. private _modifierHeightOffset;
  116925. /**
  116926. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  116927. * allow modification of the rotationOffset value.
  116928. */
  116929. private _modifierRotationOffset;
  116930. /**
  116931. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  116932. * allow modification of the radius value.
  116933. */
  116934. private _modifierRadius;
  116935. }
  116936. }
  116937. declare module BABYLON {
  116938. interface FreeCameraInputsManager {
  116939. /**
  116940. * @hidden
  116941. */
  116942. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  116943. /**
  116944. * Add orientation input support to the input manager.
  116945. * @returns the current input manager
  116946. */
  116947. addDeviceOrientation(): FreeCameraInputsManager;
  116948. }
  116949. /**
  116950. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  116951. * Screen rotation is taken into account.
  116952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116953. */
  116954. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  116955. private _camera;
  116956. private _screenOrientationAngle;
  116957. private _constantTranform;
  116958. private _screenQuaternion;
  116959. private _alpha;
  116960. private _beta;
  116961. private _gamma;
  116962. /**
  116963. * Can be used to detect if a device orientation sensor is available on a device
  116964. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  116965. * @returns a promise that will resolve on orientation change
  116966. */
  116967. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  116968. /**
  116969. * @hidden
  116970. */
  116971. _onDeviceOrientationChangedObservable: Observable<void>;
  116972. /**
  116973. * Instantiates a new input
  116974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  116975. */
  116976. constructor();
  116977. /**
  116978. * Define the camera controlled by the input.
  116979. */
  116980. get camera(): FreeCamera;
  116981. set camera(camera: FreeCamera);
  116982. /**
  116983. * Attach the input controls to a specific dom element to get the input from.
  116984. * @param element Defines the element the controls should be listened from
  116985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  116986. */
  116987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  116988. private _orientationChanged;
  116989. private _deviceOrientation;
  116990. /**
  116991. * Detach the current controls from the specified dom element.
  116992. * @param element Defines the element to stop listening the inputs from
  116993. */
  116994. detachControl(element: Nullable<HTMLElement>): void;
  116995. /**
  116996. * Update the current camera state depending on the inputs that have been used this frame.
  116997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  116998. */
  116999. checkInputs(): void;
  117000. /**
  117001. * Gets the class name of the current intput.
  117002. * @returns the class name
  117003. */
  117004. getClassName(): string;
  117005. /**
  117006. * Get the friendly name associated with the input class.
  117007. * @returns the input friendly name
  117008. */
  117009. getSimpleName(): string;
  117010. }
  117011. }
  117012. declare module BABYLON {
  117013. /**
  117014. * Manage the gamepad inputs to control a free camera.
  117015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117016. */
  117017. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  117018. /**
  117019. * Define the camera the input is attached to.
  117020. */
  117021. camera: FreeCamera;
  117022. /**
  117023. * Define the Gamepad controlling the input
  117024. */
  117025. gamepad: Nullable<Gamepad>;
  117026. /**
  117027. * Defines the gamepad rotation sensiblity.
  117028. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  117029. */
  117030. gamepadAngularSensibility: number;
  117031. /**
  117032. * Defines the gamepad move sensiblity.
  117033. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  117034. */
  117035. gamepadMoveSensibility: number;
  117036. private _yAxisScale;
  117037. /**
  117038. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  117039. */
  117040. get invertYAxis(): boolean;
  117041. set invertYAxis(value: boolean);
  117042. private _onGamepadConnectedObserver;
  117043. private _onGamepadDisconnectedObserver;
  117044. private _cameraTransform;
  117045. private _deltaTransform;
  117046. private _vector3;
  117047. private _vector2;
  117048. /**
  117049. * Attach the input controls to a specific dom element to get the input from.
  117050. * @param element Defines the element the controls should be listened from
  117051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117052. */
  117053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117054. /**
  117055. * Detach the current controls from the specified dom element.
  117056. * @param element Defines the element to stop listening the inputs from
  117057. */
  117058. detachControl(element: Nullable<HTMLElement>): void;
  117059. /**
  117060. * Update the current camera state depending on the inputs that have been used this frame.
  117061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117062. */
  117063. checkInputs(): void;
  117064. /**
  117065. * Gets the class name of the current intput.
  117066. * @returns the class name
  117067. */
  117068. getClassName(): string;
  117069. /**
  117070. * Get the friendly name associated with the input class.
  117071. * @returns the input friendly name
  117072. */
  117073. getSimpleName(): string;
  117074. }
  117075. }
  117076. declare module BABYLON {
  117077. /**
  117078. * Defines the potential axis of a Joystick
  117079. */
  117080. export enum JoystickAxis {
  117081. /** X axis */
  117082. X = 0,
  117083. /** Y axis */
  117084. Y = 1,
  117085. /** Z axis */
  117086. Z = 2
  117087. }
  117088. /**
  117089. * Class used to define virtual joystick (used in touch mode)
  117090. */
  117091. export class VirtualJoystick {
  117092. /**
  117093. * Gets or sets a boolean indicating that left and right values must be inverted
  117094. */
  117095. reverseLeftRight: boolean;
  117096. /**
  117097. * Gets or sets a boolean indicating that up and down values must be inverted
  117098. */
  117099. reverseUpDown: boolean;
  117100. /**
  117101. * Gets the offset value for the position (ie. the change of the position value)
  117102. */
  117103. deltaPosition: Vector3;
  117104. /**
  117105. * Gets a boolean indicating if the virtual joystick was pressed
  117106. */
  117107. pressed: boolean;
  117108. /**
  117109. * Canvas the virtual joystick will render onto, default z-index of this is 5
  117110. */
  117111. static Canvas: Nullable<HTMLCanvasElement>;
  117112. private static _globalJoystickIndex;
  117113. private static vjCanvasContext;
  117114. private static vjCanvasWidth;
  117115. private static vjCanvasHeight;
  117116. private static halfWidth;
  117117. private _action;
  117118. private _axisTargetedByLeftAndRight;
  117119. private _axisTargetedByUpAndDown;
  117120. private _joystickSensibility;
  117121. private _inversedSensibility;
  117122. private _joystickPointerID;
  117123. private _joystickColor;
  117124. private _joystickPointerPos;
  117125. private _joystickPreviousPointerPos;
  117126. private _joystickPointerStartPos;
  117127. private _deltaJoystickVector;
  117128. private _leftJoystick;
  117129. private _touches;
  117130. private _onPointerDownHandlerRef;
  117131. private _onPointerMoveHandlerRef;
  117132. private _onPointerUpHandlerRef;
  117133. private _onResize;
  117134. /**
  117135. * Creates a new virtual joystick
  117136. * @param leftJoystick defines that the joystick is for left hand (false by default)
  117137. */
  117138. constructor(leftJoystick?: boolean);
  117139. /**
  117140. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  117141. * @param newJoystickSensibility defines the new sensibility
  117142. */
  117143. setJoystickSensibility(newJoystickSensibility: number): void;
  117144. private _onPointerDown;
  117145. private _onPointerMove;
  117146. private _onPointerUp;
  117147. /**
  117148. * Change the color of the virtual joystick
  117149. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  117150. */
  117151. setJoystickColor(newColor: string): void;
  117152. /**
  117153. * Defines a callback to call when the joystick is touched
  117154. * @param action defines the callback
  117155. */
  117156. setActionOnTouch(action: () => any): void;
  117157. /**
  117158. * Defines which axis you'd like to control for left & right
  117159. * @param axis defines the axis to use
  117160. */
  117161. setAxisForLeftRight(axis: JoystickAxis): void;
  117162. /**
  117163. * Defines which axis you'd like to control for up & down
  117164. * @param axis defines the axis to use
  117165. */
  117166. setAxisForUpDown(axis: JoystickAxis): void;
  117167. private _drawVirtualJoystick;
  117168. /**
  117169. * Release internal HTML canvas
  117170. */
  117171. releaseCanvas(): void;
  117172. }
  117173. }
  117174. declare module BABYLON {
  117175. interface FreeCameraInputsManager {
  117176. /**
  117177. * Add virtual joystick input support to the input manager.
  117178. * @returns the current input manager
  117179. */
  117180. addVirtualJoystick(): FreeCameraInputsManager;
  117181. }
  117182. /**
  117183. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  117184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  117185. */
  117186. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  117187. /**
  117188. * Defines the camera the input is attached to.
  117189. */
  117190. camera: FreeCamera;
  117191. private _leftjoystick;
  117192. private _rightjoystick;
  117193. /**
  117194. * Gets the left stick of the virtual joystick.
  117195. * @returns The virtual Joystick
  117196. */
  117197. getLeftJoystick(): VirtualJoystick;
  117198. /**
  117199. * Gets the right stick of the virtual joystick.
  117200. * @returns The virtual Joystick
  117201. */
  117202. getRightJoystick(): VirtualJoystick;
  117203. /**
  117204. * Update the current camera state depending on the inputs that have been used this frame.
  117205. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  117206. */
  117207. checkInputs(): void;
  117208. /**
  117209. * Attach the input controls to a specific dom element to get the input from.
  117210. * @param element Defines the element the controls should be listened from
  117211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  117212. */
  117213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  117214. /**
  117215. * Detach the current controls from the specified dom element.
  117216. * @param element Defines the element to stop listening the inputs from
  117217. */
  117218. detachControl(element: Nullable<HTMLElement>): void;
  117219. /**
  117220. * Gets the class name of the current intput.
  117221. * @returns the class name
  117222. */
  117223. getClassName(): string;
  117224. /**
  117225. * Get the friendly name associated with the input class.
  117226. * @returns the input friendly name
  117227. */
  117228. getSimpleName(): string;
  117229. }
  117230. }
  117231. declare module BABYLON {
  117232. /**
  117233. * This represents a FPS type of camera controlled by touch.
  117234. * This is like a universal camera minus the Gamepad controls.
  117235. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117236. */
  117237. export class TouchCamera extends FreeCamera {
  117238. /**
  117239. * Defines the touch sensibility for rotation.
  117240. * The higher the faster.
  117241. */
  117242. get touchAngularSensibility(): number;
  117243. set touchAngularSensibility(value: number);
  117244. /**
  117245. * Defines the touch sensibility for move.
  117246. * The higher the faster.
  117247. */
  117248. get touchMoveSensibility(): number;
  117249. set touchMoveSensibility(value: number);
  117250. /**
  117251. * Instantiates a new touch camera.
  117252. * This represents a FPS type of camera controlled by touch.
  117253. * This is like a universal camera minus the Gamepad controls.
  117254. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117255. * @param name Define the name of the camera in the scene
  117256. * @param position Define the start position of the camera in the scene
  117257. * @param scene Define the scene the camera belongs to
  117258. */
  117259. constructor(name: string, position: Vector3, scene: Scene);
  117260. /**
  117261. * Gets the current object class name.
  117262. * @return the class name
  117263. */
  117264. getClassName(): string;
  117265. /** @hidden */
  117266. _setupInputs(): void;
  117267. }
  117268. }
  117269. declare module BABYLON {
  117270. /**
  117271. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  117272. * being tilted forward or back and left or right.
  117273. */
  117274. export class DeviceOrientationCamera extends FreeCamera {
  117275. private _initialQuaternion;
  117276. private _quaternionCache;
  117277. private _tmpDragQuaternion;
  117278. private _disablePointerInputWhenUsingDeviceOrientation;
  117279. /**
  117280. * Creates a new device orientation camera
  117281. * @param name The name of the camera
  117282. * @param position The start position camera
  117283. * @param scene The scene the camera belongs to
  117284. */
  117285. constructor(name: string, position: Vector3, scene: Scene);
  117286. /**
  117287. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  117288. */
  117289. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  117290. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  117291. private _dragFactor;
  117292. /**
  117293. * Enabled turning on the y axis when the orientation sensor is active
  117294. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  117295. */
  117296. enableHorizontalDragging(dragFactor?: number): void;
  117297. /**
  117298. * Gets the current instance class name ("DeviceOrientationCamera").
  117299. * This helps avoiding instanceof at run time.
  117300. * @returns the class name
  117301. */
  117302. getClassName(): string;
  117303. /**
  117304. * @hidden
  117305. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  117306. */
  117307. _checkInputs(): void;
  117308. /**
  117309. * Reset the camera to its default orientation on the specified axis only.
  117310. * @param axis The axis to reset
  117311. */
  117312. resetToCurrentRotation(axis?: Axis): void;
  117313. }
  117314. }
  117315. declare module BABYLON {
  117316. /**
  117317. * Defines supported buttons for XBox360 compatible gamepads
  117318. */
  117319. export enum Xbox360Button {
  117320. /** A */
  117321. A = 0,
  117322. /** B */
  117323. B = 1,
  117324. /** X */
  117325. X = 2,
  117326. /** Y */
  117327. Y = 3,
  117328. /** Left button */
  117329. LB = 4,
  117330. /** Right button */
  117331. RB = 5,
  117332. /** Back */
  117333. Back = 8,
  117334. /** Start */
  117335. Start = 9,
  117336. /** Left stick */
  117337. LeftStick = 10,
  117338. /** Right stick */
  117339. RightStick = 11
  117340. }
  117341. /** Defines values for XBox360 DPad */
  117342. export enum Xbox360Dpad {
  117343. /** Up */
  117344. Up = 12,
  117345. /** Down */
  117346. Down = 13,
  117347. /** Left */
  117348. Left = 14,
  117349. /** Right */
  117350. Right = 15
  117351. }
  117352. /**
  117353. * Defines a XBox360 gamepad
  117354. */
  117355. export class Xbox360Pad extends Gamepad {
  117356. private _leftTrigger;
  117357. private _rightTrigger;
  117358. private _onlefttriggerchanged;
  117359. private _onrighttriggerchanged;
  117360. private _onbuttondown;
  117361. private _onbuttonup;
  117362. private _ondpaddown;
  117363. private _ondpadup;
  117364. /** Observable raised when a button is pressed */
  117365. onButtonDownObservable: Observable<Xbox360Button>;
  117366. /** Observable raised when a button is released */
  117367. onButtonUpObservable: Observable<Xbox360Button>;
  117368. /** Observable raised when a pad is pressed */
  117369. onPadDownObservable: Observable<Xbox360Dpad>;
  117370. /** Observable raised when a pad is released */
  117371. onPadUpObservable: Observable<Xbox360Dpad>;
  117372. private _buttonA;
  117373. private _buttonB;
  117374. private _buttonX;
  117375. private _buttonY;
  117376. private _buttonBack;
  117377. private _buttonStart;
  117378. private _buttonLB;
  117379. private _buttonRB;
  117380. private _buttonLeftStick;
  117381. private _buttonRightStick;
  117382. private _dPadUp;
  117383. private _dPadDown;
  117384. private _dPadLeft;
  117385. private _dPadRight;
  117386. private _isXboxOnePad;
  117387. /**
  117388. * Creates a new XBox360 gamepad object
  117389. * @param id defines the id of this gamepad
  117390. * @param index defines its index
  117391. * @param gamepad defines the internal HTML gamepad object
  117392. * @param xboxOne defines if it is a XBox One gamepad
  117393. */
  117394. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  117395. /**
  117396. * Defines the callback to call when left trigger is pressed
  117397. * @param callback defines the callback to use
  117398. */
  117399. onlefttriggerchanged(callback: (value: number) => void): void;
  117400. /**
  117401. * Defines the callback to call when right trigger is pressed
  117402. * @param callback defines the callback to use
  117403. */
  117404. onrighttriggerchanged(callback: (value: number) => void): void;
  117405. /**
  117406. * Gets the left trigger value
  117407. */
  117408. get leftTrigger(): number;
  117409. /**
  117410. * Sets the left trigger value
  117411. */
  117412. set leftTrigger(newValue: number);
  117413. /**
  117414. * Gets the right trigger value
  117415. */
  117416. get rightTrigger(): number;
  117417. /**
  117418. * Sets the right trigger value
  117419. */
  117420. set rightTrigger(newValue: number);
  117421. /**
  117422. * Defines the callback to call when a button is pressed
  117423. * @param callback defines the callback to use
  117424. */
  117425. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  117426. /**
  117427. * Defines the callback to call when a button is released
  117428. * @param callback defines the callback to use
  117429. */
  117430. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  117431. /**
  117432. * Defines the callback to call when a pad is pressed
  117433. * @param callback defines the callback to use
  117434. */
  117435. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  117436. /**
  117437. * Defines the callback to call when a pad is released
  117438. * @param callback defines the callback to use
  117439. */
  117440. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  117441. private _setButtonValue;
  117442. private _setDPadValue;
  117443. /**
  117444. * Gets the value of the `A` button
  117445. */
  117446. get buttonA(): number;
  117447. /**
  117448. * Sets the value of the `A` button
  117449. */
  117450. set buttonA(value: number);
  117451. /**
  117452. * Gets the value of the `B` button
  117453. */
  117454. get buttonB(): number;
  117455. /**
  117456. * Sets the value of the `B` button
  117457. */
  117458. set buttonB(value: number);
  117459. /**
  117460. * Gets the value of the `X` button
  117461. */
  117462. get buttonX(): number;
  117463. /**
  117464. * Sets the value of the `X` button
  117465. */
  117466. set buttonX(value: number);
  117467. /**
  117468. * Gets the value of the `Y` button
  117469. */
  117470. get buttonY(): number;
  117471. /**
  117472. * Sets the value of the `Y` button
  117473. */
  117474. set buttonY(value: number);
  117475. /**
  117476. * Gets the value of the `Start` button
  117477. */
  117478. get buttonStart(): number;
  117479. /**
  117480. * Sets the value of the `Start` button
  117481. */
  117482. set buttonStart(value: number);
  117483. /**
  117484. * Gets the value of the `Back` button
  117485. */
  117486. get buttonBack(): number;
  117487. /**
  117488. * Sets the value of the `Back` button
  117489. */
  117490. set buttonBack(value: number);
  117491. /**
  117492. * Gets the value of the `Left` button
  117493. */
  117494. get buttonLB(): number;
  117495. /**
  117496. * Sets the value of the `Left` button
  117497. */
  117498. set buttonLB(value: number);
  117499. /**
  117500. * Gets the value of the `Right` button
  117501. */
  117502. get buttonRB(): number;
  117503. /**
  117504. * Sets the value of the `Right` button
  117505. */
  117506. set buttonRB(value: number);
  117507. /**
  117508. * Gets the value of the Left joystick
  117509. */
  117510. get buttonLeftStick(): number;
  117511. /**
  117512. * Sets the value of the Left joystick
  117513. */
  117514. set buttonLeftStick(value: number);
  117515. /**
  117516. * Gets the value of the Right joystick
  117517. */
  117518. get buttonRightStick(): number;
  117519. /**
  117520. * Sets the value of the Right joystick
  117521. */
  117522. set buttonRightStick(value: number);
  117523. /**
  117524. * Gets the value of D-pad up
  117525. */
  117526. get dPadUp(): number;
  117527. /**
  117528. * Sets the value of D-pad up
  117529. */
  117530. set dPadUp(value: number);
  117531. /**
  117532. * Gets the value of D-pad down
  117533. */
  117534. get dPadDown(): number;
  117535. /**
  117536. * Sets the value of D-pad down
  117537. */
  117538. set dPadDown(value: number);
  117539. /**
  117540. * Gets the value of D-pad left
  117541. */
  117542. get dPadLeft(): number;
  117543. /**
  117544. * Sets the value of D-pad left
  117545. */
  117546. set dPadLeft(value: number);
  117547. /**
  117548. * Gets the value of D-pad right
  117549. */
  117550. get dPadRight(): number;
  117551. /**
  117552. * Sets the value of D-pad right
  117553. */
  117554. set dPadRight(value: number);
  117555. /**
  117556. * Force the gamepad to synchronize with device values
  117557. */
  117558. update(): void;
  117559. /**
  117560. * Disposes the gamepad
  117561. */
  117562. dispose(): void;
  117563. }
  117564. }
  117565. declare module BABYLON {
  117566. /**
  117567. * Defines supported buttons for DualShock compatible gamepads
  117568. */
  117569. export enum DualShockButton {
  117570. /** Cross */
  117571. Cross = 0,
  117572. /** Circle */
  117573. Circle = 1,
  117574. /** Square */
  117575. Square = 2,
  117576. /** Triangle */
  117577. Triangle = 3,
  117578. /** L1 */
  117579. L1 = 4,
  117580. /** R1 */
  117581. R1 = 5,
  117582. /** Share */
  117583. Share = 8,
  117584. /** Options */
  117585. Options = 9,
  117586. /** Left stick */
  117587. LeftStick = 10,
  117588. /** Right stick */
  117589. RightStick = 11
  117590. }
  117591. /** Defines values for DualShock DPad */
  117592. export enum DualShockDpad {
  117593. /** Up */
  117594. Up = 12,
  117595. /** Down */
  117596. Down = 13,
  117597. /** Left */
  117598. Left = 14,
  117599. /** Right */
  117600. Right = 15
  117601. }
  117602. /**
  117603. * Defines a DualShock gamepad
  117604. */
  117605. export class DualShockPad extends Gamepad {
  117606. private _leftTrigger;
  117607. private _rightTrigger;
  117608. private _onlefttriggerchanged;
  117609. private _onrighttriggerchanged;
  117610. private _onbuttondown;
  117611. private _onbuttonup;
  117612. private _ondpaddown;
  117613. private _ondpadup;
  117614. /** Observable raised when a button is pressed */
  117615. onButtonDownObservable: Observable<DualShockButton>;
  117616. /** Observable raised when a button is released */
  117617. onButtonUpObservable: Observable<DualShockButton>;
  117618. /** Observable raised when a pad is pressed */
  117619. onPadDownObservable: Observable<DualShockDpad>;
  117620. /** Observable raised when a pad is released */
  117621. onPadUpObservable: Observable<DualShockDpad>;
  117622. private _buttonCross;
  117623. private _buttonCircle;
  117624. private _buttonSquare;
  117625. private _buttonTriangle;
  117626. private _buttonShare;
  117627. private _buttonOptions;
  117628. private _buttonL1;
  117629. private _buttonR1;
  117630. private _buttonLeftStick;
  117631. private _buttonRightStick;
  117632. private _dPadUp;
  117633. private _dPadDown;
  117634. private _dPadLeft;
  117635. private _dPadRight;
  117636. /**
  117637. * Creates a new DualShock gamepad object
  117638. * @param id defines the id of this gamepad
  117639. * @param index defines its index
  117640. * @param gamepad defines the internal HTML gamepad object
  117641. */
  117642. constructor(id: string, index: number, gamepad: any);
  117643. /**
  117644. * Defines the callback to call when left trigger is pressed
  117645. * @param callback defines the callback to use
  117646. */
  117647. onlefttriggerchanged(callback: (value: number) => void): void;
  117648. /**
  117649. * Defines the callback to call when right trigger is pressed
  117650. * @param callback defines the callback to use
  117651. */
  117652. onrighttriggerchanged(callback: (value: number) => void): void;
  117653. /**
  117654. * Gets the left trigger value
  117655. */
  117656. get leftTrigger(): number;
  117657. /**
  117658. * Sets the left trigger value
  117659. */
  117660. set leftTrigger(newValue: number);
  117661. /**
  117662. * Gets the right trigger value
  117663. */
  117664. get rightTrigger(): number;
  117665. /**
  117666. * Sets the right trigger value
  117667. */
  117668. set rightTrigger(newValue: number);
  117669. /**
  117670. * Defines the callback to call when a button is pressed
  117671. * @param callback defines the callback to use
  117672. */
  117673. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  117674. /**
  117675. * Defines the callback to call when a button is released
  117676. * @param callback defines the callback to use
  117677. */
  117678. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  117679. /**
  117680. * Defines the callback to call when a pad is pressed
  117681. * @param callback defines the callback to use
  117682. */
  117683. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  117684. /**
  117685. * Defines the callback to call when a pad is released
  117686. * @param callback defines the callback to use
  117687. */
  117688. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  117689. private _setButtonValue;
  117690. private _setDPadValue;
  117691. /**
  117692. * Gets the value of the `Cross` button
  117693. */
  117694. get buttonCross(): number;
  117695. /**
  117696. * Sets the value of the `Cross` button
  117697. */
  117698. set buttonCross(value: number);
  117699. /**
  117700. * Gets the value of the `Circle` button
  117701. */
  117702. get buttonCircle(): number;
  117703. /**
  117704. * Sets the value of the `Circle` button
  117705. */
  117706. set buttonCircle(value: number);
  117707. /**
  117708. * Gets the value of the `Square` button
  117709. */
  117710. get buttonSquare(): number;
  117711. /**
  117712. * Sets the value of the `Square` button
  117713. */
  117714. set buttonSquare(value: number);
  117715. /**
  117716. * Gets the value of the `Triangle` button
  117717. */
  117718. get buttonTriangle(): number;
  117719. /**
  117720. * Sets the value of the `Triangle` button
  117721. */
  117722. set buttonTriangle(value: number);
  117723. /**
  117724. * Gets the value of the `Options` button
  117725. */
  117726. get buttonOptions(): number;
  117727. /**
  117728. * Sets the value of the `Options` button
  117729. */
  117730. set buttonOptions(value: number);
  117731. /**
  117732. * Gets the value of the `Share` button
  117733. */
  117734. get buttonShare(): number;
  117735. /**
  117736. * Sets the value of the `Share` button
  117737. */
  117738. set buttonShare(value: number);
  117739. /**
  117740. * Gets the value of the `L1` button
  117741. */
  117742. get buttonL1(): number;
  117743. /**
  117744. * Sets the value of the `L1` button
  117745. */
  117746. set buttonL1(value: number);
  117747. /**
  117748. * Gets the value of the `R1` button
  117749. */
  117750. get buttonR1(): number;
  117751. /**
  117752. * Sets the value of the `R1` button
  117753. */
  117754. set buttonR1(value: number);
  117755. /**
  117756. * Gets the value of the Left joystick
  117757. */
  117758. get buttonLeftStick(): number;
  117759. /**
  117760. * Sets the value of the Left joystick
  117761. */
  117762. set buttonLeftStick(value: number);
  117763. /**
  117764. * Gets the value of the Right joystick
  117765. */
  117766. get buttonRightStick(): number;
  117767. /**
  117768. * Sets the value of the Right joystick
  117769. */
  117770. set buttonRightStick(value: number);
  117771. /**
  117772. * Gets the value of D-pad up
  117773. */
  117774. get dPadUp(): number;
  117775. /**
  117776. * Sets the value of D-pad up
  117777. */
  117778. set dPadUp(value: number);
  117779. /**
  117780. * Gets the value of D-pad down
  117781. */
  117782. get dPadDown(): number;
  117783. /**
  117784. * Sets the value of D-pad down
  117785. */
  117786. set dPadDown(value: number);
  117787. /**
  117788. * Gets the value of D-pad left
  117789. */
  117790. get dPadLeft(): number;
  117791. /**
  117792. * Sets the value of D-pad left
  117793. */
  117794. set dPadLeft(value: number);
  117795. /**
  117796. * Gets the value of D-pad right
  117797. */
  117798. get dPadRight(): number;
  117799. /**
  117800. * Sets the value of D-pad right
  117801. */
  117802. set dPadRight(value: number);
  117803. /**
  117804. * Force the gamepad to synchronize with device values
  117805. */
  117806. update(): void;
  117807. /**
  117808. * Disposes the gamepad
  117809. */
  117810. dispose(): void;
  117811. }
  117812. }
  117813. declare module BABYLON {
  117814. /**
  117815. * Manager for handling gamepads
  117816. */
  117817. export class GamepadManager {
  117818. private _scene?;
  117819. private _babylonGamepads;
  117820. private _oneGamepadConnected;
  117821. /** @hidden */
  117822. _isMonitoring: boolean;
  117823. private _gamepadEventSupported;
  117824. private _gamepadSupport?;
  117825. /**
  117826. * observable to be triggered when the gamepad controller has been connected
  117827. */
  117828. onGamepadConnectedObservable: Observable<Gamepad>;
  117829. /**
  117830. * observable to be triggered when the gamepad controller has been disconnected
  117831. */
  117832. onGamepadDisconnectedObservable: Observable<Gamepad>;
  117833. private _onGamepadConnectedEvent;
  117834. private _onGamepadDisconnectedEvent;
  117835. /**
  117836. * Initializes the gamepad manager
  117837. * @param _scene BabylonJS scene
  117838. */
  117839. constructor(_scene?: Scene | undefined);
  117840. /**
  117841. * The gamepads in the game pad manager
  117842. */
  117843. get gamepads(): Gamepad[];
  117844. /**
  117845. * Get the gamepad controllers based on type
  117846. * @param type The type of gamepad controller
  117847. * @returns Nullable gamepad
  117848. */
  117849. getGamepadByType(type?: number): Nullable<Gamepad>;
  117850. /**
  117851. * Disposes the gamepad manager
  117852. */
  117853. dispose(): void;
  117854. private _addNewGamepad;
  117855. private _startMonitoringGamepads;
  117856. private _stopMonitoringGamepads;
  117857. /** @hidden */
  117858. _checkGamepadsStatus(): void;
  117859. private _updateGamepadObjects;
  117860. }
  117861. }
  117862. declare module BABYLON {
  117863. interface Scene {
  117864. /** @hidden */
  117865. _gamepadManager: Nullable<GamepadManager>;
  117866. /**
  117867. * Gets the gamepad manager associated with the scene
  117868. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  117869. */
  117870. gamepadManager: GamepadManager;
  117871. }
  117872. /**
  117873. * Interface representing a free camera inputs manager
  117874. */
  117875. interface FreeCameraInputsManager {
  117876. /**
  117877. * Adds gamepad input support to the FreeCameraInputsManager.
  117878. * @returns the FreeCameraInputsManager
  117879. */
  117880. addGamepad(): FreeCameraInputsManager;
  117881. }
  117882. /**
  117883. * Interface representing an arc rotate camera inputs manager
  117884. */
  117885. interface ArcRotateCameraInputsManager {
  117886. /**
  117887. * Adds gamepad input support to the ArcRotateCamera InputManager.
  117888. * @returns the camera inputs manager
  117889. */
  117890. addGamepad(): ArcRotateCameraInputsManager;
  117891. }
  117892. /**
  117893. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  117894. */
  117895. export class GamepadSystemSceneComponent implements ISceneComponent {
  117896. /**
  117897. * The component name helpfull to identify the component in the list of scene components.
  117898. */
  117899. readonly name: string;
  117900. /**
  117901. * The scene the component belongs to.
  117902. */
  117903. scene: Scene;
  117904. /**
  117905. * Creates a new instance of the component for the given scene
  117906. * @param scene Defines the scene to register the component in
  117907. */
  117908. constructor(scene: Scene);
  117909. /**
  117910. * Registers the component in a given scene
  117911. */
  117912. register(): void;
  117913. /**
  117914. * Rebuilds the elements related to this component in case of
  117915. * context lost for instance.
  117916. */
  117917. rebuild(): void;
  117918. /**
  117919. * Disposes the component and the associated ressources
  117920. */
  117921. dispose(): void;
  117922. private _beforeCameraUpdate;
  117923. }
  117924. }
  117925. declare module BABYLON {
  117926. /**
  117927. * 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,
  117928. * which still works and will still be found in many Playgrounds.
  117929. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117930. */
  117931. export class UniversalCamera extends TouchCamera {
  117932. /**
  117933. * Defines the gamepad rotation sensiblity.
  117934. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  117935. */
  117936. get gamepadAngularSensibility(): number;
  117937. set gamepadAngularSensibility(value: number);
  117938. /**
  117939. * Defines the gamepad move sensiblity.
  117940. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  117941. */
  117942. get gamepadMoveSensibility(): number;
  117943. set gamepadMoveSensibility(value: number);
  117944. /**
  117945. * 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,
  117946. * which still works and will still be found in many Playgrounds.
  117947. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117948. * @param name Define the name of the camera in the scene
  117949. * @param position Define the start position of the camera in the scene
  117950. * @param scene Define the scene the camera belongs to
  117951. */
  117952. constructor(name: string, position: Vector3, scene: Scene);
  117953. /**
  117954. * Gets the current object class name.
  117955. * @return the class name
  117956. */
  117957. getClassName(): string;
  117958. }
  117959. }
  117960. declare module BABYLON {
  117961. /**
  117962. * This represents a FPS type of camera. This is only here for back compat purpose.
  117963. * Please use the UniversalCamera instead as both are identical.
  117964. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117965. */
  117966. export class GamepadCamera extends UniversalCamera {
  117967. /**
  117968. * Instantiates a new Gamepad Camera
  117969. * This represents a FPS type of camera. This is only here for back compat purpose.
  117970. * Please use the UniversalCamera instead as both are identical.
  117971. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  117972. * @param name Define the name of the camera in the scene
  117973. * @param position Define the start position of the camera in the scene
  117974. * @param scene Define the scene the camera belongs to
  117975. */
  117976. constructor(name: string, position: Vector3, scene: Scene);
  117977. /**
  117978. * Gets the current object class name.
  117979. * @return the class name
  117980. */
  117981. getClassName(): string;
  117982. }
  117983. }
  117984. declare module BABYLON {
  117985. /** @hidden */
  117986. export var passPixelShader: {
  117987. name: string;
  117988. shader: string;
  117989. };
  117990. }
  117991. declare module BABYLON {
  117992. /** @hidden */
  117993. export var passCubePixelShader: {
  117994. name: string;
  117995. shader: string;
  117996. };
  117997. }
  117998. declare module BABYLON {
  117999. /**
  118000. * PassPostProcess which produces an output the same as it's input
  118001. */
  118002. export class PassPostProcess extends PostProcess {
  118003. /**
  118004. * Creates the PassPostProcess
  118005. * @param name The name of the effect.
  118006. * @param options The required width/height ratio to downsize to before computing the render pass.
  118007. * @param camera The camera to apply the render pass to.
  118008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118009. * @param engine The engine which the post process will be applied. (default: current engine)
  118010. * @param reusable If the post process can be reused on the same frame. (default: false)
  118011. * @param textureType The type of texture to be used when performing the post processing.
  118012. * @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)
  118013. */
  118014. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118015. }
  118016. /**
  118017. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  118018. */
  118019. export class PassCubePostProcess extends PostProcess {
  118020. private _face;
  118021. /**
  118022. * Gets or sets the cube face to display.
  118023. * * 0 is +X
  118024. * * 1 is -X
  118025. * * 2 is +Y
  118026. * * 3 is -Y
  118027. * * 4 is +Z
  118028. * * 5 is -Z
  118029. */
  118030. get face(): number;
  118031. set face(value: number);
  118032. /**
  118033. * Creates the PassCubePostProcess
  118034. * @param name The name of the effect.
  118035. * @param options The required width/height ratio to downsize to before computing the render pass.
  118036. * @param camera The camera to apply the render pass to.
  118037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118038. * @param engine The engine which the post process will be applied. (default: current engine)
  118039. * @param reusable If the post process can be reused on the same frame. (default: false)
  118040. * @param textureType The type of texture to be used when performing the post processing.
  118041. * @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)
  118042. */
  118043. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118044. }
  118045. }
  118046. declare module BABYLON {
  118047. /** @hidden */
  118048. export var anaglyphPixelShader: {
  118049. name: string;
  118050. shader: string;
  118051. };
  118052. }
  118053. declare module BABYLON {
  118054. /**
  118055. * Postprocess used to generate anaglyphic rendering
  118056. */
  118057. export class AnaglyphPostProcess extends PostProcess {
  118058. private _passedProcess;
  118059. /**
  118060. * Creates a new AnaglyphPostProcess
  118061. * @param name defines postprocess name
  118062. * @param options defines creation options or target ratio scale
  118063. * @param rigCameras defines cameras using this postprocess
  118064. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  118065. * @param engine defines hosting engine
  118066. * @param reusable defines if the postprocess will be reused multiple times per frame
  118067. */
  118068. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  118069. }
  118070. }
  118071. declare module BABYLON {
  118072. /**
  118073. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  118074. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118075. */
  118076. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  118077. /**
  118078. * Creates a new AnaglyphArcRotateCamera
  118079. * @param name defines camera name
  118080. * @param alpha defines alpha angle (in radians)
  118081. * @param beta defines beta angle (in radians)
  118082. * @param radius defines radius
  118083. * @param target defines camera target
  118084. * @param interaxialDistance defines distance between each color axis
  118085. * @param scene defines the hosting scene
  118086. */
  118087. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  118088. /**
  118089. * Gets camera class name
  118090. * @returns AnaglyphArcRotateCamera
  118091. */
  118092. getClassName(): string;
  118093. }
  118094. }
  118095. declare module BABYLON {
  118096. /**
  118097. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  118098. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118099. */
  118100. export class AnaglyphFreeCamera extends FreeCamera {
  118101. /**
  118102. * Creates a new AnaglyphFreeCamera
  118103. * @param name defines camera name
  118104. * @param position defines initial position
  118105. * @param interaxialDistance defines distance between each color axis
  118106. * @param scene defines the hosting scene
  118107. */
  118108. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118109. /**
  118110. * Gets camera class name
  118111. * @returns AnaglyphFreeCamera
  118112. */
  118113. getClassName(): string;
  118114. }
  118115. }
  118116. declare module BABYLON {
  118117. /**
  118118. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  118119. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118120. */
  118121. export class AnaglyphGamepadCamera extends GamepadCamera {
  118122. /**
  118123. * Creates a new AnaglyphGamepadCamera
  118124. * @param name defines camera name
  118125. * @param position defines initial position
  118126. * @param interaxialDistance defines distance between each color axis
  118127. * @param scene defines the hosting scene
  118128. */
  118129. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118130. /**
  118131. * Gets camera class name
  118132. * @returns AnaglyphGamepadCamera
  118133. */
  118134. getClassName(): string;
  118135. }
  118136. }
  118137. declare module BABYLON {
  118138. /**
  118139. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  118140. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  118141. */
  118142. export class AnaglyphUniversalCamera extends UniversalCamera {
  118143. /**
  118144. * Creates a new AnaglyphUniversalCamera
  118145. * @param name defines camera name
  118146. * @param position defines initial position
  118147. * @param interaxialDistance defines distance between each color axis
  118148. * @param scene defines the hosting scene
  118149. */
  118150. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  118151. /**
  118152. * Gets camera class name
  118153. * @returns AnaglyphUniversalCamera
  118154. */
  118155. getClassName(): string;
  118156. }
  118157. }
  118158. declare module BABYLON {
  118159. /**
  118160. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  118161. * @see http://doc.babylonjs.com/features/cameras
  118162. */
  118163. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  118164. /**
  118165. * Creates a new StereoscopicArcRotateCamera
  118166. * @param name defines camera name
  118167. * @param alpha defines alpha angle (in radians)
  118168. * @param beta defines beta angle (in radians)
  118169. * @param radius defines radius
  118170. * @param target defines camera target
  118171. * @param interaxialDistance defines distance between each color axis
  118172. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118173. * @param scene defines the hosting scene
  118174. */
  118175. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118176. /**
  118177. * Gets camera class name
  118178. * @returns StereoscopicArcRotateCamera
  118179. */
  118180. getClassName(): string;
  118181. }
  118182. }
  118183. declare module BABYLON {
  118184. /**
  118185. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  118186. * @see http://doc.babylonjs.com/features/cameras
  118187. */
  118188. export class StereoscopicFreeCamera extends FreeCamera {
  118189. /**
  118190. * Creates a new StereoscopicFreeCamera
  118191. * @param name defines camera name
  118192. * @param position defines initial position
  118193. * @param interaxialDistance defines distance between each color axis
  118194. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118195. * @param scene defines the hosting scene
  118196. */
  118197. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118198. /**
  118199. * Gets camera class name
  118200. * @returns StereoscopicFreeCamera
  118201. */
  118202. getClassName(): string;
  118203. }
  118204. }
  118205. declare module BABYLON {
  118206. /**
  118207. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  118208. * @see http://doc.babylonjs.com/features/cameras
  118209. */
  118210. export class StereoscopicGamepadCamera extends GamepadCamera {
  118211. /**
  118212. * Creates a new StereoscopicGamepadCamera
  118213. * @param name defines camera name
  118214. * @param position defines initial position
  118215. * @param interaxialDistance defines distance between each color axis
  118216. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118217. * @param scene defines the hosting scene
  118218. */
  118219. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118220. /**
  118221. * Gets camera class name
  118222. * @returns StereoscopicGamepadCamera
  118223. */
  118224. getClassName(): string;
  118225. }
  118226. }
  118227. declare module BABYLON {
  118228. /**
  118229. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  118230. * @see http://doc.babylonjs.com/features/cameras
  118231. */
  118232. export class StereoscopicUniversalCamera extends UniversalCamera {
  118233. /**
  118234. * Creates a new StereoscopicUniversalCamera
  118235. * @param name defines camera name
  118236. * @param position defines initial position
  118237. * @param interaxialDistance defines distance between each color axis
  118238. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  118239. * @param scene defines the hosting scene
  118240. */
  118241. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  118242. /**
  118243. * Gets camera class name
  118244. * @returns StereoscopicUniversalCamera
  118245. */
  118246. getClassName(): string;
  118247. }
  118248. }
  118249. declare module BABYLON {
  118250. /**
  118251. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  118252. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118253. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118254. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118255. */
  118256. export class VirtualJoysticksCamera extends FreeCamera {
  118257. /**
  118258. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  118259. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  118260. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  118261. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  118262. * @param name Define the name of the camera in the scene
  118263. * @param position Define the start position of the camera in the scene
  118264. * @param scene Define the scene the camera belongs to
  118265. */
  118266. constructor(name: string, position: Vector3, scene: Scene);
  118267. /**
  118268. * Gets the current object class name.
  118269. * @return the class name
  118270. */
  118271. getClassName(): string;
  118272. }
  118273. }
  118274. declare module BABYLON {
  118275. /**
  118276. * This represents all the required metrics to create a VR camera.
  118277. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  118278. */
  118279. export class VRCameraMetrics {
  118280. /**
  118281. * Define the horizontal resolution off the screen.
  118282. */
  118283. hResolution: number;
  118284. /**
  118285. * Define the vertical resolution off the screen.
  118286. */
  118287. vResolution: number;
  118288. /**
  118289. * Define the horizontal screen size.
  118290. */
  118291. hScreenSize: number;
  118292. /**
  118293. * Define the vertical screen size.
  118294. */
  118295. vScreenSize: number;
  118296. /**
  118297. * Define the vertical screen center position.
  118298. */
  118299. vScreenCenter: number;
  118300. /**
  118301. * Define the distance of the eyes to the screen.
  118302. */
  118303. eyeToScreenDistance: number;
  118304. /**
  118305. * Define the distance between both lenses
  118306. */
  118307. lensSeparationDistance: number;
  118308. /**
  118309. * Define the distance between both viewer's eyes.
  118310. */
  118311. interpupillaryDistance: number;
  118312. /**
  118313. * Define the distortion factor of the VR postprocess.
  118314. * Please, touch with care.
  118315. */
  118316. distortionK: number[];
  118317. /**
  118318. * Define the chromatic aberration correction factors for the VR post process.
  118319. */
  118320. chromaAbCorrection: number[];
  118321. /**
  118322. * Define the scale factor of the post process.
  118323. * The smaller the better but the slower.
  118324. */
  118325. postProcessScaleFactor: number;
  118326. /**
  118327. * Define an offset for the lens center.
  118328. */
  118329. lensCenterOffset: number;
  118330. /**
  118331. * Define if the current vr camera should compensate the distortion of the lense or not.
  118332. */
  118333. compensateDistortion: boolean;
  118334. /**
  118335. * Defines if multiview should be enabled when rendering (Default: false)
  118336. */
  118337. multiviewEnabled: boolean;
  118338. /**
  118339. * Gets the rendering aspect ratio based on the provided resolutions.
  118340. */
  118341. get aspectRatio(): number;
  118342. /**
  118343. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  118344. */
  118345. get aspectRatioFov(): number;
  118346. /**
  118347. * @hidden
  118348. */
  118349. get leftHMatrix(): Matrix;
  118350. /**
  118351. * @hidden
  118352. */
  118353. get rightHMatrix(): Matrix;
  118354. /**
  118355. * @hidden
  118356. */
  118357. get leftPreViewMatrix(): Matrix;
  118358. /**
  118359. * @hidden
  118360. */
  118361. get rightPreViewMatrix(): Matrix;
  118362. /**
  118363. * Get the default VRMetrics based on the most generic setup.
  118364. * @returns the default vr metrics
  118365. */
  118366. static GetDefault(): VRCameraMetrics;
  118367. }
  118368. }
  118369. declare module BABYLON {
  118370. /** @hidden */
  118371. export var vrDistortionCorrectionPixelShader: {
  118372. name: string;
  118373. shader: string;
  118374. };
  118375. }
  118376. declare module BABYLON {
  118377. /**
  118378. * VRDistortionCorrectionPostProcess used for mobile VR
  118379. */
  118380. export class VRDistortionCorrectionPostProcess extends PostProcess {
  118381. private _isRightEye;
  118382. private _distortionFactors;
  118383. private _postProcessScaleFactor;
  118384. private _lensCenterOffset;
  118385. private _scaleIn;
  118386. private _scaleFactor;
  118387. private _lensCenter;
  118388. /**
  118389. * Initializes the VRDistortionCorrectionPostProcess
  118390. * @param name The name of the effect.
  118391. * @param camera The camera to apply the render pass to.
  118392. * @param isRightEye If this is for the right eye distortion
  118393. * @param vrMetrics All the required metrics for the VR camera
  118394. */
  118395. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  118396. }
  118397. }
  118398. declare module BABYLON {
  118399. /**
  118400. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  118401. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118402. */
  118403. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  118404. /**
  118405. * Creates a new VRDeviceOrientationArcRotateCamera
  118406. * @param name defines camera name
  118407. * @param alpha defines the camera rotation along the logitudinal axis
  118408. * @param beta defines the camera rotation along the latitudinal axis
  118409. * @param radius defines the camera distance from its target
  118410. * @param target defines the camera target
  118411. * @param scene defines the scene the camera belongs to
  118412. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118413. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118414. */
  118415. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118416. /**
  118417. * Gets camera class name
  118418. * @returns VRDeviceOrientationArcRotateCamera
  118419. */
  118420. getClassName(): string;
  118421. }
  118422. }
  118423. declare module BABYLON {
  118424. /**
  118425. * Camera used to simulate VR rendering (based on FreeCamera)
  118426. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118427. */
  118428. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  118429. /**
  118430. * Creates a new VRDeviceOrientationFreeCamera
  118431. * @param name defines camera name
  118432. * @param position defines the start position of the camera
  118433. * @param scene defines the scene the camera belongs to
  118434. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118435. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118436. */
  118437. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118438. /**
  118439. * Gets camera class name
  118440. * @returns VRDeviceOrientationFreeCamera
  118441. */
  118442. getClassName(): string;
  118443. }
  118444. }
  118445. declare module BABYLON {
  118446. /**
  118447. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  118448. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  118449. */
  118450. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  118451. /**
  118452. * Creates a new VRDeviceOrientationGamepadCamera
  118453. * @param name defines camera name
  118454. * @param position defines the start position of the camera
  118455. * @param scene defines the scene the camera belongs to
  118456. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  118457. * @param vrCameraMetrics defines the vr metrics associated to the camera
  118458. */
  118459. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  118460. /**
  118461. * Gets camera class name
  118462. * @returns VRDeviceOrientationGamepadCamera
  118463. */
  118464. getClassName(): string;
  118465. }
  118466. }
  118467. declare module BABYLON {
  118468. /** @hidden */
  118469. export var imageProcessingPixelShader: {
  118470. name: string;
  118471. shader: string;
  118472. };
  118473. }
  118474. declare module BABYLON {
  118475. /**
  118476. * ImageProcessingPostProcess
  118477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  118478. */
  118479. export class ImageProcessingPostProcess extends PostProcess {
  118480. /**
  118481. * Default configuration related to image processing available in the PBR Material.
  118482. */
  118483. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118484. /**
  118485. * Gets the image processing configuration used either in this material.
  118486. */
  118487. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118488. /**
  118489. * Sets the Default image processing configuration used either in the this material.
  118490. *
  118491. * If sets to null, the scene one is in use.
  118492. */
  118493. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  118494. /**
  118495. * Keep track of the image processing observer to allow dispose and replace.
  118496. */
  118497. private _imageProcessingObserver;
  118498. /**
  118499. * Attaches a new image processing configuration to the PBR Material.
  118500. * @param configuration
  118501. */
  118502. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  118503. /**
  118504. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118505. */
  118506. get colorCurves(): Nullable<ColorCurves>;
  118507. /**
  118508. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118509. */
  118510. set colorCurves(value: Nullable<ColorCurves>);
  118511. /**
  118512. * Gets wether the color curves effect is enabled.
  118513. */
  118514. get colorCurvesEnabled(): boolean;
  118515. /**
  118516. * Sets wether the color curves effect is enabled.
  118517. */
  118518. set colorCurvesEnabled(value: boolean);
  118519. /**
  118520. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118521. */
  118522. get colorGradingTexture(): Nullable<BaseTexture>;
  118523. /**
  118524. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118525. */
  118526. set colorGradingTexture(value: Nullable<BaseTexture>);
  118527. /**
  118528. * Gets wether the color grading effect is enabled.
  118529. */
  118530. get colorGradingEnabled(): boolean;
  118531. /**
  118532. * Gets wether the color grading effect is enabled.
  118533. */
  118534. set colorGradingEnabled(value: boolean);
  118535. /**
  118536. * Gets exposure used in the effect.
  118537. */
  118538. get exposure(): number;
  118539. /**
  118540. * Sets exposure used in the effect.
  118541. */
  118542. set exposure(value: number);
  118543. /**
  118544. * Gets wether tonemapping is enabled or not.
  118545. */
  118546. get toneMappingEnabled(): boolean;
  118547. /**
  118548. * Sets wether tonemapping is enabled or not
  118549. */
  118550. set toneMappingEnabled(value: boolean);
  118551. /**
  118552. * Gets the type of tone mapping effect.
  118553. */
  118554. get toneMappingType(): number;
  118555. /**
  118556. * Sets the type of tone mapping effect.
  118557. */
  118558. set toneMappingType(value: number);
  118559. /**
  118560. * Gets contrast used in the effect.
  118561. */
  118562. get contrast(): number;
  118563. /**
  118564. * Sets contrast used in the effect.
  118565. */
  118566. set contrast(value: number);
  118567. /**
  118568. * Gets Vignette stretch size.
  118569. */
  118570. get vignetteStretch(): number;
  118571. /**
  118572. * Sets Vignette stretch size.
  118573. */
  118574. set vignetteStretch(value: number);
  118575. /**
  118576. * Gets Vignette centre X Offset.
  118577. */
  118578. get vignetteCentreX(): number;
  118579. /**
  118580. * Sets Vignette centre X Offset.
  118581. */
  118582. set vignetteCentreX(value: number);
  118583. /**
  118584. * Gets Vignette centre Y Offset.
  118585. */
  118586. get vignetteCentreY(): number;
  118587. /**
  118588. * Sets Vignette centre Y Offset.
  118589. */
  118590. set vignetteCentreY(value: number);
  118591. /**
  118592. * Gets Vignette weight or intensity of the vignette effect.
  118593. */
  118594. get vignetteWeight(): number;
  118595. /**
  118596. * Sets Vignette weight or intensity of the vignette effect.
  118597. */
  118598. set vignetteWeight(value: number);
  118599. /**
  118600. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118601. * if vignetteEnabled is set to true.
  118602. */
  118603. get vignetteColor(): Color4;
  118604. /**
  118605. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118606. * if vignetteEnabled is set to true.
  118607. */
  118608. set vignetteColor(value: Color4);
  118609. /**
  118610. * Gets Camera field of view used by the Vignette effect.
  118611. */
  118612. get vignetteCameraFov(): number;
  118613. /**
  118614. * Sets Camera field of view used by the Vignette effect.
  118615. */
  118616. set vignetteCameraFov(value: number);
  118617. /**
  118618. * Gets the vignette blend mode allowing different kind of effect.
  118619. */
  118620. get vignetteBlendMode(): number;
  118621. /**
  118622. * Sets the vignette blend mode allowing different kind of effect.
  118623. */
  118624. set vignetteBlendMode(value: number);
  118625. /**
  118626. * Gets wether the vignette effect is enabled.
  118627. */
  118628. get vignetteEnabled(): boolean;
  118629. /**
  118630. * Sets wether the vignette effect is enabled.
  118631. */
  118632. set vignetteEnabled(value: boolean);
  118633. private _fromLinearSpace;
  118634. /**
  118635. * Gets wether the input of the processing is in Gamma or Linear Space.
  118636. */
  118637. get fromLinearSpace(): boolean;
  118638. /**
  118639. * Sets wether the input of the processing is in Gamma or Linear Space.
  118640. */
  118641. set fromLinearSpace(value: boolean);
  118642. /**
  118643. * Defines cache preventing GC.
  118644. */
  118645. private _defines;
  118646. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  118647. /**
  118648. * "ImageProcessingPostProcess"
  118649. * @returns "ImageProcessingPostProcess"
  118650. */
  118651. getClassName(): string;
  118652. protected _updateParameters(): void;
  118653. dispose(camera?: Camera): void;
  118654. }
  118655. }
  118656. declare module BABYLON {
  118657. /**
  118658. * Class containing static functions to help procedurally build meshes
  118659. */
  118660. export class GroundBuilder {
  118661. /**
  118662. * Creates a ground mesh
  118663. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118664. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118666. * @param name defines the name of the mesh
  118667. * @param options defines the options used to create the mesh
  118668. * @param scene defines the hosting scene
  118669. * @returns the ground mesh
  118670. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118671. */
  118672. static CreateGround(name: string, options: {
  118673. width?: number;
  118674. height?: number;
  118675. subdivisions?: number;
  118676. subdivisionsX?: number;
  118677. subdivisionsY?: number;
  118678. updatable?: boolean;
  118679. }, scene: any): Mesh;
  118680. /**
  118681. * Creates a tiled ground mesh
  118682. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118683. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118684. * * 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
  118685. * * 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
  118686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118687. * @param name defines the name of the mesh
  118688. * @param options defines the options used to create the mesh
  118689. * @param scene defines the hosting scene
  118690. * @returns the tiled ground mesh
  118691. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118692. */
  118693. static CreateTiledGround(name: string, options: {
  118694. xmin: number;
  118695. zmin: number;
  118696. xmax: number;
  118697. zmax: number;
  118698. subdivisions?: {
  118699. w: number;
  118700. h: number;
  118701. };
  118702. precision?: {
  118703. w: number;
  118704. h: number;
  118705. };
  118706. updatable?: boolean;
  118707. }, scene?: Nullable<Scene>): Mesh;
  118708. /**
  118709. * Creates a ground mesh from a height map
  118710. * * The parameter `url` sets the URL of the height map image resource.
  118711. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118712. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118713. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118714. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118715. * * 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.
  118716. * * 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).
  118717. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118719. * @param name defines the name of the mesh
  118720. * @param url defines the url to the height map
  118721. * @param options defines the options used to create the mesh
  118722. * @param scene defines the hosting scene
  118723. * @returns the ground mesh
  118724. * @see https://doc.babylonjs.com/babylon101/height_map
  118725. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118726. */
  118727. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118728. width?: number;
  118729. height?: number;
  118730. subdivisions?: number;
  118731. minHeight?: number;
  118732. maxHeight?: number;
  118733. colorFilter?: Color3;
  118734. alphaFilter?: number;
  118735. updatable?: boolean;
  118736. onReady?: (mesh: GroundMesh) => void;
  118737. }, scene?: Nullable<Scene>): GroundMesh;
  118738. }
  118739. }
  118740. declare module BABYLON {
  118741. /**
  118742. * Class containing static functions to help procedurally build meshes
  118743. */
  118744. export class TorusBuilder {
  118745. /**
  118746. * Creates a torus mesh
  118747. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  118748. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118749. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118753. * @param name defines the name of the mesh
  118754. * @param options defines the options used to create the mesh
  118755. * @param scene defines the hosting scene
  118756. * @returns the torus mesh
  118757. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118758. */
  118759. static CreateTorus(name: string, options: {
  118760. diameter?: number;
  118761. thickness?: number;
  118762. tessellation?: number;
  118763. updatable?: boolean;
  118764. sideOrientation?: number;
  118765. frontUVs?: Vector4;
  118766. backUVs?: Vector4;
  118767. }, scene: any): Mesh;
  118768. }
  118769. }
  118770. declare module BABYLON {
  118771. /**
  118772. * Class containing static functions to help procedurally build meshes
  118773. */
  118774. export class CylinderBuilder {
  118775. /**
  118776. * Creates a cylinder or a cone mesh
  118777. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  118778. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  118779. * * 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.
  118780. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  118781. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  118782. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  118783. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  118784. * * 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).
  118785. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  118786. * * 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).
  118787. * * 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
  118788. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  118789. * * 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
  118790. * * 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.
  118791. * * If `enclose` is false, a ring surface is one element.
  118792. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  118793. * * 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
  118794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118797. * @param name defines the name of the mesh
  118798. * @param options defines the options used to create the mesh
  118799. * @param scene defines the hosting scene
  118800. * @returns the cylinder mesh
  118801. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  118802. */
  118803. static CreateCylinder(name: string, options: {
  118804. height?: number;
  118805. diameterTop?: number;
  118806. diameterBottom?: number;
  118807. diameter?: number;
  118808. tessellation?: number;
  118809. subdivisions?: number;
  118810. arc?: number;
  118811. faceColors?: Color4[];
  118812. faceUV?: Vector4[];
  118813. updatable?: boolean;
  118814. hasRings?: boolean;
  118815. enclose?: boolean;
  118816. cap?: number;
  118817. sideOrientation?: number;
  118818. frontUVs?: Vector4;
  118819. backUVs?: Vector4;
  118820. }, scene: any): Mesh;
  118821. }
  118822. }
  118823. declare module BABYLON {
  118824. /**
  118825. * States of the webXR experience
  118826. */
  118827. export enum WebXRState {
  118828. /**
  118829. * Transitioning to being in XR mode
  118830. */
  118831. ENTERING_XR = 0,
  118832. /**
  118833. * Transitioning to non XR mode
  118834. */
  118835. EXITING_XR = 1,
  118836. /**
  118837. * In XR mode and presenting
  118838. */
  118839. IN_XR = 2,
  118840. /**
  118841. * Not entered XR mode
  118842. */
  118843. NOT_IN_XR = 3
  118844. }
  118845. /**
  118846. * Abstraction of the XR render target
  118847. */
  118848. export interface WebXRRenderTarget extends IDisposable {
  118849. /**
  118850. * xrpresent context of the canvas which can be used to display/mirror xr content
  118851. */
  118852. canvasContext: WebGLRenderingContext;
  118853. /**
  118854. * xr layer for the canvas
  118855. */
  118856. xrLayer: Nullable<XRWebGLLayer>;
  118857. /**
  118858. * Initializes the xr layer for the session
  118859. * @param xrSession xr session
  118860. * @returns a promise that will resolve once the XR Layer has been created
  118861. */
  118862. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  118863. }
  118864. }
  118865. declare module BABYLON {
  118866. /**
  118867. * COnfiguration object for WebXR output canvas
  118868. */
  118869. export class WebXRManagedOutputCanvasOptions {
  118870. /**
  118871. * An optional canvas in case you wish to create it yourself and provide it here.
  118872. * If not provided, a new canvas will be created
  118873. */
  118874. canvasElement?: HTMLCanvasElement;
  118875. /**
  118876. * Options for this XR Layer output
  118877. */
  118878. canvasOptions?: XRWebGLLayerOptions;
  118879. /**
  118880. * CSS styling for a newly created canvas (if not provided)
  118881. */
  118882. newCanvasCssStyle?: string;
  118883. /**
  118884. * Get the default values of the configuration object
  118885. * @returns default values of this configuration object
  118886. */
  118887. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  118888. }
  118889. /**
  118890. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  118891. */
  118892. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  118893. private _options;
  118894. private _canvas;
  118895. private _engine;
  118896. /**
  118897. * Rendering context of the canvas which can be used to display/mirror xr content
  118898. */
  118899. canvasContext: WebGLRenderingContext;
  118900. /**
  118901. * xr layer for the canvas
  118902. */
  118903. xrLayer: Nullable<XRWebGLLayer>;
  118904. /**
  118905. * Initializes the canvas to be added/removed upon entering/exiting xr
  118906. * @param _xrSessionManager The XR Session manager
  118907. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  118908. */
  118909. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  118910. /**
  118911. * Disposes of the object
  118912. */
  118913. dispose(): void;
  118914. /**
  118915. * Initializes the xr layer for the session
  118916. * @param xrSession xr session
  118917. * @returns a promise that will resolve once the XR Layer has been created
  118918. */
  118919. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  118920. private _addCanvas;
  118921. private _removeCanvas;
  118922. private _setManagedOutputCanvas;
  118923. }
  118924. }
  118925. declare module BABYLON {
  118926. /**
  118927. * Manages an XRSession to work with Babylon's engine
  118928. * @see https://doc.babylonjs.com/how_to/webxr
  118929. */
  118930. export class WebXRSessionManager implements IDisposable {
  118931. /** The scene which the session should be created for */
  118932. scene: Scene;
  118933. private _referenceSpace;
  118934. private _rttProvider;
  118935. private _sessionEnded;
  118936. private _xrNavigator;
  118937. private baseLayer;
  118938. /**
  118939. * The base reference space from which the session started. good if you want to reset your
  118940. * reference space
  118941. */
  118942. baseReferenceSpace: XRReferenceSpace;
  118943. /**
  118944. * Current XR frame
  118945. */
  118946. currentFrame: Nullable<XRFrame>;
  118947. /** WebXR timestamp updated every frame */
  118948. currentTimestamp: number;
  118949. /**
  118950. * Used just in case of a failure to initialize an immersive session.
  118951. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  118952. */
  118953. defaultHeightCompensation: number;
  118954. /**
  118955. * Fires every time a new xrFrame arrives which can be used to update the camera
  118956. */
  118957. onXRFrameObservable: Observable<XRFrame>;
  118958. /**
  118959. * Fires when the reference space changed
  118960. */
  118961. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  118962. /**
  118963. * Fires when the xr session is ended either by the device or manually done
  118964. */
  118965. onXRSessionEnded: Observable<any>;
  118966. /**
  118967. * Fires when the xr session is ended either by the device or manually done
  118968. */
  118969. onXRSessionInit: Observable<XRSession>;
  118970. /**
  118971. * Underlying xr session
  118972. */
  118973. session: XRSession;
  118974. /**
  118975. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  118976. * or get the offset the player is currently at.
  118977. */
  118978. viewerReferenceSpace: XRReferenceSpace;
  118979. /**
  118980. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  118981. * @param scene The scene which the session should be created for
  118982. */
  118983. constructor(
  118984. /** The scene which the session should be created for */
  118985. scene: Scene);
  118986. /**
  118987. * The current reference space used in this session. This reference space can constantly change!
  118988. * It is mainly used to offset the camera's position.
  118989. */
  118990. get referenceSpace(): XRReferenceSpace;
  118991. /**
  118992. * Set a new reference space and triggers the observable
  118993. */
  118994. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  118995. /**
  118996. * Disposes of the session manager
  118997. */
  118998. dispose(): void;
  118999. /**
  119000. * Stops the xrSession and restores the render loop
  119001. * @returns Promise which resolves after it exits XR
  119002. */
  119003. exitXRAsync(): Promise<void>;
  119004. /**
  119005. * Gets the correct render target texture to be rendered this frame for this eye
  119006. * @param eye the eye for which to get the render target
  119007. * @returns the render target for the specified eye
  119008. */
  119009. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  119010. /**
  119011. * Creates a WebXRRenderTarget object for the XR session
  119012. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  119013. * @param options optional options to provide when creating a new render target
  119014. * @returns a WebXR render target to which the session can render
  119015. */
  119016. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  119017. /**
  119018. * Initializes the manager
  119019. * After initialization enterXR can be called to start an XR session
  119020. * @returns Promise which resolves after it is initialized
  119021. */
  119022. initializeAsync(): Promise<void>;
  119023. /**
  119024. * Initializes an xr session
  119025. * @param xrSessionMode mode to initialize
  119026. * @param xrSessionInit defines optional and required values to pass to the session builder
  119027. * @returns a promise which will resolve once the session has been initialized
  119028. */
  119029. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  119030. /**
  119031. * Checks if a session would be supported for the creation options specified
  119032. * @param sessionMode session mode to check if supported eg. immersive-vr
  119033. * @returns A Promise that resolves to true if supported and false if not
  119034. */
  119035. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119036. /**
  119037. * Resets the reference space to the one started the session
  119038. */
  119039. resetReferenceSpace(): void;
  119040. /**
  119041. * Starts rendering to the xr layer
  119042. */
  119043. runXRRenderLoop(): void;
  119044. /**
  119045. * Sets the reference space on the xr session
  119046. * @param referenceSpaceType space to set
  119047. * @returns a promise that will resolve once the reference space has been set
  119048. */
  119049. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  119050. /**
  119051. * Updates the render state of the session
  119052. * @param state state to set
  119053. * @returns a promise that resolves once the render state has been updated
  119054. */
  119055. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  119056. /**
  119057. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  119058. * @param sessionMode defines the session to test
  119059. * @returns a promise with boolean as final value
  119060. */
  119061. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  119062. private _createRenderTargetTexture;
  119063. }
  119064. }
  119065. declare module BABYLON {
  119066. /**
  119067. * WebXR Camera which holds the views for the xrSession
  119068. * @see https://doc.babylonjs.com/how_to/webxr_camera
  119069. */
  119070. export class WebXRCamera extends FreeCamera {
  119071. private _xrSessionManager;
  119072. private _firstFrame;
  119073. private _referenceQuaternion;
  119074. private _referencedPosition;
  119075. private _xrInvPositionCache;
  119076. private _xrInvQuaternionCache;
  119077. /**
  119078. * Should position compensation execute on first frame.
  119079. * This is used when copying the position from a native (non XR) camera
  119080. */
  119081. compensateOnFirstFrame: boolean;
  119082. /**
  119083. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  119084. * @param name the name of the camera
  119085. * @param scene the scene to add the camera to
  119086. * @param _xrSessionManager a constructed xr session manager
  119087. */
  119088. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  119089. /**
  119090. * Return the user's height, unrelated to the current ground.
  119091. * This will be the y position of this camera, when ground level is 0.
  119092. */
  119093. get realWorldHeight(): number;
  119094. /** @hidden */
  119095. _updateForDualEyeDebugging(): void;
  119096. /**
  119097. * Sets this camera's transformation based on a non-vr camera
  119098. * @param otherCamera the non-vr camera to copy the transformation from
  119099. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  119100. */
  119101. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  119102. /**
  119103. * Gets the current instance class name ("WebXRCamera").
  119104. * @returns the class name
  119105. */
  119106. getClassName(): string;
  119107. private _updateFromXRSession;
  119108. private _updateNumberOfRigCameras;
  119109. private _updateReferenceSpace;
  119110. private _updateReferenceSpaceOffset;
  119111. }
  119112. }
  119113. declare module BABYLON {
  119114. /**
  119115. * Defining the interface required for a (webxr) feature
  119116. */
  119117. export interface IWebXRFeature extends IDisposable {
  119118. /**
  119119. * Is this feature attached
  119120. */
  119121. attached: boolean;
  119122. /**
  119123. * Should auto-attach be disabled?
  119124. */
  119125. disableAutoAttach: boolean;
  119126. /**
  119127. * Attach the feature to the session
  119128. * Will usually be called by the features manager
  119129. *
  119130. * @param force should attachment be forced (even when already attached)
  119131. * @returns true if successful.
  119132. */
  119133. attach(force?: boolean): boolean;
  119134. /**
  119135. * Detach the feature from the session
  119136. * Will usually be called by the features manager
  119137. *
  119138. * @returns true if successful.
  119139. */
  119140. detach(): boolean;
  119141. }
  119142. /**
  119143. * A list of the currently available features without referencing them
  119144. */
  119145. export class WebXRFeatureName {
  119146. /**
  119147. * The name of the anchor system feature
  119148. */
  119149. static ANCHOR_SYSTEM: string;
  119150. /**
  119151. * The name of the background remover feature
  119152. */
  119153. static BACKGROUND_REMOVER: string;
  119154. /**
  119155. * The name of the hit test feature
  119156. */
  119157. static HIT_TEST: string;
  119158. /**
  119159. * physics impostors for xr controllers feature
  119160. */
  119161. static PHYSICS_CONTROLLERS: string;
  119162. /**
  119163. * The name of the plane detection feature
  119164. */
  119165. static PLANE_DETECTION: string;
  119166. /**
  119167. * The name of the pointer selection feature
  119168. */
  119169. static POINTER_SELECTION: string;
  119170. /**
  119171. * The name of the teleportation feature
  119172. */
  119173. static TELEPORTATION: string;
  119174. }
  119175. /**
  119176. * Defining the constructor of a feature. Used to register the modules.
  119177. */
  119178. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  119179. /**
  119180. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  119181. * It is mainly used in AR sessions.
  119182. *
  119183. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  119184. */
  119185. export class WebXRFeaturesManager implements IDisposable {
  119186. private _xrSessionManager;
  119187. private static readonly _AvailableFeatures;
  119188. private _features;
  119189. /**
  119190. * constructs a new features manages.
  119191. *
  119192. * @param _xrSessionManager an instance of WebXRSessionManager
  119193. */
  119194. constructor(_xrSessionManager: WebXRSessionManager);
  119195. /**
  119196. * Used to register a module. After calling this function a developer can use this feature in the scene.
  119197. * Mainly used internally.
  119198. *
  119199. * @param featureName the name of the feature to register
  119200. * @param constructorFunction the function used to construct the module
  119201. * @param version the (babylon) version of the module
  119202. * @param stable is that a stable version of this module
  119203. */
  119204. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  119205. /**
  119206. * Returns a constructor of a specific feature.
  119207. *
  119208. * @param featureName the name of the feature to construct
  119209. * @param version the version of the feature to load
  119210. * @param xrSessionManager the xrSessionManager. Used to construct the module
  119211. * @param options optional options provided to the module.
  119212. * @returns a function that, when called, will return a new instance of this feature
  119213. */
  119214. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  119215. /**
  119216. * Can be used to return the list of features currently registered
  119217. *
  119218. * @returns an Array of available features
  119219. */
  119220. static GetAvailableFeatures(): string[];
  119221. /**
  119222. * Gets the versions available for a specific feature
  119223. * @param featureName the name of the feature
  119224. * @returns an array with the available versions
  119225. */
  119226. static GetAvailableVersions(featureName: string): string[];
  119227. /**
  119228. * Return the latest unstable version of this feature
  119229. * @param featureName the name of the feature to search
  119230. * @returns the version number. if not found will return -1
  119231. */
  119232. static GetLatestVersionOfFeature(featureName: string): number;
  119233. /**
  119234. * Return the latest stable version of this feature
  119235. * @param featureName the name of the feature to search
  119236. * @returns the version number. if not found will return -1
  119237. */
  119238. static GetStableVersionOfFeature(featureName: string): number;
  119239. /**
  119240. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  119241. * Can be used during a session to start a feature
  119242. * @param featureName the name of feature to attach
  119243. */
  119244. attachFeature(featureName: string): void;
  119245. /**
  119246. * Can be used inside a session or when the session ends to detach a specific feature
  119247. * @param featureName the name of the feature to detach
  119248. */
  119249. detachFeature(featureName: string): void;
  119250. /**
  119251. * Used to disable an already-enabled feature
  119252. * The feature will be disposed and will be recreated once enabled.
  119253. * @param featureName the feature to disable
  119254. * @returns true if disable was successful
  119255. */
  119256. disableFeature(featureName: string | {
  119257. Name: string;
  119258. }): boolean;
  119259. /**
  119260. * dispose this features manager
  119261. */
  119262. dispose(): void;
  119263. /**
  119264. * 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.
  119265. * 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.
  119266. *
  119267. * @param featureName the name of the feature to load or the class of the feature
  119268. * @param version optional version to load. if not provided the latest version will be enabled
  119269. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  119270. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  119271. * @returns a new constructed feature or throws an error if feature not found.
  119272. */
  119273. enableFeature(featureName: string | {
  119274. Name: string;
  119275. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  119276. /**
  119277. * get the implementation of an enabled feature.
  119278. * @param featureName the name of the feature to load
  119279. * @returns the feature class, if found
  119280. */
  119281. getEnabledFeature(featureName: string): IWebXRFeature;
  119282. /**
  119283. * Get the list of enabled features
  119284. * @returns an array of enabled features
  119285. */
  119286. getEnabledFeatures(): string[];
  119287. }
  119288. }
  119289. declare module BABYLON {
  119290. /**
  119291. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  119292. * @see https://doc.babylonjs.com/how_to/webxr
  119293. */
  119294. export class WebXRExperienceHelper implements IDisposable {
  119295. private scene;
  119296. private _nonVRCamera;
  119297. private _originalSceneAutoClear;
  119298. private _supported;
  119299. /**
  119300. * Camera used to render xr content
  119301. */
  119302. camera: WebXRCamera;
  119303. /** A features manager for this xr session */
  119304. featuresManager: WebXRFeaturesManager;
  119305. /**
  119306. * Observers registered here will be triggered after the camera's initial transformation is set
  119307. * This can be used to set a different ground level or an extra rotation.
  119308. *
  119309. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  119310. * to the position set after this observable is done executing.
  119311. */
  119312. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  119313. /**
  119314. * Fires when the state of the experience helper has changed
  119315. */
  119316. onStateChangedObservable: Observable<WebXRState>;
  119317. /** Session manager used to keep track of xr session */
  119318. sessionManager: WebXRSessionManager;
  119319. /**
  119320. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  119321. */
  119322. state: WebXRState;
  119323. /**
  119324. * Creates a WebXRExperienceHelper
  119325. * @param scene The scene the helper should be created in
  119326. */
  119327. private constructor();
  119328. /**
  119329. * Creates the experience helper
  119330. * @param scene the scene to attach the experience helper to
  119331. * @returns a promise for the experience helper
  119332. */
  119333. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  119334. /**
  119335. * Disposes of the experience helper
  119336. */
  119337. dispose(): void;
  119338. /**
  119339. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  119340. * @param sessionMode options for the XR session
  119341. * @param referenceSpaceType frame of reference of the XR session
  119342. * @param renderTarget the output canvas that will be used to enter XR mode
  119343. * @returns promise that resolves after xr mode has entered
  119344. */
  119345. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  119346. /**
  119347. * Exits XR mode and returns the scene to its original state
  119348. * @returns promise that resolves after xr mode has exited
  119349. */
  119350. exitXRAsync(): Promise<void>;
  119351. private _nonXRToXRCamera;
  119352. private _setState;
  119353. }
  119354. }
  119355. declare module BABYLON {
  119356. /**
  119357. * X-Y values for axes in WebXR
  119358. */
  119359. export interface IWebXRMotionControllerAxesValue {
  119360. /**
  119361. * The value of the x axis
  119362. */
  119363. x: number;
  119364. /**
  119365. * The value of the y-axis
  119366. */
  119367. y: number;
  119368. }
  119369. /**
  119370. * changed / previous values for the values of this component
  119371. */
  119372. export interface IWebXRMotionControllerComponentChangesValues<T> {
  119373. /**
  119374. * current (this frame) value
  119375. */
  119376. current: T;
  119377. /**
  119378. * previous (last change) value
  119379. */
  119380. previous: T;
  119381. }
  119382. /**
  119383. * Represents changes in the component between current frame and last values recorded
  119384. */
  119385. export interface IWebXRMotionControllerComponentChanges {
  119386. /**
  119387. * will be populated with previous and current values if axes changed
  119388. */
  119389. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  119390. /**
  119391. * will be populated with previous and current values if pressed changed
  119392. */
  119393. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119394. /**
  119395. * will be populated with previous and current values if touched changed
  119396. */
  119397. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  119398. /**
  119399. * will be populated with previous and current values if value changed
  119400. */
  119401. value?: IWebXRMotionControllerComponentChangesValues<number>;
  119402. }
  119403. /**
  119404. * This class represents a single component (for example button or thumbstick) of a motion controller
  119405. */
  119406. export class WebXRControllerComponent implements IDisposable {
  119407. /**
  119408. * the id of this component
  119409. */
  119410. id: string;
  119411. /**
  119412. * the type of the component
  119413. */
  119414. type: MotionControllerComponentType;
  119415. private _buttonIndex;
  119416. private _axesIndices;
  119417. private _axes;
  119418. private _changes;
  119419. private _currentValue;
  119420. private _hasChanges;
  119421. private _pressed;
  119422. private _touched;
  119423. /**
  119424. * button component type
  119425. */
  119426. static BUTTON_TYPE: MotionControllerComponentType;
  119427. /**
  119428. * squeeze component type
  119429. */
  119430. static SQUEEZE_TYPE: MotionControllerComponentType;
  119431. /**
  119432. * Thumbstick component type
  119433. */
  119434. static THUMBSTICK_TYPE: MotionControllerComponentType;
  119435. /**
  119436. * Touchpad component type
  119437. */
  119438. static TOUCHPAD_TYPE: MotionControllerComponentType;
  119439. /**
  119440. * trigger component type
  119441. */
  119442. static TRIGGER_TYPE: MotionControllerComponentType;
  119443. /**
  119444. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  119445. * the axes data changes
  119446. */
  119447. onAxisValueChangedObservable: Observable<{
  119448. x: number;
  119449. y: number;
  119450. }>;
  119451. /**
  119452. * Observers registered here will be triggered when the state of a button changes
  119453. * State change is either pressed / touched / value
  119454. */
  119455. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  119456. /**
  119457. * Creates a new component for a motion controller.
  119458. * It is created by the motion controller itself
  119459. *
  119460. * @param id the id of this component
  119461. * @param type the type of the component
  119462. * @param _buttonIndex index in the buttons array of the gamepad
  119463. * @param _axesIndices indices of the values in the axes array of the gamepad
  119464. */
  119465. constructor(
  119466. /**
  119467. * the id of this component
  119468. */
  119469. id: string,
  119470. /**
  119471. * the type of the component
  119472. */
  119473. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  119474. /**
  119475. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  119476. */
  119477. get axes(): IWebXRMotionControllerAxesValue;
  119478. /**
  119479. * Get the changes. Elements will be populated only if they changed with their previous and current value
  119480. */
  119481. get changes(): IWebXRMotionControllerComponentChanges;
  119482. /**
  119483. * Return whether or not the component changed the last frame
  119484. */
  119485. get hasChanges(): boolean;
  119486. /**
  119487. * is the button currently pressed
  119488. */
  119489. get pressed(): boolean;
  119490. /**
  119491. * is the button currently touched
  119492. */
  119493. get touched(): boolean;
  119494. /**
  119495. * Get the current value of this component
  119496. */
  119497. get value(): number;
  119498. /**
  119499. * Dispose this component
  119500. */
  119501. dispose(): void;
  119502. /**
  119503. * Are there axes correlating to this component
  119504. * @return true is axes data is available
  119505. */
  119506. isAxes(): boolean;
  119507. /**
  119508. * Is this component a button (hence - pressable)
  119509. * @returns true if can be pressed
  119510. */
  119511. isButton(): boolean;
  119512. /**
  119513. * update this component using the gamepad object it is in. Called on every frame
  119514. * @param nativeController the native gamepad controller object
  119515. */
  119516. update(nativeController: IMinimalMotionControllerObject): void;
  119517. }
  119518. }
  119519. declare module BABYLON {
  119520. /**
  119521. * Class used to represent data loading progression
  119522. */
  119523. export class SceneLoaderProgressEvent {
  119524. /** defines if data length to load can be evaluated */
  119525. readonly lengthComputable: boolean;
  119526. /** defines the loaded data length */
  119527. readonly loaded: number;
  119528. /** defines the data length to load */
  119529. readonly total: number;
  119530. /**
  119531. * Create a new progress event
  119532. * @param lengthComputable defines if data length to load can be evaluated
  119533. * @param loaded defines the loaded data length
  119534. * @param total defines the data length to load
  119535. */
  119536. constructor(
  119537. /** defines if data length to load can be evaluated */
  119538. lengthComputable: boolean,
  119539. /** defines the loaded data length */
  119540. loaded: number,
  119541. /** defines the data length to load */
  119542. total: number);
  119543. /**
  119544. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  119545. * @param event defines the source event
  119546. * @returns a new SceneLoaderProgressEvent
  119547. */
  119548. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  119549. }
  119550. /**
  119551. * Interface used by SceneLoader plugins to define supported file extensions
  119552. */
  119553. export interface ISceneLoaderPluginExtensions {
  119554. /**
  119555. * Defines the list of supported extensions
  119556. */
  119557. [extension: string]: {
  119558. isBinary: boolean;
  119559. };
  119560. }
  119561. /**
  119562. * Interface used by SceneLoader plugin factory
  119563. */
  119564. export interface ISceneLoaderPluginFactory {
  119565. /**
  119566. * Defines the name of the factory
  119567. */
  119568. name: string;
  119569. /**
  119570. * Function called to create a new plugin
  119571. * @return the new plugin
  119572. */
  119573. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  119574. /**
  119575. * The callback that returns true if the data can be directly loaded.
  119576. * @param data string containing the file data
  119577. * @returns if the data can be loaded directly
  119578. */
  119579. canDirectLoad?(data: string): boolean;
  119580. }
  119581. /**
  119582. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  119583. */
  119584. export interface ISceneLoaderPluginBase {
  119585. /**
  119586. * The friendly name of this plugin.
  119587. */
  119588. name: string;
  119589. /**
  119590. * The file extensions supported by this plugin.
  119591. */
  119592. extensions: string | ISceneLoaderPluginExtensions;
  119593. /**
  119594. * The callback called when loading from a url.
  119595. * @param scene scene loading this url
  119596. * @param url url to load
  119597. * @param onSuccess callback called when the file successfully loads
  119598. * @param onProgress callback called while file is loading (if the server supports this mode)
  119599. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119600. * @param onError callback called when the file fails to load
  119601. * @returns a file request object
  119602. */
  119603. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119604. /**
  119605. * The callback called when loading from a file object.
  119606. * @param scene scene loading this file
  119607. * @param file defines the file to load
  119608. * @param onSuccess defines the callback to call when data is loaded
  119609. * @param onProgress defines the callback to call during loading process
  119610. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119611. * @param onError defines the callback to call when an error occurs
  119612. * @returns a file request object
  119613. */
  119614. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  119615. /**
  119616. * The callback that returns true if the data can be directly loaded.
  119617. * @param data string containing the file data
  119618. * @returns if the data can be loaded directly
  119619. */
  119620. canDirectLoad?(data: string): boolean;
  119621. /**
  119622. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  119623. * @param scene scene loading this data
  119624. * @param data string containing the data
  119625. * @returns data to pass to the plugin
  119626. */
  119627. directLoad?(scene: Scene, data: string): any;
  119628. /**
  119629. * The callback that allows custom handling of the root url based on the response url.
  119630. * @param rootUrl the original root url
  119631. * @param responseURL the response url if available
  119632. * @returns the new root url
  119633. */
  119634. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  119635. }
  119636. /**
  119637. * Interface used to define a SceneLoader plugin
  119638. */
  119639. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  119640. /**
  119641. * Import meshes into a scene.
  119642. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119643. * @param scene The scene to import into
  119644. * @param data The data to import
  119645. * @param rootUrl The root url for scene and resources
  119646. * @param meshes The meshes array to import into
  119647. * @param particleSystems The particle systems array to import into
  119648. * @param skeletons The skeletons array to import into
  119649. * @param onError The callback when import fails
  119650. * @returns True if successful or false otherwise
  119651. */
  119652. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  119653. /**
  119654. * Load into a scene.
  119655. * @param scene The scene to load into
  119656. * @param data The data to import
  119657. * @param rootUrl The root url for scene and resources
  119658. * @param onError The callback when import fails
  119659. * @returns True if successful or false otherwise
  119660. */
  119661. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  119662. /**
  119663. * Load into an asset container.
  119664. * @param scene The scene to load into
  119665. * @param data The data to import
  119666. * @param rootUrl The root url for scene and resources
  119667. * @param onError The callback when import fails
  119668. * @returns The loaded asset container
  119669. */
  119670. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  119671. }
  119672. /**
  119673. * Interface used to define an async SceneLoader plugin
  119674. */
  119675. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  119676. /**
  119677. * Import meshes into a scene.
  119678. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119679. * @param scene The scene to import into
  119680. * @param data The data to import
  119681. * @param rootUrl The root url for scene and resources
  119682. * @param onProgress The callback when the load progresses
  119683. * @param fileName Defines the name of the file to load
  119684. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  119685. */
  119686. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  119687. meshes: AbstractMesh[];
  119688. particleSystems: IParticleSystem[];
  119689. skeletons: Skeleton[];
  119690. animationGroups: AnimationGroup[];
  119691. }>;
  119692. /**
  119693. * Load into a scene.
  119694. * @param scene The scene to load into
  119695. * @param data The data to import
  119696. * @param rootUrl The root url for scene and resources
  119697. * @param onProgress The callback when the load progresses
  119698. * @param fileName Defines the name of the file to load
  119699. * @returns Nothing
  119700. */
  119701. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  119702. /**
  119703. * Load into an asset container.
  119704. * @param scene The scene to load into
  119705. * @param data The data to import
  119706. * @param rootUrl The root url for scene and resources
  119707. * @param onProgress The callback when the load progresses
  119708. * @param fileName Defines the name of the file to load
  119709. * @returns The loaded asset container
  119710. */
  119711. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  119712. }
  119713. /**
  119714. * Mode that determines how to handle old animation groups before loading new ones.
  119715. */
  119716. export enum SceneLoaderAnimationGroupLoadingMode {
  119717. /**
  119718. * Reset all old animations to initial state then dispose them.
  119719. */
  119720. Clean = 0,
  119721. /**
  119722. * Stop all old animations.
  119723. */
  119724. Stop = 1,
  119725. /**
  119726. * Restart old animations from first frame.
  119727. */
  119728. Sync = 2,
  119729. /**
  119730. * Old animations remains untouched.
  119731. */
  119732. NoSync = 3
  119733. }
  119734. /**
  119735. * Class used to load scene from various file formats using registered plugins
  119736. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  119737. */
  119738. export class SceneLoader {
  119739. /**
  119740. * No logging while loading
  119741. */
  119742. static readonly NO_LOGGING: number;
  119743. /**
  119744. * Minimal logging while loading
  119745. */
  119746. static readonly MINIMAL_LOGGING: number;
  119747. /**
  119748. * Summary logging while loading
  119749. */
  119750. static readonly SUMMARY_LOGGING: number;
  119751. /**
  119752. * Detailled logging while loading
  119753. */
  119754. static readonly DETAILED_LOGGING: number;
  119755. /**
  119756. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  119757. */
  119758. static get ForceFullSceneLoadingForIncremental(): boolean;
  119759. static set ForceFullSceneLoadingForIncremental(value: boolean);
  119760. /**
  119761. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  119762. */
  119763. static get ShowLoadingScreen(): boolean;
  119764. static set ShowLoadingScreen(value: boolean);
  119765. /**
  119766. * Defines the current logging level (while loading the scene)
  119767. * @ignorenaming
  119768. */
  119769. static get loggingLevel(): number;
  119770. static set loggingLevel(value: number);
  119771. /**
  119772. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  119773. */
  119774. static get CleanBoneMatrixWeights(): boolean;
  119775. static set CleanBoneMatrixWeights(value: boolean);
  119776. /**
  119777. * Event raised when a plugin is used to load a scene
  119778. */
  119779. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  119780. private static _registeredPlugins;
  119781. private static _getDefaultPlugin;
  119782. private static _getPluginForExtension;
  119783. private static _getPluginForDirectLoad;
  119784. private static _getPluginForFilename;
  119785. private static _getDirectLoad;
  119786. private static _loadData;
  119787. private static _getFileInfo;
  119788. /**
  119789. * Gets a plugin that can load the given extension
  119790. * @param extension defines the extension to load
  119791. * @returns a plugin or null if none works
  119792. */
  119793. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  119794. /**
  119795. * Gets a boolean indicating that the given extension can be loaded
  119796. * @param extension defines the extension to load
  119797. * @returns true if the extension is supported
  119798. */
  119799. static IsPluginForExtensionAvailable(extension: string): boolean;
  119800. /**
  119801. * Adds a new plugin to the list of registered plugins
  119802. * @param plugin defines the plugin to add
  119803. */
  119804. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  119805. /**
  119806. * Import meshes into a scene
  119807. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119808. * @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)
  119809. * @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)
  119810. * @param scene the instance of BABYLON.Scene to append to
  119811. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  119812. * @param onProgress a callback with a progress event for each file being loaded
  119813. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119814. * @param pluginExtension the extension used to determine the plugin
  119815. * @returns The loaded plugin
  119816. */
  119817. 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>;
  119818. /**
  119819. * Import meshes into a scene
  119820. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  119821. * @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)
  119822. * @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)
  119823. * @param scene the instance of BABYLON.Scene to append to
  119824. * @param onProgress a callback with a progress event for each file being loaded
  119825. * @param pluginExtension the extension used to determine the plugin
  119826. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  119827. */
  119828. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  119829. meshes: AbstractMesh[];
  119830. particleSystems: IParticleSystem[];
  119831. skeletons: Skeleton[];
  119832. animationGroups: AnimationGroup[];
  119833. }>;
  119834. /**
  119835. * Load a scene
  119836. * @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)
  119837. * @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)
  119838. * @param engine is the instance of BABYLON.Engine to use to create the scene
  119839. * @param onSuccess a callback with the scene when import succeeds
  119840. * @param onProgress a callback with a progress event for each file being loaded
  119841. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119842. * @param pluginExtension the extension used to determine the plugin
  119843. * @returns The loaded plugin
  119844. */
  119845. 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>;
  119846. /**
  119847. * Load a scene
  119848. * @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)
  119849. * @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)
  119850. * @param engine is the instance of BABYLON.Engine to use to create the scene
  119851. * @param onProgress a callback with a progress event for each file being loaded
  119852. * @param pluginExtension the extension used to determine the plugin
  119853. * @returns The loaded scene
  119854. */
  119855. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  119856. /**
  119857. * Append a scene
  119858. * @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)
  119859. * @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)
  119860. * @param scene is the instance of BABYLON.Scene to append to
  119861. * @param onSuccess a callback with the scene when import succeeds
  119862. * @param onProgress a callback with a progress event for each file being loaded
  119863. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119864. * @param pluginExtension the extension used to determine the plugin
  119865. * @returns The loaded plugin
  119866. */
  119867. 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>;
  119868. /**
  119869. * Append a scene
  119870. * @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)
  119871. * @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)
  119872. * @param scene is the instance of BABYLON.Scene to append to
  119873. * @param onProgress a callback with a progress event for each file being loaded
  119874. * @param pluginExtension the extension used to determine the plugin
  119875. * @returns The given scene
  119876. */
  119877. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  119878. /**
  119879. * Load a scene into an asset container
  119880. * @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)
  119881. * @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)
  119882. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119883. * @param onSuccess a callback with the scene when import succeeds
  119884. * @param onProgress a callback with a progress event for each file being loaded
  119885. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119886. * @param pluginExtension the extension used to determine the plugin
  119887. * @returns The loaded plugin
  119888. */
  119889. 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>;
  119890. /**
  119891. * Load a scene into an asset container
  119892. * @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)
  119893. * @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)
  119894. * @param scene is the instance of Scene to append to
  119895. * @param onProgress a callback with a progress event for each file being loaded
  119896. * @param pluginExtension the extension used to determine the plugin
  119897. * @returns The loaded asset container
  119898. */
  119899. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  119900. /**
  119901. * Import animations from a file into a scene
  119902. * @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)
  119903. * @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)
  119904. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119905. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  119906. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  119907. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  119908. * @param onSuccess a callback with the scene when import succeeds
  119909. * @param onProgress a callback with a progress event for each file being loaded
  119910. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119911. */
  119912. 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;
  119913. /**
  119914. * Import animations from a file into a scene
  119915. * @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)
  119916. * @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)
  119917. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119918. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  119919. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  119920. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  119921. * @param onSuccess a callback with the scene when import succeeds
  119922. * @param onProgress a callback with a progress event for each file being loaded
  119923. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  119924. * @returns the updated scene with imported animations
  119925. */
  119926. 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>;
  119927. }
  119928. }
  119929. declare module BABYLON {
  119930. /**
  119931. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  119932. */
  119933. export type MotionControllerHandedness = "none" | "left" | "right";
  119934. /**
  119935. * The type of components available in motion controllers.
  119936. * This is not the name of the component.
  119937. */
  119938. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  119939. /**
  119940. * The state of a controller component
  119941. */
  119942. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  119943. /**
  119944. * The schema of motion controller layout.
  119945. * No object will be initialized using this interface
  119946. * This is used just to define the profile.
  119947. */
  119948. export interface IMotionControllerLayout {
  119949. /**
  119950. * Path to load the assets. Usually relative to the base path
  119951. */
  119952. assetPath: string;
  119953. /**
  119954. * Available components (unsorted)
  119955. */
  119956. components: {
  119957. /**
  119958. * A map of component Ids
  119959. */
  119960. [componentId: string]: {
  119961. /**
  119962. * The type of input the component outputs
  119963. */
  119964. type: MotionControllerComponentType;
  119965. /**
  119966. * The indices of this component in the gamepad object
  119967. */
  119968. gamepadIndices: {
  119969. /**
  119970. * Index of button
  119971. */
  119972. button?: number;
  119973. /**
  119974. * If available, index of x-axis
  119975. */
  119976. xAxis?: number;
  119977. /**
  119978. * If available, index of y-axis
  119979. */
  119980. yAxis?: number;
  119981. };
  119982. /**
  119983. * The mesh's root node name
  119984. */
  119985. rootNodeName: string;
  119986. /**
  119987. * Animation definitions for this model
  119988. */
  119989. visualResponses: {
  119990. [stateKey: string]: {
  119991. /**
  119992. * What property will be animated
  119993. */
  119994. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  119995. /**
  119996. * What states influence this visual response
  119997. */
  119998. states: MotionControllerComponentStateType[];
  119999. /**
  120000. * Type of animation - movement or visibility
  120001. */
  120002. valueNodeProperty: "transform" | "visibility";
  120003. /**
  120004. * Base node name to move. Its position will be calculated according to the min and max nodes
  120005. */
  120006. valueNodeName?: string;
  120007. /**
  120008. * Minimum movement node
  120009. */
  120010. minNodeName?: string;
  120011. /**
  120012. * Max movement node
  120013. */
  120014. maxNodeName?: string;
  120015. };
  120016. };
  120017. /**
  120018. * If touch enabled, what is the name of node to display user feedback
  120019. */
  120020. touchPointNodeName?: string;
  120021. };
  120022. };
  120023. /**
  120024. * Is it xr standard mapping or not
  120025. */
  120026. gamepadMapping: "" | "xr-standard";
  120027. /**
  120028. * Base root node of this entire model
  120029. */
  120030. rootNodeName: string;
  120031. /**
  120032. * Defines the main button component id
  120033. */
  120034. selectComponentId: string;
  120035. }
  120036. /**
  120037. * A definition for the layout map in the input profile
  120038. */
  120039. export interface IMotionControllerLayoutMap {
  120040. /**
  120041. * Layouts with handedness type as a key
  120042. */
  120043. [handedness: string]: IMotionControllerLayout;
  120044. }
  120045. /**
  120046. * The XR Input profile schema
  120047. * Profiles can be found here:
  120048. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  120049. */
  120050. export interface IMotionControllerProfile {
  120051. /**
  120052. * fallback profiles for this profileId
  120053. */
  120054. fallbackProfileIds: string[];
  120055. /**
  120056. * The layout map, with handedness as key
  120057. */
  120058. layouts: IMotionControllerLayoutMap;
  120059. /**
  120060. * The id of this profile
  120061. * correlates to the profile(s) in the xrInput.profiles array
  120062. */
  120063. profileId: string;
  120064. }
  120065. /**
  120066. * A helper-interface for the 3 meshes needed for controller button animation
  120067. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  120068. */
  120069. export interface IMotionControllerButtonMeshMap {
  120070. /**
  120071. * the mesh that defines the pressed value mesh position.
  120072. * This is used to find the max-position of this button
  120073. */
  120074. pressedMesh: AbstractMesh;
  120075. /**
  120076. * the mesh that defines the unpressed value mesh position.
  120077. * This is used to find the min (or initial) position of this button
  120078. */
  120079. unpressedMesh: AbstractMesh;
  120080. /**
  120081. * The mesh that will be changed when value changes
  120082. */
  120083. valueMesh: AbstractMesh;
  120084. }
  120085. /**
  120086. * A helper-interface for the 3 meshes needed for controller axis animation.
  120087. * This will be expanded when touchpad animations are fully supported
  120088. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  120089. */
  120090. export interface IMotionControllerMeshMap {
  120091. /**
  120092. * the mesh that defines the maximum value mesh position.
  120093. */
  120094. maxMesh?: AbstractMesh;
  120095. /**
  120096. * the mesh that defines the minimum value mesh position.
  120097. */
  120098. minMesh?: AbstractMesh;
  120099. /**
  120100. * The mesh that will be changed when axis value changes
  120101. */
  120102. valueMesh: AbstractMesh;
  120103. }
  120104. /**
  120105. * The elements needed for change-detection of the gamepad objects in motion controllers
  120106. */
  120107. export interface IMinimalMotionControllerObject {
  120108. /**
  120109. * Available axes of this controller
  120110. */
  120111. axes: number[];
  120112. /**
  120113. * An array of available buttons
  120114. */
  120115. buttons: Array<{
  120116. /**
  120117. * Value of the button/trigger
  120118. */
  120119. value: number;
  120120. /**
  120121. * If the button/trigger is currently touched
  120122. */
  120123. touched: boolean;
  120124. /**
  120125. * If the button/trigger is currently pressed
  120126. */
  120127. pressed: boolean;
  120128. }>;
  120129. /**
  120130. * EXPERIMENTAL haptic support.
  120131. */
  120132. hapticActuators?: Array<{
  120133. pulse: (value: number, duration: number) => Promise<boolean>;
  120134. }>;
  120135. }
  120136. /**
  120137. * An Abstract Motion controller
  120138. * This class receives an xrInput and a profile layout and uses those to initialize the components
  120139. * Each component has an observable to check for changes in value and state
  120140. */
  120141. export abstract class WebXRAbstractMotionController implements IDisposable {
  120142. protected scene: Scene;
  120143. protected layout: IMotionControllerLayout;
  120144. /**
  120145. * The gamepad object correlating to this controller
  120146. */
  120147. gamepadObject: IMinimalMotionControllerObject;
  120148. /**
  120149. * handedness (left/right/none) of this controller
  120150. */
  120151. handedness: MotionControllerHandedness;
  120152. private _initComponent;
  120153. private _modelReady;
  120154. /**
  120155. * A map of components (WebXRControllerComponent) in this motion controller
  120156. * Components have a ComponentType and can also have both button and axis definitions
  120157. */
  120158. readonly components: {
  120159. [id: string]: WebXRControllerComponent;
  120160. };
  120161. /**
  120162. * Disable the model's animation. Can be set at any time.
  120163. */
  120164. disableAnimation: boolean;
  120165. /**
  120166. * Observers registered here will be triggered when the model of this controller is done loading
  120167. */
  120168. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  120169. /**
  120170. * The profile id of this motion controller
  120171. */
  120172. abstract profileId: string;
  120173. /**
  120174. * The root mesh of the model. It is null if the model was not yet initialized
  120175. */
  120176. rootMesh: Nullable<AbstractMesh>;
  120177. /**
  120178. * constructs a new abstract motion controller
  120179. * @param scene the scene to which the model of the controller will be added
  120180. * @param layout The profile layout to load
  120181. * @param gamepadObject The gamepad object correlating to this controller
  120182. * @param handedness handedness (left/right/none) of this controller
  120183. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  120184. */
  120185. constructor(scene: Scene, layout: IMotionControllerLayout,
  120186. /**
  120187. * The gamepad object correlating to this controller
  120188. */
  120189. gamepadObject: IMinimalMotionControllerObject,
  120190. /**
  120191. * handedness (left/right/none) of this controller
  120192. */
  120193. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  120194. /**
  120195. * Dispose this controller, the model mesh and all its components
  120196. */
  120197. dispose(): void;
  120198. /**
  120199. * Returns all components of specific type
  120200. * @param type the type to search for
  120201. * @return an array of components with this type
  120202. */
  120203. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  120204. /**
  120205. * get a component based an its component id as defined in layout.components
  120206. * @param id the id of the component
  120207. * @returns the component correlates to the id or undefined if not found
  120208. */
  120209. getComponent(id: string): WebXRControllerComponent;
  120210. /**
  120211. * Get the list of components available in this motion controller
  120212. * @returns an array of strings correlating to available components
  120213. */
  120214. getComponentIds(): string[];
  120215. /**
  120216. * Get the first component of specific type
  120217. * @param type type of component to find
  120218. * @return a controller component or null if not found
  120219. */
  120220. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  120221. /**
  120222. * Get the main (Select) component of this controller as defined in the layout
  120223. * @returns the main component of this controller
  120224. */
  120225. getMainComponent(): WebXRControllerComponent;
  120226. /**
  120227. * Loads the model correlating to this controller
  120228. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  120229. * @returns A promise fulfilled with the result of the model loading
  120230. */
  120231. loadModel(): Promise<boolean>;
  120232. /**
  120233. * Update this model using the current XRFrame
  120234. * @param xrFrame the current xr frame to use and update the model
  120235. */
  120236. updateFromXRFrame(xrFrame: XRFrame): void;
  120237. /**
  120238. * Backwards compatibility due to a deeply-integrated typo
  120239. */
  120240. get handness(): XREye;
  120241. /**
  120242. * Pulse (vibrate) this controller
  120243. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  120244. * Consecutive calls to this function will cancel the last pulse call
  120245. *
  120246. * @param value the strength of the pulse in 0.0...1.0 range
  120247. * @param duration Duration of the pulse in milliseconds
  120248. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  120249. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  120250. */
  120251. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  120252. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120253. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  120254. /**
  120255. * Moves the axis on the controller mesh based on its current state
  120256. * @param axis the index of the axis
  120257. * @param axisValue the value of the axis which determines the meshes new position
  120258. * @hidden
  120259. */
  120260. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  120261. /**
  120262. * Update the model itself with the current frame data
  120263. * @param xrFrame the frame to use for updating the model mesh
  120264. */
  120265. protected updateModel(xrFrame: XRFrame): void;
  120266. /**
  120267. * Get the filename and path for this controller's model
  120268. * @returns a map of filename and path
  120269. */
  120270. protected abstract _getFilenameAndPath(): {
  120271. filename: string;
  120272. path: string;
  120273. };
  120274. /**
  120275. * This function is called before the mesh is loaded. It checks for loading constraints.
  120276. * For example, this function can check if the GLB loader is available
  120277. * If this function returns false, the generic controller will be loaded instead
  120278. * @returns Is the client ready to load the mesh
  120279. */
  120280. protected abstract _getModelLoadingConstraints(): boolean;
  120281. /**
  120282. * This function will be called after the model was successfully loaded and can be used
  120283. * for mesh transformations before it is available for the user
  120284. * @param meshes the loaded meshes
  120285. */
  120286. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  120287. /**
  120288. * Set the root mesh for this controller. Important for the WebXR controller class
  120289. * @param meshes the loaded meshes
  120290. */
  120291. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  120292. /**
  120293. * A function executed each frame that updates the mesh (if needed)
  120294. * @param xrFrame the current xrFrame
  120295. */
  120296. protected abstract _updateModel(xrFrame: XRFrame): void;
  120297. private _getGenericFilenameAndPath;
  120298. private _getGenericParentMesh;
  120299. }
  120300. }
  120301. declare module BABYLON {
  120302. /**
  120303. * A generic trigger-only motion controller for WebXR
  120304. */
  120305. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  120306. /**
  120307. * Static version of the profile id of this controller
  120308. */
  120309. static ProfileId: string;
  120310. profileId: string;
  120311. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  120312. protected _getFilenameAndPath(): {
  120313. filename: string;
  120314. path: string;
  120315. };
  120316. protected _getModelLoadingConstraints(): boolean;
  120317. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  120318. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120319. protected _updateModel(): void;
  120320. }
  120321. }
  120322. declare module BABYLON {
  120323. /**
  120324. * Class containing static functions to help procedurally build meshes
  120325. */
  120326. export class SphereBuilder {
  120327. /**
  120328. * Creates a sphere mesh
  120329. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  120330. * * 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`)
  120331. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  120332. * * 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
  120333. * * 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)
  120334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120337. * @param name defines the name of the mesh
  120338. * @param options defines the options used to create the mesh
  120339. * @param scene defines the hosting scene
  120340. * @returns the sphere mesh
  120341. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  120342. */
  120343. static CreateSphere(name: string, options: {
  120344. segments?: number;
  120345. diameter?: number;
  120346. diameterX?: number;
  120347. diameterY?: number;
  120348. diameterZ?: number;
  120349. arc?: number;
  120350. slice?: number;
  120351. sideOrientation?: number;
  120352. frontUVs?: Vector4;
  120353. backUVs?: Vector4;
  120354. updatable?: boolean;
  120355. }, scene?: Nullable<Scene>): Mesh;
  120356. }
  120357. }
  120358. declare module BABYLON {
  120359. /**
  120360. * A profiled motion controller has its profile loaded from an online repository.
  120361. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  120362. */
  120363. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  120364. private _repositoryUrl;
  120365. private _buttonMeshMapping;
  120366. private _touchDots;
  120367. /**
  120368. * The profile ID of this controller. Will be populated when the controller initializes.
  120369. */
  120370. profileId: string;
  120371. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  120372. dispose(): void;
  120373. protected _getFilenameAndPath(): {
  120374. filename: string;
  120375. path: string;
  120376. };
  120377. protected _getModelLoadingConstraints(): boolean;
  120378. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  120379. protected _setRootMesh(meshes: AbstractMesh[]): void;
  120380. protected _updateModel(_xrFrame: XRFrame): void;
  120381. }
  120382. }
  120383. declare module BABYLON {
  120384. /**
  120385. * A construction function type to create a new controller based on an xrInput object
  120386. */
  120387. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  120388. /**
  120389. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  120390. *
  120391. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  120392. * it should be replaced with auto-loaded controllers.
  120393. *
  120394. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  120395. */
  120396. export class WebXRMotionControllerManager {
  120397. private static _AvailableControllers;
  120398. private static _Fallbacks;
  120399. private static _ProfileLoadingPromises;
  120400. private static _ProfilesList;
  120401. /**
  120402. * The base URL of the online controller repository. Can be changed at any time.
  120403. */
  120404. static BaseRepositoryUrl: string;
  120405. /**
  120406. * Which repository gets priority - local or online
  120407. */
  120408. static PrioritizeOnlineRepository: boolean;
  120409. /**
  120410. * Use the online repository, or use only locally-defined controllers
  120411. */
  120412. static UseOnlineRepository: boolean;
  120413. /**
  120414. * Clear the cache used for profile loading and reload when requested again
  120415. */
  120416. static ClearProfilesCache(): void;
  120417. /**
  120418. * Register the default fallbacks.
  120419. * This function is called automatically when this file is imported.
  120420. */
  120421. static DefaultFallbacks(): void;
  120422. /**
  120423. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  120424. * @param profileId the profile to which a fallback needs to be found
  120425. * @return an array with corresponding fallback profiles
  120426. */
  120427. static FindFallbackWithProfileId(profileId: string): string[];
  120428. /**
  120429. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  120430. * The order of search:
  120431. *
  120432. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  120433. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  120434. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  120435. * 4) return the generic trigger controller if none were found
  120436. *
  120437. * @param xrInput the xrInput to which a new controller is initialized
  120438. * @param scene the scene to which the model will be added
  120439. * @param forceProfile force a certain profile for this controller
  120440. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  120441. */
  120442. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  120443. /**
  120444. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  120445. *
  120446. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  120447. *
  120448. * @param type the profile type to register
  120449. * @param constructFunction the function to be called when loading this profile
  120450. */
  120451. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  120452. /**
  120453. * Register a fallback to a specific profile.
  120454. * @param profileId the profileId that will receive the fallbacks
  120455. * @param fallbacks A list of fallback profiles
  120456. */
  120457. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  120458. /**
  120459. * Will update the list of profiles available in the repository
  120460. * @return a promise that resolves to a map of profiles available online
  120461. */
  120462. static UpdateProfilesList(): Promise<{
  120463. [profile: string]: string;
  120464. }>;
  120465. private static _LoadProfileFromRepository;
  120466. private static _LoadProfilesFromAvailableControllers;
  120467. }
  120468. }
  120469. declare module BABYLON {
  120470. /**
  120471. * Configuration options for the WebXR controller creation
  120472. */
  120473. export interface IWebXRControllerOptions {
  120474. /**
  120475. * Should the controller mesh be animated when a user interacts with it
  120476. * The pressed buttons / thumbstick and touchpad animations will be disabled
  120477. */
  120478. disableMotionControllerAnimation?: boolean;
  120479. /**
  120480. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  120481. */
  120482. doNotLoadControllerMesh?: boolean;
  120483. /**
  120484. * Force a specific controller type for this controller.
  120485. * This can be used when creating your own profile or when testing different controllers
  120486. */
  120487. forceControllerProfile?: string;
  120488. /**
  120489. * Defines a rendering group ID for meshes that will be loaded.
  120490. * This is for the default controllers only.
  120491. */
  120492. renderingGroupId?: number;
  120493. }
  120494. /**
  120495. * Represents an XR controller
  120496. */
  120497. export class WebXRInputSource {
  120498. private _scene;
  120499. /** The underlying input source for the controller */
  120500. inputSource: XRInputSource;
  120501. private _options;
  120502. private _tmpQuaternion;
  120503. private _tmpVector;
  120504. private _uniqueId;
  120505. /**
  120506. * 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
  120507. */
  120508. grip?: AbstractMesh;
  120509. /**
  120510. * If available, this is the gamepad object related to this controller.
  120511. * Using this object it is possible to get click events and trackpad changes of the
  120512. * webxr controller that is currently being used.
  120513. */
  120514. motionController?: WebXRAbstractMotionController;
  120515. /**
  120516. * Event that fires when the controller is removed/disposed.
  120517. * The object provided as event data is this controller, after associated assets were disposed.
  120518. * uniqueId is still available.
  120519. */
  120520. onDisposeObservable: Observable<WebXRInputSource>;
  120521. /**
  120522. * Will be triggered when the mesh associated with the motion controller is done loading.
  120523. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  120524. * A shortened version of controller -> motion controller -> on mesh loaded.
  120525. */
  120526. onMeshLoadedObservable: Observable<AbstractMesh>;
  120527. /**
  120528. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  120529. */
  120530. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  120531. /**
  120532. * Pointer which can be used to select objects or attach a visible laser to
  120533. */
  120534. pointer: AbstractMesh;
  120535. /**
  120536. * Creates the controller
  120537. * @see https://doc.babylonjs.com/how_to/webxr
  120538. * @param _scene the scene which the controller should be associated to
  120539. * @param inputSource the underlying input source for the controller
  120540. * @param _options options for this controller creation
  120541. */
  120542. constructor(_scene: Scene,
  120543. /** The underlying input source for the controller */
  120544. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  120545. /**
  120546. * Get this controllers unique id
  120547. */
  120548. get uniqueId(): string;
  120549. /**
  120550. * Disposes of the object
  120551. */
  120552. dispose(): void;
  120553. /**
  120554. * Gets a world space ray coming from the pointer or grip
  120555. * @param result the resulting ray
  120556. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  120557. */
  120558. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  120559. /**
  120560. * Updates the controller pose based on the given XRFrame
  120561. * @param xrFrame xr frame to update the pose with
  120562. * @param referenceSpace reference space to use
  120563. */
  120564. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  120565. }
  120566. }
  120567. declare module BABYLON {
  120568. /**
  120569. * The schema for initialization options of the XR Input class
  120570. */
  120571. export interface IWebXRInputOptions {
  120572. /**
  120573. * If set to true no model will be automatically loaded
  120574. */
  120575. doNotLoadControllerMeshes?: boolean;
  120576. /**
  120577. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  120578. * If not found, the xr input profile data will be used.
  120579. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  120580. */
  120581. forceInputProfile?: string;
  120582. /**
  120583. * Do not send a request to the controller repository to load the profile.
  120584. *
  120585. * Instead, use the controllers available in babylon itself.
  120586. */
  120587. disableOnlineControllerRepository?: boolean;
  120588. /**
  120589. * A custom URL for the controllers repository
  120590. */
  120591. customControllersRepositoryURL?: string;
  120592. /**
  120593. * Should the controller model's components not move according to the user input
  120594. */
  120595. disableControllerAnimation?: boolean;
  120596. /**
  120597. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  120598. */
  120599. controllerOptions?: IWebXRControllerOptions;
  120600. }
  120601. /**
  120602. * XR input used to track XR inputs such as controllers/rays
  120603. */
  120604. export class WebXRInput implements IDisposable {
  120605. /**
  120606. * the xr session manager for this session
  120607. */
  120608. xrSessionManager: WebXRSessionManager;
  120609. /**
  120610. * the WebXR camera for this session. Mainly used for teleportation
  120611. */
  120612. xrCamera: WebXRCamera;
  120613. private readonly options;
  120614. /**
  120615. * XR controllers being tracked
  120616. */
  120617. controllers: Array<WebXRInputSource>;
  120618. private _frameObserver;
  120619. private _sessionEndedObserver;
  120620. private _sessionInitObserver;
  120621. /**
  120622. * Event when a controller has been connected/added
  120623. */
  120624. onControllerAddedObservable: Observable<WebXRInputSource>;
  120625. /**
  120626. * Event when a controller has been removed/disconnected
  120627. */
  120628. onControllerRemovedObservable: Observable<WebXRInputSource>;
  120629. /**
  120630. * Initializes the WebXRInput
  120631. * @param xrSessionManager the xr session manager for this session
  120632. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  120633. * @param options = initialization options for this xr input
  120634. */
  120635. constructor(
  120636. /**
  120637. * the xr session manager for this session
  120638. */
  120639. xrSessionManager: WebXRSessionManager,
  120640. /**
  120641. * the WebXR camera for this session. Mainly used for teleportation
  120642. */
  120643. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  120644. private _onInputSourcesChange;
  120645. private _addAndRemoveControllers;
  120646. /**
  120647. * Disposes of the object
  120648. */
  120649. dispose(): void;
  120650. }
  120651. }
  120652. declare module BABYLON {
  120653. /**
  120654. * This is the base class for all WebXR features.
  120655. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  120656. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  120657. */
  120658. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  120659. protected _xrSessionManager: WebXRSessionManager;
  120660. private _attached;
  120661. private _removeOnDetach;
  120662. /**
  120663. * Should auto-attach be disabled?
  120664. */
  120665. disableAutoAttach: boolean;
  120666. /**
  120667. * Construct a new (abstract) WebXR feature
  120668. * @param _xrSessionManager the xr session manager for this feature
  120669. */
  120670. constructor(_xrSessionManager: WebXRSessionManager);
  120671. /**
  120672. * Is this feature attached
  120673. */
  120674. get attached(): boolean;
  120675. /**
  120676. * attach this feature
  120677. *
  120678. * @param force should attachment be forced (even when already attached)
  120679. * @returns true if successful, false is failed or already attached
  120680. */
  120681. attach(force?: boolean): boolean;
  120682. /**
  120683. * detach this feature.
  120684. *
  120685. * @returns true if successful, false if failed or already detached
  120686. */
  120687. detach(): boolean;
  120688. /**
  120689. * Dispose this feature and all of the resources attached
  120690. */
  120691. dispose(): void;
  120692. /**
  120693. * This is used to register callbacks that will automatically be removed when detach is called.
  120694. * @param observable the observable to which the observer will be attached
  120695. * @param callback the callback to register
  120696. */
  120697. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  120698. /**
  120699. * Code in this function will be executed on each xrFrame received from the browser.
  120700. * This function will not execute after the feature is detached.
  120701. * @param _xrFrame the current frame
  120702. */
  120703. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  120704. }
  120705. }
  120706. declare module BABYLON {
  120707. /**
  120708. * Renders a layer on top of an existing scene
  120709. */
  120710. export class UtilityLayerRenderer implements IDisposable {
  120711. /** the original scene that will be rendered on top of */
  120712. originalScene: Scene;
  120713. private _pointerCaptures;
  120714. private _lastPointerEvents;
  120715. private static _DefaultUtilityLayer;
  120716. private static _DefaultKeepDepthUtilityLayer;
  120717. private _sharedGizmoLight;
  120718. private _renderCamera;
  120719. /**
  120720. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  120721. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  120722. * @returns the camera that is used when rendering the utility layer
  120723. */
  120724. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  120725. /**
  120726. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  120727. * @param cam the camera that should be used when rendering the utility layer
  120728. */
  120729. setRenderCamera(cam: Nullable<Camera>): void;
  120730. /**
  120731. * @hidden
  120732. * Light which used by gizmos to get light shading
  120733. */
  120734. _getSharedGizmoLight(): HemisphericLight;
  120735. /**
  120736. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  120737. */
  120738. pickUtilitySceneFirst: boolean;
  120739. /**
  120740. * 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)
  120741. */
  120742. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  120743. /**
  120744. * 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)
  120745. */
  120746. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  120747. /**
  120748. * The scene that is rendered on top of the original scene
  120749. */
  120750. utilityLayerScene: Scene;
  120751. /**
  120752. * If the utility layer should automatically be rendered on top of existing scene
  120753. */
  120754. shouldRender: boolean;
  120755. /**
  120756. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  120757. */
  120758. onlyCheckPointerDownEvents: boolean;
  120759. /**
  120760. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  120761. */
  120762. processAllEvents: boolean;
  120763. /**
  120764. * Observable raised when the pointer move from the utility layer scene to the main scene
  120765. */
  120766. onPointerOutObservable: Observable<number>;
  120767. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  120768. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  120769. private _afterRenderObserver;
  120770. private _sceneDisposeObserver;
  120771. private _originalPointerObserver;
  120772. /**
  120773. * Instantiates a UtilityLayerRenderer
  120774. * @param originalScene the original scene that will be rendered on top of
  120775. * @param handleEvents boolean indicating if the utility layer should handle events
  120776. */
  120777. constructor(
  120778. /** the original scene that will be rendered on top of */
  120779. originalScene: Scene, handleEvents?: boolean);
  120780. private _notifyObservers;
  120781. /**
  120782. * Renders the utility layers scene on top of the original scene
  120783. */
  120784. render(): void;
  120785. /**
  120786. * Disposes of the renderer
  120787. */
  120788. dispose(): void;
  120789. private _updateCamera;
  120790. }
  120791. }
  120792. declare module BABYLON {
  120793. /**
  120794. * Options interface for the pointer selection module
  120795. */
  120796. export interface IWebXRControllerPointerSelectionOptions {
  120797. /**
  120798. * if provided, this scene will be used to render meshes.
  120799. */
  120800. customUtilityLayerScene?: Scene;
  120801. /**
  120802. * 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)
  120803. * If not disabled, the last picked point will be used to execute a pointer up event
  120804. * If disabled, pointer up event will be triggered right after the pointer down event.
  120805. * Used in screen and gaze target ray mode only
  120806. */
  120807. disablePointerUpOnTouchOut: boolean;
  120808. /**
  120809. * For gaze mode (time to select instead of press)
  120810. */
  120811. forceGazeMode: boolean;
  120812. /**
  120813. * 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
  120814. * to start a new countdown to the pointer down event.
  120815. * Defaults to 1.
  120816. */
  120817. gazeModePointerMovedFactor?: number;
  120818. /**
  120819. * Different button type to use instead of the main component
  120820. */
  120821. overrideButtonId?: string;
  120822. /**
  120823. * use this rendering group id for the meshes (optional)
  120824. */
  120825. renderingGroupId?: number;
  120826. /**
  120827. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  120828. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  120829. * 3000 means 3 seconds between pointing at something and selecting it
  120830. */
  120831. timeToSelect?: number;
  120832. /**
  120833. * Should meshes created here be added to a utility layer or the main scene
  120834. */
  120835. useUtilityLayer?: boolean;
  120836. /**
  120837. * the xr input to use with this pointer selection
  120838. */
  120839. xrInput: WebXRInput;
  120840. }
  120841. /**
  120842. * A module that will enable pointer selection for motion controllers of XR Input Sources
  120843. */
  120844. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  120845. private readonly _options;
  120846. private static _idCounter;
  120847. private _attachController;
  120848. private _controllers;
  120849. private _scene;
  120850. private _tmpVectorForPickCompare;
  120851. /**
  120852. * The module's name
  120853. */
  120854. static readonly Name: string;
  120855. /**
  120856. * The (Babylon) version of this module.
  120857. * This is an integer representing the implementation version.
  120858. * This number does not correspond to the WebXR specs version
  120859. */
  120860. static readonly Version: number;
  120861. /**
  120862. * Disable lighting on the laser pointer (so it will always be visible)
  120863. */
  120864. disablePointerLighting: boolean;
  120865. /**
  120866. * Disable lighting on the selection mesh (so it will always be visible)
  120867. */
  120868. disableSelectionMeshLighting: boolean;
  120869. /**
  120870. * Should the laser pointer be displayed
  120871. */
  120872. displayLaserPointer: boolean;
  120873. /**
  120874. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  120875. */
  120876. displaySelectionMesh: boolean;
  120877. /**
  120878. * This color will be set to the laser pointer when selection is triggered
  120879. */
  120880. laserPointerPickedColor: Color3;
  120881. /**
  120882. * Default color of the laser pointer
  120883. */
  120884. lasterPointerDefaultColor: Color3;
  120885. /**
  120886. * default color of the selection ring
  120887. */
  120888. selectionMeshDefaultColor: Color3;
  120889. /**
  120890. * This color will be applied to the selection ring when selection is triggered
  120891. */
  120892. selectionMeshPickedColor: Color3;
  120893. /**
  120894. * Optional filter to be used for ray selection. This predicate shares behavior with
  120895. * scene.pointerMovePredicate which takes priority if it is also assigned.
  120896. */
  120897. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  120898. /**
  120899. * constructs a new background remover module
  120900. * @param _xrSessionManager the session manager for this module
  120901. * @param _options read-only options to be used in this module
  120902. */
  120903. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  120904. /**
  120905. * attach this feature
  120906. * Will usually be called by the features manager
  120907. *
  120908. * @returns true if successful.
  120909. */
  120910. attach(): boolean;
  120911. /**
  120912. * detach this feature.
  120913. * Will usually be called by the features manager
  120914. *
  120915. * @returns true if successful.
  120916. */
  120917. detach(): boolean;
  120918. /**
  120919. * Will get the mesh under a specific pointer.
  120920. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  120921. * @param controllerId the controllerId to check
  120922. * @returns The mesh under pointer or null if no mesh is under the pointer
  120923. */
  120924. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  120925. /**
  120926. * Get the xr controller that correlates to the pointer id in the pointer event
  120927. *
  120928. * @param id the pointer id to search for
  120929. * @returns the controller that correlates to this id or null if not found
  120930. */
  120931. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  120932. protected _onXRFrame(_xrFrame: XRFrame): void;
  120933. private _attachGazeMode;
  120934. private _attachScreenRayMode;
  120935. private _attachTrackedPointerRayMode;
  120936. private _convertNormalToDirectionOfRay;
  120937. private _detachController;
  120938. private _generateNewMeshPair;
  120939. private _pickingMoved;
  120940. private _updatePointerDistance;
  120941. }
  120942. }
  120943. declare module BABYLON {
  120944. /**
  120945. * Button which can be used to enter a different mode of XR
  120946. */
  120947. export class WebXREnterExitUIButton {
  120948. /** button element */
  120949. element: HTMLElement;
  120950. /** XR initialization options for the button */
  120951. sessionMode: XRSessionMode;
  120952. /** Reference space type */
  120953. referenceSpaceType: XRReferenceSpaceType;
  120954. /**
  120955. * Creates a WebXREnterExitUIButton
  120956. * @param element button element
  120957. * @param sessionMode XR initialization session mode
  120958. * @param referenceSpaceType the type of reference space to be used
  120959. */
  120960. constructor(
  120961. /** button element */
  120962. element: HTMLElement,
  120963. /** XR initialization options for the button */
  120964. sessionMode: XRSessionMode,
  120965. /** Reference space type */
  120966. referenceSpaceType: XRReferenceSpaceType);
  120967. /**
  120968. * Extendable function which can be used to update the button's visuals when the state changes
  120969. * @param activeButton the current active button in the UI
  120970. */
  120971. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  120972. }
  120973. /**
  120974. * Options to create the webXR UI
  120975. */
  120976. export class WebXREnterExitUIOptions {
  120977. /**
  120978. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  120979. */
  120980. customButtons?: Array<WebXREnterExitUIButton>;
  120981. /**
  120982. * A reference space type to use when creating the default button.
  120983. * Default is local-floor
  120984. */
  120985. referenceSpaceType?: XRReferenceSpaceType;
  120986. /**
  120987. * Context to enter xr with
  120988. */
  120989. renderTarget?: Nullable<WebXRRenderTarget>;
  120990. /**
  120991. * A session mode to use when creating the default button.
  120992. * Default is immersive-vr
  120993. */
  120994. sessionMode?: XRSessionMode;
  120995. }
  120996. /**
  120997. * UI to allow the user to enter/exit XR mode
  120998. */
  120999. export class WebXREnterExitUI implements IDisposable {
  121000. private scene;
  121001. /** version of the options passed to this UI */
  121002. options: WebXREnterExitUIOptions;
  121003. private _activeButton;
  121004. private _buttons;
  121005. private _overlay;
  121006. /**
  121007. * Fired every time the active button is changed.
  121008. *
  121009. * When xr is entered via a button that launches xr that button will be the callback parameter
  121010. *
  121011. * When exiting xr the callback parameter will be null)
  121012. */
  121013. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  121014. /**
  121015. *
  121016. * @param scene babylon scene object to use
  121017. * @param options (read-only) version of the options passed to this UI
  121018. */
  121019. private constructor();
  121020. /**
  121021. * Creates UI to allow the user to enter/exit XR mode
  121022. * @param scene the scene to add the ui to
  121023. * @param helper the xr experience helper to enter/exit xr with
  121024. * @param options options to configure the UI
  121025. * @returns the created ui
  121026. */
  121027. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  121028. /**
  121029. * Disposes of the XR UI component
  121030. */
  121031. dispose(): void;
  121032. private _updateButtons;
  121033. }
  121034. }
  121035. declare module BABYLON {
  121036. /**
  121037. * Class containing static functions to help procedurally build meshes
  121038. */
  121039. export class LinesBuilder {
  121040. /**
  121041. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121042. * * 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
  121043. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121044. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121045. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121046. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121047. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121048. * * 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
  121049. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121052. * @param name defines the name of the new line system
  121053. * @param options defines the options used to create the line system
  121054. * @param scene defines the hosting scene
  121055. * @returns a new line system mesh
  121056. */
  121057. static CreateLineSystem(name: string, options: {
  121058. lines: Vector3[][];
  121059. updatable?: boolean;
  121060. instance?: Nullable<LinesMesh>;
  121061. colors?: Nullable<Color4[][]>;
  121062. useVertexAlpha?: boolean;
  121063. }, scene: Nullable<Scene>): LinesMesh;
  121064. /**
  121065. * Creates a line mesh
  121066. * 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
  121067. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121068. * * The parameter `points` is an array successive Vector3
  121069. * * 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
  121070. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121071. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121072. * * When updating an instance, remember that only point positions can change, not the number of points
  121073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121075. * @param name defines the name of the new line system
  121076. * @param options defines the options used to create the line system
  121077. * @param scene defines the hosting scene
  121078. * @returns a new line mesh
  121079. */
  121080. static CreateLines(name: string, options: {
  121081. points: Vector3[];
  121082. updatable?: boolean;
  121083. instance?: Nullable<LinesMesh>;
  121084. colors?: Color4[];
  121085. useVertexAlpha?: boolean;
  121086. }, scene?: Nullable<Scene>): LinesMesh;
  121087. /**
  121088. * Creates a dashed line mesh
  121089. * * 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
  121090. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121091. * * The parameter `points` is an array successive Vector3
  121092. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121093. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121094. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121095. * * 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
  121096. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121097. * * When updating an instance, remember that only point positions can change, not the number of points
  121098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121099. * @param name defines the name of the mesh
  121100. * @param options defines the options used to create the mesh
  121101. * @param scene defines the hosting scene
  121102. * @returns the dashed line mesh
  121103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121104. */
  121105. static CreateDashedLines(name: string, options: {
  121106. points: Vector3[];
  121107. dashSize?: number;
  121108. gapSize?: number;
  121109. dashNb?: number;
  121110. updatable?: boolean;
  121111. instance?: LinesMesh;
  121112. useVertexAlpha?: boolean;
  121113. }, scene?: Nullable<Scene>): LinesMesh;
  121114. }
  121115. }
  121116. declare module BABYLON {
  121117. /**
  121118. * The options container for the teleportation module
  121119. */
  121120. export interface IWebXRTeleportationOptions {
  121121. /**
  121122. * if provided, this scene will be used to render meshes.
  121123. */
  121124. customUtilityLayerScene?: Scene;
  121125. /**
  121126. * Values to configure the default target mesh
  121127. */
  121128. defaultTargetMeshOptions?: {
  121129. /**
  121130. * Fill color of the teleportation area
  121131. */
  121132. teleportationFillColor?: string;
  121133. /**
  121134. * Border color for the teleportation area
  121135. */
  121136. teleportationBorderColor?: string;
  121137. /**
  121138. * Disable the mesh's animation sequence
  121139. */
  121140. disableAnimation?: boolean;
  121141. /**
  121142. * Disable lighting on the material or the ring and arrow
  121143. */
  121144. disableLighting?: boolean;
  121145. /**
  121146. * Override the default material of the torus and arrow
  121147. */
  121148. torusArrowMaterial?: Material;
  121149. };
  121150. /**
  121151. * A list of meshes to use as floor meshes.
  121152. * Meshes can be added and removed after initializing the feature using the
  121153. * addFloorMesh and removeFloorMesh functions
  121154. * If empty, rotation will still work
  121155. */
  121156. floorMeshes?: AbstractMesh[];
  121157. /**
  121158. * use this rendering group id for the meshes (optional)
  121159. */
  121160. renderingGroupId?: number;
  121161. /**
  121162. * Should teleportation move only to snap points
  121163. */
  121164. snapPointsOnly?: boolean;
  121165. /**
  121166. * An array of points to which the teleportation will snap to.
  121167. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  121168. */
  121169. snapPositions?: Vector3[];
  121170. /**
  121171. * How close should the teleportation ray be in order to snap to position.
  121172. * Default to 0.8 units (meters)
  121173. */
  121174. snapToPositionRadius?: number;
  121175. /**
  121176. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  121177. * If you want to support rotation, make sure your mesh has a direction indicator.
  121178. *
  121179. * When left untouched, the default mesh will be initialized.
  121180. */
  121181. teleportationTargetMesh?: AbstractMesh;
  121182. /**
  121183. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  121184. */
  121185. timeToTeleport?: number;
  121186. /**
  121187. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  121188. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  121189. */
  121190. useMainComponentOnly?: boolean;
  121191. /**
  121192. * Should meshes created here be added to a utility layer or the main scene
  121193. */
  121194. useUtilityLayer?: boolean;
  121195. /**
  121196. * Babylon XR Input class for controller
  121197. */
  121198. xrInput: WebXRInput;
  121199. }
  121200. /**
  121201. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  121202. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  121203. * the input of the attached controllers.
  121204. */
  121205. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  121206. private _options;
  121207. private _controllers;
  121208. private _currentTeleportationControllerId;
  121209. private _floorMeshes;
  121210. private _quadraticBezierCurve;
  121211. private _selectionFeature;
  121212. private _snapToPositions;
  121213. private _snappedToPoint;
  121214. private _teleportationRingMaterial?;
  121215. private _tmpRay;
  121216. private _tmpVector;
  121217. /**
  121218. * The module's name
  121219. */
  121220. static readonly Name: string;
  121221. /**
  121222. * The (Babylon) version of this module.
  121223. * This is an integer representing the implementation version.
  121224. * This number does not correspond to the webxr specs version
  121225. */
  121226. static readonly Version: number;
  121227. /**
  121228. * Is movement backwards enabled
  121229. */
  121230. backwardsMovementEnabled: boolean;
  121231. /**
  121232. * Distance to travel when moving backwards
  121233. */
  121234. backwardsTeleportationDistance: number;
  121235. /**
  121236. * The distance from the user to the inspection point in the direction of the controller
  121237. * A higher number will allow the user to move further
  121238. * defaults to 5 (meters, in xr units)
  121239. */
  121240. parabolicCheckRadius: number;
  121241. /**
  121242. * Should the module support parabolic ray on top of direct ray
  121243. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  121244. * Very helpful when moving between floors / different heights
  121245. */
  121246. parabolicRayEnabled: boolean;
  121247. /**
  121248. * How much rotation should be applied when rotating right and left
  121249. */
  121250. rotationAngle: number;
  121251. /**
  121252. * Is rotation enabled when moving forward?
  121253. * Disabling this feature will prevent the user from deciding the direction when teleporting
  121254. */
  121255. rotationEnabled: boolean;
  121256. /**
  121257. * constructs a new anchor system
  121258. * @param _xrSessionManager an instance of WebXRSessionManager
  121259. * @param _options configuration object for this feature
  121260. */
  121261. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  121262. /**
  121263. * Get the snapPointsOnly flag
  121264. */
  121265. get snapPointsOnly(): boolean;
  121266. /**
  121267. * Sets the snapPointsOnly flag
  121268. * @param snapToPoints should teleportation be exclusively to snap points
  121269. */
  121270. set snapPointsOnly(snapToPoints: boolean);
  121271. /**
  121272. * Add a new mesh to the floor meshes array
  121273. * @param mesh the mesh to use as floor mesh
  121274. */
  121275. addFloorMesh(mesh: AbstractMesh): void;
  121276. /**
  121277. * Add a new snap-to point to fix teleportation to this position
  121278. * @param newSnapPoint The new Snap-To point
  121279. */
  121280. addSnapPoint(newSnapPoint: Vector3): void;
  121281. attach(): boolean;
  121282. detach(): boolean;
  121283. dispose(): void;
  121284. /**
  121285. * Remove a mesh from the floor meshes array
  121286. * @param mesh the mesh to remove
  121287. */
  121288. removeFloorMesh(mesh: AbstractMesh): void;
  121289. /**
  121290. * Remove a mesh from the floor meshes array using its name
  121291. * @param name the mesh name to remove
  121292. */
  121293. removeFloorMeshByName(name: string): void;
  121294. /**
  121295. * 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
  121296. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  121297. * @returns was the point found and removed or not
  121298. */
  121299. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  121300. /**
  121301. * This function sets a selection feature that will be disabled when
  121302. * the forward ray is shown and will be reattached when hidden.
  121303. * This is used to remove the selection rays when moving.
  121304. * @param selectionFeature the feature to disable when forward movement is enabled
  121305. */
  121306. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  121307. protected _onXRFrame(_xrFrame: XRFrame): void;
  121308. private _attachController;
  121309. private _createDefaultTargetMesh;
  121310. private _detachController;
  121311. private _findClosestSnapPointWithRadius;
  121312. private _setTargetMeshPosition;
  121313. private _setTargetMeshVisibility;
  121314. private _showParabolicPath;
  121315. private _teleportForward;
  121316. }
  121317. }
  121318. declare module BABYLON {
  121319. /**
  121320. * Options for the default xr helper
  121321. */
  121322. export class WebXRDefaultExperienceOptions {
  121323. /**
  121324. * Enable or disable default UI to enter XR
  121325. */
  121326. disableDefaultUI?: boolean;
  121327. /**
  121328. * Should teleportation not initialize. defaults to false.
  121329. */
  121330. disableTeleportation?: boolean;
  121331. /**
  121332. * Floor meshes that will be used for teleport
  121333. */
  121334. floorMeshes?: Array<AbstractMesh>;
  121335. /**
  121336. * If set to true, the first frame will not be used to reset position
  121337. * The first frame is mainly used when copying transformation from the old camera
  121338. * Mainly used in AR
  121339. */
  121340. ignoreNativeCameraTransformation?: boolean;
  121341. /**
  121342. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  121343. */
  121344. inputOptions?: IWebXRInputOptions;
  121345. /**
  121346. * optional configuration for the output canvas
  121347. */
  121348. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  121349. /**
  121350. * optional UI options. This can be used among other to change session mode and reference space type
  121351. */
  121352. uiOptions?: WebXREnterExitUIOptions;
  121353. /**
  121354. * When loading teleportation and pointer select, use stable versions instead of latest.
  121355. */
  121356. useStablePlugins?: boolean;
  121357. /**
  121358. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  121359. */
  121360. renderingGroupId?: number;
  121361. }
  121362. /**
  121363. * Default experience which provides a similar setup to the previous webVRExperience
  121364. */
  121365. export class WebXRDefaultExperience {
  121366. /**
  121367. * Base experience
  121368. */
  121369. baseExperience: WebXRExperienceHelper;
  121370. /**
  121371. * Enables ui for entering/exiting xr
  121372. */
  121373. enterExitUI: WebXREnterExitUI;
  121374. /**
  121375. * Input experience extension
  121376. */
  121377. input: WebXRInput;
  121378. /**
  121379. * Enables laser pointer and selection
  121380. */
  121381. pointerSelection: WebXRControllerPointerSelection;
  121382. /**
  121383. * Default target xr should render to
  121384. */
  121385. renderTarget: WebXRRenderTarget;
  121386. /**
  121387. * Enables teleportation
  121388. */
  121389. teleportation: WebXRMotionControllerTeleportation;
  121390. private constructor();
  121391. /**
  121392. * Creates the default xr experience
  121393. * @param scene scene
  121394. * @param options options for basic configuration
  121395. * @returns resulting WebXRDefaultExperience
  121396. */
  121397. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121398. /**
  121399. * DIsposes of the experience helper
  121400. */
  121401. dispose(): void;
  121402. }
  121403. }
  121404. declare module BABYLON {
  121405. /**
  121406. * Options to modify the vr teleportation behavior.
  121407. */
  121408. export interface VRTeleportationOptions {
  121409. /**
  121410. * The name of the mesh which should be used as the teleportation floor. (default: null)
  121411. */
  121412. floorMeshName?: string;
  121413. /**
  121414. * A list of meshes to be used as the teleportation floor. (default: empty)
  121415. */
  121416. floorMeshes?: Mesh[];
  121417. /**
  121418. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  121419. */
  121420. teleportationMode?: number;
  121421. /**
  121422. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  121423. */
  121424. teleportationTime?: number;
  121425. /**
  121426. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  121427. */
  121428. teleportationSpeed?: number;
  121429. /**
  121430. * The easing function used in the animation or null for Linear. (default CircleEase)
  121431. */
  121432. easingFunction?: EasingFunction;
  121433. }
  121434. /**
  121435. * Options to modify the vr experience helper's behavior.
  121436. */
  121437. export interface VRExperienceHelperOptions extends WebVROptions {
  121438. /**
  121439. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  121440. */
  121441. createDeviceOrientationCamera?: boolean;
  121442. /**
  121443. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  121444. */
  121445. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  121446. /**
  121447. * Uses the main button on the controller to toggle the laser casted. (default: true)
  121448. */
  121449. laserToggle?: boolean;
  121450. /**
  121451. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  121452. */
  121453. floorMeshes?: Mesh[];
  121454. /**
  121455. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  121456. */
  121457. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  121458. /**
  121459. * Defines if WebXR should be used instead of WebVR (if available)
  121460. */
  121461. useXR?: boolean;
  121462. }
  121463. /**
  121464. * Event containing information after VR has been entered
  121465. */
  121466. export class OnAfterEnteringVRObservableEvent {
  121467. /**
  121468. * If entering vr was successful
  121469. */
  121470. success: boolean;
  121471. }
  121472. /**
  121473. * Helps to quickly add VR support to an existing scene.
  121474. * See http://doc.babylonjs.com/how_to/webvr_helper
  121475. */
  121476. export class VRExperienceHelper {
  121477. /** Options to modify the vr experience helper's behavior. */
  121478. webVROptions: VRExperienceHelperOptions;
  121479. private _scene;
  121480. private _position;
  121481. private _btnVR;
  121482. private _btnVRDisplayed;
  121483. private _webVRsupported;
  121484. private _webVRready;
  121485. private _webVRrequesting;
  121486. private _webVRpresenting;
  121487. private _hasEnteredVR;
  121488. private _fullscreenVRpresenting;
  121489. private _inputElement;
  121490. private _webVRCamera;
  121491. private _vrDeviceOrientationCamera;
  121492. private _deviceOrientationCamera;
  121493. private _existingCamera;
  121494. private _onKeyDown;
  121495. private _onVrDisplayPresentChange;
  121496. private _onVRDisplayChanged;
  121497. private _onVRRequestPresentStart;
  121498. private _onVRRequestPresentComplete;
  121499. /**
  121500. * 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)
  121501. */
  121502. enableGazeEvenWhenNoPointerLock: boolean;
  121503. /**
  121504. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  121505. */
  121506. exitVROnDoubleTap: boolean;
  121507. /**
  121508. * Observable raised right before entering VR.
  121509. */
  121510. onEnteringVRObservable: Observable<VRExperienceHelper>;
  121511. /**
  121512. * Observable raised when entering VR has completed.
  121513. */
  121514. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  121515. /**
  121516. * Observable raised when exiting VR.
  121517. */
  121518. onExitingVRObservable: Observable<VRExperienceHelper>;
  121519. /**
  121520. * Observable raised when controller mesh is loaded.
  121521. */
  121522. onControllerMeshLoadedObservable: Observable<WebVRController>;
  121523. /** Return this.onEnteringVRObservable
  121524. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  121525. */
  121526. get onEnteringVR(): Observable<VRExperienceHelper>;
  121527. /** Return this.onExitingVRObservable
  121528. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  121529. */
  121530. get onExitingVR(): Observable<VRExperienceHelper>;
  121531. /** Return this.onControllerMeshLoadedObservable
  121532. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  121533. */
  121534. get onControllerMeshLoaded(): Observable<WebVRController>;
  121535. private _rayLength;
  121536. private _useCustomVRButton;
  121537. private _teleportationRequested;
  121538. private _teleportActive;
  121539. private _floorMeshName;
  121540. private _floorMeshesCollection;
  121541. private _teleportationMode;
  121542. private _teleportationTime;
  121543. private _teleportationSpeed;
  121544. private _teleportationEasing;
  121545. private _rotationAllowed;
  121546. private _teleportBackwardsVector;
  121547. private _teleportationTarget;
  121548. private _isDefaultTeleportationTarget;
  121549. private _postProcessMove;
  121550. private _teleportationFillColor;
  121551. private _teleportationBorderColor;
  121552. private _rotationAngle;
  121553. private _haloCenter;
  121554. private _cameraGazer;
  121555. private _padSensibilityUp;
  121556. private _padSensibilityDown;
  121557. private _leftController;
  121558. private _rightController;
  121559. private _gazeColor;
  121560. private _laserColor;
  121561. private _pickedLaserColor;
  121562. private _pickedGazeColor;
  121563. /**
  121564. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  121565. */
  121566. onNewMeshSelected: Observable<AbstractMesh>;
  121567. /**
  121568. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  121569. * This observable will provide the mesh and the controller used to select the mesh
  121570. */
  121571. onMeshSelectedWithController: Observable<{
  121572. mesh: AbstractMesh;
  121573. controller: WebVRController;
  121574. }>;
  121575. /**
  121576. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  121577. */
  121578. onNewMeshPicked: Observable<PickingInfo>;
  121579. private _circleEase;
  121580. /**
  121581. * Observable raised before camera teleportation
  121582. */
  121583. onBeforeCameraTeleport: Observable<Vector3>;
  121584. /**
  121585. * Observable raised after camera teleportation
  121586. */
  121587. onAfterCameraTeleport: Observable<Vector3>;
  121588. /**
  121589. * Observable raised when current selected mesh gets unselected
  121590. */
  121591. onSelectedMeshUnselected: Observable<AbstractMesh>;
  121592. private _raySelectionPredicate;
  121593. /**
  121594. * To be optionaly changed by user to define custom ray selection
  121595. */
  121596. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  121597. /**
  121598. * To be optionaly changed by user to define custom selection logic (after ray selection)
  121599. */
  121600. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  121601. /**
  121602. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  121603. */
  121604. teleportationEnabled: boolean;
  121605. private _defaultHeight;
  121606. private _teleportationInitialized;
  121607. private _interactionsEnabled;
  121608. private _interactionsRequested;
  121609. private _displayGaze;
  121610. private _displayLaserPointer;
  121611. /**
  121612. * The mesh used to display where the user is going to teleport.
  121613. */
  121614. get teleportationTarget(): Mesh;
  121615. /**
  121616. * Sets the mesh to be used to display where the user is going to teleport.
  121617. */
  121618. set teleportationTarget(value: Mesh);
  121619. /**
  121620. * 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
  121621. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  121622. * See http://doc.babylonjs.com/resources/baking_transformations
  121623. */
  121624. get gazeTrackerMesh(): Mesh;
  121625. set gazeTrackerMesh(value: Mesh);
  121626. /**
  121627. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  121628. */
  121629. updateGazeTrackerScale: boolean;
  121630. /**
  121631. * If the gaze trackers color should be updated when selecting meshes
  121632. */
  121633. updateGazeTrackerColor: boolean;
  121634. /**
  121635. * If the controller laser color should be updated when selecting meshes
  121636. */
  121637. updateControllerLaserColor: boolean;
  121638. /**
  121639. * The gaze tracking mesh corresponding to the left controller
  121640. */
  121641. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  121642. /**
  121643. * The gaze tracking mesh corresponding to the right controller
  121644. */
  121645. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  121646. /**
  121647. * If the ray of the gaze should be displayed.
  121648. */
  121649. get displayGaze(): boolean;
  121650. /**
  121651. * Sets if the ray of the gaze should be displayed.
  121652. */
  121653. set displayGaze(value: boolean);
  121654. /**
  121655. * If the ray of the LaserPointer should be displayed.
  121656. */
  121657. get displayLaserPointer(): boolean;
  121658. /**
  121659. * Sets if the ray of the LaserPointer should be displayed.
  121660. */
  121661. set displayLaserPointer(value: boolean);
  121662. /**
  121663. * The deviceOrientationCamera used as the camera when not in VR.
  121664. */
  121665. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  121666. /**
  121667. * Based on the current WebVR support, returns the current VR camera used.
  121668. */
  121669. get currentVRCamera(): Nullable<Camera>;
  121670. /**
  121671. * The webVRCamera which is used when in VR.
  121672. */
  121673. get webVRCamera(): WebVRFreeCamera;
  121674. /**
  121675. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  121676. */
  121677. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  121678. /**
  121679. * The html button that is used to trigger entering into VR.
  121680. */
  121681. get vrButton(): Nullable<HTMLButtonElement>;
  121682. private get _teleportationRequestInitiated();
  121683. /**
  121684. * Defines whether or not Pointer lock should be requested when switching to
  121685. * full screen.
  121686. */
  121687. requestPointerLockOnFullScreen: boolean;
  121688. /**
  121689. * If asking to force XR, this will be populated with the default xr experience
  121690. */
  121691. xr: WebXRDefaultExperience;
  121692. /**
  121693. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  121694. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  121695. */
  121696. xrTestDone: boolean;
  121697. /**
  121698. * Instantiates a VRExperienceHelper.
  121699. * Helps to quickly add VR support to an existing scene.
  121700. * @param scene The scene the VRExperienceHelper belongs to.
  121701. * @param webVROptions Options to modify the vr experience helper's behavior.
  121702. */
  121703. constructor(scene: Scene,
  121704. /** Options to modify the vr experience helper's behavior. */
  121705. webVROptions?: VRExperienceHelperOptions);
  121706. private completeVRInit;
  121707. private _onDefaultMeshLoaded;
  121708. private _onResize;
  121709. private _onFullscreenChange;
  121710. /**
  121711. * Gets a value indicating if we are currently in VR mode.
  121712. */
  121713. get isInVRMode(): boolean;
  121714. private onVrDisplayPresentChange;
  121715. private onVRDisplayChanged;
  121716. private moveButtonToBottomRight;
  121717. private displayVRButton;
  121718. private updateButtonVisibility;
  121719. private _cachedAngularSensibility;
  121720. /**
  121721. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  121722. * Otherwise, will use the fullscreen API.
  121723. */
  121724. enterVR(): void;
  121725. /**
  121726. * Attempt to exit VR, or fullscreen.
  121727. */
  121728. exitVR(): void;
  121729. /**
  121730. * The position of the vr experience helper.
  121731. */
  121732. get position(): Vector3;
  121733. /**
  121734. * Sets the position of the vr experience helper.
  121735. */
  121736. set position(value: Vector3);
  121737. /**
  121738. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  121739. */
  121740. enableInteractions(): void;
  121741. private get _noControllerIsActive();
  121742. private beforeRender;
  121743. private _isTeleportationFloor;
  121744. /**
  121745. * Adds a floor mesh to be used for teleportation.
  121746. * @param floorMesh the mesh to be used for teleportation.
  121747. */
  121748. addFloorMesh(floorMesh: Mesh): void;
  121749. /**
  121750. * Removes a floor mesh from being used for teleportation.
  121751. * @param floorMesh the mesh to be removed.
  121752. */
  121753. removeFloorMesh(floorMesh: Mesh): void;
  121754. /**
  121755. * Enables interactions and teleportation using the VR controllers and gaze.
  121756. * @param vrTeleportationOptions options to modify teleportation behavior.
  121757. */
  121758. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  121759. private _onNewGamepadConnected;
  121760. private _tryEnableInteractionOnController;
  121761. private _onNewGamepadDisconnected;
  121762. private _enableInteractionOnController;
  121763. private _checkTeleportWithRay;
  121764. private _checkRotate;
  121765. private _checkTeleportBackwards;
  121766. private _enableTeleportationOnController;
  121767. private _createTeleportationCircles;
  121768. private _displayTeleportationTarget;
  121769. private _hideTeleportationTarget;
  121770. private _rotateCamera;
  121771. private _moveTeleportationSelectorTo;
  121772. private _workingVector;
  121773. private _workingQuaternion;
  121774. private _workingMatrix;
  121775. /**
  121776. * Time Constant Teleportation Mode
  121777. */
  121778. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  121779. /**
  121780. * Speed Constant Teleportation Mode
  121781. */
  121782. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  121783. /**
  121784. * Teleports the users feet to the desired location
  121785. * @param location The location where the user's feet should be placed
  121786. */
  121787. teleportCamera(location: Vector3): void;
  121788. private _convertNormalToDirectionOfRay;
  121789. private _castRayAndSelectObject;
  121790. private _notifySelectedMeshUnselected;
  121791. /**
  121792. * Permanently set new colors for the laser pointer
  121793. * @param color the new laser color
  121794. * @param pickedColor the new laser color when picked mesh detected
  121795. */
  121796. setLaserColor(color: Color3, pickedColor?: Color3): void;
  121797. /**
  121798. * Set lighting enabled / disabled on the laser pointer of both controllers
  121799. * @param enabled should the lighting be enabled on the laser pointer
  121800. */
  121801. setLaserLightingState(enabled?: boolean): void;
  121802. /**
  121803. * Permanently set new colors for the gaze pointer
  121804. * @param color the new gaze color
  121805. * @param pickedColor the new gaze color when picked mesh detected
  121806. */
  121807. setGazeColor(color: Color3, pickedColor?: Color3): void;
  121808. /**
  121809. * Sets the color of the laser ray from the vr controllers.
  121810. * @param color new color for the ray.
  121811. */
  121812. changeLaserColor(color: Color3): void;
  121813. /**
  121814. * Sets the color of the ray from the vr headsets gaze.
  121815. * @param color new color for the ray.
  121816. */
  121817. changeGazeColor(color: Color3): void;
  121818. /**
  121819. * Exits VR and disposes of the vr experience helper
  121820. */
  121821. dispose(): void;
  121822. /**
  121823. * Gets the name of the VRExperienceHelper class
  121824. * @returns "VRExperienceHelper"
  121825. */
  121826. getClassName(): string;
  121827. }
  121828. }
  121829. declare module BABYLON {
  121830. /**
  121831. * Contains an array of blocks representing the octree
  121832. */
  121833. export interface IOctreeContainer<T> {
  121834. /**
  121835. * Blocks within the octree
  121836. */
  121837. blocks: Array<OctreeBlock<T>>;
  121838. }
  121839. /**
  121840. * Class used to store a cell in an octree
  121841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121842. */
  121843. export class OctreeBlock<T> {
  121844. /**
  121845. * Gets the content of the current block
  121846. */
  121847. entries: T[];
  121848. /**
  121849. * Gets the list of block children
  121850. */
  121851. blocks: Array<OctreeBlock<T>>;
  121852. private _depth;
  121853. private _maxDepth;
  121854. private _capacity;
  121855. private _minPoint;
  121856. private _maxPoint;
  121857. private _boundingVectors;
  121858. private _creationFunc;
  121859. /**
  121860. * Creates a new block
  121861. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  121862. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  121863. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  121864. * @param depth defines the current depth of this block in the octree
  121865. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  121866. * @param creationFunc defines a callback to call when an element is added to the block
  121867. */
  121868. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  121869. /**
  121870. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  121871. */
  121872. get capacity(): number;
  121873. /**
  121874. * Gets the minimum vector (in world space) of the block's bounding box
  121875. */
  121876. get minPoint(): Vector3;
  121877. /**
  121878. * Gets the maximum vector (in world space) of the block's bounding box
  121879. */
  121880. get maxPoint(): Vector3;
  121881. /**
  121882. * Add a new element to this block
  121883. * @param entry defines the element to add
  121884. */
  121885. addEntry(entry: T): void;
  121886. /**
  121887. * Remove an element from this block
  121888. * @param entry defines the element to remove
  121889. */
  121890. removeEntry(entry: T): void;
  121891. /**
  121892. * Add an array of elements to this block
  121893. * @param entries defines the array of elements to add
  121894. */
  121895. addEntries(entries: T[]): void;
  121896. /**
  121897. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  121898. * @param frustumPlanes defines the frustum planes to test
  121899. * @param selection defines the array to store current content if selection is positive
  121900. * @param allowDuplicate defines if the selection array can contains duplicated entries
  121901. */
  121902. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  121903. /**
  121904. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  121905. * @param sphereCenter defines the bounding sphere center
  121906. * @param sphereRadius defines the bounding sphere radius
  121907. * @param selection defines the array to store current content if selection is positive
  121908. * @param allowDuplicate defines if the selection array can contains duplicated entries
  121909. */
  121910. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  121911. /**
  121912. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  121913. * @param ray defines the ray to test with
  121914. * @param selection defines the array to store current content if selection is positive
  121915. */
  121916. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  121917. /**
  121918. * Subdivide the content into child blocks (this block will then be empty)
  121919. */
  121920. createInnerBlocks(): void;
  121921. /**
  121922. * @hidden
  121923. */
  121924. 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;
  121925. }
  121926. }
  121927. declare module BABYLON {
  121928. /**
  121929. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  121930. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121931. */
  121932. export class Octree<T> {
  121933. /** 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.) */
  121934. maxDepth: number;
  121935. /**
  121936. * Blocks within the octree containing objects
  121937. */
  121938. blocks: Array<OctreeBlock<T>>;
  121939. /**
  121940. * Content stored in the octree
  121941. */
  121942. dynamicContent: T[];
  121943. private _maxBlockCapacity;
  121944. private _selectionContent;
  121945. private _creationFunc;
  121946. /**
  121947. * Creates a octree
  121948. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  121949. * @param creationFunc function to be used to instatiate the octree
  121950. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  121951. * @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.)
  121952. */
  121953. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  121954. /** 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.) */
  121955. maxDepth?: number);
  121956. /**
  121957. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  121958. * @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);
  121959. * @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);
  121960. * @param entries meshes to be added to the octree blocks
  121961. */
  121962. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  121963. /**
  121964. * Adds a mesh to the octree
  121965. * @param entry Mesh to add to the octree
  121966. */
  121967. addMesh(entry: T): void;
  121968. /**
  121969. * Remove an element from the octree
  121970. * @param entry defines the element to remove
  121971. */
  121972. removeMesh(entry: T): void;
  121973. /**
  121974. * Selects an array of meshes within the frustum
  121975. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  121976. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  121977. * @returns array of meshes within the frustum
  121978. */
  121979. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  121980. /**
  121981. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  121982. * @param sphereCenter defines the bounding sphere center
  121983. * @param sphereRadius defines the bounding sphere radius
  121984. * @param allowDuplicate defines if the selection array can contains duplicated entries
  121985. * @returns an array of objects that intersect the sphere
  121986. */
  121987. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  121988. /**
  121989. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  121990. * @param ray defines the ray to test with
  121991. * @returns array of intersected objects
  121992. */
  121993. intersectsRay(ray: Ray): SmartArray<T>;
  121994. /**
  121995. * Adds a mesh into the octree block if it intersects the block
  121996. */
  121997. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  121998. /**
  121999. * Adds a submesh into the octree block if it intersects the block
  122000. */
  122001. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  122002. }
  122003. }
  122004. declare module BABYLON {
  122005. interface Scene {
  122006. /**
  122007. * @hidden
  122008. * Backing Filed
  122009. */
  122010. _selectionOctree: Octree<AbstractMesh>;
  122011. /**
  122012. * Gets the octree used to boost mesh selection (picking)
  122013. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122014. */
  122015. selectionOctree: Octree<AbstractMesh>;
  122016. /**
  122017. * Creates or updates the octree used to boost selection (picking)
  122018. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122019. * @param maxCapacity defines the maximum capacity per leaf
  122020. * @param maxDepth defines the maximum depth of the octree
  122021. * @returns an octree of AbstractMesh
  122022. */
  122023. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  122024. }
  122025. interface AbstractMesh {
  122026. /**
  122027. * @hidden
  122028. * Backing Field
  122029. */
  122030. _submeshesOctree: Octree<SubMesh>;
  122031. /**
  122032. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  122033. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  122034. * @param maxCapacity defines the maximum size of each block (64 by default)
  122035. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  122036. * @returns the new octree
  122037. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  122038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  122039. */
  122040. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  122041. }
  122042. /**
  122043. * Defines the octree scene component responsible to manage any octrees
  122044. * in a given scene.
  122045. */
  122046. export class OctreeSceneComponent {
  122047. /**
  122048. * The component name help to identify the component in the list of scene components.
  122049. */
  122050. readonly name: string;
  122051. /**
  122052. * The scene the component belongs to.
  122053. */
  122054. scene: Scene;
  122055. /**
  122056. * Indicates if the meshes have been checked to make sure they are isEnabled()
  122057. */
  122058. readonly checksIsEnabled: boolean;
  122059. /**
  122060. * Creates a new instance of the component for the given scene
  122061. * @param scene Defines the scene to register the component in
  122062. */
  122063. constructor(scene: Scene);
  122064. /**
  122065. * Registers the component in a given scene
  122066. */
  122067. register(): void;
  122068. /**
  122069. * Return the list of active meshes
  122070. * @returns the list of active meshes
  122071. */
  122072. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  122073. /**
  122074. * Return the list of active sub meshes
  122075. * @param mesh The mesh to get the candidates sub meshes from
  122076. * @returns the list of active sub meshes
  122077. */
  122078. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  122079. private _tempRay;
  122080. /**
  122081. * Return the list of sub meshes intersecting with a given local ray
  122082. * @param mesh defines the mesh to find the submesh for
  122083. * @param localRay defines the ray in local space
  122084. * @returns the list of intersecting sub meshes
  122085. */
  122086. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  122087. /**
  122088. * Return the list of sub meshes colliding with a collider
  122089. * @param mesh defines the mesh to find the submesh for
  122090. * @param collider defines the collider to evaluate the collision against
  122091. * @returns the list of colliding sub meshes
  122092. */
  122093. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  122094. /**
  122095. * Rebuilds the elements related to this component in case of
  122096. * context lost for instance.
  122097. */
  122098. rebuild(): void;
  122099. /**
  122100. * Disposes the component and the associated ressources.
  122101. */
  122102. dispose(): void;
  122103. }
  122104. }
  122105. declare module BABYLON {
  122106. /**
  122107. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  122108. */
  122109. export class Gizmo implements IDisposable {
  122110. /** The utility layer the gizmo will be added to */
  122111. gizmoLayer: UtilityLayerRenderer;
  122112. /**
  122113. * The root mesh of the gizmo
  122114. */
  122115. _rootMesh: Mesh;
  122116. private _attachedMesh;
  122117. /**
  122118. * Ratio for the scale of the gizmo (Default: 1)
  122119. */
  122120. scaleRatio: number;
  122121. /**
  122122. * If a custom mesh has been set (Default: false)
  122123. */
  122124. protected _customMeshSet: boolean;
  122125. /**
  122126. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  122127. * * When set, interactions will be enabled
  122128. */
  122129. get attachedMesh(): Nullable<AbstractMesh>;
  122130. set attachedMesh(value: Nullable<AbstractMesh>);
  122131. /**
  122132. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122133. * @param mesh The mesh to replace the default mesh of the gizmo
  122134. */
  122135. setCustomMesh(mesh: Mesh): void;
  122136. /**
  122137. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  122138. */
  122139. updateGizmoRotationToMatchAttachedMesh: boolean;
  122140. /**
  122141. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  122142. */
  122143. updateGizmoPositionToMatchAttachedMesh: boolean;
  122144. /**
  122145. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  122146. */
  122147. updateScale: boolean;
  122148. protected _interactionsEnabled: boolean;
  122149. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122150. private _beforeRenderObserver;
  122151. private _tempVector;
  122152. /**
  122153. * Creates a gizmo
  122154. * @param gizmoLayer The utility layer the gizmo will be added to
  122155. */
  122156. constructor(
  122157. /** The utility layer the gizmo will be added to */
  122158. gizmoLayer?: UtilityLayerRenderer);
  122159. /**
  122160. * Updates the gizmo to match the attached mesh's position/rotation
  122161. */
  122162. protected _update(): void;
  122163. /**
  122164. * Disposes of the gizmo
  122165. */
  122166. dispose(): void;
  122167. }
  122168. }
  122169. declare module BABYLON {
  122170. /**
  122171. * Single plane drag gizmo
  122172. */
  122173. export class PlaneDragGizmo extends Gizmo {
  122174. /**
  122175. * Drag behavior responsible for the gizmos dragging interactions
  122176. */
  122177. dragBehavior: PointerDragBehavior;
  122178. private _pointerObserver;
  122179. /**
  122180. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122181. */
  122182. snapDistance: number;
  122183. /**
  122184. * Event that fires each time the gizmo snaps to a new location.
  122185. * * snapDistance is the the change in distance
  122186. */
  122187. onSnapObservable: Observable<{
  122188. snapDistance: number;
  122189. }>;
  122190. private _plane;
  122191. private _coloredMaterial;
  122192. private _hoverMaterial;
  122193. private _isEnabled;
  122194. private _parent;
  122195. /** @hidden */
  122196. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  122197. /** @hidden */
  122198. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122199. /**
  122200. * Creates a PlaneDragGizmo
  122201. * @param gizmoLayer The utility layer the gizmo will be added to
  122202. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  122203. * @param color The color of the gizmo
  122204. */
  122205. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122206. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122207. /**
  122208. * If the gizmo is enabled
  122209. */
  122210. set isEnabled(value: boolean);
  122211. get isEnabled(): boolean;
  122212. /**
  122213. * Disposes of the gizmo
  122214. */
  122215. dispose(): void;
  122216. }
  122217. }
  122218. declare module BABYLON {
  122219. /**
  122220. * Gizmo that enables dragging a mesh along 3 axis
  122221. */
  122222. export class PositionGizmo extends Gizmo {
  122223. /**
  122224. * Internal gizmo used for interactions on the x axis
  122225. */
  122226. xGizmo: AxisDragGizmo;
  122227. /**
  122228. * Internal gizmo used for interactions on the y axis
  122229. */
  122230. yGizmo: AxisDragGizmo;
  122231. /**
  122232. * Internal gizmo used for interactions on the z axis
  122233. */
  122234. zGizmo: AxisDragGizmo;
  122235. /**
  122236. * Internal gizmo used for interactions on the yz plane
  122237. */
  122238. xPlaneGizmo: PlaneDragGizmo;
  122239. /**
  122240. * Internal gizmo used for interactions on the xz plane
  122241. */
  122242. yPlaneGizmo: PlaneDragGizmo;
  122243. /**
  122244. * Internal gizmo used for interactions on the xy plane
  122245. */
  122246. zPlaneGizmo: PlaneDragGizmo;
  122247. /**
  122248. * private variables
  122249. */
  122250. private _meshAttached;
  122251. private _updateGizmoRotationToMatchAttachedMesh;
  122252. private _snapDistance;
  122253. private _scaleRatio;
  122254. /** Fires an event when any of it's sub gizmos are dragged */
  122255. onDragStartObservable: Observable<unknown>;
  122256. /** Fires an event when any of it's sub gizmos are released from dragging */
  122257. onDragEndObservable: Observable<unknown>;
  122258. /**
  122259. * If set to true, planar drag is enabled
  122260. */
  122261. private _planarGizmoEnabled;
  122262. get attachedMesh(): Nullable<AbstractMesh>;
  122263. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122264. /**
  122265. * Creates a PositionGizmo
  122266. * @param gizmoLayer The utility layer the gizmo will be added to
  122267. */
  122268. constructor(gizmoLayer?: UtilityLayerRenderer);
  122269. /**
  122270. * If the planar drag gizmo is enabled
  122271. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  122272. */
  122273. set planarGizmoEnabled(value: boolean);
  122274. get planarGizmoEnabled(): boolean;
  122275. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122276. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122277. /**
  122278. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122279. */
  122280. set snapDistance(value: number);
  122281. get snapDistance(): number;
  122282. /**
  122283. * Ratio for the scale of the gizmo (Default: 1)
  122284. */
  122285. set scaleRatio(value: number);
  122286. get scaleRatio(): number;
  122287. /**
  122288. * Disposes of the gizmo
  122289. */
  122290. dispose(): void;
  122291. /**
  122292. * CustomMeshes are not supported by this gizmo
  122293. * @param mesh The mesh to replace the default mesh of the gizmo
  122294. */
  122295. setCustomMesh(mesh: Mesh): void;
  122296. }
  122297. }
  122298. declare module BABYLON {
  122299. /**
  122300. * Single axis drag gizmo
  122301. */
  122302. export class AxisDragGizmo extends Gizmo {
  122303. /**
  122304. * Drag behavior responsible for the gizmos dragging interactions
  122305. */
  122306. dragBehavior: PointerDragBehavior;
  122307. private _pointerObserver;
  122308. /**
  122309. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122310. */
  122311. snapDistance: number;
  122312. /**
  122313. * Event that fires each time the gizmo snaps to a new location.
  122314. * * snapDistance is the the change in distance
  122315. */
  122316. onSnapObservable: Observable<{
  122317. snapDistance: number;
  122318. }>;
  122319. private _isEnabled;
  122320. private _parent;
  122321. private _arrow;
  122322. private _coloredMaterial;
  122323. private _hoverMaterial;
  122324. /** @hidden */
  122325. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  122326. /** @hidden */
  122327. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  122328. /**
  122329. * Creates an AxisDragGizmo
  122330. * @param gizmoLayer The utility layer the gizmo will be added to
  122331. * @param dragAxis The axis which the gizmo will be able to drag on
  122332. * @param color The color of the gizmo
  122333. */
  122334. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  122335. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122336. /**
  122337. * If the gizmo is enabled
  122338. */
  122339. set isEnabled(value: boolean);
  122340. get isEnabled(): boolean;
  122341. /**
  122342. * Disposes of the gizmo
  122343. */
  122344. dispose(): void;
  122345. }
  122346. }
  122347. declare module BABYLON.Debug {
  122348. /**
  122349. * The Axes viewer will show 3 axes in a specific point in space
  122350. */
  122351. export class AxesViewer {
  122352. private _xAxis;
  122353. private _yAxis;
  122354. private _zAxis;
  122355. private _scaleLinesFactor;
  122356. private _instanced;
  122357. /**
  122358. * Gets the hosting scene
  122359. */
  122360. scene: Scene;
  122361. /**
  122362. * Gets or sets a number used to scale line length
  122363. */
  122364. scaleLines: number;
  122365. /** Gets the node hierarchy used to render x-axis */
  122366. get xAxis(): TransformNode;
  122367. /** Gets the node hierarchy used to render y-axis */
  122368. get yAxis(): TransformNode;
  122369. /** Gets the node hierarchy used to render z-axis */
  122370. get zAxis(): TransformNode;
  122371. /**
  122372. * Creates a new AxesViewer
  122373. * @param scene defines the hosting scene
  122374. * @param scaleLines defines a number used to scale line length (1 by default)
  122375. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  122376. * @param xAxis defines the node hierarchy used to render the x-axis
  122377. * @param yAxis defines the node hierarchy used to render the y-axis
  122378. * @param zAxis defines the node hierarchy used to render the z-axis
  122379. */
  122380. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  122381. /**
  122382. * Force the viewer to update
  122383. * @param position defines the position of the viewer
  122384. * @param xaxis defines the x axis of the viewer
  122385. * @param yaxis defines the y axis of the viewer
  122386. * @param zaxis defines the z axis of the viewer
  122387. */
  122388. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  122389. /**
  122390. * Creates an instance of this axes viewer.
  122391. * @returns a new axes viewer with instanced meshes
  122392. */
  122393. createInstance(): AxesViewer;
  122394. /** Releases resources */
  122395. dispose(): void;
  122396. private static _SetRenderingGroupId;
  122397. }
  122398. }
  122399. declare module BABYLON.Debug {
  122400. /**
  122401. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  122402. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  122403. */
  122404. export class BoneAxesViewer extends AxesViewer {
  122405. /**
  122406. * Gets or sets the target mesh where to display the axes viewer
  122407. */
  122408. mesh: Nullable<Mesh>;
  122409. /**
  122410. * Gets or sets the target bone where to display the axes viewer
  122411. */
  122412. bone: Nullable<Bone>;
  122413. /** Gets current position */
  122414. pos: Vector3;
  122415. /** Gets direction of X axis */
  122416. xaxis: Vector3;
  122417. /** Gets direction of Y axis */
  122418. yaxis: Vector3;
  122419. /** Gets direction of Z axis */
  122420. zaxis: Vector3;
  122421. /**
  122422. * Creates a new BoneAxesViewer
  122423. * @param scene defines the hosting scene
  122424. * @param bone defines the target bone
  122425. * @param mesh defines the target mesh
  122426. * @param scaleLines defines a scaling factor for line length (1 by default)
  122427. */
  122428. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  122429. /**
  122430. * Force the viewer to update
  122431. */
  122432. update(): void;
  122433. /** Releases resources */
  122434. dispose(): void;
  122435. }
  122436. }
  122437. declare module BABYLON {
  122438. /**
  122439. * Interface used to define scene explorer extensibility option
  122440. */
  122441. export interface IExplorerExtensibilityOption {
  122442. /**
  122443. * Define the option label
  122444. */
  122445. label: string;
  122446. /**
  122447. * Defines the action to execute on click
  122448. */
  122449. action: (entity: any) => void;
  122450. }
  122451. /**
  122452. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  122453. */
  122454. export interface IExplorerExtensibilityGroup {
  122455. /**
  122456. * Defines a predicate to test if a given type mut be extended
  122457. */
  122458. predicate: (entity: any) => boolean;
  122459. /**
  122460. * Gets the list of options added to a type
  122461. */
  122462. entries: IExplorerExtensibilityOption[];
  122463. }
  122464. /**
  122465. * Interface used to define the options to use to create the Inspector
  122466. */
  122467. export interface IInspectorOptions {
  122468. /**
  122469. * Display in overlay mode (default: false)
  122470. */
  122471. overlay?: boolean;
  122472. /**
  122473. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  122474. */
  122475. globalRoot?: HTMLElement;
  122476. /**
  122477. * Display the Scene explorer
  122478. */
  122479. showExplorer?: boolean;
  122480. /**
  122481. * Display the property inspector
  122482. */
  122483. showInspector?: boolean;
  122484. /**
  122485. * Display in embed mode (both panes on the right)
  122486. */
  122487. embedMode?: boolean;
  122488. /**
  122489. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  122490. */
  122491. handleResize?: boolean;
  122492. /**
  122493. * Allow the panes to popup (default: true)
  122494. */
  122495. enablePopup?: boolean;
  122496. /**
  122497. * Allow the panes to be closed by users (default: true)
  122498. */
  122499. enableClose?: boolean;
  122500. /**
  122501. * Optional list of extensibility entries
  122502. */
  122503. explorerExtensibility?: IExplorerExtensibilityGroup[];
  122504. /**
  122505. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  122506. */
  122507. inspectorURL?: string;
  122508. /**
  122509. * Optional initial tab (default to DebugLayerTab.Properties)
  122510. */
  122511. initialTab?: DebugLayerTab;
  122512. }
  122513. interface Scene {
  122514. /**
  122515. * @hidden
  122516. * Backing field
  122517. */
  122518. _debugLayer: DebugLayer;
  122519. /**
  122520. * Gets the debug layer (aka Inspector) associated with the scene
  122521. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122522. */
  122523. debugLayer: DebugLayer;
  122524. }
  122525. /**
  122526. * Enum of inspector action tab
  122527. */
  122528. export enum DebugLayerTab {
  122529. /**
  122530. * Properties tag (default)
  122531. */
  122532. Properties = 0,
  122533. /**
  122534. * Debug tab
  122535. */
  122536. Debug = 1,
  122537. /**
  122538. * Statistics tab
  122539. */
  122540. Statistics = 2,
  122541. /**
  122542. * Tools tab
  122543. */
  122544. Tools = 3,
  122545. /**
  122546. * Settings tab
  122547. */
  122548. Settings = 4
  122549. }
  122550. /**
  122551. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122552. * what is happening in your scene
  122553. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122554. */
  122555. export class DebugLayer {
  122556. /**
  122557. * Define the url to get the inspector script from.
  122558. * By default it uses the babylonjs CDN.
  122559. * @ignoreNaming
  122560. */
  122561. static InspectorURL: string;
  122562. private _scene;
  122563. private BJSINSPECTOR;
  122564. private _onPropertyChangedObservable?;
  122565. /**
  122566. * Observable triggered when a property is changed through the inspector.
  122567. */
  122568. get onPropertyChangedObservable(): any;
  122569. /**
  122570. * Instantiates a new debug layer.
  122571. * The debug layer (aka Inspector) is the go to tool in order to better understand
  122572. * what is happening in your scene
  122573. * @see http://doc.babylonjs.com/features/playground_debuglayer
  122574. * @param scene Defines the scene to inspect
  122575. */
  122576. constructor(scene: Scene);
  122577. /** Creates the inspector window. */
  122578. private _createInspector;
  122579. /**
  122580. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  122581. * @param entity defines the entity to select
  122582. * @param lineContainerTitle defines the specific block to highlight
  122583. */
  122584. select(entity: any, lineContainerTitle?: string): void;
  122585. /** Get the inspector from bundle or global */
  122586. private _getGlobalInspector;
  122587. /**
  122588. * Get if the inspector is visible or not.
  122589. * @returns true if visible otherwise, false
  122590. */
  122591. isVisible(): boolean;
  122592. /**
  122593. * Hide the inspector and close its window.
  122594. */
  122595. hide(): void;
  122596. /**
  122597. * Launch the debugLayer.
  122598. * @param config Define the configuration of the inspector
  122599. * @return a promise fulfilled when the debug layer is visible
  122600. */
  122601. show(config?: IInspectorOptions): Promise<DebugLayer>;
  122602. }
  122603. }
  122604. declare module BABYLON {
  122605. /**
  122606. * Class containing static functions to help procedurally build meshes
  122607. */
  122608. export class BoxBuilder {
  122609. /**
  122610. * Creates a box mesh
  122611. * * The parameter `size` sets the size (float) of each box side (default 1)
  122612. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122613. * * 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)
  122614. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122618. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122619. * @param name defines the name of the mesh
  122620. * @param options defines the options used to create the mesh
  122621. * @param scene defines the hosting scene
  122622. * @returns the box mesh
  122623. */
  122624. static CreateBox(name: string, options: {
  122625. size?: number;
  122626. width?: number;
  122627. height?: number;
  122628. depth?: number;
  122629. faceUV?: Vector4[];
  122630. faceColors?: Color4[];
  122631. sideOrientation?: number;
  122632. frontUVs?: Vector4;
  122633. backUVs?: Vector4;
  122634. wrap?: boolean;
  122635. topBaseAt?: number;
  122636. bottomBaseAt?: number;
  122637. updatable?: boolean;
  122638. }, scene?: Nullable<Scene>): Mesh;
  122639. }
  122640. }
  122641. declare module BABYLON.Debug {
  122642. /**
  122643. * Used to show the physics impostor around the specific mesh
  122644. */
  122645. export class PhysicsViewer {
  122646. /** @hidden */
  122647. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  122648. /** @hidden */
  122649. protected _meshes: Array<Nullable<AbstractMesh>>;
  122650. /** @hidden */
  122651. protected _scene: Nullable<Scene>;
  122652. /** @hidden */
  122653. protected _numMeshes: number;
  122654. /** @hidden */
  122655. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  122656. private _renderFunction;
  122657. private _utilityLayer;
  122658. private _debugBoxMesh;
  122659. private _debugSphereMesh;
  122660. private _debugCylinderMesh;
  122661. private _debugMaterial;
  122662. private _debugMeshMeshes;
  122663. /**
  122664. * Creates a new PhysicsViewer
  122665. * @param scene defines the hosting scene
  122666. */
  122667. constructor(scene: Scene);
  122668. /** @hidden */
  122669. protected _updateDebugMeshes(): void;
  122670. /**
  122671. * Renders a specified physic impostor
  122672. * @param impostor defines the impostor to render
  122673. * @param targetMesh defines the mesh represented by the impostor
  122674. * @returns the new debug mesh used to render the impostor
  122675. */
  122676. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  122677. /**
  122678. * Hides a specified physic impostor
  122679. * @param impostor defines the impostor to hide
  122680. */
  122681. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  122682. private _getDebugMaterial;
  122683. private _getDebugBoxMesh;
  122684. private _getDebugSphereMesh;
  122685. private _getDebugCylinderMesh;
  122686. private _getDebugMeshMesh;
  122687. private _getDebugMesh;
  122688. /** Releases all resources */
  122689. dispose(): void;
  122690. }
  122691. }
  122692. declare module BABYLON {
  122693. /**
  122694. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122695. * in order to better appreciate the issue one might have.
  122696. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122697. */
  122698. export class RayHelper {
  122699. /**
  122700. * Defines the ray we are currently tryin to visualize.
  122701. */
  122702. ray: Nullable<Ray>;
  122703. private _renderPoints;
  122704. private _renderLine;
  122705. private _renderFunction;
  122706. private _scene;
  122707. private _updateToMeshFunction;
  122708. private _attachedToMesh;
  122709. private _meshSpaceDirection;
  122710. private _meshSpaceOrigin;
  122711. /**
  122712. * Helper function to create a colored helper in a scene in one line.
  122713. * @param ray Defines the ray we are currently tryin to visualize
  122714. * @param scene Defines the scene the ray is used in
  122715. * @param color Defines the color we want to see the ray in
  122716. * @returns The newly created ray helper.
  122717. */
  122718. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  122719. /**
  122720. * Instantiate a new ray helper.
  122721. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  122722. * in order to better appreciate the issue one might have.
  122723. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  122724. * @param ray Defines the ray we are currently tryin to visualize
  122725. */
  122726. constructor(ray: Ray);
  122727. /**
  122728. * Shows the ray we are willing to debug.
  122729. * @param scene Defines the scene the ray needs to be rendered in
  122730. * @param color Defines the color the ray needs to be rendered in
  122731. */
  122732. show(scene: Scene, color?: Color3): void;
  122733. /**
  122734. * Hides the ray we are debugging.
  122735. */
  122736. hide(): void;
  122737. private _render;
  122738. /**
  122739. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  122740. * @param mesh Defines the mesh we want the helper attached to
  122741. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  122742. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  122743. * @param length Defines the length of the ray
  122744. */
  122745. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  122746. /**
  122747. * Detach the ray helper from the mesh it has previously been attached to.
  122748. */
  122749. detachFromMesh(): void;
  122750. private _updateToMesh;
  122751. /**
  122752. * Dispose the helper and release its associated resources.
  122753. */
  122754. dispose(): void;
  122755. }
  122756. }
  122757. declare module BABYLON.Debug {
  122758. /**
  122759. * Class used to render a debug view of a given skeleton
  122760. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  122761. */
  122762. export class SkeletonViewer {
  122763. /** defines the skeleton to render */
  122764. skeleton: Skeleton;
  122765. /** defines the mesh attached to the skeleton */
  122766. mesh: AbstractMesh;
  122767. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  122768. autoUpdateBonesMatrices: boolean;
  122769. /** defines the rendering group id to use with the viewer */
  122770. renderingGroupId: number;
  122771. /** Gets or sets the color used to render the skeleton */
  122772. color: Color3;
  122773. private _scene;
  122774. private _debugLines;
  122775. private _debugMesh;
  122776. private _isEnabled;
  122777. private _renderFunction;
  122778. private _utilityLayer;
  122779. /**
  122780. * Returns the mesh used to render the bones
  122781. */
  122782. get debugMesh(): Nullable<LinesMesh>;
  122783. /**
  122784. * Creates a new SkeletonViewer
  122785. * @param skeleton defines the skeleton to render
  122786. * @param mesh defines the mesh attached to the skeleton
  122787. * @param scene defines the hosting scene
  122788. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  122789. * @param renderingGroupId defines the rendering group id to use with the viewer
  122790. */
  122791. constructor(
  122792. /** defines the skeleton to render */
  122793. skeleton: Skeleton,
  122794. /** defines the mesh attached to the skeleton */
  122795. mesh: AbstractMesh, scene: Scene,
  122796. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  122797. autoUpdateBonesMatrices?: boolean,
  122798. /** defines the rendering group id to use with the viewer */
  122799. renderingGroupId?: number);
  122800. /** Gets or sets a boolean indicating if the viewer is enabled */
  122801. set isEnabled(value: boolean);
  122802. get isEnabled(): boolean;
  122803. private _getBonePosition;
  122804. private _getLinesForBonesWithLength;
  122805. private _getLinesForBonesNoLength;
  122806. /** Update the viewer to sync with current skeleton state */
  122807. update(): void;
  122808. /** Release associated resources */
  122809. dispose(): void;
  122810. }
  122811. }
  122812. declare module BABYLON {
  122813. /**
  122814. * This class will take all inputs from Keyboard, Pointer, and
  122815. * any Gamepads and provide a polling system that all devices
  122816. * will use. This class assumes that there will only be one
  122817. * pointer device and one keyboard.
  122818. */
  122819. export class DeviceInputSystem implements IDisposable {
  122820. /** POINTER_DEVICE */
  122821. static readonly POINTER_DEVICE: string;
  122822. /** KEYBOARD_DEVICE */
  122823. static readonly KEYBOARD_DEVICE: string;
  122824. /**
  122825. * Observable to be triggered when a device is connected
  122826. */
  122827. onDeviceConnectedObservable: Observable<string>;
  122828. /**
  122829. * Observable to be triggered when a device is disconnected
  122830. */
  122831. onDeviceDisconnectedObservable: Observable<string>;
  122832. private _inputs;
  122833. private _gamepads;
  122834. private _keyboardActive;
  122835. private _pointerActive;
  122836. private _elementToAttachTo;
  122837. private _keyboardDownEvent;
  122838. private _keyboardUpEvent;
  122839. private _pointerMoveEvent;
  122840. private _pointerDownEvent;
  122841. private _pointerUpEvent;
  122842. private _gamepadConnectedEvent;
  122843. private _gamepadDisconnectedEvent;
  122844. private static _MAX_KEYCODES;
  122845. private static _MAX_POINTER_INPUTS;
  122846. /**
  122847. * Default Constructor
  122848. * @param engine - engine to pull input element from
  122849. */
  122850. constructor(engine: Engine);
  122851. /**
  122852. * Checks for current device input value, given an id and input index
  122853. * @param deviceName Id of connected device
  122854. * @param inputIndex Index of device input
  122855. * @returns Current value of input
  122856. */
  122857. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  122858. /**
  122859. * Dispose of all the eventlisteners and clears the observables
  122860. */
  122861. dispose(): void;
  122862. /**
  122863. * Add device and inputs to device map
  122864. * @param deviceName Assigned name of device (may be SN)
  122865. * @param numberOfInputs Number of input entries to create for given device
  122866. */
  122867. private _registerDevice;
  122868. /**
  122869. * Given a specific device name, remove that device from the device map
  122870. * @param deviceName Name of device to be removed
  122871. */
  122872. private _unregisterDevice;
  122873. /**
  122874. * Handle all actions that come from keyboard interaction
  122875. */
  122876. private _handleKeyActions;
  122877. /**
  122878. * Handle all actions that come from pointer interaction
  122879. */
  122880. private _handlePointerActions;
  122881. /**
  122882. * Handle all actions that come from gamepad interaction
  122883. */
  122884. private _handleGamepadActions;
  122885. /**
  122886. * Update all non-event based devices with each frame
  122887. */
  122888. private _updateDevice;
  122889. }
  122890. }
  122891. declare module BABYLON {
  122892. /**
  122893. * Options to create the null engine
  122894. */
  122895. export class NullEngineOptions {
  122896. /**
  122897. * Render width (Default: 512)
  122898. */
  122899. renderWidth: number;
  122900. /**
  122901. * Render height (Default: 256)
  122902. */
  122903. renderHeight: number;
  122904. /**
  122905. * Texture size (Default: 512)
  122906. */
  122907. textureSize: number;
  122908. /**
  122909. * If delta time between frames should be constant
  122910. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122911. */
  122912. deterministicLockstep: boolean;
  122913. /**
  122914. * Maximum about of steps between frames (Default: 4)
  122915. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122916. */
  122917. lockstepMaxSteps: number;
  122918. }
  122919. /**
  122920. * The null engine class provides support for headless version of babylon.js.
  122921. * This can be used in server side scenario or for testing purposes
  122922. */
  122923. export class NullEngine extends Engine {
  122924. private _options;
  122925. /**
  122926. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122927. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122928. * @returns true if engine is in deterministic lock step mode
  122929. */
  122930. isDeterministicLockStep(): boolean;
  122931. /**
  122932. * Gets the max steps when engine is running in deterministic lock step
  122933. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122934. * @returns the max steps
  122935. */
  122936. getLockstepMaxSteps(): number;
  122937. /**
  122938. * Gets the current hardware scaling level.
  122939. * By default the hardware scaling level is computed from the window device ratio.
  122940. * 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.
  122941. * @returns a number indicating the current hardware scaling level
  122942. */
  122943. getHardwareScalingLevel(): number;
  122944. constructor(options?: NullEngineOptions);
  122945. /**
  122946. * Creates a vertex buffer
  122947. * @param vertices the data for the vertex buffer
  122948. * @returns the new WebGL static buffer
  122949. */
  122950. createVertexBuffer(vertices: FloatArray): DataBuffer;
  122951. /**
  122952. * Creates a new index buffer
  122953. * @param indices defines the content of the index buffer
  122954. * @param updatable defines if the index buffer must be updatable
  122955. * @returns a new webGL buffer
  122956. */
  122957. createIndexBuffer(indices: IndicesArray): DataBuffer;
  122958. /**
  122959. * Clear the current render buffer or the current render target (if any is set up)
  122960. * @param color defines the color to use
  122961. * @param backBuffer defines if the back buffer must be cleared
  122962. * @param depth defines if the depth buffer must be cleared
  122963. * @param stencil defines if the stencil buffer must be cleared
  122964. */
  122965. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122966. /**
  122967. * Gets the current render width
  122968. * @param useScreen defines if screen size must be used (or the current render target if any)
  122969. * @returns a number defining the current render width
  122970. */
  122971. getRenderWidth(useScreen?: boolean): number;
  122972. /**
  122973. * Gets the current render height
  122974. * @param useScreen defines if screen size must be used (or the current render target if any)
  122975. * @returns a number defining the current render height
  122976. */
  122977. getRenderHeight(useScreen?: boolean): number;
  122978. /**
  122979. * Set the WebGL's viewport
  122980. * @param viewport defines the viewport element to be used
  122981. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  122982. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  122983. */
  122984. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  122985. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  122986. /**
  122987. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  122988. * @param pipelineContext defines the pipeline context to use
  122989. * @param uniformsNames defines the list of uniform names
  122990. * @returns an array of webGL uniform locations
  122991. */
  122992. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  122993. /**
  122994. * Gets the lsit of active attributes for a given webGL program
  122995. * @param pipelineContext defines the pipeline context to use
  122996. * @param attributesNames defines the list of attribute names to get
  122997. * @returns an array of indices indicating the offset of each attribute
  122998. */
  122999. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  123000. /**
  123001. * Binds an effect to the webGL context
  123002. * @param effect defines the effect to bind
  123003. */
  123004. bindSamplers(effect: Effect): void;
  123005. /**
  123006. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  123007. * @param effect defines the effect to activate
  123008. */
  123009. enableEffect(effect: Effect): void;
  123010. /**
  123011. * Set various states to the webGL context
  123012. * @param culling defines backface culling state
  123013. * @param zOffset defines the value to apply to zOffset (0 by default)
  123014. * @param force defines if states must be applied even if cache is up to date
  123015. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  123016. */
  123017. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  123018. /**
  123019. * Set the value of an uniform to an array of int32
  123020. * @param uniform defines the webGL uniform location where to store the value
  123021. * @param array defines the array of int32 to store
  123022. */
  123023. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  123024. /**
  123025. * Set the value of an uniform to an array of int32 (stored as vec2)
  123026. * @param uniform defines the webGL uniform location where to store the value
  123027. * @param array defines the array of int32 to store
  123028. */
  123029. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  123030. /**
  123031. * Set the value of an uniform to an array of int32 (stored as vec3)
  123032. * @param uniform defines the webGL uniform location where to store the value
  123033. * @param array defines the array of int32 to store
  123034. */
  123035. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  123036. /**
  123037. * Set the value of an uniform to an array of int32 (stored as vec4)
  123038. * @param uniform defines the webGL uniform location where to store the value
  123039. * @param array defines the array of int32 to store
  123040. */
  123041. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  123042. /**
  123043. * Set the value of an uniform to an array of float32
  123044. * @param uniform defines the webGL uniform location where to store the value
  123045. * @param array defines the array of float32 to store
  123046. */
  123047. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  123048. /**
  123049. * Set the value of an uniform to an array of float32 (stored as vec2)
  123050. * @param uniform defines the webGL uniform location where to store the value
  123051. * @param array defines the array of float32 to store
  123052. */
  123053. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  123054. /**
  123055. * Set the value of an uniform to an array of float32 (stored as vec3)
  123056. * @param uniform defines the webGL uniform location where to store the value
  123057. * @param array defines the array of float32 to store
  123058. */
  123059. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  123060. /**
  123061. * Set the value of an uniform to an array of float32 (stored as vec4)
  123062. * @param uniform defines the webGL uniform location where to store the value
  123063. * @param array defines the array of float32 to store
  123064. */
  123065. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  123066. /**
  123067. * Set the value of an uniform to an array of number
  123068. * @param uniform defines the webGL uniform location where to store the value
  123069. * @param array defines the array of number to store
  123070. */
  123071. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  123072. /**
  123073. * Set the value of an uniform to an array of number (stored as vec2)
  123074. * @param uniform defines the webGL uniform location where to store the value
  123075. * @param array defines the array of number to store
  123076. */
  123077. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  123078. /**
  123079. * Set the value of an uniform to an array of number (stored as vec3)
  123080. * @param uniform defines the webGL uniform location where to store the value
  123081. * @param array defines the array of number to store
  123082. */
  123083. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  123084. /**
  123085. * Set the value of an uniform to an array of number (stored as vec4)
  123086. * @param uniform defines the webGL uniform location where to store the value
  123087. * @param array defines the array of number to store
  123088. */
  123089. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  123090. /**
  123091. * Set the value of an uniform to an array of float32 (stored as matrices)
  123092. * @param uniform defines the webGL uniform location where to store the value
  123093. * @param matrices defines the array of float32 to store
  123094. */
  123095. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  123096. /**
  123097. * Set the value of an uniform to a matrix (3x3)
  123098. * @param uniform defines the webGL uniform location where to store the value
  123099. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  123100. */
  123101. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123102. /**
  123103. * Set the value of an uniform to a matrix (2x2)
  123104. * @param uniform defines the webGL uniform location where to store the value
  123105. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  123106. */
  123107. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  123108. /**
  123109. * Set the value of an uniform to a number (float)
  123110. * @param uniform defines the webGL uniform location where to store the value
  123111. * @param value defines the float number to store
  123112. */
  123113. setFloat(uniform: WebGLUniformLocation, value: number): void;
  123114. /**
  123115. * Set the value of an uniform to a vec2
  123116. * @param uniform defines the webGL uniform location where to store the value
  123117. * @param x defines the 1st component of the value
  123118. * @param y defines the 2nd component of the value
  123119. */
  123120. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  123121. /**
  123122. * Set the value of an uniform to a vec3
  123123. * @param uniform defines the webGL uniform location where to store the value
  123124. * @param x defines the 1st component of the value
  123125. * @param y defines the 2nd component of the value
  123126. * @param z defines the 3rd component of the value
  123127. */
  123128. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  123129. /**
  123130. * Set the value of an uniform to a boolean
  123131. * @param uniform defines the webGL uniform location where to store the value
  123132. * @param bool defines the boolean to store
  123133. */
  123134. setBool(uniform: WebGLUniformLocation, bool: number): void;
  123135. /**
  123136. * Set the value of an uniform to a vec4
  123137. * @param uniform defines the webGL uniform location where to store the value
  123138. * @param x defines the 1st component of the value
  123139. * @param y defines the 2nd component of the value
  123140. * @param z defines the 3rd component of the value
  123141. * @param w defines the 4th component of the value
  123142. */
  123143. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  123144. /**
  123145. * Sets the current alpha mode
  123146. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  123147. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  123148. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  123149. */
  123150. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  123151. /**
  123152. * Bind webGl buffers directly to the webGL context
  123153. * @param vertexBuffers defines the vertex buffer to bind
  123154. * @param indexBuffer defines the index buffer to bind
  123155. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  123156. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  123157. * @param effect defines the effect associated with the vertex buffer
  123158. */
  123159. bindBuffers(vertexBuffers: {
  123160. [key: string]: VertexBuffer;
  123161. }, indexBuffer: DataBuffer, effect: Effect): void;
  123162. /**
  123163. * Force the entire cache to be cleared
  123164. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  123165. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  123166. */
  123167. wipeCaches(bruteForce?: boolean): void;
  123168. /**
  123169. * Send a draw order
  123170. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  123171. * @param indexStart defines the starting index
  123172. * @param indexCount defines the number of index to draw
  123173. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123174. */
  123175. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  123176. /**
  123177. * Draw a list of indexed primitives
  123178. * @param fillMode defines the primitive to use
  123179. * @param indexStart defines the starting index
  123180. * @param indexCount defines the number of index to draw
  123181. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123182. */
  123183. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  123184. /**
  123185. * Draw a list of unindexed primitives
  123186. * @param fillMode defines the primitive to use
  123187. * @param verticesStart defines the index of first vertex to draw
  123188. * @param verticesCount defines the count of vertices to draw
  123189. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  123190. */
  123191. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  123192. /** @hidden */
  123193. _createTexture(): WebGLTexture;
  123194. /** @hidden */
  123195. _releaseTexture(texture: InternalTexture): void;
  123196. /**
  123197. * Usually called from Texture.ts.
  123198. * Passed information to create a WebGLTexture
  123199. * @param urlArg defines a value which contains one of the following:
  123200. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  123201. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  123202. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  123203. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  123204. * @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)
  123205. * @param scene needed for loading to the correct scene
  123206. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  123207. * @param onLoad optional callback to be called upon successful completion
  123208. * @param onError optional callback to be called upon failure
  123209. * @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
  123210. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  123211. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  123212. * @param forcedExtension defines the extension to use to pick the right loader
  123213. * @param mimeType defines an optional mime type
  123214. * @returns a InternalTexture for assignment back into BABYLON.Texture
  123215. */
  123216. 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;
  123217. /**
  123218. * Creates a new render target texture
  123219. * @param size defines the size of the texture
  123220. * @param options defines the options used to create the texture
  123221. * @returns a new render target texture stored in an InternalTexture
  123222. */
  123223. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  123224. /**
  123225. * Update the sampling mode of a given texture
  123226. * @param samplingMode defines the required sampling mode
  123227. * @param texture defines the texture to update
  123228. */
  123229. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  123230. /**
  123231. * Binds the frame buffer to the specified texture.
  123232. * @param texture The texture to render to or null for the default canvas
  123233. * @param faceIndex The face of the texture to render to in case of cube texture
  123234. * @param requiredWidth The width of the target to render to
  123235. * @param requiredHeight The height of the target to render to
  123236. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  123237. * @param lodLevel defines le lod level to bind to the frame buffer
  123238. */
  123239. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  123240. /**
  123241. * Unbind the current render target texture from the webGL context
  123242. * @param texture defines the render target texture to unbind
  123243. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123244. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123245. */
  123246. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  123247. /**
  123248. * Creates a dynamic vertex buffer
  123249. * @param vertices the data for the dynamic vertex buffer
  123250. * @returns the new WebGL dynamic buffer
  123251. */
  123252. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  123253. /**
  123254. * Update the content of a dynamic texture
  123255. * @param texture defines the texture to update
  123256. * @param canvas defines the canvas containing the source
  123257. * @param invertY defines if data must be stored with Y axis inverted
  123258. * @param premulAlpha defines if alpha is stored as premultiplied
  123259. * @param format defines the format of the data
  123260. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  123261. */
  123262. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  123263. /**
  123264. * Gets a boolean indicating if all created effects are ready
  123265. * @returns true if all effects are ready
  123266. */
  123267. areAllEffectsReady(): boolean;
  123268. /**
  123269. * @hidden
  123270. * Get the current error code of the webGL context
  123271. * @returns the error code
  123272. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  123273. */
  123274. getError(): number;
  123275. /** @hidden */
  123276. _getUnpackAlignement(): number;
  123277. /** @hidden */
  123278. _unpackFlipY(value: boolean): void;
  123279. /**
  123280. * Update a dynamic index buffer
  123281. * @param indexBuffer defines the target index buffer
  123282. * @param indices defines the data to update
  123283. * @param offset defines the offset in the target index buffer where update should start
  123284. */
  123285. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  123286. /**
  123287. * Updates a dynamic vertex buffer.
  123288. * @param vertexBuffer the vertex buffer to update
  123289. * @param vertices the data used to update the vertex buffer
  123290. * @param byteOffset the byte offset of the data (optional)
  123291. * @param byteLength the byte length of the data (optional)
  123292. */
  123293. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  123294. /** @hidden */
  123295. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  123296. /** @hidden */
  123297. _bindTexture(channel: number, texture: InternalTexture): void;
  123298. protected _deleteBuffer(buffer: WebGLBuffer): void;
  123299. /**
  123300. * 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
  123301. */
  123302. releaseEffects(): void;
  123303. displayLoadingUI(): void;
  123304. hideLoadingUI(): void;
  123305. /** @hidden */
  123306. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123307. /** @hidden */
  123308. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123309. /** @hidden */
  123310. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  123311. /** @hidden */
  123312. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  123313. }
  123314. }
  123315. declare module BABYLON {
  123316. /**
  123317. * @hidden
  123318. **/
  123319. export class _TimeToken {
  123320. _startTimeQuery: Nullable<WebGLQuery>;
  123321. _endTimeQuery: Nullable<WebGLQuery>;
  123322. _timeElapsedQuery: Nullable<WebGLQuery>;
  123323. _timeElapsedQueryEnded: boolean;
  123324. }
  123325. }
  123326. declare module BABYLON {
  123327. /** @hidden */
  123328. export class _OcclusionDataStorage {
  123329. /** @hidden */
  123330. occlusionInternalRetryCounter: number;
  123331. /** @hidden */
  123332. isOcclusionQueryInProgress: boolean;
  123333. /** @hidden */
  123334. isOccluded: boolean;
  123335. /** @hidden */
  123336. occlusionRetryCount: number;
  123337. /** @hidden */
  123338. occlusionType: number;
  123339. /** @hidden */
  123340. occlusionQueryAlgorithmType: number;
  123341. }
  123342. interface Engine {
  123343. /**
  123344. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  123345. * @return the new query
  123346. */
  123347. createQuery(): WebGLQuery;
  123348. /**
  123349. * Delete and release a webGL query
  123350. * @param query defines the query to delete
  123351. * @return the current engine
  123352. */
  123353. deleteQuery(query: WebGLQuery): Engine;
  123354. /**
  123355. * Check if a given query has resolved and got its value
  123356. * @param query defines the query to check
  123357. * @returns true if the query got its value
  123358. */
  123359. isQueryResultAvailable(query: WebGLQuery): boolean;
  123360. /**
  123361. * Gets the value of a given query
  123362. * @param query defines the query to check
  123363. * @returns the value of the query
  123364. */
  123365. getQueryResult(query: WebGLQuery): number;
  123366. /**
  123367. * Initiates an occlusion query
  123368. * @param algorithmType defines the algorithm to use
  123369. * @param query defines the query to use
  123370. * @returns the current engine
  123371. * @see http://doc.babylonjs.com/features/occlusionquery
  123372. */
  123373. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  123374. /**
  123375. * Ends an occlusion query
  123376. * @see http://doc.babylonjs.com/features/occlusionquery
  123377. * @param algorithmType defines the algorithm to use
  123378. * @returns the current engine
  123379. */
  123380. endOcclusionQuery(algorithmType: number): Engine;
  123381. /**
  123382. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  123383. * Please note that only one query can be issued at a time
  123384. * @returns a time token used to track the time span
  123385. */
  123386. startTimeQuery(): Nullable<_TimeToken>;
  123387. /**
  123388. * Ends a time query
  123389. * @param token defines the token used to measure the time span
  123390. * @returns the time spent (in ns)
  123391. */
  123392. endTimeQuery(token: _TimeToken): int;
  123393. /** @hidden */
  123394. _currentNonTimestampToken: Nullable<_TimeToken>;
  123395. /** @hidden */
  123396. _createTimeQuery(): WebGLQuery;
  123397. /** @hidden */
  123398. _deleteTimeQuery(query: WebGLQuery): void;
  123399. /** @hidden */
  123400. _getGlAlgorithmType(algorithmType: number): number;
  123401. /** @hidden */
  123402. _getTimeQueryResult(query: WebGLQuery): any;
  123403. /** @hidden */
  123404. _getTimeQueryAvailability(query: WebGLQuery): any;
  123405. }
  123406. interface AbstractMesh {
  123407. /**
  123408. * Backing filed
  123409. * @hidden
  123410. */
  123411. __occlusionDataStorage: _OcclusionDataStorage;
  123412. /**
  123413. * Access property
  123414. * @hidden
  123415. */
  123416. _occlusionDataStorage: _OcclusionDataStorage;
  123417. /**
  123418. * 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.
  123419. * The default value is -1 which means don't break the query and wait till the result
  123420. * @see http://doc.babylonjs.com/features/occlusionquery
  123421. */
  123422. occlusionRetryCount: number;
  123423. /**
  123424. * 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:
  123425. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  123426. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  123427. * * 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.
  123428. * @see http://doc.babylonjs.com/features/occlusionquery
  123429. */
  123430. occlusionType: number;
  123431. /**
  123432. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  123433. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  123434. * * 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.
  123435. * @see http://doc.babylonjs.com/features/occlusionquery
  123436. */
  123437. occlusionQueryAlgorithmType: number;
  123438. /**
  123439. * 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
  123440. * @see http://doc.babylonjs.com/features/occlusionquery
  123441. */
  123442. isOccluded: boolean;
  123443. /**
  123444. * Flag to check the progress status of the query
  123445. * @see http://doc.babylonjs.com/features/occlusionquery
  123446. */
  123447. isOcclusionQueryInProgress: boolean;
  123448. }
  123449. }
  123450. declare module BABYLON {
  123451. /** @hidden */
  123452. export var _forceTransformFeedbackToBundle: boolean;
  123453. interface Engine {
  123454. /**
  123455. * Creates a webGL transform feedback object
  123456. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  123457. * @returns the webGL transform feedback object
  123458. */
  123459. createTransformFeedback(): WebGLTransformFeedback;
  123460. /**
  123461. * Delete a webGL transform feedback object
  123462. * @param value defines the webGL transform feedback object to delete
  123463. */
  123464. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  123465. /**
  123466. * Bind a webGL transform feedback object to the webgl context
  123467. * @param value defines the webGL transform feedback object to bind
  123468. */
  123469. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  123470. /**
  123471. * Begins a transform feedback operation
  123472. * @param usePoints defines if points or triangles must be used
  123473. */
  123474. beginTransformFeedback(usePoints: boolean): void;
  123475. /**
  123476. * Ends a transform feedback operation
  123477. */
  123478. endTransformFeedback(): void;
  123479. /**
  123480. * Specify the varyings to use with transform feedback
  123481. * @param program defines the associated webGL program
  123482. * @param value defines the list of strings representing the varying names
  123483. */
  123484. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  123485. /**
  123486. * Bind a webGL buffer for a transform feedback operation
  123487. * @param value defines the webGL buffer to bind
  123488. */
  123489. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  123490. }
  123491. }
  123492. declare module BABYLON {
  123493. /**
  123494. * Creation options of the multi render target texture.
  123495. */
  123496. export interface IMultiRenderTargetOptions {
  123497. /**
  123498. * Define if the texture needs to create mip maps after render.
  123499. */
  123500. generateMipMaps?: boolean;
  123501. /**
  123502. * Define the types of all the draw buffers we want to create
  123503. */
  123504. types?: number[];
  123505. /**
  123506. * Define the sampling modes of all the draw buffers we want to create
  123507. */
  123508. samplingModes?: number[];
  123509. /**
  123510. * Define if a depth buffer is required
  123511. */
  123512. generateDepthBuffer?: boolean;
  123513. /**
  123514. * Define if a stencil buffer is required
  123515. */
  123516. generateStencilBuffer?: boolean;
  123517. /**
  123518. * Define if a depth texture is required instead of a depth buffer
  123519. */
  123520. generateDepthTexture?: boolean;
  123521. /**
  123522. * Define the number of desired draw buffers
  123523. */
  123524. textureCount?: number;
  123525. /**
  123526. * Define if aspect ratio should be adapted to the texture or stay the scene one
  123527. */
  123528. doNotChangeAspectRatio?: boolean;
  123529. /**
  123530. * Define the default type of the buffers we are creating
  123531. */
  123532. defaultType?: number;
  123533. }
  123534. /**
  123535. * A multi render target, like a render target provides the ability to render to a texture.
  123536. * Unlike the render target, it can render to several draw buffers in one draw.
  123537. * This is specially interesting in deferred rendering or for any effects requiring more than
  123538. * just one color from a single pass.
  123539. */
  123540. export class MultiRenderTarget extends RenderTargetTexture {
  123541. private _internalTextures;
  123542. private _textures;
  123543. private _multiRenderTargetOptions;
  123544. /**
  123545. * Get if draw buffers are currently supported by the used hardware and browser.
  123546. */
  123547. get isSupported(): boolean;
  123548. /**
  123549. * Get the list of textures generated by the multi render target.
  123550. */
  123551. get textures(): Texture[];
  123552. /**
  123553. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  123554. */
  123555. get depthTexture(): Texture;
  123556. /**
  123557. * Set the wrapping mode on U of all the textures we are rendering to.
  123558. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123559. */
  123560. set wrapU(wrap: number);
  123561. /**
  123562. * Set the wrapping mode on V of all the textures we are rendering to.
  123563. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  123564. */
  123565. set wrapV(wrap: number);
  123566. /**
  123567. * Instantiate a new multi render target texture.
  123568. * A multi render target, like a render target provides the ability to render to a texture.
  123569. * Unlike the render target, it can render to several draw buffers in one draw.
  123570. * This is specially interesting in deferred rendering or for any effects requiring more than
  123571. * just one color from a single pass.
  123572. * @param name Define the name of the texture
  123573. * @param size Define the size of the buffers to render to
  123574. * @param count Define the number of target we are rendering into
  123575. * @param scene Define the scene the texture belongs to
  123576. * @param options Define the options used to create the multi render target
  123577. */
  123578. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  123579. /** @hidden */
  123580. _rebuild(): void;
  123581. private _createInternalTextures;
  123582. private _createTextures;
  123583. /**
  123584. * Define the number of samples used if MSAA is enabled.
  123585. */
  123586. get samples(): number;
  123587. set samples(value: number);
  123588. /**
  123589. * Resize all the textures in the multi render target.
  123590. * Be carrefull as it will recreate all the data in the new texture.
  123591. * @param size Define the new size
  123592. */
  123593. resize(size: any): void;
  123594. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123595. /**
  123596. * Dispose the render targets and their associated resources
  123597. */
  123598. dispose(): void;
  123599. /**
  123600. * Release all the underlying texture used as draw buffers.
  123601. */
  123602. releaseInternalTextures(): void;
  123603. }
  123604. }
  123605. declare module BABYLON {
  123606. interface ThinEngine {
  123607. /**
  123608. * Unbind a list of render target textures from the webGL context
  123609. * This is used only when drawBuffer extension or webGL2 are active
  123610. * @param textures defines the render target textures to unbind
  123611. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  123612. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  123613. */
  123614. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  123615. /**
  123616. * Create a multi render target texture
  123617. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  123618. * @param size defines the size of the texture
  123619. * @param options defines the creation options
  123620. * @returns the cube texture as an InternalTexture
  123621. */
  123622. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  123623. /**
  123624. * Update the sample count for a given multiple render target texture
  123625. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123626. * @param textures defines the textures to update
  123627. * @param samples defines the sample count to set
  123628. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123629. */
  123630. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  123631. }
  123632. }
  123633. declare module BABYLON {
  123634. /**
  123635. * Class used to define an additional view for the engine
  123636. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123637. */
  123638. export class EngineView {
  123639. /** Defines the canvas where to render the view */
  123640. target: HTMLCanvasElement;
  123641. /** Defines an optional camera used to render the view (will use active camera else) */
  123642. camera?: Camera;
  123643. }
  123644. interface Engine {
  123645. /**
  123646. * Gets or sets the HTML element to use for attaching events
  123647. */
  123648. inputElement: Nullable<HTMLElement>;
  123649. /**
  123650. * Gets the current engine view
  123651. * @see https://doc.babylonjs.com/how_to/multi_canvases
  123652. */
  123653. activeView: Nullable<EngineView>;
  123654. /** Gets or sets the list of views */
  123655. views: EngineView[];
  123656. /**
  123657. * Register a new child canvas
  123658. * @param canvas defines the canvas to register
  123659. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  123660. * @returns the associated view
  123661. */
  123662. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  123663. /**
  123664. * Remove a registered child canvas
  123665. * @param canvas defines the canvas to remove
  123666. * @returns the current engine
  123667. */
  123668. unRegisterView(canvas: HTMLCanvasElement): Engine;
  123669. }
  123670. }
  123671. declare module BABYLON {
  123672. interface Engine {
  123673. /** @hidden */
  123674. _excludedCompressedTextures: string[];
  123675. /** @hidden */
  123676. _textureFormatInUse: string;
  123677. /**
  123678. * Gets the list of texture formats supported
  123679. */
  123680. readonly texturesSupported: Array<string>;
  123681. /**
  123682. * Gets the texture format in use
  123683. */
  123684. readonly textureFormatInUse: Nullable<string>;
  123685. /**
  123686. * Set the compressed texture extensions or file names to skip.
  123687. *
  123688. * @param skippedFiles defines the list of those texture files you want to skip
  123689. * Example: [".dds", ".env", "myfile.png"]
  123690. */
  123691. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  123692. /**
  123693. * Set the compressed texture format to use, based on the formats you have, and the formats
  123694. * supported by the hardware / browser.
  123695. *
  123696. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  123697. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  123698. * to API arguments needed to compressed textures. This puts the burden on the container
  123699. * generator to house the arcane code for determining these for current & future formats.
  123700. *
  123701. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  123702. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  123703. *
  123704. * Note: The result of this call is not taken into account when a texture is base64.
  123705. *
  123706. * @param formatsAvailable defines the list of those format families you have created
  123707. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  123708. *
  123709. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  123710. * @returns The extension selected.
  123711. */
  123712. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  123713. }
  123714. }
  123715. declare module BABYLON {
  123716. /**
  123717. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  123718. */
  123719. export interface CubeMapInfo {
  123720. /**
  123721. * The pixel array for the front face.
  123722. * This is stored in format, left to right, up to down format.
  123723. */
  123724. front: Nullable<ArrayBufferView>;
  123725. /**
  123726. * The pixel array for the back face.
  123727. * This is stored in format, left to right, up to down format.
  123728. */
  123729. back: Nullable<ArrayBufferView>;
  123730. /**
  123731. * The pixel array for the left face.
  123732. * This is stored in format, left to right, up to down format.
  123733. */
  123734. left: Nullable<ArrayBufferView>;
  123735. /**
  123736. * The pixel array for the right face.
  123737. * This is stored in format, left to right, up to down format.
  123738. */
  123739. right: Nullable<ArrayBufferView>;
  123740. /**
  123741. * The pixel array for the up face.
  123742. * This is stored in format, left to right, up to down format.
  123743. */
  123744. up: Nullable<ArrayBufferView>;
  123745. /**
  123746. * The pixel array for the down face.
  123747. * This is stored in format, left to right, up to down format.
  123748. */
  123749. down: Nullable<ArrayBufferView>;
  123750. /**
  123751. * The size of the cubemap stored.
  123752. *
  123753. * Each faces will be size * size pixels.
  123754. */
  123755. size: number;
  123756. /**
  123757. * The format of the texture.
  123758. *
  123759. * RGBA, RGB.
  123760. */
  123761. format: number;
  123762. /**
  123763. * The type of the texture data.
  123764. *
  123765. * UNSIGNED_INT, FLOAT.
  123766. */
  123767. type: number;
  123768. /**
  123769. * Specifies whether the texture is in gamma space.
  123770. */
  123771. gammaSpace: boolean;
  123772. }
  123773. /**
  123774. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  123775. */
  123776. export class PanoramaToCubeMapTools {
  123777. private static FACE_FRONT;
  123778. private static FACE_BACK;
  123779. private static FACE_RIGHT;
  123780. private static FACE_LEFT;
  123781. private static FACE_DOWN;
  123782. private static FACE_UP;
  123783. /**
  123784. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  123785. *
  123786. * @param float32Array The source data.
  123787. * @param inputWidth The width of the input panorama.
  123788. * @param inputHeight The height of the input panorama.
  123789. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  123790. * @return The cubemap data
  123791. */
  123792. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  123793. private static CreateCubemapTexture;
  123794. private static CalcProjectionSpherical;
  123795. }
  123796. }
  123797. declare module BABYLON {
  123798. /**
  123799. * Helper class dealing with the extraction of spherical polynomial dataArray
  123800. * from a cube map.
  123801. */
  123802. export class CubeMapToSphericalPolynomialTools {
  123803. private static FileFaces;
  123804. /**
  123805. * Converts a texture to the according Spherical Polynomial data.
  123806. * This extracts the first 3 orders only as they are the only one used in the lighting.
  123807. *
  123808. * @param texture The texture to extract the information from.
  123809. * @return The Spherical Polynomial data.
  123810. */
  123811. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  123812. /**
  123813. * Converts a cubemap to the according Spherical Polynomial data.
  123814. * This extracts the first 3 orders only as they are the only one used in the lighting.
  123815. *
  123816. * @param cubeInfo The Cube map to extract the information from.
  123817. * @return The Spherical Polynomial data.
  123818. */
  123819. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  123820. }
  123821. }
  123822. declare module BABYLON {
  123823. interface BaseTexture {
  123824. /**
  123825. * Get the polynomial representation of the texture data.
  123826. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  123827. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  123828. */
  123829. sphericalPolynomial: Nullable<SphericalPolynomial>;
  123830. }
  123831. }
  123832. declare module BABYLON {
  123833. /** @hidden */
  123834. export var rgbdEncodePixelShader: {
  123835. name: string;
  123836. shader: string;
  123837. };
  123838. }
  123839. declare module BABYLON {
  123840. /** @hidden */
  123841. export var rgbdDecodePixelShader: {
  123842. name: string;
  123843. shader: string;
  123844. };
  123845. }
  123846. declare module BABYLON {
  123847. /**
  123848. * Raw texture data and descriptor sufficient for WebGL texture upload
  123849. */
  123850. export interface EnvironmentTextureInfo {
  123851. /**
  123852. * Version of the environment map
  123853. */
  123854. version: number;
  123855. /**
  123856. * Width of image
  123857. */
  123858. width: number;
  123859. /**
  123860. * Irradiance information stored in the file.
  123861. */
  123862. irradiance: any;
  123863. /**
  123864. * Specular information stored in the file.
  123865. */
  123866. specular: any;
  123867. }
  123868. /**
  123869. * Defines One Image in the file. It requires only the position in the file
  123870. * as well as the length.
  123871. */
  123872. interface BufferImageData {
  123873. /**
  123874. * Length of the image data.
  123875. */
  123876. length: number;
  123877. /**
  123878. * Position of the data from the null terminator delimiting the end of the JSON.
  123879. */
  123880. position: number;
  123881. }
  123882. /**
  123883. * Defines the specular data enclosed in the file.
  123884. * This corresponds to the version 1 of the data.
  123885. */
  123886. export interface EnvironmentTextureSpecularInfoV1 {
  123887. /**
  123888. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  123889. */
  123890. specularDataPosition?: number;
  123891. /**
  123892. * This contains all the images data needed to reconstruct the cubemap.
  123893. */
  123894. mipmaps: Array<BufferImageData>;
  123895. /**
  123896. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  123897. */
  123898. lodGenerationScale: number;
  123899. }
  123900. /**
  123901. * Sets of helpers addressing the serialization and deserialization of environment texture
  123902. * stored in a BabylonJS env file.
  123903. * Those files are usually stored as .env files.
  123904. */
  123905. export class EnvironmentTextureTools {
  123906. /**
  123907. * Magic number identifying the env file.
  123908. */
  123909. private static _MagicBytes;
  123910. /**
  123911. * Gets the environment info from an env file.
  123912. * @param data The array buffer containing the .env bytes.
  123913. * @returns the environment file info (the json header) if successfully parsed.
  123914. */
  123915. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  123916. /**
  123917. * Creates an environment texture from a loaded cube texture.
  123918. * @param texture defines the cube texture to convert in env file
  123919. * @return a promise containing the environment data if succesfull.
  123920. */
  123921. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  123922. /**
  123923. * Creates a JSON representation of the spherical data.
  123924. * @param texture defines the texture containing the polynomials
  123925. * @return the JSON representation of the spherical info
  123926. */
  123927. private static _CreateEnvTextureIrradiance;
  123928. /**
  123929. * Creates the ArrayBufferViews used for initializing environment texture image data.
  123930. * @param data the image data
  123931. * @param info parameters that determine what views will be created for accessing the underlying buffer
  123932. * @return the views described by info providing access to the underlying buffer
  123933. */
  123934. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  123935. /**
  123936. * Uploads the texture info contained in the env file to the GPU.
  123937. * @param texture defines the internal texture to upload to
  123938. * @param data defines the data to load
  123939. * @param info defines the texture info retrieved through the GetEnvInfo method
  123940. * @returns a promise
  123941. */
  123942. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  123943. private static _OnImageReadyAsync;
  123944. /**
  123945. * Uploads the levels of image data to the GPU.
  123946. * @param texture defines the internal texture to upload to
  123947. * @param imageData defines the array buffer views of image data [mipmap][face]
  123948. * @returns a promise
  123949. */
  123950. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  123951. /**
  123952. * Uploads spherical polynomials information to the texture.
  123953. * @param texture defines the texture we are trying to upload the information to
  123954. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  123955. */
  123956. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  123957. /** @hidden */
  123958. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  123959. }
  123960. }
  123961. declare module BABYLON {
  123962. /**
  123963. * Contains position and normal vectors for a vertex
  123964. */
  123965. export class PositionNormalVertex {
  123966. /** the position of the vertex (defaut: 0,0,0) */
  123967. position: Vector3;
  123968. /** the normal of the vertex (defaut: 0,1,0) */
  123969. normal: Vector3;
  123970. /**
  123971. * Creates a PositionNormalVertex
  123972. * @param position the position of the vertex (defaut: 0,0,0)
  123973. * @param normal the normal of the vertex (defaut: 0,1,0)
  123974. */
  123975. constructor(
  123976. /** the position of the vertex (defaut: 0,0,0) */
  123977. position?: Vector3,
  123978. /** the normal of the vertex (defaut: 0,1,0) */
  123979. normal?: Vector3);
  123980. /**
  123981. * Clones the PositionNormalVertex
  123982. * @returns the cloned PositionNormalVertex
  123983. */
  123984. clone(): PositionNormalVertex;
  123985. }
  123986. /**
  123987. * Contains position, normal and uv vectors for a vertex
  123988. */
  123989. export class PositionNormalTextureVertex {
  123990. /** the position of the vertex (defaut: 0,0,0) */
  123991. position: Vector3;
  123992. /** the normal of the vertex (defaut: 0,1,0) */
  123993. normal: Vector3;
  123994. /** the uv of the vertex (default: 0,0) */
  123995. uv: Vector2;
  123996. /**
  123997. * Creates a PositionNormalTextureVertex
  123998. * @param position the position of the vertex (defaut: 0,0,0)
  123999. * @param normal the normal of the vertex (defaut: 0,1,0)
  124000. * @param uv the uv of the vertex (default: 0,0)
  124001. */
  124002. constructor(
  124003. /** the position of the vertex (defaut: 0,0,0) */
  124004. position?: Vector3,
  124005. /** the normal of the vertex (defaut: 0,1,0) */
  124006. normal?: Vector3,
  124007. /** the uv of the vertex (default: 0,0) */
  124008. uv?: Vector2);
  124009. /**
  124010. * Clones the PositionNormalTextureVertex
  124011. * @returns the cloned PositionNormalTextureVertex
  124012. */
  124013. clone(): PositionNormalTextureVertex;
  124014. }
  124015. }
  124016. declare module BABYLON {
  124017. /** @hidden */
  124018. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  124019. private _genericAttributeLocation;
  124020. private _varyingLocationCount;
  124021. private _varyingLocationMap;
  124022. private _replacements;
  124023. private _textureCount;
  124024. private _uniforms;
  124025. lineProcessor(line: string): string;
  124026. attributeProcessor(attribute: string): string;
  124027. varyingProcessor(varying: string, isFragment: boolean): string;
  124028. uniformProcessor(uniform: string): string;
  124029. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  124030. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  124031. }
  124032. }
  124033. declare module BABYLON {
  124034. /**
  124035. * Container for accessors for natively-stored mesh data buffers.
  124036. */
  124037. class NativeDataBuffer extends DataBuffer {
  124038. /**
  124039. * Accessor value used to identify/retrieve a natively-stored index buffer.
  124040. */
  124041. nativeIndexBuffer?: any;
  124042. /**
  124043. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  124044. */
  124045. nativeVertexBuffer?: any;
  124046. }
  124047. /** @hidden */
  124048. class NativeTexture extends InternalTexture {
  124049. getInternalTexture(): InternalTexture;
  124050. getViewCount(): number;
  124051. }
  124052. /** @hidden */
  124053. export class NativeEngine extends Engine {
  124054. private readonly _native;
  124055. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  124056. private readonly INVALID_HANDLE;
  124057. getHardwareScalingLevel(): number;
  124058. constructor();
  124059. dispose(): void;
  124060. /**
  124061. * Can be used to override the current requestAnimationFrame requester.
  124062. * @hidden
  124063. */
  124064. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  124065. /**
  124066. * Override default engine behavior.
  124067. * @param color
  124068. * @param backBuffer
  124069. * @param depth
  124070. * @param stencil
  124071. */
  124072. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  124073. /**
  124074. * Gets host document
  124075. * @returns the host document object
  124076. */
  124077. getHostDocument(): Nullable<Document>;
  124078. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  124079. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  124080. createVertexBuffer(data: DataArray): NativeDataBuffer;
  124081. recordVertexArrayObject(vertexBuffers: {
  124082. [key: string]: VertexBuffer;
  124083. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  124084. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124085. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  124086. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  124087. /**
  124088. * Draw a list of indexed primitives
  124089. * @param fillMode defines the primitive to use
  124090. * @param indexStart defines the starting index
  124091. * @param indexCount defines the number of index to draw
  124092. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124093. */
  124094. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  124095. /**
  124096. * Draw a list of unindexed primitives
  124097. * @param fillMode defines the primitive to use
  124098. * @param verticesStart defines the index of first vertex to draw
  124099. * @param verticesCount defines the count of vertices to draw
  124100. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124101. */
  124102. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124103. createPipelineContext(): IPipelineContext;
  124104. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  124105. /** @hidden */
  124106. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  124107. /** @hidden */
  124108. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  124109. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124110. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  124111. protected _setProgram(program: WebGLProgram): void;
  124112. _releaseEffect(effect: Effect): void;
  124113. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  124114. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  124115. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  124116. bindSamplers(effect: Effect): void;
  124117. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  124118. getRenderWidth(useScreen?: boolean): number;
  124119. getRenderHeight(useScreen?: boolean): number;
  124120. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  124121. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  124122. /**
  124123. * Set the z offset to apply to current rendering
  124124. * @param value defines the offset to apply
  124125. */
  124126. setZOffset(value: number): void;
  124127. /**
  124128. * Gets the current value of the zOffset
  124129. * @returns the current zOffset state
  124130. */
  124131. getZOffset(): number;
  124132. /**
  124133. * Enable or disable depth buffering
  124134. * @param enable defines the state to set
  124135. */
  124136. setDepthBuffer(enable: boolean): void;
  124137. /**
  124138. * Gets a boolean indicating if depth writing is enabled
  124139. * @returns the current depth writing state
  124140. */
  124141. getDepthWrite(): boolean;
  124142. /**
  124143. * Enable or disable depth writing
  124144. * @param enable defines the state to set
  124145. */
  124146. setDepthWrite(enable: boolean): void;
  124147. /**
  124148. * Enable or disable color writing
  124149. * @param enable defines the state to set
  124150. */
  124151. setColorWrite(enable: boolean): void;
  124152. /**
  124153. * Gets a boolean indicating if color writing is enabled
  124154. * @returns the current color writing state
  124155. */
  124156. getColorWrite(): boolean;
  124157. /**
  124158. * Sets alpha constants used by some alpha blending modes
  124159. * @param r defines the red component
  124160. * @param g defines the green component
  124161. * @param b defines the blue component
  124162. * @param a defines the alpha component
  124163. */
  124164. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  124165. /**
  124166. * Sets the current alpha mode
  124167. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  124168. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  124169. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124170. */
  124171. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  124172. /**
  124173. * Gets the current alpha mode
  124174. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  124175. * @returns the current alpha mode
  124176. */
  124177. getAlphaMode(): number;
  124178. setInt(uniform: WebGLUniformLocation, int: number): void;
  124179. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  124180. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  124181. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  124182. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  124183. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  124184. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  124185. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  124186. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  124187. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  124188. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  124189. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  124190. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  124191. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  124192. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124193. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  124194. setFloat(uniform: WebGLUniformLocation, value: number): void;
  124195. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  124196. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  124197. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  124198. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  124199. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  124200. wipeCaches(bruteForce?: boolean): void;
  124201. _createTexture(): WebGLTexture;
  124202. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  124203. /**
  124204. * Usually called from Texture.ts.
  124205. * Passed information to create a WebGLTexture
  124206. * @param url defines a value which contains one of the following:
  124207. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  124208. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  124209. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  124210. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  124211. * @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)
  124212. * @param scene needed for loading to the correct scene
  124213. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  124214. * @param onLoad optional callback to be called upon successful completion
  124215. * @param onError optional callback to be called upon failure
  124216. * @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
  124217. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  124218. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  124219. * @param forcedExtension defines the extension to use to pick the right loader
  124220. * @param mimeType defines an optional mime type
  124221. * @returns a InternalTexture for assignment back into BABYLON.Texture
  124222. */
  124223. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  124224. /**
  124225. * Creates a cube texture
  124226. * @param rootUrl defines the url where the files to load is located
  124227. * @param scene defines the current scene
  124228. * @param files defines the list of files to load (1 per face)
  124229. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  124230. * @param onLoad defines an optional callback raised when the texture is loaded
  124231. * @param onError defines an optional callback raised if there is an issue to load the texture
  124232. * @param format defines the format of the data
  124233. * @param forcedExtension defines the extension to use to pick the right loader
  124234. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  124235. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  124236. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  124237. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  124238. * @returns the cube texture as an InternalTexture
  124239. */
  124240. 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;
  124241. private _getSamplingFilter;
  124242. private static _GetNativeTextureFormat;
  124243. createRenderTargetTexture(size: number | {
  124244. width: number;
  124245. height: number;
  124246. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  124247. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  124248. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  124249. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  124250. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  124251. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  124252. /**
  124253. * Updates a dynamic vertex buffer.
  124254. * @param vertexBuffer the vertex buffer to update
  124255. * @param data the data used to update the vertex buffer
  124256. * @param byteOffset the byte offset of the data (optional)
  124257. * @param byteLength the byte length of the data (optional)
  124258. */
  124259. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  124260. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  124261. private _updateAnisotropicLevel;
  124262. private _getAddressMode;
  124263. /** @hidden */
  124264. _bindTexture(channel: number, texture: InternalTexture): void;
  124265. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  124266. releaseEffects(): void;
  124267. /** @hidden */
  124268. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124269. /** @hidden */
  124270. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124271. /** @hidden */
  124272. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  124273. /** @hidden */
  124274. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  124275. }
  124276. }
  124277. declare module BABYLON {
  124278. /**
  124279. * Gather the list of clipboard event types as constants.
  124280. */
  124281. export class ClipboardEventTypes {
  124282. /**
  124283. * The clipboard event is fired when a copy command is active (pressed).
  124284. */
  124285. static readonly COPY: number;
  124286. /**
  124287. * The clipboard event is fired when a cut command is active (pressed).
  124288. */
  124289. static readonly CUT: number;
  124290. /**
  124291. * The clipboard event is fired when a paste command is active (pressed).
  124292. */
  124293. static readonly PASTE: number;
  124294. }
  124295. /**
  124296. * This class is used to store clipboard related info for the onClipboardObservable event.
  124297. */
  124298. export class ClipboardInfo {
  124299. /**
  124300. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124301. */
  124302. type: number;
  124303. /**
  124304. * Defines the related dom event
  124305. */
  124306. event: ClipboardEvent;
  124307. /**
  124308. *Creates an instance of ClipboardInfo.
  124309. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  124310. * @param event Defines the related dom event
  124311. */
  124312. constructor(
  124313. /**
  124314. * Defines the type of event (BABYLON.ClipboardEventTypes)
  124315. */
  124316. type: number,
  124317. /**
  124318. * Defines the related dom event
  124319. */
  124320. event: ClipboardEvent);
  124321. /**
  124322. * Get the clipboard event's type from the keycode.
  124323. * @param keyCode Defines the keyCode for the current keyboard event.
  124324. * @return {number}
  124325. */
  124326. static GetTypeFromCharacter(keyCode: number): number;
  124327. }
  124328. }
  124329. declare module BABYLON {
  124330. /**
  124331. * Google Daydream controller
  124332. */
  124333. export class DaydreamController extends WebVRController {
  124334. /**
  124335. * Base Url for the controller model.
  124336. */
  124337. static MODEL_BASE_URL: string;
  124338. /**
  124339. * File name for the controller model.
  124340. */
  124341. static MODEL_FILENAME: string;
  124342. /**
  124343. * Gamepad Id prefix used to identify Daydream Controller.
  124344. */
  124345. static readonly GAMEPAD_ID_PREFIX: string;
  124346. /**
  124347. * Creates a new DaydreamController from a gamepad
  124348. * @param vrGamepad the gamepad that the controller should be created from
  124349. */
  124350. constructor(vrGamepad: any);
  124351. /**
  124352. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124353. * @param scene scene in which to add meshes
  124354. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124355. */
  124356. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124357. /**
  124358. * Called once for each button that changed state since the last frame
  124359. * @param buttonIdx Which button index changed
  124360. * @param state New state of the button
  124361. * @param changes Which properties on the state changed since last frame
  124362. */
  124363. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124364. }
  124365. }
  124366. declare module BABYLON {
  124367. /**
  124368. * Gear VR Controller
  124369. */
  124370. export class GearVRController extends WebVRController {
  124371. /**
  124372. * Base Url for the controller model.
  124373. */
  124374. static MODEL_BASE_URL: string;
  124375. /**
  124376. * File name for the controller model.
  124377. */
  124378. static MODEL_FILENAME: string;
  124379. /**
  124380. * Gamepad Id prefix used to identify this controller.
  124381. */
  124382. static readonly GAMEPAD_ID_PREFIX: string;
  124383. private readonly _buttonIndexToObservableNameMap;
  124384. /**
  124385. * Creates a new GearVRController from a gamepad
  124386. * @param vrGamepad the gamepad that the controller should be created from
  124387. */
  124388. constructor(vrGamepad: any);
  124389. /**
  124390. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124391. * @param scene scene in which to add meshes
  124392. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124393. */
  124394. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124395. /**
  124396. * Called once for each button that changed state since the last frame
  124397. * @param buttonIdx Which button index changed
  124398. * @param state New state of the button
  124399. * @param changes Which properties on the state changed since last frame
  124400. */
  124401. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124402. }
  124403. }
  124404. declare module BABYLON {
  124405. /**
  124406. * Generic Controller
  124407. */
  124408. export class GenericController extends WebVRController {
  124409. /**
  124410. * Base Url for the controller model.
  124411. */
  124412. static readonly MODEL_BASE_URL: string;
  124413. /**
  124414. * File name for the controller model.
  124415. */
  124416. static readonly MODEL_FILENAME: string;
  124417. /**
  124418. * Creates a new GenericController from a gamepad
  124419. * @param vrGamepad the gamepad that the controller should be created from
  124420. */
  124421. constructor(vrGamepad: any);
  124422. /**
  124423. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124424. * @param scene scene in which to add meshes
  124425. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124426. */
  124427. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124428. /**
  124429. * Called once for each button that changed state since the last frame
  124430. * @param buttonIdx Which button index changed
  124431. * @param state New state of the button
  124432. * @param changes Which properties on the state changed since last frame
  124433. */
  124434. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124435. }
  124436. }
  124437. declare module BABYLON {
  124438. /**
  124439. * Oculus Touch Controller
  124440. */
  124441. export class OculusTouchController extends WebVRController {
  124442. /**
  124443. * Base Url for the controller model.
  124444. */
  124445. static MODEL_BASE_URL: string;
  124446. /**
  124447. * File name for the left controller model.
  124448. */
  124449. static MODEL_LEFT_FILENAME: string;
  124450. /**
  124451. * File name for the right controller model.
  124452. */
  124453. static MODEL_RIGHT_FILENAME: string;
  124454. /**
  124455. * Base Url for the Quest controller model.
  124456. */
  124457. static QUEST_MODEL_BASE_URL: string;
  124458. /**
  124459. * @hidden
  124460. * If the controllers are running on a device that needs the updated Quest controller models
  124461. */
  124462. static _IsQuest: boolean;
  124463. /**
  124464. * Fired when the secondary trigger on this controller is modified
  124465. */
  124466. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  124467. /**
  124468. * Fired when the thumb rest on this controller is modified
  124469. */
  124470. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  124471. /**
  124472. * Creates a new OculusTouchController from a gamepad
  124473. * @param vrGamepad the gamepad that the controller should be created from
  124474. */
  124475. constructor(vrGamepad: any);
  124476. /**
  124477. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124478. * @param scene scene in which to add meshes
  124479. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124480. */
  124481. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124482. /**
  124483. * Fired when the A button on this controller is modified
  124484. */
  124485. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124486. /**
  124487. * Fired when the B button on this controller is modified
  124488. */
  124489. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124490. /**
  124491. * Fired when the X button on this controller is modified
  124492. */
  124493. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124494. /**
  124495. * Fired when the Y button on this controller is modified
  124496. */
  124497. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124498. /**
  124499. * Called once for each button that changed state since the last frame
  124500. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  124501. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  124502. * 2) secondary trigger (same)
  124503. * 3) A (right) X (left), touch, pressed = value
  124504. * 4) B / Y
  124505. * 5) thumb rest
  124506. * @param buttonIdx Which button index changed
  124507. * @param state New state of the button
  124508. * @param changes Which properties on the state changed since last frame
  124509. */
  124510. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124511. }
  124512. }
  124513. declare module BABYLON {
  124514. /**
  124515. * Vive Controller
  124516. */
  124517. export class ViveController extends WebVRController {
  124518. /**
  124519. * Base Url for the controller model.
  124520. */
  124521. static MODEL_BASE_URL: string;
  124522. /**
  124523. * File name for the controller model.
  124524. */
  124525. static MODEL_FILENAME: string;
  124526. /**
  124527. * Creates a new ViveController from a gamepad
  124528. * @param vrGamepad the gamepad that the controller should be created from
  124529. */
  124530. constructor(vrGamepad: any);
  124531. /**
  124532. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124533. * @param scene scene in which to add meshes
  124534. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124535. */
  124536. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  124537. /**
  124538. * Fired when the left button on this controller is modified
  124539. */
  124540. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124541. /**
  124542. * Fired when the right button on this controller is modified
  124543. */
  124544. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124545. /**
  124546. * Fired when the menu button on this controller is modified
  124547. */
  124548. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124549. /**
  124550. * Called once for each button that changed state since the last frame
  124551. * Vive mapping:
  124552. * 0: touchpad
  124553. * 1: trigger
  124554. * 2: left AND right buttons
  124555. * 3: menu button
  124556. * @param buttonIdx Which button index changed
  124557. * @param state New state of the button
  124558. * @param changes Which properties on the state changed since last frame
  124559. */
  124560. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124561. }
  124562. }
  124563. declare module BABYLON {
  124564. /**
  124565. * Defines the WindowsMotionController object that the state of the windows motion controller
  124566. */
  124567. export class WindowsMotionController extends WebVRController {
  124568. /**
  124569. * The base url used to load the left and right controller models
  124570. */
  124571. static MODEL_BASE_URL: string;
  124572. /**
  124573. * The name of the left controller model file
  124574. */
  124575. static MODEL_LEFT_FILENAME: string;
  124576. /**
  124577. * The name of the right controller model file
  124578. */
  124579. static MODEL_RIGHT_FILENAME: string;
  124580. /**
  124581. * The controller name prefix for this controller type
  124582. */
  124583. static readonly GAMEPAD_ID_PREFIX: string;
  124584. /**
  124585. * The controller id pattern for this controller type
  124586. */
  124587. private static readonly GAMEPAD_ID_PATTERN;
  124588. private _loadedMeshInfo;
  124589. protected readonly _mapping: {
  124590. buttons: string[];
  124591. buttonMeshNames: {
  124592. trigger: string;
  124593. menu: string;
  124594. grip: string;
  124595. thumbstick: string;
  124596. trackpad: string;
  124597. };
  124598. buttonObservableNames: {
  124599. trigger: string;
  124600. menu: string;
  124601. grip: string;
  124602. thumbstick: string;
  124603. trackpad: string;
  124604. };
  124605. axisMeshNames: string[];
  124606. pointingPoseMeshName: string;
  124607. };
  124608. /**
  124609. * Fired when the trackpad on this controller is clicked
  124610. */
  124611. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124612. /**
  124613. * Fired when the trackpad on this controller is modified
  124614. */
  124615. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124616. /**
  124617. * The current x and y values of this controller's trackpad
  124618. */
  124619. trackpad: StickValues;
  124620. /**
  124621. * Creates a new WindowsMotionController from a gamepad
  124622. * @param vrGamepad the gamepad that the controller should be created from
  124623. */
  124624. constructor(vrGamepad: any);
  124625. /**
  124626. * Fired when the trigger on this controller is modified
  124627. */
  124628. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124629. /**
  124630. * Fired when the menu button on this controller is modified
  124631. */
  124632. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124633. /**
  124634. * Fired when the grip button on this controller is modified
  124635. */
  124636. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124637. /**
  124638. * Fired when the thumbstick button on this controller is modified
  124639. */
  124640. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124641. /**
  124642. * Fired when the touchpad button on this controller is modified
  124643. */
  124644. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124645. /**
  124646. * Fired when the touchpad values on this controller are modified
  124647. */
  124648. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  124649. protected _updateTrackpad(): void;
  124650. /**
  124651. * Called once per frame by the engine.
  124652. */
  124653. update(): void;
  124654. /**
  124655. * Called once for each button that changed state since the last frame
  124656. * @param buttonIdx Which button index changed
  124657. * @param state New state of the button
  124658. * @param changes Which properties on the state changed since last frame
  124659. */
  124660. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  124661. /**
  124662. * Moves the buttons on the controller mesh based on their current state
  124663. * @param buttonName the name of the button to move
  124664. * @param buttonValue the value of the button which determines the buttons new position
  124665. */
  124666. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  124667. /**
  124668. * Moves the axis on the controller mesh based on its current state
  124669. * @param axis the index of the axis
  124670. * @param axisValue the value of the axis which determines the meshes new position
  124671. * @hidden
  124672. */
  124673. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  124674. /**
  124675. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  124676. * @param scene scene in which to add meshes
  124677. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  124678. */
  124679. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  124680. /**
  124681. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  124682. * can be transformed by button presses and axes values, based on this._mapping.
  124683. *
  124684. * @param scene scene in which the meshes exist
  124685. * @param meshes list of meshes that make up the controller model to process
  124686. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  124687. */
  124688. private processModel;
  124689. private createMeshInfo;
  124690. /**
  124691. * Gets the ray of the controller in the direction the controller is pointing
  124692. * @param length the length the resulting ray should be
  124693. * @returns a ray in the direction the controller is pointing
  124694. */
  124695. getForwardRay(length?: number): Ray;
  124696. /**
  124697. * Disposes of the controller
  124698. */
  124699. dispose(): void;
  124700. }
  124701. /**
  124702. * This class represents a new windows motion controller in XR.
  124703. */
  124704. export class XRWindowsMotionController extends WindowsMotionController {
  124705. /**
  124706. * Changing the original WIndowsMotionController mapping to fir the new mapping
  124707. */
  124708. protected readonly _mapping: {
  124709. buttons: string[];
  124710. buttonMeshNames: {
  124711. trigger: string;
  124712. menu: string;
  124713. grip: string;
  124714. thumbstick: string;
  124715. trackpad: string;
  124716. };
  124717. buttonObservableNames: {
  124718. trigger: string;
  124719. menu: string;
  124720. grip: string;
  124721. thumbstick: string;
  124722. trackpad: string;
  124723. };
  124724. axisMeshNames: string[];
  124725. pointingPoseMeshName: string;
  124726. };
  124727. /**
  124728. * Construct a new XR-Based windows motion controller
  124729. *
  124730. * @param gamepadInfo the gamepad object from the browser
  124731. */
  124732. constructor(gamepadInfo: any);
  124733. /**
  124734. * holds the thumbstick values (X,Y)
  124735. */
  124736. thumbstickValues: StickValues;
  124737. /**
  124738. * Fired when the thumbstick on this controller is clicked
  124739. */
  124740. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  124741. /**
  124742. * Fired when the thumbstick on this controller is modified
  124743. */
  124744. onThumbstickValuesChangedObservable: Observable<StickValues>;
  124745. /**
  124746. * Fired when the touchpad button on this controller is modified
  124747. */
  124748. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  124749. /**
  124750. * Fired when the touchpad values on this controller are modified
  124751. */
  124752. onTrackpadValuesChangedObservable: Observable<StickValues>;
  124753. /**
  124754. * Fired when the thumbstick button on this controller is modified
  124755. * here to prevent breaking changes
  124756. */
  124757. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  124758. /**
  124759. * updating the thumbstick(!) and not the trackpad.
  124760. * This is named this way due to the difference between WebVR and XR and to avoid
  124761. * changing the parent class.
  124762. */
  124763. protected _updateTrackpad(): void;
  124764. /**
  124765. * Disposes the class with joy
  124766. */
  124767. dispose(): void;
  124768. }
  124769. }
  124770. declare module BABYLON {
  124771. /**
  124772. * Class containing static functions to help procedurally build meshes
  124773. */
  124774. export class PolyhedronBuilder {
  124775. /**
  124776. * Creates a polyhedron mesh
  124777. * * 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
  124778. * * The parameter `size` (positive float, default 1) sets the polygon size
  124779. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124780. * * 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`
  124781. * * 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
  124782. * * 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)`)
  124783. * * 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
  124784. * * 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
  124785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124788. * @param name defines the name of the mesh
  124789. * @param options defines the options used to create the mesh
  124790. * @param scene defines the hosting scene
  124791. * @returns the polyhedron mesh
  124792. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124793. */
  124794. static CreatePolyhedron(name: string, options: {
  124795. type?: number;
  124796. size?: number;
  124797. sizeX?: number;
  124798. sizeY?: number;
  124799. sizeZ?: number;
  124800. custom?: any;
  124801. faceUV?: Vector4[];
  124802. faceColors?: Color4[];
  124803. flat?: boolean;
  124804. updatable?: boolean;
  124805. sideOrientation?: number;
  124806. frontUVs?: Vector4;
  124807. backUVs?: Vector4;
  124808. }, scene?: Nullable<Scene>): Mesh;
  124809. }
  124810. }
  124811. declare module BABYLON {
  124812. /**
  124813. * Gizmo that enables scaling a mesh along 3 axis
  124814. */
  124815. export class ScaleGizmo extends Gizmo {
  124816. /**
  124817. * Internal gizmo used for interactions on the x axis
  124818. */
  124819. xGizmo: AxisScaleGizmo;
  124820. /**
  124821. * Internal gizmo used for interactions on the y axis
  124822. */
  124823. yGizmo: AxisScaleGizmo;
  124824. /**
  124825. * Internal gizmo used for interactions on the z axis
  124826. */
  124827. zGizmo: AxisScaleGizmo;
  124828. /**
  124829. * Internal gizmo used to scale all axis equally
  124830. */
  124831. uniformScaleGizmo: AxisScaleGizmo;
  124832. private _meshAttached;
  124833. private _updateGizmoRotationToMatchAttachedMesh;
  124834. private _snapDistance;
  124835. private _scaleRatio;
  124836. private _uniformScalingMesh;
  124837. private _octahedron;
  124838. private _sensitivity;
  124839. /** Fires an event when any of it's sub gizmos are dragged */
  124840. onDragStartObservable: Observable<unknown>;
  124841. /** Fires an event when any of it's sub gizmos are released from dragging */
  124842. onDragEndObservable: Observable<unknown>;
  124843. get attachedMesh(): Nullable<AbstractMesh>;
  124844. set attachedMesh(mesh: Nullable<AbstractMesh>);
  124845. /**
  124846. * Creates a ScaleGizmo
  124847. * @param gizmoLayer The utility layer the gizmo will be added to
  124848. */
  124849. constructor(gizmoLayer?: UtilityLayerRenderer);
  124850. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  124851. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  124852. /**
  124853. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  124854. */
  124855. set snapDistance(value: number);
  124856. get snapDistance(): number;
  124857. /**
  124858. * Ratio for the scale of the gizmo (Default: 1)
  124859. */
  124860. set scaleRatio(value: number);
  124861. get scaleRatio(): number;
  124862. /**
  124863. * Sensitivity factor for dragging (Default: 1)
  124864. */
  124865. set sensitivity(value: number);
  124866. get sensitivity(): number;
  124867. /**
  124868. * Disposes of the gizmo
  124869. */
  124870. dispose(): void;
  124871. }
  124872. }
  124873. declare module BABYLON {
  124874. /**
  124875. * Single axis scale gizmo
  124876. */
  124877. export class AxisScaleGizmo extends Gizmo {
  124878. /**
  124879. * Drag behavior responsible for the gizmos dragging interactions
  124880. */
  124881. dragBehavior: PointerDragBehavior;
  124882. private _pointerObserver;
  124883. /**
  124884. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  124885. */
  124886. snapDistance: number;
  124887. /**
  124888. * Event that fires each time the gizmo snaps to a new location.
  124889. * * snapDistance is the the change in distance
  124890. */
  124891. onSnapObservable: Observable<{
  124892. snapDistance: number;
  124893. }>;
  124894. /**
  124895. * If the scaling operation should be done on all axis (default: false)
  124896. */
  124897. uniformScaling: boolean;
  124898. /**
  124899. * Custom sensitivity value for the drag strength
  124900. */
  124901. sensitivity: number;
  124902. private _isEnabled;
  124903. private _parent;
  124904. private _arrow;
  124905. private _coloredMaterial;
  124906. private _hoverMaterial;
  124907. /**
  124908. * Creates an AxisScaleGizmo
  124909. * @param gizmoLayer The utility layer the gizmo will be added to
  124910. * @param dragAxis The axis which the gizmo will be able to scale on
  124911. * @param color The color of the gizmo
  124912. */
  124913. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  124914. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  124915. /**
  124916. * If the gizmo is enabled
  124917. */
  124918. set isEnabled(value: boolean);
  124919. get isEnabled(): boolean;
  124920. /**
  124921. * Disposes of the gizmo
  124922. */
  124923. dispose(): void;
  124924. /**
  124925. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  124926. * @param mesh The mesh to replace the default mesh of the gizmo
  124927. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  124928. */
  124929. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  124930. }
  124931. }
  124932. declare module BABYLON {
  124933. /**
  124934. * Bounding box gizmo
  124935. */
  124936. export class BoundingBoxGizmo extends Gizmo {
  124937. private _lineBoundingBox;
  124938. private _rotateSpheresParent;
  124939. private _scaleBoxesParent;
  124940. private _boundingDimensions;
  124941. private _renderObserver;
  124942. private _pointerObserver;
  124943. private _scaleDragSpeed;
  124944. private _tmpQuaternion;
  124945. private _tmpVector;
  124946. private _tmpRotationMatrix;
  124947. /**
  124948. * 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)
  124949. */
  124950. ignoreChildren: boolean;
  124951. /**
  124952. * 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)
  124953. */
  124954. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  124955. /**
  124956. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  124957. */
  124958. rotationSphereSize: number;
  124959. /**
  124960. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  124961. */
  124962. scaleBoxSize: number;
  124963. /**
  124964. * 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)
  124965. */
  124966. fixedDragMeshScreenSize: boolean;
  124967. /**
  124968. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  124969. */
  124970. fixedDragMeshScreenSizeDistanceFactor: number;
  124971. /**
  124972. * Fired when a rotation sphere or scale box is dragged
  124973. */
  124974. onDragStartObservable: Observable<{}>;
  124975. /**
  124976. * Fired when a scale box is dragged
  124977. */
  124978. onScaleBoxDragObservable: Observable<{}>;
  124979. /**
  124980. * Fired when a scale box drag is ended
  124981. */
  124982. onScaleBoxDragEndObservable: Observable<{}>;
  124983. /**
  124984. * Fired when a rotation sphere is dragged
  124985. */
  124986. onRotationSphereDragObservable: Observable<{}>;
  124987. /**
  124988. * Fired when a rotation sphere drag is ended
  124989. */
  124990. onRotationSphereDragEndObservable: Observable<{}>;
  124991. /**
  124992. * 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)
  124993. */
  124994. scalePivot: Nullable<Vector3>;
  124995. /**
  124996. * Mesh used as a pivot to rotate the attached mesh
  124997. */
  124998. private _anchorMesh;
  124999. private _existingMeshScale;
  125000. private _dragMesh;
  125001. private pointerDragBehavior;
  125002. private coloredMaterial;
  125003. private hoverColoredMaterial;
  125004. /**
  125005. * Sets the color of the bounding box gizmo
  125006. * @param color the color to set
  125007. */
  125008. setColor(color: Color3): void;
  125009. /**
  125010. * Creates an BoundingBoxGizmo
  125011. * @param gizmoLayer The utility layer the gizmo will be added to
  125012. * @param color The color of the gizmo
  125013. */
  125014. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  125015. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125016. private _selectNode;
  125017. /**
  125018. * Updates the bounding box information for the Gizmo
  125019. */
  125020. updateBoundingBox(): void;
  125021. private _updateRotationSpheres;
  125022. private _updateScaleBoxes;
  125023. /**
  125024. * Enables rotation on the specified axis and disables rotation on the others
  125025. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  125026. */
  125027. setEnabledRotationAxis(axis: string): void;
  125028. /**
  125029. * Enables/disables scaling
  125030. * @param enable if scaling should be enabled
  125031. * @param homogeneousScaling defines if scaling should only be homogeneous
  125032. */
  125033. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  125034. private _updateDummy;
  125035. /**
  125036. * Enables a pointer drag behavior on the bounding box of the gizmo
  125037. */
  125038. enableDragBehavior(): void;
  125039. /**
  125040. * Disposes of the gizmo
  125041. */
  125042. dispose(): void;
  125043. /**
  125044. * 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)
  125045. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  125046. * @returns the bounding box mesh with the passed in mesh as a child
  125047. */
  125048. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  125049. /**
  125050. * CustomMeshes are not supported by this gizmo
  125051. * @param mesh The mesh to replace the default mesh of the gizmo
  125052. */
  125053. setCustomMesh(mesh: Mesh): void;
  125054. }
  125055. }
  125056. declare module BABYLON {
  125057. /**
  125058. * Single plane rotation gizmo
  125059. */
  125060. export class PlaneRotationGizmo extends Gizmo {
  125061. /**
  125062. * Drag behavior responsible for the gizmos dragging interactions
  125063. */
  125064. dragBehavior: PointerDragBehavior;
  125065. private _pointerObserver;
  125066. /**
  125067. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  125068. */
  125069. snapDistance: number;
  125070. /**
  125071. * Event that fires each time the gizmo snaps to a new location.
  125072. * * snapDistance is the the change in distance
  125073. */
  125074. onSnapObservable: Observable<{
  125075. snapDistance: number;
  125076. }>;
  125077. private _isEnabled;
  125078. private _parent;
  125079. /**
  125080. * Creates a PlaneRotationGizmo
  125081. * @param gizmoLayer The utility layer the gizmo will be added to
  125082. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  125083. * @param color The color of the gizmo
  125084. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125085. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125086. */
  125087. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  125088. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  125089. /**
  125090. * If the gizmo is enabled
  125091. */
  125092. set isEnabled(value: boolean);
  125093. get isEnabled(): boolean;
  125094. /**
  125095. * Disposes of the gizmo
  125096. */
  125097. dispose(): void;
  125098. }
  125099. }
  125100. declare module BABYLON {
  125101. /**
  125102. * Gizmo that enables rotating a mesh along 3 axis
  125103. */
  125104. export class RotationGizmo extends Gizmo {
  125105. /**
  125106. * Internal gizmo used for interactions on the x axis
  125107. */
  125108. xGizmo: PlaneRotationGizmo;
  125109. /**
  125110. * Internal gizmo used for interactions on the y axis
  125111. */
  125112. yGizmo: PlaneRotationGizmo;
  125113. /**
  125114. * Internal gizmo used for interactions on the z axis
  125115. */
  125116. zGizmo: PlaneRotationGizmo;
  125117. /** Fires an event when any of it's sub gizmos are dragged */
  125118. onDragStartObservable: Observable<unknown>;
  125119. /** Fires an event when any of it's sub gizmos are released from dragging */
  125120. onDragEndObservable: Observable<unknown>;
  125121. private _meshAttached;
  125122. get attachedMesh(): Nullable<AbstractMesh>;
  125123. set attachedMesh(mesh: Nullable<AbstractMesh>);
  125124. /**
  125125. * Creates a RotationGizmo
  125126. * @param gizmoLayer The utility layer the gizmo will be added to
  125127. * @param tessellation Amount of tessellation to be used when creating rotation circles
  125128. * @param useEulerRotation Use and update Euler angle instead of quaternion
  125129. */
  125130. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  125131. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  125132. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  125133. /**
  125134. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  125135. */
  125136. set snapDistance(value: number);
  125137. get snapDistance(): number;
  125138. /**
  125139. * Ratio for the scale of the gizmo (Default: 1)
  125140. */
  125141. set scaleRatio(value: number);
  125142. get scaleRatio(): number;
  125143. /**
  125144. * Disposes of the gizmo
  125145. */
  125146. dispose(): void;
  125147. /**
  125148. * CustomMeshes are not supported by this gizmo
  125149. * @param mesh The mesh to replace the default mesh of the gizmo
  125150. */
  125151. setCustomMesh(mesh: Mesh): void;
  125152. }
  125153. }
  125154. declare module BABYLON {
  125155. /**
  125156. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  125157. */
  125158. export class GizmoManager implements IDisposable {
  125159. private scene;
  125160. /**
  125161. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  125162. */
  125163. gizmos: {
  125164. positionGizmo: Nullable<PositionGizmo>;
  125165. rotationGizmo: Nullable<RotationGizmo>;
  125166. scaleGizmo: Nullable<ScaleGizmo>;
  125167. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  125168. };
  125169. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  125170. clearGizmoOnEmptyPointerEvent: boolean;
  125171. /** Fires an event when the manager is attached to a mesh */
  125172. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  125173. private _gizmosEnabled;
  125174. private _pointerObserver;
  125175. private _attachedMesh;
  125176. private _boundingBoxColor;
  125177. private _defaultUtilityLayer;
  125178. private _defaultKeepDepthUtilityLayer;
  125179. /**
  125180. * When bounding box gizmo is enabled, this can be used to track drag/end events
  125181. */
  125182. boundingBoxDragBehavior: SixDofDragBehavior;
  125183. /**
  125184. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  125185. */
  125186. attachableMeshes: Nullable<Array<AbstractMesh>>;
  125187. /**
  125188. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  125189. */
  125190. usePointerToAttachGizmos: boolean;
  125191. /**
  125192. * Utility layer that the bounding box gizmo belongs to
  125193. */
  125194. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  125195. /**
  125196. * Utility layer that all gizmos besides bounding box belong to
  125197. */
  125198. get utilityLayer(): UtilityLayerRenderer;
  125199. /**
  125200. * Instatiates a gizmo manager
  125201. * @param scene the scene to overlay the gizmos on top of
  125202. */
  125203. constructor(scene: Scene);
  125204. /**
  125205. * Attaches a set of gizmos to the specified mesh
  125206. * @param mesh The mesh the gizmo's should be attached to
  125207. */
  125208. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  125209. /**
  125210. * If the position gizmo is enabled
  125211. */
  125212. set positionGizmoEnabled(value: boolean);
  125213. get positionGizmoEnabled(): boolean;
  125214. /**
  125215. * If the rotation gizmo is enabled
  125216. */
  125217. set rotationGizmoEnabled(value: boolean);
  125218. get rotationGizmoEnabled(): boolean;
  125219. /**
  125220. * If the scale gizmo is enabled
  125221. */
  125222. set scaleGizmoEnabled(value: boolean);
  125223. get scaleGizmoEnabled(): boolean;
  125224. /**
  125225. * If the boundingBox gizmo is enabled
  125226. */
  125227. set boundingBoxGizmoEnabled(value: boolean);
  125228. get boundingBoxGizmoEnabled(): boolean;
  125229. /**
  125230. * Disposes of the gizmo manager
  125231. */
  125232. dispose(): void;
  125233. }
  125234. }
  125235. declare module BABYLON {
  125236. /**
  125237. * A directional light is defined by a direction (what a surprise!).
  125238. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  125239. * 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.
  125240. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125241. */
  125242. export class DirectionalLight extends ShadowLight {
  125243. private _shadowFrustumSize;
  125244. /**
  125245. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  125246. */
  125247. get shadowFrustumSize(): number;
  125248. /**
  125249. * Specifies a fix frustum size for the shadow generation.
  125250. */
  125251. set shadowFrustumSize(value: number);
  125252. private _shadowOrthoScale;
  125253. /**
  125254. * Gets the shadow projection scale against the optimal computed one.
  125255. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125256. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125257. */
  125258. get shadowOrthoScale(): number;
  125259. /**
  125260. * Sets the shadow projection scale against the optimal computed one.
  125261. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  125262. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  125263. */
  125264. set shadowOrthoScale(value: number);
  125265. /**
  125266. * Automatically compute the projection matrix to best fit (including all the casters)
  125267. * on each frame.
  125268. */
  125269. autoUpdateExtends: boolean;
  125270. /**
  125271. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  125272. * on each frame. autoUpdateExtends must be set to true for this to work
  125273. */
  125274. autoCalcShadowZBounds: boolean;
  125275. private _orthoLeft;
  125276. private _orthoRight;
  125277. private _orthoTop;
  125278. private _orthoBottom;
  125279. /**
  125280. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  125281. * The directional light is emitted from everywhere in the given direction.
  125282. * It can cast shadows.
  125283. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125284. * @param name The friendly name of the light
  125285. * @param direction The direction of the light
  125286. * @param scene The scene the light belongs to
  125287. */
  125288. constructor(name: string, direction: Vector3, scene: Scene);
  125289. /**
  125290. * Returns the string "DirectionalLight".
  125291. * @return The class name
  125292. */
  125293. getClassName(): string;
  125294. /**
  125295. * Returns the integer 1.
  125296. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125297. */
  125298. getTypeID(): number;
  125299. /**
  125300. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  125301. * Returns the DirectionalLight Shadow projection matrix.
  125302. */
  125303. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125304. /**
  125305. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  125306. * Returns the DirectionalLight Shadow projection matrix.
  125307. */
  125308. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  125309. /**
  125310. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  125311. * Returns the DirectionalLight Shadow projection matrix.
  125312. */
  125313. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125314. protected _buildUniformLayout(): void;
  125315. /**
  125316. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  125317. * @param effect The effect to update
  125318. * @param lightIndex The index of the light in the effect to update
  125319. * @returns The directional light
  125320. */
  125321. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  125322. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  125323. /**
  125324. * Gets the minZ used for shadow according to both the scene and the light.
  125325. *
  125326. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125327. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125328. * @param activeCamera The camera we are returning the min for
  125329. * @returns the depth min z
  125330. */
  125331. getDepthMinZ(activeCamera: Camera): number;
  125332. /**
  125333. * Gets the maxZ used for shadow according to both the scene and the light.
  125334. *
  125335. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  125336. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  125337. * @param activeCamera The camera we are returning the max for
  125338. * @returns the depth max z
  125339. */
  125340. getDepthMaxZ(activeCamera: Camera): number;
  125341. /**
  125342. * Prepares the list of defines specific to the light type.
  125343. * @param defines the list of defines
  125344. * @param lightIndex defines the index of the light for the effect
  125345. */
  125346. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125347. }
  125348. }
  125349. declare module BABYLON {
  125350. /**
  125351. * Class containing static functions to help procedurally build meshes
  125352. */
  125353. export class HemisphereBuilder {
  125354. /**
  125355. * Creates a hemisphere mesh
  125356. * @param name defines the name of the mesh
  125357. * @param options defines the options used to create the mesh
  125358. * @param scene defines the hosting scene
  125359. * @returns the hemisphere mesh
  125360. */
  125361. static CreateHemisphere(name: string, options: {
  125362. segments?: number;
  125363. diameter?: number;
  125364. sideOrientation?: number;
  125365. }, scene: any): Mesh;
  125366. }
  125367. }
  125368. declare module BABYLON {
  125369. /**
  125370. * A spot light is defined by a position, a direction, an angle, and an exponent.
  125371. * These values define a cone of light starting from the position, emitting toward the direction.
  125372. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  125373. * and the exponent defines the speed of the decay of the light with distance (reach).
  125374. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125375. */
  125376. export class SpotLight extends ShadowLight {
  125377. private _angle;
  125378. private _innerAngle;
  125379. private _cosHalfAngle;
  125380. private _lightAngleScale;
  125381. private _lightAngleOffset;
  125382. /**
  125383. * Gets the cone angle of the spot light in Radians.
  125384. */
  125385. get angle(): number;
  125386. /**
  125387. * Sets the cone angle of the spot light in Radians.
  125388. */
  125389. set angle(value: number);
  125390. /**
  125391. * Only used in gltf falloff mode, this defines the angle where
  125392. * the directional falloff will start before cutting at angle which could be seen
  125393. * as outer angle.
  125394. */
  125395. get innerAngle(): number;
  125396. /**
  125397. * Only used in gltf falloff mode, this defines the angle where
  125398. * the directional falloff will start before cutting at angle which could be seen
  125399. * as outer angle.
  125400. */
  125401. set innerAngle(value: number);
  125402. private _shadowAngleScale;
  125403. /**
  125404. * Allows scaling the angle of the light for shadow generation only.
  125405. */
  125406. get shadowAngleScale(): number;
  125407. /**
  125408. * Allows scaling the angle of the light for shadow generation only.
  125409. */
  125410. set shadowAngleScale(value: number);
  125411. /**
  125412. * The light decay speed with the distance from the emission spot.
  125413. */
  125414. exponent: number;
  125415. private _projectionTextureMatrix;
  125416. /**
  125417. * Allows reading the projecton texture
  125418. */
  125419. get projectionTextureMatrix(): Matrix;
  125420. protected _projectionTextureLightNear: number;
  125421. /**
  125422. * Gets the near clip of the Spotlight for texture projection.
  125423. */
  125424. get projectionTextureLightNear(): number;
  125425. /**
  125426. * Sets the near clip of the Spotlight for texture projection.
  125427. */
  125428. set projectionTextureLightNear(value: number);
  125429. protected _projectionTextureLightFar: number;
  125430. /**
  125431. * Gets the far clip of the Spotlight for texture projection.
  125432. */
  125433. get projectionTextureLightFar(): number;
  125434. /**
  125435. * Sets the far clip of the Spotlight for texture projection.
  125436. */
  125437. set projectionTextureLightFar(value: number);
  125438. protected _projectionTextureUpDirection: Vector3;
  125439. /**
  125440. * Gets the Up vector of the Spotlight for texture projection.
  125441. */
  125442. get projectionTextureUpDirection(): Vector3;
  125443. /**
  125444. * Sets the Up vector of the Spotlight for texture projection.
  125445. */
  125446. set projectionTextureUpDirection(value: Vector3);
  125447. private _projectionTexture;
  125448. /**
  125449. * Gets the projection texture of the light.
  125450. */
  125451. get projectionTexture(): Nullable<BaseTexture>;
  125452. /**
  125453. * Sets the projection texture of the light.
  125454. */
  125455. set projectionTexture(value: Nullable<BaseTexture>);
  125456. private _projectionTextureViewLightDirty;
  125457. private _projectionTextureProjectionLightDirty;
  125458. private _projectionTextureDirty;
  125459. private _projectionTextureViewTargetVector;
  125460. private _projectionTextureViewLightMatrix;
  125461. private _projectionTextureProjectionLightMatrix;
  125462. private _projectionTextureScalingMatrix;
  125463. /**
  125464. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  125465. * It can cast shadows.
  125466. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125467. * @param name The light friendly name
  125468. * @param position The position of the spot light in the scene
  125469. * @param direction The direction of the light in the scene
  125470. * @param angle The cone angle of the light in Radians
  125471. * @param exponent The light decay speed with the distance from the emission spot
  125472. * @param scene The scene the lights belongs to
  125473. */
  125474. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  125475. /**
  125476. * Returns the string "SpotLight".
  125477. * @returns the class name
  125478. */
  125479. getClassName(): string;
  125480. /**
  125481. * Returns the integer 2.
  125482. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125483. */
  125484. getTypeID(): number;
  125485. /**
  125486. * Overrides the direction setter to recompute the projection texture view light Matrix.
  125487. */
  125488. protected _setDirection(value: Vector3): void;
  125489. /**
  125490. * Overrides the position setter to recompute the projection texture view light Matrix.
  125491. */
  125492. protected _setPosition(value: Vector3): void;
  125493. /**
  125494. * 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.
  125495. * Returns the SpotLight.
  125496. */
  125497. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125498. protected _computeProjectionTextureViewLightMatrix(): void;
  125499. protected _computeProjectionTextureProjectionLightMatrix(): void;
  125500. /**
  125501. * Main function for light texture projection matrix computing.
  125502. */
  125503. protected _computeProjectionTextureMatrix(): void;
  125504. protected _buildUniformLayout(): void;
  125505. private _computeAngleValues;
  125506. /**
  125507. * Sets the passed Effect "effect" with the Light textures.
  125508. * @param effect The effect to update
  125509. * @param lightIndex The index of the light in the effect to update
  125510. * @returns The light
  125511. */
  125512. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  125513. /**
  125514. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  125515. * @param effect The effect to update
  125516. * @param lightIndex The index of the light in the effect to update
  125517. * @returns The spot light
  125518. */
  125519. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  125520. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125521. /**
  125522. * Disposes the light and the associated resources.
  125523. */
  125524. dispose(): void;
  125525. /**
  125526. * Prepares the list of defines specific to the light type.
  125527. * @param defines the list of defines
  125528. * @param lightIndex defines the index of the light for the effect
  125529. */
  125530. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125531. }
  125532. }
  125533. declare module BABYLON {
  125534. /**
  125535. * Gizmo that enables viewing a light
  125536. */
  125537. export class LightGizmo extends Gizmo {
  125538. private _lightMesh;
  125539. private _material;
  125540. private _cachedPosition;
  125541. private _cachedForward;
  125542. private _attachedMeshParent;
  125543. /**
  125544. * Creates a LightGizmo
  125545. * @param gizmoLayer The utility layer the gizmo will be added to
  125546. */
  125547. constructor(gizmoLayer?: UtilityLayerRenderer);
  125548. private _light;
  125549. /**
  125550. * The light that the gizmo is attached to
  125551. */
  125552. set light(light: Nullable<Light>);
  125553. get light(): Nullable<Light>;
  125554. /**
  125555. * Gets the material used to render the light gizmo
  125556. */
  125557. get material(): StandardMaterial;
  125558. /**
  125559. * @hidden
  125560. * Updates the gizmo to match the attached mesh's position/rotation
  125561. */
  125562. protected _update(): void;
  125563. private static _Scale;
  125564. /**
  125565. * Creates the lines for a light mesh
  125566. */
  125567. private static _CreateLightLines;
  125568. /**
  125569. * Disposes of the light gizmo
  125570. */
  125571. dispose(): void;
  125572. private static _CreateHemisphericLightMesh;
  125573. private static _CreatePointLightMesh;
  125574. private static _CreateSpotLightMesh;
  125575. private static _CreateDirectionalLightMesh;
  125576. }
  125577. }
  125578. declare module BABYLON {
  125579. /** @hidden */
  125580. export var backgroundFragmentDeclaration: {
  125581. name: string;
  125582. shader: string;
  125583. };
  125584. }
  125585. declare module BABYLON {
  125586. /** @hidden */
  125587. export var backgroundUboDeclaration: {
  125588. name: string;
  125589. shader: string;
  125590. };
  125591. }
  125592. declare module BABYLON {
  125593. /** @hidden */
  125594. export var backgroundPixelShader: {
  125595. name: string;
  125596. shader: string;
  125597. };
  125598. }
  125599. declare module BABYLON {
  125600. /** @hidden */
  125601. export var backgroundVertexDeclaration: {
  125602. name: string;
  125603. shader: string;
  125604. };
  125605. }
  125606. declare module BABYLON {
  125607. /** @hidden */
  125608. export var backgroundVertexShader: {
  125609. name: string;
  125610. shader: string;
  125611. };
  125612. }
  125613. declare module BABYLON {
  125614. /**
  125615. * Background material used to create an efficient environement around your scene.
  125616. */
  125617. export class BackgroundMaterial extends PushMaterial {
  125618. /**
  125619. * Standard reflectance value at parallel view angle.
  125620. */
  125621. static StandardReflectance0: number;
  125622. /**
  125623. * Standard reflectance value at grazing angle.
  125624. */
  125625. static StandardReflectance90: number;
  125626. protected _primaryColor: Color3;
  125627. /**
  125628. * Key light Color (multiply against the environement texture)
  125629. */
  125630. primaryColor: Color3;
  125631. protected __perceptualColor: Nullable<Color3>;
  125632. /**
  125633. * Experimental Internal Use Only.
  125634. *
  125635. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  125636. * This acts as a helper to set the primary color to a more "human friendly" value.
  125637. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  125638. * output color as close as possible from the chosen value.
  125639. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  125640. * part of lighting setup.)
  125641. */
  125642. get _perceptualColor(): Nullable<Color3>;
  125643. set _perceptualColor(value: Nullable<Color3>);
  125644. protected _primaryColorShadowLevel: float;
  125645. /**
  125646. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  125647. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  125648. */
  125649. get primaryColorShadowLevel(): float;
  125650. set primaryColorShadowLevel(value: float);
  125651. protected _primaryColorHighlightLevel: float;
  125652. /**
  125653. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  125654. * The primary color is used at the level chosen to define what the white area would look.
  125655. */
  125656. get primaryColorHighlightLevel(): float;
  125657. set primaryColorHighlightLevel(value: float);
  125658. protected _reflectionTexture: Nullable<BaseTexture>;
  125659. /**
  125660. * Reflection Texture used in the material.
  125661. * Should be author in a specific way for the best result (refer to the documentation).
  125662. */
  125663. reflectionTexture: Nullable<BaseTexture>;
  125664. protected _reflectionBlur: float;
  125665. /**
  125666. * Reflection Texture level of blur.
  125667. *
  125668. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  125669. * texture twice.
  125670. */
  125671. reflectionBlur: float;
  125672. protected _diffuseTexture: Nullable<BaseTexture>;
  125673. /**
  125674. * Diffuse Texture used in the material.
  125675. * Should be author in a specific way for the best result (refer to the documentation).
  125676. */
  125677. diffuseTexture: Nullable<BaseTexture>;
  125678. protected _shadowLights: Nullable<IShadowLight[]>;
  125679. /**
  125680. * Specify the list of lights casting shadow on the material.
  125681. * All scene shadow lights will be included if null.
  125682. */
  125683. shadowLights: Nullable<IShadowLight[]>;
  125684. protected _shadowLevel: float;
  125685. /**
  125686. * Helps adjusting the shadow to a softer level if required.
  125687. * 0 means black shadows and 1 means no shadows.
  125688. */
  125689. shadowLevel: float;
  125690. protected _sceneCenter: Vector3;
  125691. /**
  125692. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  125693. * It is usually zero but might be interesting to modify according to your setup.
  125694. */
  125695. sceneCenter: Vector3;
  125696. protected _opacityFresnel: boolean;
  125697. /**
  125698. * This helps specifying that the material is falling off to the sky box at grazing angle.
  125699. * This helps ensuring a nice transition when the camera goes under the ground.
  125700. */
  125701. opacityFresnel: boolean;
  125702. protected _reflectionFresnel: boolean;
  125703. /**
  125704. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  125705. * This helps adding a mirror texture on the ground.
  125706. */
  125707. reflectionFresnel: boolean;
  125708. protected _reflectionFalloffDistance: number;
  125709. /**
  125710. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  125711. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  125712. */
  125713. reflectionFalloffDistance: number;
  125714. protected _reflectionAmount: number;
  125715. /**
  125716. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  125717. */
  125718. reflectionAmount: number;
  125719. protected _reflectionReflectance0: number;
  125720. /**
  125721. * This specifies the weight of the reflection at grazing angle.
  125722. */
  125723. reflectionReflectance0: number;
  125724. protected _reflectionReflectance90: number;
  125725. /**
  125726. * This specifies the weight of the reflection at a perpendicular point of view.
  125727. */
  125728. reflectionReflectance90: number;
  125729. /**
  125730. * Sets the reflection reflectance fresnel values according to the default standard
  125731. * empirically know to work well :-)
  125732. */
  125733. set reflectionStandardFresnelWeight(value: number);
  125734. protected _useRGBColor: boolean;
  125735. /**
  125736. * Helps to directly use the maps channels instead of their level.
  125737. */
  125738. useRGBColor: boolean;
  125739. protected _enableNoise: boolean;
  125740. /**
  125741. * This helps reducing the banding effect that could occur on the background.
  125742. */
  125743. enableNoise: boolean;
  125744. /**
  125745. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125746. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  125747. * Recommended to be keep at 1.0 except for special cases.
  125748. */
  125749. get fovMultiplier(): number;
  125750. set fovMultiplier(value: number);
  125751. private _fovMultiplier;
  125752. /**
  125753. * Enable the FOV adjustment feature controlled by fovMultiplier.
  125754. */
  125755. useEquirectangularFOV: boolean;
  125756. private _maxSimultaneousLights;
  125757. /**
  125758. * Number of Simultaneous lights allowed on the material.
  125759. */
  125760. maxSimultaneousLights: int;
  125761. /**
  125762. * Default configuration related to image processing available in the Background Material.
  125763. */
  125764. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125765. /**
  125766. * Keep track of the image processing observer to allow dispose and replace.
  125767. */
  125768. private _imageProcessingObserver;
  125769. /**
  125770. * Attaches a new image processing configuration to the PBR Material.
  125771. * @param configuration (if null the scene configuration will be use)
  125772. */
  125773. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125774. /**
  125775. * Gets the image processing configuration used either in this material.
  125776. */
  125777. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  125778. /**
  125779. * Sets the Default image processing configuration used either in the this material.
  125780. *
  125781. * If sets to null, the scene one is in use.
  125782. */
  125783. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  125784. /**
  125785. * Gets wether the color curves effect is enabled.
  125786. */
  125787. get cameraColorCurvesEnabled(): boolean;
  125788. /**
  125789. * Sets wether the color curves effect is enabled.
  125790. */
  125791. set cameraColorCurvesEnabled(value: boolean);
  125792. /**
  125793. * Gets wether the color grading effect is enabled.
  125794. */
  125795. get cameraColorGradingEnabled(): boolean;
  125796. /**
  125797. * Gets wether the color grading effect is enabled.
  125798. */
  125799. set cameraColorGradingEnabled(value: boolean);
  125800. /**
  125801. * Gets wether tonemapping is enabled or not.
  125802. */
  125803. get cameraToneMappingEnabled(): boolean;
  125804. /**
  125805. * Sets wether tonemapping is enabled or not
  125806. */
  125807. set cameraToneMappingEnabled(value: boolean);
  125808. /**
  125809. * The camera exposure used on this material.
  125810. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125811. * This corresponds to a photographic exposure.
  125812. */
  125813. get cameraExposure(): float;
  125814. /**
  125815. * The camera exposure used on this material.
  125816. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125817. * This corresponds to a photographic exposure.
  125818. */
  125819. set cameraExposure(value: float);
  125820. /**
  125821. * Gets The camera contrast used on this material.
  125822. */
  125823. get cameraContrast(): float;
  125824. /**
  125825. * Sets The camera contrast used on this material.
  125826. */
  125827. set cameraContrast(value: float);
  125828. /**
  125829. * Gets the Color Grading 2D Lookup Texture.
  125830. */
  125831. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125832. /**
  125833. * Sets the Color Grading 2D Lookup Texture.
  125834. */
  125835. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125836. /**
  125837. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125838. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125839. * 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;
  125840. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125841. */
  125842. get cameraColorCurves(): Nullable<ColorCurves>;
  125843. /**
  125844. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125845. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125846. * 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;
  125847. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125848. */
  125849. set cameraColorCurves(value: Nullable<ColorCurves>);
  125850. /**
  125851. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  125852. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  125853. */
  125854. switchToBGR: boolean;
  125855. private _renderTargets;
  125856. private _reflectionControls;
  125857. private _white;
  125858. private _primaryShadowColor;
  125859. private _primaryHighlightColor;
  125860. /**
  125861. * Instantiates a Background Material in the given scene
  125862. * @param name The friendly name of the material
  125863. * @param scene The scene to add the material to
  125864. */
  125865. constructor(name: string, scene: Scene);
  125866. /**
  125867. * Gets a boolean indicating that current material needs to register RTT
  125868. */
  125869. get hasRenderTargetTextures(): boolean;
  125870. /**
  125871. * The entire material has been created in order to prevent overdraw.
  125872. * @returns false
  125873. */
  125874. needAlphaTesting(): boolean;
  125875. /**
  125876. * The entire material has been created in order to prevent overdraw.
  125877. * @returns true if blending is enable
  125878. */
  125879. needAlphaBlending(): boolean;
  125880. /**
  125881. * Checks wether the material is ready to be rendered for a given mesh.
  125882. * @param mesh The mesh to render
  125883. * @param subMesh The submesh to check against
  125884. * @param useInstances Specify wether or not the material is used with instances
  125885. * @returns true if all the dependencies are ready (Textures, Effects...)
  125886. */
  125887. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  125888. /**
  125889. * Compute the primary color according to the chosen perceptual color.
  125890. */
  125891. private _computePrimaryColorFromPerceptualColor;
  125892. /**
  125893. * Compute the highlights and shadow colors according to their chosen levels.
  125894. */
  125895. private _computePrimaryColors;
  125896. /**
  125897. * Build the uniform buffer used in the material.
  125898. */
  125899. buildUniformLayout(): void;
  125900. /**
  125901. * Unbind the material.
  125902. */
  125903. unbind(): void;
  125904. /**
  125905. * Bind only the world matrix to the material.
  125906. * @param world The world matrix to bind.
  125907. */
  125908. bindOnlyWorldMatrix(world: Matrix): void;
  125909. /**
  125910. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  125911. * @param world The world matrix to bind.
  125912. * @param subMesh The submesh to bind for.
  125913. */
  125914. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  125915. /**
  125916. * Checks to see if a texture is used in the material.
  125917. * @param texture - Base texture to use.
  125918. * @returns - Boolean specifying if a texture is used in the material.
  125919. */
  125920. hasTexture(texture: BaseTexture): boolean;
  125921. /**
  125922. * Dispose the material.
  125923. * @param forceDisposeEffect Force disposal of the associated effect.
  125924. * @param forceDisposeTextures Force disposal of the associated textures.
  125925. */
  125926. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  125927. /**
  125928. * Clones the material.
  125929. * @param name The cloned name.
  125930. * @returns The cloned material.
  125931. */
  125932. clone(name: string): BackgroundMaterial;
  125933. /**
  125934. * Serializes the current material to its JSON representation.
  125935. * @returns The JSON representation.
  125936. */
  125937. serialize(): any;
  125938. /**
  125939. * Gets the class name of the material
  125940. * @returns "BackgroundMaterial"
  125941. */
  125942. getClassName(): string;
  125943. /**
  125944. * Parse a JSON input to create back a background material.
  125945. * @param source The JSON data to parse
  125946. * @param scene The scene to create the parsed material in
  125947. * @param rootUrl The root url of the assets the material depends upon
  125948. * @returns the instantiated BackgroundMaterial.
  125949. */
  125950. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  125951. }
  125952. }
  125953. declare module BABYLON {
  125954. /**
  125955. * Represents the different options available during the creation of
  125956. * a Environment helper.
  125957. *
  125958. * This can control the default ground, skybox and image processing setup of your scene.
  125959. */
  125960. export interface IEnvironmentHelperOptions {
  125961. /**
  125962. * Specifies whether or not to create a ground.
  125963. * True by default.
  125964. */
  125965. createGround: boolean;
  125966. /**
  125967. * Specifies the ground size.
  125968. * 15 by default.
  125969. */
  125970. groundSize: number;
  125971. /**
  125972. * The texture used on the ground for the main color.
  125973. * Comes from the BabylonJS CDN by default.
  125974. *
  125975. * Remarks: Can be either a texture or a url.
  125976. */
  125977. groundTexture: string | BaseTexture;
  125978. /**
  125979. * The color mixed in the ground texture by default.
  125980. * BabylonJS clearColor by default.
  125981. */
  125982. groundColor: Color3;
  125983. /**
  125984. * Specifies the ground opacity.
  125985. * 1 by default.
  125986. */
  125987. groundOpacity: number;
  125988. /**
  125989. * Enables the ground to receive shadows.
  125990. * True by default.
  125991. */
  125992. enableGroundShadow: boolean;
  125993. /**
  125994. * Helps preventing the shadow to be fully black on the ground.
  125995. * 0.5 by default.
  125996. */
  125997. groundShadowLevel: number;
  125998. /**
  125999. * Creates a mirror texture attach to the ground.
  126000. * false by default.
  126001. */
  126002. enableGroundMirror: boolean;
  126003. /**
  126004. * Specifies the ground mirror size ratio.
  126005. * 0.3 by default as the default kernel is 64.
  126006. */
  126007. groundMirrorSizeRatio: number;
  126008. /**
  126009. * Specifies the ground mirror blur kernel size.
  126010. * 64 by default.
  126011. */
  126012. groundMirrorBlurKernel: number;
  126013. /**
  126014. * Specifies the ground mirror visibility amount.
  126015. * 1 by default
  126016. */
  126017. groundMirrorAmount: number;
  126018. /**
  126019. * Specifies the ground mirror reflectance weight.
  126020. * This uses the standard weight of the background material to setup the fresnel effect
  126021. * of the mirror.
  126022. * 1 by default.
  126023. */
  126024. groundMirrorFresnelWeight: number;
  126025. /**
  126026. * Specifies the ground mirror Falloff distance.
  126027. * This can helps reducing the size of the reflection.
  126028. * 0 by Default.
  126029. */
  126030. groundMirrorFallOffDistance: number;
  126031. /**
  126032. * Specifies the ground mirror texture type.
  126033. * Unsigned Int by Default.
  126034. */
  126035. groundMirrorTextureType: number;
  126036. /**
  126037. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  126038. * the shown objects.
  126039. */
  126040. groundYBias: number;
  126041. /**
  126042. * Specifies whether or not to create a skybox.
  126043. * True by default.
  126044. */
  126045. createSkybox: boolean;
  126046. /**
  126047. * Specifies the skybox size.
  126048. * 20 by default.
  126049. */
  126050. skyboxSize: number;
  126051. /**
  126052. * The texture used on the skybox for the main color.
  126053. * Comes from the BabylonJS CDN by default.
  126054. *
  126055. * Remarks: Can be either a texture or a url.
  126056. */
  126057. skyboxTexture: string | BaseTexture;
  126058. /**
  126059. * The color mixed in the skybox texture by default.
  126060. * BabylonJS clearColor by default.
  126061. */
  126062. skyboxColor: Color3;
  126063. /**
  126064. * The background rotation around the Y axis of the scene.
  126065. * This helps aligning the key lights of your scene with the background.
  126066. * 0 by default.
  126067. */
  126068. backgroundYRotation: number;
  126069. /**
  126070. * Compute automatically the size of the elements to best fit with the scene.
  126071. */
  126072. sizeAuto: boolean;
  126073. /**
  126074. * Default position of the rootMesh if autoSize is not true.
  126075. */
  126076. rootPosition: Vector3;
  126077. /**
  126078. * Sets up the image processing in the scene.
  126079. * true by default.
  126080. */
  126081. setupImageProcessing: boolean;
  126082. /**
  126083. * The texture used as your environment texture in the scene.
  126084. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  126085. *
  126086. * Remarks: Can be either a texture or a url.
  126087. */
  126088. environmentTexture: string | BaseTexture;
  126089. /**
  126090. * The value of the exposure to apply to the scene.
  126091. * 0.6 by default if setupImageProcessing is true.
  126092. */
  126093. cameraExposure: number;
  126094. /**
  126095. * The value of the contrast to apply to the scene.
  126096. * 1.6 by default if setupImageProcessing is true.
  126097. */
  126098. cameraContrast: number;
  126099. /**
  126100. * Specifies whether or not tonemapping should be enabled in the scene.
  126101. * true by default if setupImageProcessing is true.
  126102. */
  126103. toneMappingEnabled: boolean;
  126104. }
  126105. /**
  126106. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  126107. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  126108. * It also helps with the default setup of your imageProcessing configuration.
  126109. */
  126110. export class EnvironmentHelper {
  126111. /**
  126112. * Default ground texture URL.
  126113. */
  126114. private static _groundTextureCDNUrl;
  126115. /**
  126116. * Default skybox texture URL.
  126117. */
  126118. private static _skyboxTextureCDNUrl;
  126119. /**
  126120. * Default environment texture URL.
  126121. */
  126122. private static _environmentTextureCDNUrl;
  126123. /**
  126124. * Creates the default options for the helper.
  126125. */
  126126. private static _getDefaultOptions;
  126127. private _rootMesh;
  126128. /**
  126129. * Gets the root mesh created by the helper.
  126130. */
  126131. get rootMesh(): Mesh;
  126132. private _skybox;
  126133. /**
  126134. * Gets the skybox created by the helper.
  126135. */
  126136. get skybox(): Nullable<Mesh>;
  126137. private _skyboxTexture;
  126138. /**
  126139. * Gets the skybox texture created by the helper.
  126140. */
  126141. get skyboxTexture(): Nullable<BaseTexture>;
  126142. private _skyboxMaterial;
  126143. /**
  126144. * Gets the skybox material created by the helper.
  126145. */
  126146. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  126147. private _ground;
  126148. /**
  126149. * Gets the ground mesh created by the helper.
  126150. */
  126151. get ground(): Nullable<Mesh>;
  126152. private _groundTexture;
  126153. /**
  126154. * Gets the ground texture created by the helper.
  126155. */
  126156. get groundTexture(): Nullable<BaseTexture>;
  126157. private _groundMirror;
  126158. /**
  126159. * Gets the ground mirror created by the helper.
  126160. */
  126161. get groundMirror(): Nullable<MirrorTexture>;
  126162. /**
  126163. * Gets the ground mirror render list to helps pushing the meshes
  126164. * you wish in the ground reflection.
  126165. */
  126166. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  126167. private _groundMaterial;
  126168. /**
  126169. * Gets the ground material created by the helper.
  126170. */
  126171. get groundMaterial(): Nullable<BackgroundMaterial>;
  126172. /**
  126173. * Stores the creation options.
  126174. */
  126175. private readonly _scene;
  126176. private _options;
  126177. /**
  126178. * This observable will be notified with any error during the creation of the environment,
  126179. * mainly texture creation errors.
  126180. */
  126181. onErrorObservable: Observable<{
  126182. message?: string;
  126183. exception?: any;
  126184. }>;
  126185. /**
  126186. * constructor
  126187. * @param options Defines the options we want to customize the helper
  126188. * @param scene The scene to add the material to
  126189. */
  126190. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  126191. /**
  126192. * Updates the background according to the new options
  126193. * @param options
  126194. */
  126195. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  126196. /**
  126197. * Sets the primary color of all the available elements.
  126198. * @param color the main color to affect to the ground and the background
  126199. */
  126200. setMainColor(color: Color3): void;
  126201. /**
  126202. * Setup the image processing according to the specified options.
  126203. */
  126204. private _setupImageProcessing;
  126205. /**
  126206. * Setup the environment texture according to the specified options.
  126207. */
  126208. private _setupEnvironmentTexture;
  126209. /**
  126210. * Setup the background according to the specified options.
  126211. */
  126212. private _setupBackground;
  126213. /**
  126214. * Get the scene sizes according to the setup.
  126215. */
  126216. private _getSceneSize;
  126217. /**
  126218. * Setup the ground according to the specified options.
  126219. */
  126220. private _setupGround;
  126221. /**
  126222. * Setup the ground material according to the specified options.
  126223. */
  126224. private _setupGroundMaterial;
  126225. /**
  126226. * Setup the ground diffuse texture according to the specified options.
  126227. */
  126228. private _setupGroundDiffuseTexture;
  126229. /**
  126230. * Setup the ground mirror texture according to the specified options.
  126231. */
  126232. private _setupGroundMirrorTexture;
  126233. /**
  126234. * Setup the ground to receive the mirror texture.
  126235. */
  126236. private _setupMirrorInGroundMaterial;
  126237. /**
  126238. * Setup the skybox according to the specified options.
  126239. */
  126240. private _setupSkybox;
  126241. /**
  126242. * Setup the skybox material according to the specified options.
  126243. */
  126244. private _setupSkyboxMaterial;
  126245. /**
  126246. * Setup the skybox reflection texture according to the specified options.
  126247. */
  126248. private _setupSkyboxReflectionTexture;
  126249. private _errorHandler;
  126250. /**
  126251. * Dispose all the elements created by the Helper.
  126252. */
  126253. dispose(): void;
  126254. }
  126255. }
  126256. declare module BABYLON {
  126257. /**
  126258. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  126259. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  126260. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  126261. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  126262. */
  126263. export class PhotoDome extends TransformNode {
  126264. /**
  126265. * Define the image as a Monoscopic panoramic 360 image.
  126266. */
  126267. static readonly MODE_MONOSCOPIC: number;
  126268. /**
  126269. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126270. */
  126271. static readonly MODE_TOPBOTTOM: number;
  126272. /**
  126273. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126274. */
  126275. static readonly MODE_SIDEBYSIDE: number;
  126276. private _useDirectMapping;
  126277. /**
  126278. * The texture being displayed on the sphere
  126279. */
  126280. protected _photoTexture: Texture;
  126281. /**
  126282. * Gets or sets the texture being displayed on the sphere
  126283. */
  126284. get photoTexture(): Texture;
  126285. set photoTexture(value: Texture);
  126286. /**
  126287. * Observable raised when an error occured while loading the 360 image
  126288. */
  126289. onLoadErrorObservable: Observable<string>;
  126290. /**
  126291. * The skybox material
  126292. */
  126293. protected _material: BackgroundMaterial;
  126294. /**
  126295. * The surface used for the skybox
  126296. */
  126297. protected _mesh: Mesh;
  126298. /**
  126299. * Gets the mesh used for the skybox.
  126300. */
  126301. get mesh(): Mesh;
  126302. /**
  126303. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126304. * Also see the options.resolution property.
  126305. */
  126306. get fovMultiplier(): number;
  126307. set fovMultiplier(value: number);
  126308. private _imageMode;
  126309. /**
  126310. * Gets or set the current video mode for the video. It can be:
  126311. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  126312. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  126313. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  126314. */
  126315. get imageMode(): number;
  126316. set imageMode(value: number);
  126317. /**
  126318. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  126319. * @param name Element's name, child elements will append suffixes for their own names.
  126320. * @param urlsOfPhoto defines the url of the photo to display
  126321. * @param options defines an object containing optional or exposed sub element properties
  126322. * @param onError defines a callback called when an error occured while loading the texture
  126323. */
  126324. constructor(name: string, urlOfPhoto: string, options: {
  126325. resolution?: number;
  126326. size?: number;
  126327. useDirectMapping?: boolean;
  126328. faceForward?: boolean;
  126329. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  126330. private _onBeforeCameraRenderObserver;
  126331. private _changeImageMode;
  126332. /**
  126333. * Releases resources associated with this node.
  126334. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126335. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126336. */
  126337. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126338. }
  126339. }
  126340. declare module BABYLON {
  126341. /**
  126342. * Class used to host RGBD texture specific utilities
  126343. */
  126344. export class RGBDTextureTools {
  126345. /**
  126346. * Expand the RGBD Texture from RGBD to Half Float if possible.
  126347. * @param texture the texture to expand.
  126348. */
  126349. static ExpandRGBDTexture(texture: Texture): void;
  126350. }
  126351. }
  126352. declare module BABYLON {
  126353. /**
  126354. * Class used to host texture specific utilities
  126355. */
  126356. export class BRDFTextureTools {
  126357. /**
  126358. * Prevents texture cache collision
  126359. */
  126360. private static _instanceNumber;
  126361. /**
  126362. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  126363. * @param scene defines the hosting scene
  126364. * @returns the environment BRDF texture
  126365. */
  126366. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  126367. private static _environmentBRDFBase64Texture;
  126368. }
  126369. }
  126370. declare module BABYLON {
  126371. /**
  126372. * @hidden
  126373. */
  126374. export interface IMaterialClearCoatDefines {
  126375. CLEARCOAT: boolean;
  126376. CLEARCOAT_DEFAULTIOR: boolean;
  126377. CLEARCOAT_TEXTURE: boolean;
  126378. CLEARCOAT_TEXTUREDIRECTUV: number;
  126379. CLEARCOAT_BUMP: boolean;
  126380. CLEARCOAT_BUMPDIRECTUV: number;
  126381. CLEARCOAT_TINT: boolean;
  126382. CLEARCOAT_TINT_TEXTURE: boolean;
  126383. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  126384. /** @hidden */
  126385. _areTexturesDirty: boolean;
  126386. }
  126387. /**
  126388. * Define the code related to the clear coat parameters of the pbr material.
  126389. */
  126390. export class PBRClearCoatConfiguration {
  126391. /**
  126392. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126393. * The default fits with a polyurethane material.
  126394. */
  126395. private static readonly _DefaultIndexOfRefraction;
  126396. private _isEnabled;
  126397. /**
  126398. * Defines if the clear coat is enabled in the material.
  126399. */
  126400. isEnabled: boolean;
  126401. /**
  126402. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  126403. */
  126404. intensity: number;
  126405. /**
  126406. * Defines the clear coat layer roughness.
  126407. */
  126408. roughness: number;
  126409. private _indexOfRefraction;
  126410. /**
  126411. * Defines the index of refraction of the clear coat.
  126412. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  126413. * The default fits with a polyurethane material.
  126414. * Changing the default value is more performance intensive.
  126415. */
  126416. indexOfRefraction: number;
  126417. private _texture;
  126418. /**
  126419. * Stores the clear coat values in a texture.
  126420. */
  126421. texture: Nullable<BaseTexture>;
  126422. private _bumpTexture;
  126423. /**
  126424. * Define the clear coat specific bump texture.
  126425. */
  126426. bumpTexture: Nullable<BaseTexture>;
  126427. private _isTintEnabled;
  126428. /**
  126429. * Defines if the clear coat tint is enabled in the material.
  126430. */
  126431. isTintEnabled: boolean;
  126432. /**
  126433. * Defines the clear coat tint of the material.
  126434. * This is only use if tint is enabled
  126435. */
  126436. tintColor: Color3;
  126437. /**
  126438. * Defines the distance at which the tint color should be found in the
  126439. * clear coat media.
  126440. * This is only use if tint is enabled
  126441. */
  126442. tintColorAtDistance: number;
  126443. /**
  126444. * Defines the clear coat layer thickness.
  126445. * This is only use if tint is enabled
  126446. */
  126447. tintThickness: number;
  126448. private _tintTexture;
  126449. /**
  126450. * Stores the clear tint values in a texture.
  126451. * rgb is tint
  126452. * a is a thickness factor
  126453. */
  126454. tintTexture: Nullable<BaseTexture>;
  126455. /** @hidden */
  126456. private _internalMarkAllSubMeshesAsTexturesDirty;
  126457. /** @hidden */
  126458. _markAllSubMeshesAsTexturesDirty(): void;
  126459. /**
  126460. * Instantiate a new istance of clear coat configuration.
  126461. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126462. */
  126463. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126464. /**
  126465. * Gets wehter the submesh is ready to be used or not.
  126466. * @param defines the list of "defines" to update.
  126467. * @param scene defines the scene the material belongs to.
  126468. * @param engine defines the engine the material belongs to.
  126469. * @param disableBumpMap defines wether the material disables bump or not.
  126470. * @returns - boolean indicating that the submesh is ready or not.
  126471. */
  126472. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  126473. /**
  126474. * Checks to see if a texture is used in the material.
  126475. * @param defines the list of "defines" to update.
  126476. * @param scene defines the scene to the material belongs to.
  126477. */
  126478. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  126479. /**
  126480. * Binds the material data.
  126481. * @param uniformBuffer defines the Uniform buffer to fill in.
  126482. * @param scene defines the scene the material belongs to.
  126483. * @param engine defines the engine the material belongs to.
  126484. * @param disableBumpMap defines wether the material disables bump or not.
  126485. * @param isFrozen defines wether the material is frozen or not.
  126486. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126487. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126488. */
  126489. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  126490. /**
  126491. * Checks to see if a texture is used in the material.
  126492. * @param texture - Base texture to use.
  126493. * @returns - Boolean specifying if a texture is used in the material.
  126494. */
  126495. hasTexture(texture: BaseTexture): boolean;
  126496. /**
  126497. * Returns an array of the actively used textures.
  126498. * @param activeTextures Array of BaseTextures
  126499. */
  126500. getActiveTextures(activeTextures: BaseTexture[]): void;
  126501. /**
  126502. * Returns the animatable textures.
  126503. * @param animatables Array of animatable textures.
  126504. */
  126505. getAnimatables(animatables: IAnimatable[]): void;
  126506. /**
  126507. * Disposes the resources of the material.
  126508. * @param forceDisposeTextures - Forces the disposal of all textures.
  126509. */
  126510. dispose(forceDisposeTextures?: boolean): void;
  126511. /**
  126512. * Get the current class name of the texture useful for serialization or dynamic coding.
  126513. * @returns "PBRClearCoatConfiguration"
  126514. */
  126515. getClassName(): string;
  126516. /**
  126517. * Add fallbacks to the effect fallbacks list.
  126518. * @param defines defines the Base texture to use.
  126519. * @param fallbacks defines the current fallback list.
  126520. * @param currentRank defines the current fallback rank.
  126521. * @returns the new fallback rank.
  126522. */
  126523. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126524. /**
  126525. * Add the required uniforms to the current list.
  126526. * @param uniforms defines the current uniform list.
  126527. */
  126528. static AddUniforms(uniforms: string[]): void;
  126529. /**
  126530. * Add the required samplers to the current list.
  126531. * @param samplers defines the current sampler list.
  126532. */
  126533. static AddSamplers(samplers: string[]): void;
  126534. /**
  126535. * Add the required uniforms to the current buffer.
  126536. * @param uniformBuffer defines the current uniform buffer.
  126537. */
  126538. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126539. /**
  126540. * Makes a duplicate of the current configuration into another one.
  126541. * @param clearCoatConfiguration define the config where to copy the info
  126542. */
  126543. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  126544. /**
  126545. * Serializes this clear coat configuration.
  126546. * @returns - An object with the serialized config.
  126547. */
  126548. serialize(): any;
  126549. /**
  126550. * Parses a anisotropy Configuration from a serialized object.
  126551. * @param source - Serialized object.
  126552. * @param scene Defines the scene we are parsing for
  126553. * @param rootUrl Defines the rootUrl to load from
  126554. */
  126555. parse(source: any, scene: Scene, rootUrl: string): void;
  126556. }
  126557. }
  126558. declare module BABYLON {
  126559. /**
  126560. * @hidden
  126561. */
  126562. export interface IMaterialAnisotropicDefines {
  126563. ANISOTROPIC: boolean;
  126564. ANISOTROPIC_TEXTURE: boolean;
  126565. ANISOTROPIC_TEXTUREDIRECTUV: number;
  126566. MAINUV1: boolean;
  126567. _areTexturesDirty: boolean;
  126568. _needUVs: boolean;
  126569. }
  126570. /**
  126571. * Define the code related to the anisotropic parameters of the pbr material.
  126572. */
  126573. export class PBRAnisotropicConfiguration {
  126574. private _isEnabled;
  126575. /**
  126576. * Defines if the anisotropy is enabled in the material.
  126577. */
  126578. isEnabled: boolean;
  126579. /**
  126580. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  126581. */
  126582. intensity: number;
  126583. /**
  126584. * Defines if the effect is along the tangents, bitangents or in between.
  126585. * By default, the effect is "strectching" the highlights along the tangents.
  126586. */
  126587. direction: Vector2;
  126588. private _texture;
  126589. /**
  126590. * Stores the anisotropy values in a texture.
  126591. * rg is direction (like normal from -1 to 1)
  126592. * b is a intensity
  126593. */
  126594. texture: Nullable<BaseTexture>;
  126595. /** @hidden */
  126596. private _internalMarkAllSubMeshesAsTexturesDirty;
  126597. /** @hidden */
  126598. _markAllSubMeshesAsTexturesDirty(): void;
  126599. /**
  126600. * Instantiate a new istance of anisotropy configuration.
  126601. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126602. */
  126603. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126604. /**
  126605. * Specifies that the submesh is ready to be used.
  126606. * @param defines the list of "defines" to update.
  126607. * @param scene defines the scene the material belongs to.
  126608. * @returns - boolean indicating that the submesh is ready or not.
  126609. */
  126610. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  126611. /**
  126612. * Checks to see if a texture is used in the material.
  126613. * @param defines the list of "defines" to update.
  126614. * @param mesh the mesh we are preparing the defines for.
  126615. * @param scene defines the scene the material belongs to.
  126616. */
  126617. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  126618. /**
  126619. * Binds the material data.
  126620. * @param uniformBuffer defines the Uniform buffer to fill in.
  126621. * @param scene defines the scene the material belongs to.
  126622. * @param isFrozen defines wether the material is frozen or not.
  126623. */
  126624. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126625. /**
  126626. * Checks to see if a texture is used in the material.
  126627. * @param texture - Base texture to use.
  126628. * @returns - Boolean specifying if a texture is used in the material.
  126629. */
  126630. hasTexture(texture: BaseTexture): boolean;
  126631. /**
  126632. * Returns an array of the actively used textures.
  126633. * @param activeTextures Array of BaseTextures
  126634. */
  126635. getActiveTextures(activeTextures: BaseTexture[]): void;
  126636. /**
  126637. * Returns the animatable textures.
  126638. * @param animatables Array of animatable textures.
  126639. */
  126640. getAnimatables(animatables: IAnimatable[]): void;
  126641. /**
  126642. * Disposes the resources of the material.
  126643. * @param forceDisposeTextures - Forces the disposal of all textures.
  126644. */
  126645. dispose(forceDisposeTextures?: boolean): void;
  126646. /**
  126647. * Get the current class name of the texture useful for serialization or dynamic coding.
  126648. * @returns "PBRAnisotropicConfiguration"
  126649. */
  126650. getClassName(): string;
  126651. /**
  126652. * Add fallbacks to the effect fallbacks list.
  126653. * @param defines defines the Base texture to use.
  126654. * @param fallbacks defines the current fallback list.
  126655. * @param currentRank defines the current fallback rank.
  126656. * @returns the new fallback rank.
  126657. */
  126658. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126659. /**
  126660. * Add the required uniforms to the current list.
  126661. * @param uniforms defines the current uniform list.
  126662. */
  126663. static AddUniforms(uniforms: string[]): void;
  126664. /**
  126665. * Add the required uniforms to the current buffer.
  126666. * @param uniformBuffer defines the current uniform buffer.
  126667. */
  126668. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126669. /**
  126670. * Add the required samplers to the current list.
  126671. * @param samplers defines the current sampler list.
  126672. */
  126673. static AddSamplers(samplers: string[]): void;
  126674. /**
  126675. * Makes a duplicate of the current configuration into another one.
  126676. * @param anisotropicConfiguration define the config where to copy the info
  126677. */
  126678. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  126679. /**
  126680. * Serializes this anisotropy configuration.
  126681. * @returns - An object with the serialized config.
  126682. */
  126683. serialize(): any;
  126684. /**
  126685. * Parses a anisotropy Configuration from a serialized object.
  126686. * @param source - Serialized object.
  126687. * @param scene Defines the scene we are parsing for
  126688. * @param rootUrl Defines the rootUrl to load from
  126689. */
  126690. parse(source: any, scene: Scene, rootUrl: string): void;
  126691. }
  126692. }
  126693. declare module BABYLON {
  126694. /**
  126695. * @hidden
  126696. */
  126697. export interface IMaterialBRDFDefines {
  126698. BRDF_V_HEIGHT_CORRELATED: boolean;
  126699. MS_BRDF_ENERGY_CONSERVATION: boolean;
  126700. SPHERICAL_HARMONICS: boolean;
  126701. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  126702. /** @hidden */
  126703. _areMiscDirty: boolean;
  126704. }
  126705. /**
  126706. * Define the code related to the BRDF parameters of the pbr material.
  126707. */
  126708. export class PBRBRDFConfiguration {
  126709. /**
  126710. * Default value used for the energy conservation.
  126711. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126712. */
  126713. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  126714. /**
  126715. * Default value used for the Smith Visibility Height Correlated mode.
  126716. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  126717. */
  126718. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  126719. /**
  126720. * Default value used for the IBL diffuse part.
  126721. * This can help switching back to the polynomials mode globally which is a tiny bit
  126722. * less GPU intensive at the drawback of a lower quality.
  126723. */
  126724. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  126725. /**
  126726. * Default value used for activating energy conservation for the specular workflow.
  126727. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126728. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126729. */
  126730. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  126731. private _useEnergyConservation;
  126732. /**
  126733. * Defines if the material uses energy conservation.
  126734. */
  126735. useEnergyConservation: boolean;
  126736. private _useSmithVisibilityHeightCorrelated;
  126737. /**
  126738. * LEGACY Mode set to false
  126739. * Defines if the material uses height smith correlated visibility term.
  126740. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  126741. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  126742. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  126743. * Not relying on height correlated will also disable energy conservation.
  126744. */
  126745. useSmithVisibilityHeightCorrelated: boolean;
  126746. private _useSphericalHarmonics;
  126747. /**
  126748. * LEGACY Mode set to false
  126749. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  126750. * diffuse part of the IBL.
  126751. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  126752. * to the ground truth.
  126753. */
  126754. useSphericalHarmonics: boolean;
  126755. private _useSpecularGlossinessInputEnergyConservation;
  126756. /**
  126757. * Defines if the material uses energy conservation, when the specular workflow is active.
  126758. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  126759. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  126760. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  126761. */
  126762. useSpecularGlossinessInputEnergyConservation: boolean;
  126763. /** @hidden */
  126764. private _internalMarkAllSubMeshesAsMiscDirty;
  126765. /** @hidden */
  126766. _markAllSubMeshesAsMiscDirty(): void;
  126767. /**
  126768. * Instantiate a new istance of clear coat configuration.
  126769. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  126770. */
  126771. constructor(markAllSubMeshesAsMiscDirty: () => void);
  126772. /**
  126773. * Checks to see if a texture is used in the material.
  126774. * @param defines the list of "defines" to update.
  126775. */
  126776. prepareDefines(defines: IMaterialBRDFDefines): void;
  126777. /**
  126778. * Get the current class name of the texture useful for serialization or dynamic coding.
  126779. * @returns "PBRClearCoatConfiguration"
  126780. */
  126781. getClassName(): string;
  126782. /**
  126783. * Makes a duplicate of the current configuration into another one.
  126784. * @param brdfConfiguration define the config where to copy the info
  126785. */
  126786. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  126787. /**
  126788. * Serializes this BRDF configuration.
  126789. * @returns - An object with the serialized config.
  126790. */
  126791. serialize(): any;
  126792. /**
  126793. * Parses a anisotropy Configuration from a serialized object.
  126794. * @param source - Serialized object.
  126795. * @param scene Defines the scene we are parsing for
  126796. * @param rootUrl Defines the rootUrl to load from
  126797. */
  126798. parse(source: any, scene: Scene, rootUrl: string): void;
  126799. }
  126800. }
  126801. declare module BABYLON {
  126802. /**
  126803. * @hidden
  126804. */
  126805. export interface IMaterialSheenDefines {
  126806. SHEEN: boolean;
  126807. SHEEN_TEXTURE: boolean;
  126808. SHEEN_TEXTUREDIRECTUV: number;
  126809. SHEEN_LINKWITHALBEDO: boolean;
  126810. SHEEN_ROUGHNESS: boolean;
  126811. SHEEN_ALBEDOSCALING: boolean;
  126812. /** @hidden */
  126813. _areTexturesDirty: boolean;
  126814. }
  126815. /**
  126816. * Define the code related to the Sheen parameters of the pbr material.
  126817. */
  126818. export class PBRSheenConfiguration {
  126819. private _isEnabled;
  126820. /**
  126821. * Defines if the material uses sheen.
  126822. */
  126823. isEnabled: boolean;
  126824. private _linkSheenWithAlbedo;
  126825. /**
  126826. * Defines if the sheen is linked to the sheen color.
  126827. */
  126828. linkSheenWithAlbedo: boolean;
  126829. /**
  126830. * Defines the sheen intensity.
  126831. */
  126832. intensity: number;
  126833. /**
  126834. * Defines the sheen color.
  126835. */
  126836. color: Color3;
  126837. private _texture;
  126838. /**
  126839. * Stores the sheen tint values in a texture.
  126840. * rgb is tint
  126841. * a is a intensity
  126842. */
  126843. texture: Nullable<BaseTexture>;
  126844. private _roughness;
  126845. /**
  126846. * Defines the sheen roughness.
  126847. * It is not taken into account if linkSheenWithAlbedo is true.
  126848. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  126849. */
  126850. roughness: Nullable<number>;
  126851. private _albedoScaling;
  126852. /**
  126853. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  126854. * It allows the strength of the sheen effect to not depend on the base color of the material,
  126855. * making it easier to setup and tweak the effect
  126856. */
  126857. albedoScaling: boolean;
  126858. /** @hidden */
  126859. private _internalMarkAllSubMeshesAsTexturesDirty;
  126860. /** @hidden */
  126861. _markAllSubMeshesAsTexturesDirty(): void;
  126862. /**
  126863. * Instantiate a new istance of clear coat configuration.
  126864. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  126865. */
  126866. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  126867. /**
  126868. * Specifies that the submesh is ready to be used.
  126869. * @param defines the list of "defines" to update.
  126870. * @param scene defines the scene the material belongs to.
  126871. * @returns - boolean indicating that the submesh is ready or not.
  126872. */
  126873. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  126874. /**
  126875. * Checks to see if a texture is used in the material.
  126876. * @param defines the list of "defines" to update.
  126877. * @param scene defines the scene the material belongs to.
  126878. */
  126879. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  126880. /**
  126881. * Binds the material data.
  126882. * @param uniformBuffer defines the Uniform buffer to fill in.
  126883. * @param scene defines the scene the material belongs to.
  126884. * @param isFrozen defines wether the material is frozen or not.
  126885. */
  126886. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  126887. /**
  126888. * Checks to see if a texture is used in the material.
  126889. * @param texture - Base texture to use.
  126890. * @returns - Boolean specifying if a texture is used in the material.
  126891. */
  126892. hasTexture(texture: BaseTexture): boolean;
  126893. /**
  126894. * Returns an array of the actively used textures.
  126895. * @param activeTextures Array of BaseTextures
  126896. */
  126897. getActiveTextures(activeTextures: BaseTexture[]): void;
  126898. /**
  126899. * Returns the animatable textures.
  126900. * @param animatables Array of animatable textures.
  126901. */
  126902. getAnimatables(animatables: IAnimatable[]): void;
  126903. /**
  126904. * Disposes the resources of the material.
  126905. * @param forceDisposeTextures - Forces the disposal of all textures.
  126906. */
  126907. dispose(forceDisposeTextures?: boolean): void;
  126908. /**
  126909. * Get the current class name of the texture useful for serialization or dynamic coding.
  126910. * @returns "PBRSheenConfiguration"
  126911. */
  126912. getClassName(): string;
  126913. /**
  126914. * Add fallbacks to the effect fallbacks list.
  126915. * @param defines defines the Base texture to use.
  126916. * @param fallbacks defines the current fallback list.
  126917. * @param currentRank defines the current fallback rank.
  126918. * @returns the new fallback rank.
  126919. */
  126920. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  126921. /**
  126922. * Add the required uniforms to the current list.
  126923. * @param uniforms defines the current uniform list.
  126924. */
  126925. static AddUniforms(uniforms: string[]): void;
  126926. /**
  126927. * Add the required uniforms to the current buffer.
  126928. * @param uniformBuffer defines the current uniform buffer.
  126929. */
  126930. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  126931. /**
  126932. * Add the required samplers to the current list.
  126933. * @param samplers defines the current sampler list.
  126934. */
  126935. static AddSamplers(samplers: string[]): void;
  126936. /**
  126937. * Makes a duplicate of the current configuration into another one.
  126938. * @param sheenConfiguration define the config where to copy the info
  126939. */
  126940. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  126941. /**
  126942. * Serializes this BRDF configuration.
  126943. * @returns - An object with the serialized config.
  126944. */
  126945. serialize(): any;
  126946. /**
  126947. * Parses a anisotropy Configuration from a serialized object.
  126948. * @param source - Serialized object.
  126949. * @param scene Defines the scene we are parsing for
  126950. * @param rootUrl Defines the rootUrl to load from
  126951. */
  126952. parse(source: any, scene: Scene, rootUrl: string): void;
  126953. }
  126954. }
  126955. declare module BABYLON {
  126956. /**
  126957. * @hidden
  126958. */
  126959. export interface IMaterialSubSurfaceDefines {
  126960. SUBSURFACE: boolean;
  126961. SS_REFRACTION: boolean;
  126962. SS_TRANSLUCENCY: boolean;
  126963. SS_SCATERRING: boolean;
  126964. SS_THICKNESSANDMASK_TEXTURE: boolean;
  126965. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  126966. SS_REFRACTIONMAP_3D: boolean;
  126967. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  126968. SS_LODINREFRACTIONALPHA: boolean;
  126969. SS_GAMMAREFRACTION: boolean;
  126970. SS_RGBDREFRACTION: boolean;
  126971. SS_LINEARSPECULARREFRACTION: boolean;
  126972. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  126973. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  126974. /** @hidden */
  126975. _areTexturesDirty: boolean;
  126976. }
  126977. /**
  126978. * Define the code related to the sub surface parameters of the pbr material.
  126979. */
  126980. export class PBRSubSurfaceConfiguration {
  126981. private _isRefractionEnabled;
  126982. /**
  126983. * Defines if the refraction is enabled in the material.
  126984. */
  126985. isRefractionEnabled: boolean;
  126986. private _isTranslucencyEnabled;
  126987. /**
  126988. * Defines if the translucency is enabled in the material.
  126989. */
  126990. isTranslucencyEnabled: boolean;
  126991. private _isScatteringEnabled;
  126992. /**
  126993. * Defines the refraction intensity of the material.
  126994. * The refraction when enabled replaces the Diffuse part of the material.
  126995. * The intensity helps transitionning between diffuse and refraction.
  126996. */
  126997. refractionIntensity: number;
  126998. /**
  126999. * Defines the translucency intensity of the material.
  127000. * When translucency has been enabled, this defines how much of the "translucency"
  127001. * is addded to the diffuse part of the material.
  127002. */
  127003. translucencyIntensity: number;
  127004. /**
  127005. * Defines the scattering intensity of the material.
  127006. * When scattering has been enabled, this defines how much of the "scattered light"
  127007. * is addded to the diffuse part of the material.
  127008. */
  127009. scatteringIntensity: number;
  127010. private _thicknessTexture;
  127011. /**
  127012. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  127013. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  127014. * 0 would mean minimumThickness
  127015. * 1 would mean maximumThickness
  127016. * The other channels might be use as a mask to vary the different effects intensity.
  127017. */
  127018. thicknessTexture: Nullable<BaseTexture>;
  127019. private _refractionTexture;
  127020. /**
  127021. * Defines the texture to use for refraction.
  127022. */
  127023. refractionTexture: Nullable<BaseTexture>;
  127024. private _indexOfRefraction;
  127025. /**
  127026. * Defines the index of refraction used in the material.
  127027. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  127028. */
  127029. indexOfRefraction: number;
  127030. private _invertRefractionY;
  127031. /**
  127032. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  127033. */
  127034. invertRefractionY: boolean;
  127035. private _linkRefractionWithTransparency;
  127036. /**
  127037. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  127038. * Materials half opaque for instance using refraction could benefit from this control.
  127039. */
  127040. linkRefractionWithTransparency: boolean;
  127041. /**
  127042. * Defines the minimum thickness stored in the thickness map.
  127043. * If no thickness map is defined, this value will be used to simulate thickness.
  127044. */
  127045. minimumThickness: number;
  127046. /**
  127047. * Defines the maximum thickness stored in the thickness map.
  127048. */
  127049. maximumThickness: number;
  127050. /**
  127051. * Defines the volume tint of the material.
  127052. * This is used for both translucency and scattering.
  127053. */
  127054. tintColor: Color3;
  127055. /**
  127056. * Defines the distance at which the tint color should be found in the media.
  127057. * This is used for refraction only.
  127058. */
  127059. tintColorAtDistance: number;
  127060. /**
  127061. * Defines how far each channel transmit through the media.
  127062. * It is defined as a color to simplify it selection.
  127063. */
  127064. diffusionDistance: Color3;
  127065. private _useMaskFromThicknessTexture;
  127066. /**
  127067. * Stores the intensity of the different subsurface effects in the thickness texture.
  127068. * * the green channel is the translucency intensity.
  127069. * * the blue channel is the scattering intensity.
  127070. * * the alpha channel is the refraction intensity.
  127071. */
  127072. useMaskFromThicknessTexture: boolean;
  127073. /** @hidden */
  127074. private _internalMarkAllSubMeshesAsTexturesDirty;
  127075. /** @hidden */
  127076. _markAllSubMeshesAsTexturesDirty(): void;
  127077. /**
  127078. * Instantiate a new istance of sub surface configuration.
  127079. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  127080. */
  127081. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  127082. /**
  127083. * Gets wehter the submesh is ready to be used or not.
  127084. * @param defines the list of "defines" to update.
  127085. * @param scene defines the scene the material belongs to.
  127086. * @returns - boolean indicating that the submesh is ready or not.
  127087. */
  127088. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  127089. /**
  127090. * Checks to see if a texture is used in the material.
  127091. * @param defines the list of "defines" to update.
  127092. * @param scene defines the scene to the material belongs to.
  127093. */
  127094. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  127095. /**
  127096. * Binds the material data.
  127097. * @param uniformBuffer defines the Uniform buffer to fill in.
  127098. * @param scene defines the scene the material belongs to.
  127099. * @param engine defines the engine the material belongs to.
  127100. * @param isFrozen defines wether the material is frozen or not.
  127101. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  127102. */
  127103. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  127104. /**
  127105. * Unbinds the material from the mesh.
  127106. * @param activeEffect defines the effect that should be unbound from.
  127107. * @returns true if unbound, otherwise false
  127108. */
  127109. unbind(activeEffect: Effect): boolean;
  127110. /**
  127111. * Returns the texture used for refraction or null if none is used.
  127112. * @param scene defines the scene the material belongs to.
  127113. * @returns - Refraction texture if present. If no refraction texture and refraction
  127114. * is linked with transparency, returns environment texture. Otherwise, returns null.
  127115. */
  127116. private _getRefractionTexture;
  127117. /**
  127118. * Returns true if alpha blending should be disabled.
  127119. */
  127120. get disableAlphaBlending(): boolean;
  127121. /**
  127122. * Fills the list of render target textures.
  127123. * @param renderTargets the list of render targets to update
  127124. */
  127125. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  127126. /**
  127127. * Checks to see if a texture is used in the material.
  127128. * @param texture - Base texture to use.
  127129. * @returns - Boolean specifying if a texture is used in the material.
  127130. */
  127131. hasTexture(texture: BaseTexture): boolean;
  127132. /**
  127133. * Gets a boolean indicating that current material needs to register RTT
  127134. * @returns true if this uses a render target otherwise false.
  127135. */
  127136. hasRenderTargetTextures(): boolean;
  127137. /**
  127138. * Returns an array of the actively used textures.
  127139. * @param activeTextures Array of BaseTextures
  127140. */
  127141. getActiveTextures(activeTextures: BaseTexture[]): void;
  127142. /**
  127143. * Returns the animatable textures.
  127144. * @param animatables Array of animatable textures.
  127145. */
  127146. getAnimatables(animatables: IAnimatable[]): void;
  127147. /**
  127148. * Disposes the resources of the material.
  127149. * @param forceDisposeTextures - Forces the disposal of all textures.
  127150. */
  127151. dispose(forceDisposeTextures?: boolean): void;
  127152. /**
  127153. * Get the current class name of the texture useful for serialization or dynamic coding.
  127154. * @returns "PBRSubSurfaceConfiguration"
  127155. */
  127156. getClassName(): string;
  127157. /**
  127158. * Add fallbacks to the effect fallbacks list.
  127159. * @param defines defines the Base texture to use.
  127160. * @param fallbacks defines the current fallback list.
  127161. * @param currentRank defines the current fallback rank.
  127162. * @returns the new fallback rank.
  127163. */
  127164. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  127165. /**
  127166. * Add the required uniforms to the current list.
  127167. * @param uniforms defines the current uniform list.
  127168. */
  127169. static AddUniforms(uniforms: string[]): void;
  127170. /**
  127171. * Add the required samplers to the current list.
  127172. * @param samplers defines the current sampler list.
  127173. */
  127174. static AddSamplers(samplers: string[]): void;
  127175. /**
  127176. * Add the required uniforms to the current buffer.
  127177. * @param uniformBuffer defines the current uniform buffer.
  127178. */
  127179. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  127180. /**
  127181. * Makes a duplicate of the current configuration into another one.
  127182. * @param configuration define the config where to copy the info
  127183. */
  127184. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  127185. /**
  127186. * Serializes this Sub Surface configuration.
  127187. * @returns - An object with the serialized config.
  127188. */
  127189. serialize(): any;
  127190. /**
  127191. * Parses a anisotropy Configuration from a serialized object.
  127192. * @param source - Serialized object.
  127193. * @param scene Defines the scene we are parsing for
  127194. * @param rootUrl Defines the rootUrl to load from
  127195. */
  127196. parse(source: any, scene: Scene, rootUrl: string): void;
  127197. }
  127198. }
  127199. declare module BABYLON {
  127200. /** @hidden */
  127201. export var pbrFragmentDeclaration: {
  127202. name: string;
  127203. shader: string;
  127204. };
  127205. }
  127206. declare module BABYLON {
  127207. /** @hidden */
  127208. export var pbrUboDeclaration: {
  127209. name: string;
  127210. shader: string;
  127211. };
  127212. }
  127213. declare module BABYLON {
  127214. /** @hidden */
  127215. export var pbrFragmentExtraDeclaration: {
  127216. name: string;
  127217. shader: string;
  127218. };
  127219. }
  127220. declare module BABYLON {
  127221. /** @hidden */
  127222. export var pbrFragmentSamplersDeclaration: {
  127223. name: string;
  127224. shader: string;
  127225. };
  127226. }
  127227. declare module BABYLON {
  127228. /** @hidden */
  127229. export var pbrHelperFunctions: {
  127230. name: string;
  127231. shader: string;
  127232. };
  127233. }
  127234. declare module BABYLON {
  127235. /** @hidden */
  127236. export var harmonicsFunctions: {
  127237. name: string;
  127238. shader: string;
  127239. };
  127240. }
  127241. declare module BABYLON {
  127242. /** @hidden */
  127243. export var pbrDirectLightingSetupFunctions: {
  127244. name: string;
  127245. shader: string;
  127246. };
  127247. }
  127248. declare module BABYLON {
  127249. /** @hidden */
  127250. export var pbrDirectLightingFalloffFunctions: {
  127251. name: string;
  127252. shader: string;
  127253. };
  127254. }
  127255. declare module BABYLON {
  127256. /** @hidden */
  127257. export var pbrBRDFFunctions: {
  127258. name: string;
  127259. shader: string;
  127260. };
  127261. }
  127262. declare module BABYLON {
  127263. /** @hidden */
  127264. export var pbrDirectLightingFunctions: {
  127265. name: string;
  127266. shader: string;
  127267. };
  127268. }
  127269. declare module BABYLON {
  127270. /** @hidden */
  127271. export var pbrIBLFunctions: {
  127272. name: string;
  127273. shader: string;
  127274. };
  127275. }
  127276. declare module BABYLON {
  127277. /** @hidden */
  127278. export var pbrBlockAlbedoOpacity: {
  127279. name: string;
  127280. shader: string;
  127281. };
  127282. }
  127283. declare module BABYLON {
  127284. /** @hidden */
  127285. export var pbrBlockReflectivity: {
  127286. name: string;
  127287. shader: string;
  127288. };
  127289. }
  127290. declare module BABYLON {
  127291. /** @hidden */
  127292. export var pbrBlockAmbientOcclusion: {
  127293. name: string;
  127294. shader: string;
  127295. };
  127296. }
  127297. declare module BABYLON {
  127298. /** @hidden */
  127299. export var pbrBlockAlphaFresnel: {
  127300. name: string;
  127301. shader: string;
  127302. };
  127303. }
  127304. declare module BABYLON {
  127305. /** @hidden */
  127306. export var pbrBlockAnisotropic: {
  127307. name: string;
  127308. shader: string;
  127309. };
  127310. }
  127311. declare module BABYLON {
  127312. /** @hidden */
  127313. export var pbrBlockReflection: {
  127314. name: string;
  127315. shader: string;
  127316. };
  127317. }
  127318. declare module BABYLON {
  127319. /** @hidden */
  127320. export var pbrBlockSheen: {
  127321. name: string;
  127322. shader: string;
  127323. };
  127324. }
  127325. declare module BABYLON {
  127326. /** @hidden */
  127327. export var pbrBlockClearcoat: {
  127328. name: string;
  127329. shader: string;
  127330. };
  127331. }
  127332. declare module BABYLON {
  127333. /** @hidden */
  127334. export var pbrBlockSubSurface: {
  127335. name: string;
  127336. shader: string;
  127337. };
  127338. }
  127339. declare module BABYLON {
  127340. /** @hidden */
  127341. export var pbrBlockNormalGeometric: {
  127342. name: string;
  127343. shader: string;
  127344. };
  127345. }
  127346. declare module BABYLON {
  127347. /** @hidden */
  127348. export var pbrBlockNormalFinal: {
  127349. name: string;
  127350. shader: string;
  127351. };
  127352. }
  127353. declare module BABYLON {
  127354. /** @hidden */
  127355. export var pbrBlockGeometryInfo: {
  127356. name: string;
  127357. shader: string;
  127358. };
  127359. }
  127360. declare module BABYLON {
  127361. /** @hidden */
  127362. export var pbrBlockReflectance0: {
  127363. name: string;
  127364. shader: string;
  127365. };
  127366. }
  127367. declare module BABYLON {
  127368. /** @hidden */
  127369. export var pbrBlockReflectance: {
  127370. name: string;
  127371. shader: string;
  127372. };
  127373. }
  127374. declare module BABYLON {
  127375. /** @hidden */
  127376. export var pbrBlockDirectLighting: {
  127377. name: string;
  127378. shader: string;
  127379. };
  127380. }
  127381. declare module BABYLON {
  127382. /** @hidden */
  127383. export var pbrBlockFinalLitComponents: {
  127384. name: string;
  127385. shader: string;
  127386. };
  127387. }
  127388. declare module BABYLON {
  127389. /** @hidden */
  127390. export var pbrBlockFinalUnlitComponents: {
  127391. name: string;
  127392. shader: string;
  127393. };
  127394. }
  127395. declare module BABYLON {
  127396. /** @hidden */
  127397. export var pbrBlockFinalColorComposition: {
  127398. name: string;
  127399. shader: string;
  127400. };
  127401. }
  127402. declare module BABYLON {
  127403. /** @hidden */
  127404. export var pbrBlockImageProcessing: {
  127405. name: string;
  127406. shader: string;
  127407. };
  127408. }
  127409. declare module BABYLON {
  127410. /** @hidden */
  127411. export var pbrDebug: {
  127412. name: string;
  127413. shader: string;
  127414. };
  127415. }
  127416. declare module BABYLON {
  127417. /** @hidden */
  127418. export var pbrPixelShader: {
  127419. name: string;
  127420. shader: string;
  127421. };
  127422. }
  127423. declare module BABYLON {
  127424. /** @hidden */
  127425. export var pbrVertexDeclaration: {
  127426. name: string;
  127427. shader: string;
  127428. };
  127429. }
  127430. declare module BABYLON {
  127431. /** @hidden */
  127432. export var pbrVertexShader: {
  127433. name: string;
  127434. shader: string;
  127435. };
  127436. }
  127437. declare module BABYLON {
  127438. /**
  127439. * Manages the defines for the PBR Material.
  127440. * @hidden
  127441. */
  127442. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  127443. PBR: boolean;
  127444. MAINUV1: boolean;
  127445. MAINUV2: boolean;
  127446. UV1: boolean;
  127447. UV2: boolean;
  127448. ALBEDO: boolean;
  127449. GAMMAALBEDO: boolean;
  127450. ALBEDODIRECTUV: number;
  127451. VERTEXCOLOR: boolean;
  127452. AMBIENT: boolean;
  127453. AMBIENTDIRECTUV: number;
  127454. AMBIENTINGRAYSCALE: boolean;
  127455. OPACITY: boolean;
  127456. VERTEXALPHA: boolean;
  127457. OPACITYDIRECTUV: number;
  127458. OPACITYRGB: boolean;
  127459. ALPHATEST: boolean;
  127460. DEPTHPREPASS: boolean;
  127461. ALPHABLEND: boolean;
  127462. ALPHAFROMALBEDO: boolean;
  127463. ALPHATESTVALUE: string;
  127464. SPECULAROVERALPHA: boolean;
  127465. RADIANCEOVERALPHA: boolean;
  127466. ALPHAFRESNEL: boolean;
  127467. LINEARALPHAFRESNEL: boolean;
  127468. PREMULTIPLYALPHA: boolean;
  127469. EMISSIVE: boolean;
  127470. EMISSIVEDIRECTUV: number;
  127471. REFLECTIVITY: boolean;
  127472. REFLECTIVITYDIRECTUV: number;
  127473. SPECULARTERM: boolean;
  127474. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  127475. MICROSURFACEAUTOMATIC: boolean;
  127476. LODBASEDMICROSFURACE: boolean;
  127477. MICROSURFACEMAP: boolean;
  127478. MICROSURFACEMAPDIRECTUV: number;
  127479. METALLICWORKFLOW: boolean;
  127480. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  127481. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  127482. METALLNESSSTOREINMETALMAPBLUE: boolean;
  127483. AOSTOREINMETALMAPRED: boolean;
  127484. METALLICF0FACTORFROMMETALLICMAP: boolean;
  127485. ENVIRONMENTBRDF: boolean;
  127486. ENVIRONMENTBRDF_RGBD: boolean;
  127487. NORMAL: boolean;
  127488. TANGENT: boolean;
  127489. BUMP: boolean;
  127490. BUMPDIRECTUV: number;
  127491. OBJECTSPACE_NORMALMAP: boolean;
  127492. PARALLAX: boolean;
  127493. PARALLAXOCCLUSION: boolean;
  127494. NORMALXYSCALE: boolean;
  127495. LIGHTMAP: boolean;
  127496. LIGHTMAPDIRECTUV: number;
  127497. USELIGHTMAPASSHADOWMAP: boolean;
  127498. GAMMALIGHTMAP: boolean;
  127499. RGBDLIGHTMAP: boolean;
  127500. REFLECTION: boolean;
  127501. REFLECTIONMAP_3D: boolean;
  127502. REFLECTIONMAP_SPHERICAL: boolean;
  127503. REFLECTIONMAP_PLANAR: boolean;
  127504. REFLECTIONMAP_CUBIC: boolean;
  127505. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  127506. REFLECTIONMAP_PROJECTION: boolean;
  127507. REFLECTIONMAP_SKYBOX: boolean;
  127508. REFLECTIONMAP_EXPLICIT: boolean;
  127509. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  127510. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  127511. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  127512. INVERTCUBICMAP: boolean;
  127513. USESPHERICALFROMREFLECTIONMAP: boolean;
  127514. USEIRRADIANCEMAP: boolean;
  127515. SPHERICAL_HARMONICS: boolean;
  127516. USESPHERICALINVERTEX: boolean;
  127517. REFLECTIONMAP_OPPOSITEZ: boolean;
  127518. LODINREFLECTIONALPHA: boolean;
  127519. GAMMAREFLECTION: boolean;
  127520. RGBDREFLECTION: boolean;
  127521. LINEARSPECULARREFLECTION: boolean;
  127522. RADIANCEOCCLUSION: boolean;
  127523. HORIZONOCCLUSION: boolean;
  127524. INSTANCES: boolean;
  127525. NUM_BONE_INFLUENCERS: number;
  127526. BonesPerMesh: number;
  127527. BONETEXTURE: boolean;
  127528. NONUNIFORMSCALING: boolean;
  127529. MORPHTARGETS: boolean;
  127530. MORPHTARGETS_NORMAL: boolean;
  127531. MORPHTARGETS_TANGENT: boolean;
  127532. MORPHTARGETS_UV: boolean;
  127533. NUM_MORPH_INFLUENCERS: number;
  127534. IMAGEPROCESSING: boolean;
  127535. VIGNETTE: boolean;
  127536. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127537. VIGNETTEBLENDMODEOPAQUE: boolean;
  127538. TONEMAPPING: boolean;
  127539. TONEMAPPING_ACES: boolean;
  127540. CONTRAST: boolean;
  127541. COLORCURVES: boolean;
  127542. COLORGRADING: boolean;
  127543. COLORGRADING3D: boolean;
  127544. SAMPLER3DGREENDEPTH: boolean;
  127545. SAMPLER3DBGRMAP: boolean;
  127546. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127547. EXPOSURE: boolean;
  127548. MULTIVIEW: boolean;
  127549. USEPHYSICALLIGHTFALLOFF: boolean;
  127550. USEGLTFLIGHTFALLOFF: boolean;
  127551. TWOSIDEDLIGHTING: boolean;
  127552. SHADOWFLOAT: boolean;
  127553. CLIPPLANE: boolean;
  127554. CLIPPLANE2: boolean;
  127555. CLIPPLANE3: boolean;
  127556. CLIPPLANE4: boolean;
  127557. CLIPPLANE5: boolean;
  127558. CLIPPLANE6: boolean;
  127559. POINTSIZE: boolean;
  127560. FOG: boolean;
  127561. LOGARITHMICDEPTH: boolean;
  127562. FORCENORMALFORWARD: boolean;
  127563. SPECULARAA: boolean;
  127564. CLEARCOAT: boolean;
  127565. CLEARCOAT_DEFAULTIOR: boolean;
  127566. CLEARCOAT_TEXTURE: boolean;
  127567. CLEARCOAT_TEXTUREDIRECTUV: number;
  127568. CLEARCOAT_BUMP: boolean;
  127569. CLEARCOAT_BUMPDIRECTUV: number;
  127570. CLEARCOAT_TINT: boolean;
  127571. CLEARCOAT_TINT_TEXTURE: boolean;
  127572. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  127573. ANISOTROPIC: boolean;
  127574. ANISOTROPIC_TEXTURE: boolean;
  127575. ANISOTROPIC_TEXTUREDIRECTUV: number;
  127576. BRDF_V_HEIGHT_CORRELATED: boolean;
  127577. MS_BRDF_ENERGY_CONSERVATION: boolean;
  127578. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  127579. SHEEN: boolean;
  127580. SHEEN_TEXTURE: boolean;
  127581. SHEEN_TEXTUREDIRECTUV: number;
  127582. SHEEN_LINKWITHALBEDO: boolean;
  127583. SHEEN_ROUGHNESS: boolean;
  127584. SHEEN_ALBEDOSCALING: boolean;
  127585. SUBSURFACE: boolean;
  127586. SS_REFRACTION: boolean;
  127587. SS_TRANSLUCENCY: boolean;
  127588. SS_SCATERRING: boolean;
  127589. SS_THICKNESSANDMASK_TEXTURE: boolean;
  127590. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  127591. SS_REFRACTIONMAP_3D: boolean;
  127592. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  127593. SS_LODINREFRACTIONALPHA: boolean;
  127594. SS_GAMMAREFRACTION: boolean;
  127595. SS_RGBDREFRACTION: boolean;
  127596. SS_LINEARSPECULARREFRACTION: boolean;
  127597. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  127598. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  127599. UNLIT: boolean;
  127600. DEBUGMODE: number;
  127601. /**
  127602. * Initializes the PBR Material defines.
  127603. */
  127604. constructor();
  127605. /**
  127606. * Resets the PBR Material defines.
  127607. */
  127608. reset(): void;
  127609. }
  127610. /**
  127611. * The Physically based material base class of BJS.
  127612. *
  127613. * This offers the main features of a standard PBR material.
  127614. * For more information, please refer to the documentation :
  127615. * https://doc.babylonjs.com/how_to/physically_based_rendering
  127616. */
  127617. export abstract class PBRBaseMaterial extends PushMaterial {
  127618. /**
  127619. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  127620. */
  127621. static readonly PBRMATERIAL_OPAQUE: number;
  127622. /**
  127623. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  127624. */
  127625. static readonly PBRMATERIAL_ALPHATEST: number;
  127626. /**
  127627. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127628. */
  127629. static readonly PBRMATERIAL_ALPHABLEND: number;
  127630. /**
  127631. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  127632. * They are also discarded below the alpha cutoff threshold to improve performances.
  127633. */
  127634. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  127635. /**
  127636. * Defines the default value of how much AO map is occluding the analytical lights
  127637. * (point spot...).
  127638. */
  127639. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  127640. /**
  127641. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  127642. */
  127643. static readonly LIGHTFALLOFF_PHYSICAL: number;
  127644. /**
  127645. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  127646. * to enhance interoperability with other engines.
  127647. */
  127648. static readonly LIGHTFALLOFF_GLTF: number;
  127649. /**
  127650. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  127651. * to enhance interoperability with other materials.
  127652. */
  127653. static readonly LIGHTFALLOFF_STANDARD: number;
  127654. /**
  127655. * Intensity of the direct lights e.g. the four lights available in your scene.
  127656. * This impacts both the direct diffuse and specular highlights.
  127657. */
  127658. protected _directIntensity: number;
  127659. /**
  127660. * Intensity of the emissive part of the material.
  127661. * This helps controlling the emissive effect without modifying the emissive color.
  127662. */
  127663. protected _emissiveIntensity: number;
  127664. /**
  127665. * Intensity of the environment e.g. how much the environment will light the object
  127666. * either through harmonics for rough material or through the refelction for shiny ones.
  127667. */
  127668. protected _environmentIntensity: number;
  127669. /**
  127670. * This is a special control allowing the reduction of the specular highlights coming from the
  127671. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  127672. */
  127673. protected _specularIntensity: number;
  127674. /**
  127675. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  127676. */
  127677. private _lightingInfos;
  127678. /**
  127679. * Debug Control allowing disabling the bump map on this material.
  127680. */
  127681. protected _disableBumpMap: boolean;
  127682. /**
  127683. * AKA Diffuse Texture in standard nomenclature.
  127684. */
  127685. protected _albedoTexture: Nullable<BaseTexture>;
  127686. /**
  127687. * AKA Occlusion Texture in other nomenclature.
  127688. */
  127689. protected _ambientTexture: Nullable<BaseTexture>;
  127690. /**
  127691. * AKA Occlusion Texture Intensity in other nomenclature.
  127692. */
  127693. protected _ambientTextureStrength: number;
  127694. /**
  127695. * Defines how much the AO map is occluding the analytical lights (point spot...).
  127696. * 1 means it completely occludes it
  127697. * 0 mean it has no impact
  127698. */
  127699. protected _ambientTextureImpactOnAnalyticalLights: number;
  127700. /**
  127701. * Stores the alpha values in a texture.
  127702. */
  127703. protected _opacityTexture: Nullable<BaseTexture>;
  127704. /**
  127705. * Stores the reflection values in a texture.
  127706. */
  127707. protected _reflectionTexture: Nullable<BaseTexture>;
  127708. /**
  127709. * Stores the emissive values in a texture.
  127710. */
  127711. protected _emissiveTexture: Nullable<BaseTexture>;
  127712. /**
  127713. * AKA Specular texture in other nomenclature.
  127714. */
  127715. protected _reflectivityTexture: Nullable<BaseTexture>;
  127716. /**
  127717. * Used to switch from specular/glossiness to metallic/roughness workflow.
  127718. */
  127719. protected _metallicTexture: Nullable<BaseTexture>;
  127720. /**
  127721. * Specifies the metallic scalar of the metallic/roughness workflow.
  127722. * Can also be used to scale the metalness values of the metallic texture.
  127723. */
  127724. protected _metallic: Nullable<number>;
  127725. /**
  127726. * Specifies the roughness scalar of the metallic/roughness workflow.
  127727. * Can also be used to scale the roughness values of the metallic texture.
  127728. */
  127729. protected _roughness: Nullable<number>;
  127730. /**
  127731. * Specifies the an F0 factor to help configuring the material F0.
  127732. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  127733. * to 0.5 the previously hard coded value stays the same.
  127734. * Can also be used to scale the F0 values of the metallic texture.
  127735. */
  127736. protected _metallicF0Factor: number;
  127737. /**
  127738. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  127739. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  127740. * your expectation as it multiplies with the texture data.
  127741. */
  127742. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  127743. /**
  127744. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  127745. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  127746. */
  127747. protected _microSurfaceTexture: Nullable<BaseTexture>;
  127748. /**
  127749. * Stores surface normal data used to displace a mesh in a texture.
  127750. */
  127751. protected _bumpTexture: Nullable<BaseTexture>;
  127752. /**
  127753. * Stores the pre-calculated light information of a mesh in a texture.
  127754. */
  127755. protected _lightmapTexture: Nullable<BaseTexture>;
  127756. /**
  127757. * The color of a material in ambient lighting.
  127758. */
  127759. protected _ambientColor: Color3;
  127760. /**
  127761. * AKA Diffuse Color in other nomenclature.
  127762. */
  127763. protected _albedoColor: Color3;
  127764. /**
  127765. * AKA Specular Color in other nomenclature.
  127766. */
  127767. protected _reflectivityColor: Color3;
  127768. /**
  127769. * The color applied when light is reflected from a material.
  127770. */
  127771. protected _reflectionColor: Color3;
  127772. /**
  127773. * The color applied when light is emitted from a material.
  127774. */
  127775. protected _emissiveColor: Color3;
  127776. /**
  127777. * AKA Glossiness in other nomenclature.
  127778. */
  127779. protected _microSurface: number;
  127780. /**
  127781. * Specifies that the material will use the light map as a show map.
  127782. */
  127783. protected _useLightmapAsShadowmap: boolean;
  127784. /**
  127785. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  127786. * makes the reflect vector face the model (under horizon).
  127787. */
  127788. protected _useHorizonOcclusion: boolean;
  127789. /**
  127790. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  127791. * too much the area relying on ambient texture to define their ambient occlusion.
  127792. */
  127793. protected _useRadianceOcclusion: boolean;
  127794. /**
  127795. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  127796. */
  127797. protected _useAlphaFromAlbedoTexture: boolean;
  127798. /**
  127799. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  127800. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  127801. */
  127802. protected _useSpecularOverAlpha: boolean;
  127803. /**
  127804. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  127805. */
  127806. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  127807. /**
  127808. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  127809. */
  127810. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  127811. /**
  127812. * Specifies if the metallic texture contains the roughness information in its green channel.
  127813. */
  127814. protected _useRoughnessFromMetallicTextureGreen: boolean;
  127815. /**
  127816. * Specifies if the metallic texture contains the metallness information in its blue channel.
  127817. */
  127818. protected _useMetallnessFromMetallicTextureBlue: boolean;
  127819. /**
  127820. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  127821. */
  127822. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  127823. /**
  127824. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  127825. */
  127826. protected _useAmbientInGrayScale: boolean;
  127827. /**
  127828. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  127829. * The material will try to infer what glossiness each pixel should be.
  127830. */
  127831. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  127832. /**
  127833. * Defines the falloff type used in this material.
  127834. * It by default is Physical.
  127835. */
  127836. protected _lightFalloff: number;
  127837. /**
  127838. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  127839. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  127840. */
  127841. protected _useRadianceOverAlpha: boolean;
  127842. /**
  127843. * Allows using an object space normal map (instead of tangent space).
  127844. */
  127845. protected _useObjectSpaceNormalMap: boolean;
  127846. /**
  127847. * Allows using the bump map in parallax mode.
  127848. */
  127849. protected _useParallax: boolean;
  127850. /**
  127851. * Allows using the bump map in parallax occlusion mode.
  127852. */
  127853. protected _useParallaxOcclusion: boolean;
  127854. /**
  127855. * Controls the scale bias of the parallax mode.
  127856. */
  127857. protected _parallaxScaleBias: number;
  127858. /**
  127859. * If sets to true, disables all the lights affecting the material.
  127860. */
  127861. protected _disableLighting: boolean;
  127862. /**
  127863. * Number of Simultaneous lights allowed on the material.
  127864. */
  127865. protected _maxSimultaneousLights: number;
  127866. /**
  127867. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  127868. */
  127869. protected _invertNormalMapX: boolean;
  127870. /**
  127871. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  127872. */
  127873. protected _invertNormalMapY: boolean;
  127874. /**
  127875. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  127876. */
  127877. protected _twoSidedLighting: boolean;
  127878. /**
  127879. * Defines the alpha limits in alpha test mode.
  127880. */
  127881. protected _alphaCutOff: number;
  127882. /**
  127883. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  127884. */
  127885. protected _forceAlphaTest: boolean;
  127886. /**
  127887. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127888. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  127889. */
  127890. protected _useAlphaFresnel: boolean;
  127891. /**
  127892. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  127893. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  127894. */
  127895. protected _useLinearAlphaFresnel: boolean;
  127896. /**
  127897. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  127898. * from cos thetav and roughness:
  127899. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  127900. */
  127901. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  127902. /**
  127903. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  127904. */
  127905. protected _forceIrradianceInFragment: boolean;
  127906. /**
  127907. * Force normal to face away from face.
  127908. */
  127909. protected _forceNormalForward: boolean;
  127910. /**
  127911. * Enables specular anti aliasing in the PBR shader.
  127912. * It will both interacts on the Geometry for analytical and IBL lighting.
  127913. * It also prefilter the roughness map based on the bump values.
  127914. */
  127915. protected _enableSpecularAntiAliasing: boolean;
  127916. /**
  127917. * Default configuration related to image processing available in the PBR Material.
  127918. */
  127919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  127920. /**
  127921. * Keep track of the image processing observer to allow dispose and replace.
  127922. */
  127923. private _imageProcessingObserver;
  127924. /**
  127925. * Attaches a new image processing configuration to the PBR Material.
  127926. * @param configuration
  127927. */
  127928. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  127929. /**
  127930. * Stores the available render targets.
  127931. */
  127932. private _renderTargets;
  127933. /**
  127934. * Sets the global ambient color for the material used in lighting calculations.
  127935. */
  127936. private _globalAmbientColor;
  127937. /**
  127938. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  127939. */
  127940. private _useLogarithmicDepth;
  127941. /**
  127942. * If set to true, no lighting calculations will be applied.
  127943. */
  127944. private _unlit;
  127945. private _debugMode;
  127946. /**
  127947. * @hidden
  127948. * This is reserved for the inspector.
  127949. * Defines the material debug mode.
  127950. * It helps seeing only some components of the material while troubleshooting.
  127951. */
  127952. debugMode: number;
  127953. /**
  127954. * @hidden
  127955. * This is reserved for the inspector.
  127956. * Specify from where on screen the debug mode should start.
  127957. * The value goes from -1 (full screen) to 1 (not visible)
  127958. * It helps with side by side comparison against the final render
  127959. * This defaults to -1
  127960. */
  127961. private debugLimit;
  127962. /**
  127963. * @hidden
  127964. * This is reserved for the inspector.
  127965. * As the default viewing range might not be enough (if the ambient is really small for instance)
  127966. * You can use the factor to better multiply the final value.
  127967. */
  127968. private debugFactor;
  127969. /**
  127970. * Defines the clear coat layer parameters for the material.
  127971. */
  127972. readonly clearCoat: PBRClearCoatConfiguration;
  127973. /**
  127974. * Defines the anisotropic parameters for the material.
  127975. */
  127976. readonly anisotropy: PBRAnisotropicConfiguration;
  127977. /**
  127978. * Defines the BRDF parameters for the material.
  127979. */
  127980. readonly brdf: PBRBRDFConfiguration;
  127981. /**
  127982. * Defines the Sheen parameters for the material.
  127983. */
  127984. readonly sheen: PBRSheenConfiguration;
  127985. /**
  127986. * Defines the SubSurface parameters for the material.
  127987. */
  127988. readonly subSurface: PBRSubSurfaceConfiguration;
  127989. protected _rebuildInParallel: boolean;
  127990. /**
  127991. * Instantiates a new PBRMaterial instance.
  127992. *
  127993. * @param name The material name
  127994. * @param scene The scene the material will be use in.
  127995. */
  127996. constructor(name: string, scene: Scene);
  127997. /**
  127998. * Gets a boolean indicating that current material needs to register RTT
  127999. */
  128000. get hasRenderTargetTextures(): boolean;
  128001. /**
  128002. * Gets the name of the material class.
  128003. */
  128004. getClassName(): string;
  128005. /**
  128006. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128007. */
  128008. get useLogarithmicDepth(): boolean;
  128009. /**
  128010. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  128011. */
  128012. set useLogarithmicDepth(value: boolean);
  128013. /**
  128014. * Returns true if alpha blending should be disabled.
  128015. */
  128016. protected get _disableAlphaBlending(): boolean;
  128017. /**
  128018. * Specifies whether or not this material should be rendered in alpha blend mode.
  128019. */
  128020. needAlphaBlending(): boolean;
  128021. /**
  128022. * Specifies whether or not this material should be rendered in alpha test mode.
  128023. */
  128024. needAlphaTesting(): boolean;
  128025. /**
  128026. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  128027. */
  128028. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  128029. /**
  128030. * Gets the texture used for the alpha test.
  128031. */
  128032. getAlphaTestTexture(): Nullable<BaseTexture>;
  128033. /**
  128034. * Specifies that the submesh is ready to be used.
  128035. * @param mesh - BJS mesh.
  128036. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  128037. * @param useInstances - Specifies that instances should be used.
  128038. * @returns - boolean indicating that the submesh is ready or not.
  128039. */
  128040. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  128041. /**
  128042. * Specifies if the material uses metallic roughness workflow.
  128043. * @returns boolean specifiying if the material uses metallic roughness workflow.
  128044. */
  128045. isMetallicWorkflow(): boolean;
  128046. private _prepareEffect;
  128047. private _prepareDefines;
  128048. /**
  128049. * Force shader compilation
  128050. */
  128051. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  128052. /**
  128053. * Initializes the uniform buffer layout for the shader.
  128054. */
  128055. buildUniformLayout(): void;
  128056. /**
  128057. * Unbinds the material from the mesh
  128058. */
  128059. unbind(): void;
  128060. /**
  128061. * Binds the submesh data.
  128062. * @param world - The world matrix.
  128063. * @param mesh - The BJS mesh.
  128064. * @param subMesh - A submesh of the BJS mesh.
  128065. */
  128066. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  128067. /**
  128068. * Returns the animatable textures.
  128069. * @returns - Array of animatable textures.
  128070. */
  128071. getAnimatables(): IAnimatable[];
  128072. /**
  128073. * Returns the texture used for reflections.
  128074. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  128075. */
  128076. private _getReflectionTexture;
  128077. /**
  128078. * Returns an array of the actively used textures.
  128079. * @returns - Array of BaseTextures
  128080. */
  128081. getActiveTextures(): BaseTexture[];
  128082. /**
  128083. * Checks to see if a texture is used in the material.
  128084. * @param texture - Base texture to use.
  128085. * @returns - Boolean specifying if a texture is used in the material.
  128086. */
  128087. hasTexture(texture: BaseTexture): boolean;
  128088. /**
  128089. * Disposes the resources of the material.
  128090. * @param forceDisposeEffect - Forces the disposal of effects.
  128091. * @param forceDisposeTextures - Forces the disposal of all textures.
  128092. */
  128093. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  128094. }
  128095. }
  128096. declare module BABYLON {
  128097. /**
  128098. * The Physically based material of BJS.
  128099. *
  128100. * This offers the main features of a standard PBR material.
  128101. * For more information, please refer to the documentation :
  128102. * https://doc.babylonjs.com/how_to/physically_based_rendering
  128103. */
  128104. export class PBRMaterial extends PBRBaseMaterial {
  128105. /**
  128106. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  128107. */
  128108. static readonly PBRMATERIAL_OPAQUE: number;
  128109. /**
  128110. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  128111. */
  128112. static readonly PBRMATERIAL_ALPHATEST: number;
  128113. /**
  128114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128115. */
  128116. static readonly PBRMATERIAL_ALPHABLEND: number;
  128117. /**
  128118. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  128119. * They are also discarded below the alpha cutoff threshold to improve performances.
  128120. */
  128121. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  128122. /**
  128123. * Defines the default value of how much AO map is occluding the analytical lights
  128124. * (point spot...).
  128125. */
  128126. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  128127. /**
  128128. * Intensity of the direct lights e.g. the four lights available in your scene.
  128129. * This impacts both the direct diffuse and specular highlights.
  128130. */
  128131. directIntensity: number;
  128132. /**
  128133. * Intensity of the emissive part of the material.
  128134. * This helps controlling the emissive effect without modifying the emissive color.
  128135. */
  128136. emissiveIntensity: number;
  128137. /**
  128138. * Intensity of the environment e.g. how much the environment will light the object
  128139. * either through harmonics for rough material or through the refelction for shiny ones.
  128140. */
  128141. environmentIntensity: number;
  128142. /**
  128143. * This is a special control allowing the reduction of the specular highlights coming from the
  128144. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  128145. */
  128146. specularIntensity: number;
  128147. /**
  128148. * Debug Control allowing disabling the bump map on this material.
  128149. */
  128150. disableBumpMap: boolean;
  128151. /**
  128152. * AKA Diffuse Texture in standard nomenclature.
  128153. */
  128154. albedoTexture: BaseTexture;
  128155. /**
  128156. * AKA Occlusion Texture in other nomenclature.
  128157. */
  128158. ambientTexture: BaseTexture;
  128159. /**
  128160. * AKA Occlusion Texture Intensity in other nomenclature.
  128161. */
  128162. ambientTextureStrength: number;
  128163. /**
  128164. * Defines how much the AO map is occluding the analytical lights (point spot...).
  128165. * 1 means it completely occludes it
  128166. * 0 mean it has no impact
  128167. */
  128168. ambientTextureImpactOnAnalyticalLights: number;
  128169. /**
  128170. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  128171. */
  128172. opacityTexture: BaseTexture;
  128173. /**
  128174. * Stores the reflection values in a texture.
  128175. */
  128176. reflectionTexture: Nullable<BaseTexture>;
  128177. /**
  128178. * Stores the emissive values in a texture.
  128179. */
  128180. emissiveTexture: BaseTexture;
  128181. /**
  128182. * AKA Specular texture in other nomenclature.
  128183. */
  128184. reflectivityTexture: BaseTexture;
  128185. /**
  128186. * Used to switch from specular/glossiness to metallic/roughness workflow.
  128187. */
  128188. metallicTexture: BaseTexture;
  128189. /**
  128190. * Specifies the metallic scalar of the metallic/roughness workflow.
  128191. * Can also be used to scale the metalness values of the metallic texture.
  128192. */
  128193. metallic: Nullable<number>;
  128194. /**
  128195. * Specifies the roughness scalar of the metallic/roughness workflow.
  128196. * Can also be used to scale the roughness values of the metallic texture.
  128197. */
  128198. roughness: Nullable<number>;
  128199. /**
  128200. * Specifies the an F0 factor to help configuring the material F0.
  128201. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  128202. * to 0.5 the previously hard coded value stays the same.
  128203. * Can also be used to scale the F0 values of the metallic texture.
  128204. */
  128205. metallicF0Factor: number;
  128206. /**
  128207. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  128208. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  128209. * your expectation as it multiplies with the texture data.
  128210. */
  128211. useMetallicF0FactorFromMetallicTexture: boolean;
  128212. /**
  128213. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  128214. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  128215. */
  128216. microSurfaceTexture: BaseTexture;
  128217. /**
  128218. * Stores surface normal data used to displace a mesh in a texture.
  128219. */
  128220. bumpTexture: BaseTexture;
  128221. /**
  128222. * Stores the pre-calculated light information of a mesh in a texture.
  128223. */
  128224. lightmapTexture: BaseTexture;
  128225. /**
  128226. * Stores the refracted light information in a texture.
  128227. */
  128228. get refractionTexture(): Nullable<BaseTexture>;
  128229. set refractionTexture(value: Nullable<BaseTexture>);
  128230. /**
  128231. * The color of a material in ambient lighting.
  128232. */
  128233. ambientColor: Color3;
  128234. /**
  128235. * AKA Diffuse Color in other nomenclature.
  128236. */
  128237. albedoColor: Color3;
  128238. /**
  128239. * AKA Specular Color in other nomenclature.
  128240. */
  128241. reflectivityColor: Color3;
  128242. /**
  128243. * The color reflected from the material.
  128244. */
  128245. reflectionColor: Color3;
  128246. /**
  128247. * The color emitted from the material.
  128248. */
  128249. emissiveColor: Color3;
  128250. /**
  128251. * AKA Glossiness in other nomenclature.
  128252. */
  128253. microSurface: number;
  128254. /**
  128255. * source material index of refraction (IOR)' / 'destination material IOR.
  128256. */
  128257. get indexOfRefraction(): number;
  128258. set indexOfRefraction(value: number);
  128259. /**
  128260. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  128261. */
  128262. get invertRefractionY(): boolean;
  128263. set invertRefractionY(value: boolean);
  128264. /**
  128265. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  128266. * Materials half opaque for instance using refraction could benefit from this control.
  128267. */
  128268. get linkRefractionWithTransparency(): boolean;
  128269. set linkRefractionWithTransparency(value: boolean);
  128270. /**
  128271. * If true, the light map contains occlusion information instead of lighting info.
  128272. */
  128273. useLightmapAsShadowmap: boolean;
  128274. /**
  128275. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  128276. */
  128277. useAlphaFromAlbedoTexture: boolean;
  128278. /**
  128279. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  128280. */
  128281. forceAlphaTest: boolean;
  128282. /**
  128283. * Defines the alpha limits in alpha test mode.
  128284. */
  128285. alphaCutOff: number;
  128286. /**
  128287. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  128288. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  128289. */
  128290. useSpecularOverAlpha: boolean;
  128291. /**
  128292. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  128293. */
  128294. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  128295. /**
  128296. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  128297. */
  128298. useRoughnessFromMetallicTextureAlpha: boolean;
  128299. /**
  128300. * Specifies if the metallic texture contains the roughness information in its green channel.
  128301. */
  128302. useRoughnessFromMetallicTextureGreen: boolean;
  128303. /**
  128304. * Specifies if the metallic texture contains the metallness information in its blue channel.
  128305. */
  128306. useMetallnessFromMetallicTextureBlue: boolean;
  128307. /**
  128308. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  128309. */
  128310. useAmbientOcclusionFromMetallicTextureRed: boolean;
  128311. /**
  128312. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  128313. */
  128314. useAmbientInGrayScale: boolean;
  128315. /**
  128316. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  128317. * The material will try to infer what glossiness each pixel should be.
  128318. */
  128319. useAutoMicroSurfaceFromReflectivityMap: boolean;
  128320. /**
  128321. * BJS is using an harcoded light falloff based on a manually sets up range.
  128322. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128323. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128324. */
  128325. get usePhysicalLightFalloff(): boolean;
  128326. /**
  128327. * BJS is using an harcoded light falloff based on a manually sets up range.
  128328. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  128329. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  128330. */
  128331. set usePhysicalLightFalloff(value: boolean);
  128332. /**
  128333. * In order to support the falloff compatibility with gltf, a special mode has been added
  128334. * to reproduce the gltf light falloff.
  128335. */
  128336. get useGLTFLightFalloff(): boolean;
  128337. /**
  128338. * In order to support the falloff compatibility with gltf, a special mode has been added
  128339. * to reproduce the gltf light falloff.
  128340. */
  128341. set useGLTFLightFalloff(value: boolean);
  128342. /**
  128343. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  128344. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  128345. */
  128346. useRadianceOverAlpha: boolean;
  128347. /**
  128348. * Allows using an object space normal map (instead of tangent space).
  128349. */
  128350. useObjectSpaceNormalMap: boolean;
  128351. /**
  128352. * Allows using the bump map in parallax mode.
  128353. */
  128354. useParallax: boolean;
  128355. /**
  128356. * Allows using the bump map in parallax occlusion mode.
  128357. */
  128358. useParallaxOcclusion: boolean;
  128359. /**
  128360. * Controls the scale bias of the parallax mode.
  128361. */
  128362. parallaxScaleBias: number;
  128363. /**
  128364. * If sets to true, disables all the lights affecting the material.
  128365. */
  128366. disableLighting: boolean;
  128367. /**
  128368. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  128369. */
  128370. forceIrradianceInFragment: boolean;
  128371. /**
  128372. * Number of Simultaneous lights allowed on the material.
  128373. */
  128374. maxSimultaneousLights: number;
  128375. /**
  128376. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128377. */
  128378. invertNormalMapX: boolean;
  128379. /**
  128380. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128381. */
  128382. invertNormalMapY: boolean;
  128383. /**
  128384. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128385. */
  128386. twoSidedLighting: boolean;
  128387. /**
  128388. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128389. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  128390. */
  128391. useAlphaFresnel: boolean;
  128392. /**
  128393. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  128394. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  128395. */
  128396. useLinearAlphaFresnel: boolean;
  128397. /**
  128398. * Let user defines the brdf lookup texture used for IBL.
  128399. * A default 8bit version is embedded but you could point at :
  128400. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  128401. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  128402. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  128403. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  128404. */
  128405. environmentBRDFTexture: Nullable<BaseTexture>;
  128406. /**
  128407. * Force normal to face away from face.
  128408. */
  128409. forceNormalForward: boolean;
  128410. /**
  128411. * Enables specular anti aliasing in the PBR shader.
  128412. * It will both interacts on the Geometry for analytical and IBL lighting.
  128413. * It also prefilter the roughness map based on the bump values.
  128414. */
  128415. enableSpecularAntiAliasing: boolean;
  128416. /**
  128417. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  128418. * makes the reflect vector face the model (under horizon).
  128419. */
  128420. useHorizonOcclusion: boolean;
  128421. /**
  128422. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  128423. * too much the area relying on ambient texture to define their ambient occlusion.
  128424. */
  128425. useRadianceOcclusion: boolean;
  128426. /**
  128427. * If set to true, no lighting calculations will be applied.
  128428. */
  128429. unlit: boolean;
  128430. /**
  128431. * Gets the image processing configuration used either in this material.
  128432. */
  128433. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  128434. /**
  128435. * Sets the Default image processing configuration used either in the this material.
  128436. *
  128437. * If sets to null, the scene one is in use.
  128438. */
  128439. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  128440. /**
  128441. * Gets wether the color curves effect is enabled.
  128442. */
  128443. get cameraColorCurvesEnabled(): boolean;
  128444. /**
  128445. * Sets wether the color curves effect is enabled.
  128446. */
  128447. set cameraColorCurvesEnabled(value: boolean);
  128448. /**
  128449. * Gets wether the color grading effect is enabled.
  128450. */
  128451. get cameraColorGradingEnabled(): boolean;
  128452. /**
  128453. * Gets wether the color grading effect is enabled.
  128454. */
  128455. set cameraColorGradingEnabled(value: boolean);
  128456. /**
  128457. * Gets wether tonemapping is enabled or not.
  128458. */
  128459. get cameraToneMappingEnabled(): boolean;
  128460. /**
  128461. * Sets wether tonemapping is enabled or not
  128462. */
  128463. set cameraToneMappingEnabled(value: boolean);
  128464. /**
  128465. * The camera exposure used on this material.
  128466. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128467. * This corresponds to a photographic exposure.
  128468. */
  128469. get cameraExposure(): number;
  128470. /**
  128471. * The camera exposure used on this material.
  128472. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  128473. * This corresponds to a photographic exposure.
  128474. */
  128475. set cameraExposure(value: number);
  128476. /**
  128477. * Gets The camera contrast used on this material.
  128478. */
  128479. get cameraContrast(): number;
  128480. /**
  128481. * Sets The camera contrast used on this material.
  128482. */
  128483. set cameraContrast(value: number);
  128484. /**
  128485. * Gets the Color Grading 2D Lookup Texture.
  128486. */
  128487. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  128488. /**
  128489. * Sets the Color Grading 2D Lookup Texture.
  128490. */
  128491. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  128492. /**
  128493. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128494. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128495. * 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;
  128496. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128497. */
  128498. get cameraColorCurves(): Nullable<ColorCurves>;
  128499. /**
  128500. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  128501. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  128502. * 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;
  128503. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  128504. */
  128505. set cameraColorCurves(value: Nullable<ColorCurves>);
  128506. /**
  128507. * Instantiates a new PBRMaterial instance.
  128508. *
  128509. * @param name The material name
  128510. * @param scene The scene the material will be use in.
  128511. */
  128512. constructor(name: string, scene: Scene);
  128513. /**
  128514. * Returns the name of this material class.
  128515. */
  128516. getClassName(): string;
  128517. /**
  128518. * Makes a duplicate of the current material.
  128519. * @param name - name to use for the new material.
  128520. */
  128521. clone(name: string): PBRMaterial;
  128522. /**
  128523. * Serializes this PBR Material.
  128524. * @returns - An object with the serialized material.
  128525. */
  128526. serialize(): any;
  128527. /**
  128528. * Parses a PBR Material from a serialized object.
  128529. * @param source - Serialized object.
  128530. * @param scene - BJS scene instance.
  128531. * @param rootUrl - url for the scene object
  128532. * @returns - PBRMaterial
  128533. */
  128534. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  128535. }
  128536. }
  128537. declare module BABYLON {
  128538. /**
  128539. * Direct draw surface info
  128540. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  128541. */
  128542. export interface DDSInfo {
  128543. /**
  128544. * Width of the texture
  128545. */
  128546. width: number;
  128547. /**
  128548. * Width of the texture
  128549. */
  128550. height: number;
  128551. /**
  128552. * Number of Mipmaps for the texture
  128553. * @see https://en.wikipedia.org/wiki/Mipmap
  128554. */
  128555. mipmapCount: number;
  128556. /**
  128557. * If the textures format is a known fourCC format
  128558. * @see https://www.fourcc.org/
  128559. */
  128560. isFourCC: boolean;
  128561. /**
  128562. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  128563. */
  128564. isRGB: boolean;
  128565. /**
  128566. * If the texture is a lumincance format
  128567. */
  128568. isLuminance: boolean;
  128569. /**
  128570. * If this is a cube texture
  128571. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  128572. */
  128573. isCube: boolean;
  128574. /**
  128575. * If the texture is a compressed format eg. FOURCC_DXT1
  128576. */
  128577. isCompressed: boolean;
  128578. /**
  128579. * The dxgiFormat of the texture
  128580. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  128581. */
  128582. dxgiFormat: number;
  128583. /**
  128584. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  128585. */
  128586. textureType: number;
  128587. /**
  128588. * Sphericle polynomial created for the dds texture
  128589. */
  128590. sphericalPolynomial?: SphericalPolynomial;
  128591. }
  128592. /**
  128593. * Class used to provide DDS decompression tools
  128594. */
  128595. export class DDSTools {
  128596. /**
  128597. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  128598. */
  128599. static StoreLODInAlphaChannel: boolean;
  128600. /**
  128601. * Gets DDS information from an array buffer
  128602. * @param data defines the array buffer view to read data from
  128603. * @returns the DDS information
  128604. */
  128605. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  128606. private static _FloatView;
  128607. private static _Int32View;
  128608. private static _ToHalfFloat;
  128609. private static _FromHalfFloat;
  128610. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  128611. private static _GetHalfFloatRGBAArrayBuffer;
  128612. private static _GetFloatRGBAArrayBuffer;
  128613. private static _GetFloatAsUIntRGBAArrayBuffer;
  128614. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  128615. private static _GetRGBAArrayBuffer;
  128616. private static _ExtractLongWordOrder;
  128617. private static _GetRGBArrayBuffer;
  128618. private static _GetLuminanceArrayBuffer;
  128619. /**
  128620. * Uploads DDS Levels to a Babylon Texture
  128621. * @hidden
  128622. */
  128623. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  128624. }
  128625. interface ThinEngine {
  128626. /**
  128627. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  128628. * @param rootUrl defines the url where the file to load is located
  128629. * @param scene defines the current scene
  128630. * @param lodScale defines scale to apply to the mip map selection
  128631. * @param lodOffset defines offset to apply to the mip map selection
  128632. * @param onLoad defines an optional callback raised when the texture is loaded
  128633. * @param onError defines an optional callback raised if there is an issue to load the texture
  128634. * @param format defines the format of the data
  128635. * @param forcedExtension defines the extension to use to pick the right loader
  128636. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  128637. * @returns the cube texture as an InternalTexture
  128638. */
  128639. 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;
  128640. }
  128641. }
  128642. declare module BABYLON {
  128643. /**
  128644. * Implementation of the DDS Texture Loader.
  128645. * @hidden
  128646. */
  128647. export class _DDSTextureLoader implements IInternalTextureLoader {
  128648. /**
  128649. * Defines wether the loader supports cascade loading the different faces.
  128650. */
  128651. readonly supportCascades: boolean;
  128652. /**
  128653. * This returns if the loader support the current file information.
  128654. * @param extension defines the file extension of the file being loaded
  128655. * @returns true if the loader can load the specified file
  128656. */
  128657. canLoad(extension: string): boolean;
  128658. /**
  128659. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128660. * @param data contains the texture data
  128661. * @param texture defines the BabylonJS internal texture
  128662. * @param createPolynomials will be true if polynomials have been requested
  128663. * @param onLoad defines the callback to trigger once the texture is ready
  128664. * @param onError defines the callback to trigger in case of error
  128665. */
  128666. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128667. /**
  128668. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128669. * @param data contains the texture data
  128670. * @param texture defines the BabylonJS internal texture
  128671. * @param callback defines the method to call once ready to upload
  128672. */
  128673. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128674. }
  128675. }
  128676. declare module BABYLON {
  128677. /**
  128678. * Implementation of the ENV Texture Loader.
  128679. * @hidden
  128680. */
  128681. export class _ENVTextureLoader implements IInternalTextureLoader {
  128682. /**
  128683. * Defines wether the loader supports cascade loading the different faces.
  128684. */
  128685. readonly supportCascades: boolean;
  128686. /**
  128687. * This returns if the loader support the current file information.
  128688. * @param extension defines the file extension of the file being loaded
  128689. * @returns true if the loader can load the specified file
  128690. */
  128691. canLoad(extension: string): boolean;
  128692. /**
  128693. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128694. * @param data contains the texture data
  128695. * @param texture defines the BabylonJS internal texture
  128696. * @param createPolynomials will be true if polynomials have been requested
  128697. * @param onLoad defines the callback to trigger once the texture is ready
  128698. * @param onError defines the callback to trigger in case of error
  128699. */
  128700. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128701. /**
  128702. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128703. * @param data contains the texture data
  128704. * @param texture defines the BabylonJS internal texture
  128705. * @param callback defines the method to call once ready to upload
  128706. */
  128707. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128708. }
  128709. }
  128710. declare module BABYLON {
  128711. /**
  128712. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128713. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128714. */
  128715. export class KhronosTextureContainer {
  128716. /** contents of the KTX container file */
  128717. data: ArrayBufferView;
  128718. private static HEADER_LEN;
  128719. private static COMPRESSED_2D;
  128720. private static COMPRESSED_3D;
  128721. private static TEX_2D;
  128722. private static TEX_3D;
  128723. /**
  128724. * Gets the openGL type
  128725. */
  128726. glType: number;
  128727. /**
  128728. * Gets the openGL type size
  128729. */
  128730. glTypeSize: number;
  128731. /**
  128732. * Gets the openGL format
  128733. */
  128734. glFormat: number;
  128735. /**
  128736. * Gets the openGL internal format
  128737. */
  128738. glInternalFormat: number;
  128739. /**
  128740. * Gets the base internal format
  128741. */
  128742. glBaseInternalFormat: number;
  128743. /**
  128744. * Gets image width in pixel
  128745. */
  128746. pixelWidth: number;
  128747. /**
  128748. * Gets image height in pixel
  128749. */
  128750. pixelHeight: number;
  128751. /**
  128752. * Gets image depth in pixels
  128753. */
  128754. pixelDepth: number;
  128755. /**
  128756. * Gets the number of array elements
  128757. */
  128758. numberOfArrayElements: number;
  128759. /**
  128760. * Gets the number of faces
  128761. */
  128762. numberOfFaces: number;
  128763. /**
  128764. * Gets the number of mipmap levels
  128765. */
  128766. numberOfMipmapLevels: number;
  128767. /**
  128768. * Gets the bytes of key value data
  128769. */
  128770. bytesOfKeyValueData: number;
  128771. /**
  128772. * Gets the load type
  128773. */
  128774. loadType: number;
  128775. /**
  128776. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  128777. */
  128778. isInvalid: boolean;
  128779. /**
  128780. * Creates a new KhronosTextureContainer
  128781. * @param data contents of the KTX container file
  128782. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  128783. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  128784. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  128785. */
  128786. constructor(
  128787. /** contents of the KTX container file */
  128788. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  128789. /**
  128790. * Uploads KTX content to a Babylon Texture.
  128791. * It is assumed that the texture has already been created & is currently bound
  128792. * @hidden
  128793. */
  128794. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  128795. private _upload2DCompressedLevels;
  128796. /**
  128797. * Checks if the given data starts with a KTX file identifier.
  128798. * @param data the data to check
  128799. * @returns true if the data is a KTX file or false otherwise
  128800. */
  128801. static IsValid(data: ArrayBufferView): boolean;
  128802. }
  128803. }
  128804. declare module BABYLON {
  128805. /**
  128806. * Class for loading KTX2 files
  128807. * !!! Experimental Extension Subject to Changes !!!
  128808. * @hidden
  128809. */
  128810. export class KhronosTextureContainer2 {
  128811. private static _ModulePromise;
  128812. private static _TranscodeFormat;
  128813. constructor(engine: ThinEngine);
  128814. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  128815. private _determineTranscodeFormat;
  128816. /**
  128817. * Checks if the given data starts with a KTX2 file identifier.
  128818. * @param data the data to check
  128819. * @returns true if the data is a KTX2 file or false otherwise
  128820. */
  128821. static IsValid(data: ArrayBufferView): boolean;
  128822. }
  128823. }
  128824. declare module BABYLON {
  128825. /**
  128826. * Implementation of the KTX Texture Loader.
  128827. * @hidden
  128828. */
  128829. export class _KTXTextureLoader implements IInternalTextureLoader {
  128830. /**
  128831. * Defines wether the loader supports cascade loading the different faces.
  128832. */
  128833. readonly supportCascades: boolean;
  128834. /**
  128835. * This returns if the loader support the current file information.
  128836. * @param extension defines the file extension of the file being loaded
  128837. * @returns true if the loader can load the specified file
  128838. */
  128839. canLoad(extension: string): boolean;
  128840. /**
  128841. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  128842. * @param data contains the texture data
  128843. * @param texture defines the BabylonJS internal texture
  128844. * @param createPolynomials will be true if polynomials have been requested
  128845. * @param onLoad defines the callback to trigger once the texture is ready
  128846. * @param onError defines the callback to trigger in case of error
  128847. */
  128848. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128849. /**
  128850. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  128851. * @param data contains the texture data
  128852. * @param texture defines the BabylonJS internal texture
  128853. * @param callback defines the method to call once ready to upload
  128854. */
  128855. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  128856. }
  128857. }
  128858. declare module BABYLON {
  128859. /** @hidden */
  128860. export var _forceSceneHelpersToBundle: boolean;
  128861. interface Scene {
  128862. /**
  128863. * Creates a default light for the scene.
  128864. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  128865. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  128866. */
  128867. createDefaultLight(replace?: boolean): void;
  128868. /**
  128869. * Creates a default camera for the scene.
  128870. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  128871. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  128872. * @param replace has default false, when true replaces the active camera in the scene
  128873. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  128874. */
  128875. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  128876. /**
  128877. * Creates a default camera and a default light.
  128878. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  128879. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  128880. * @param replace has the default false, when true replaces the active camera/light in the scene
  128881. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  128882. */
  128883. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  128884. /**
  128885. * Creates a new sky box
  128886. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  128887. * @param environmentTexture defines the texture to use as environment texture
  128888. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  128889. * @param scale defines the overall scale of the skybox
  128890. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  128891. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  128892. * @returns a new mesh holding the sky box
  128893. */
  128894. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  128895. /**
  128896. * Creates a new environment
  128897. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  128898. * @param options defines the options you can use to configure the environment
  128899. * @returns the new EnvironmentHelper
  128900. */
  128901. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  128902. /**
  128903. * Creates a new VREXperienceHelper
  128904. * @see http://doc.babylonjs.com/how_to/webvr_helper
  128905. * @param webVROptions defines the options used to create the new VREXperienceHelper
  128906. * @returns a new VREXperienceHelper
  128907. */
  128908. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  128909. /**
  128910. * Creates a new WebXRDefaultExperience
  128911. * @see http://doc.babylonjs.com/how_to/webxr
  128912. * @param options experience options
  128913. * @returns a promise for a new WebXRDefaultExperience
  128914. */
  128915. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128916. }
  128917. }
  128918. declare module BABYLON {
  128919. /**
  128920. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  128921. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  128922. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  128923. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  128924. */
  128925. export class VideoDome extends TransformNode {
  128926. /**
  128927. * Define the video source as a Monoscopic panoramic 360 video.
  128928. */
  128929. static readonly MODE_MONOSCOPIC: number;
  128930. /**
  128931. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  128932. */
  128933. static readonly MODE_TOPBOTTOM: number;
  128934. /**
  128935. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  128936. */
  128937. static readonly MODE_SIDEBYSIDE: number;
  128938. private _halfDome;
  128939. private _useDirectMapping;
  128940. /**
  128941. * The video texture being displayed on the sphere
  128942. */
  128943. protected _videoTexture: VideoTexture;
  128944. /**
  128945. * Gets the video texture being displayed on the sphere
  128946. */
  128947. get videoTexture(): VideoTexture;
  128948. /**
  128949. * The skybox material
  128950. */
  128951. protected _material: BackgroundMaterial;
  128952. /**
  128953. * The surface used for the skybox
  128954. */
  128955. protected _mesh: Mesh;
  128956. /**
  128957. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  128958. */
  128959. private _halfDomeMask;
  128960. /**
  128961. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  128962. * Also see the options.resolution property.
  128963. */
  128964. get fovMultiplier(): number;
  128965. set fovMultiplier(value: number);
  128966. private _videoMode;
  128967. /**
  128968. * Gets or set the current video mode for the video. It can be:
  128969. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  128970. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  128971. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  128972. */
  128973. get videoMode(): number;
  128974. set videoMode(value: number);
  128975. /**
  128976. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  128977. *
  128978. */
  128979. get halfDome(): boolean;
  128980. /**
  128981. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  128982. */
  128983. set halfDome(enabled: boolean);
  128984. /**
  128985. * Oberserver used in Stereoscopic VR Mode.
  128986. */
  128987. private _onBeforeCameraRenderObserver;
  128988. /**
  128989. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  128990. * @param name Element's name, child elements will append suffixes for their own names.
  128991. * @param urlsOrVideo defines the url(s) or the video element to use
  128992. * @param options An object containing optional or exposed sub element properties
  128993. */
  128994. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  128995. resolution?: number;
  128996. clickToPlay?: boolean;
  128997. autoPlay?: boolean;
  128998. loop?: boolean;
  128999. size?: number;
  129000. poster?: string;
  129001. faceForward?: boolean;
  129002. useDirectMapping?: boolean;
  129003. halfDomeMode?: boolean;
  129004. }, scene: Scene);
  129005. private _changeVideoMode;
  129006. /**
  129007. * Releases resources associated with this node.
  129008. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  129009. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  129010. */
  129011. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  129012. }
  129013. }
  129014. declare module BABYLON {
  129015. /**
  129016. * This class can be used to get instrumentation data from a Babylon engine
  129017. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129018. */
  129019. export class EngineInstrumentation implements IDisposable {
  129020. /**
  129021. * Define the instrumented engine.
  129022. */
  129023. engine: Engine;
  129024. private _captureGPUFrameTime;
  129025. private _gpuFrameTimeToken;
  129026. private _gpuFrameTime;
  129027. private _captureShaderCompilationTime;
  129028. private _shaderCompilationTime;
  129029. private _onBeginFrameObserver;
  129030. private _onEndFrameObserver;
  129031. private _onBeforeShaderCompilationObserver;
  129032. private _onAfterShaderCompilationObserver;
  129033. /**
  129034. * Gets the perf counter used for GPU frame time
  129035. */
  129036. get gpuFrameTimeCounter(): PerfCounter;
  129037. /**
  129038. * Gets the GPU frame time capture status
  129039. */
  129040. get captureGPUFrameTime(): boolean;
  129041. /**
  129042. * Enable or disable the GPU frame time capture
  129043. */
  129044. set captureGPUFrameTime(value: boolean);
  129045. /**
  129046. * Gets the perf counter used for shader compilation time
  129047. */
  129048. get shaderCompilationTimeCounter(): PerfCounter;
  129049. /**
  129050. * Gets the shader compilation time capture status
  129051. */
  129052. get captureShaderCompilationTime(): boolean;
  129053. /**
  129054. * Enable or disable the shader compilation time capture
  129055. */
  129056. set captureShaderCompilationTime(value: boolean);
  129057. /**
  129058. * Instantiates a new engine instrumentation.
  129059. * This class can be used to get instrumentation data from a Babylon engine
  129060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  129061. * @param engine Defines the engine to instrument
  129062. */
  129063. constructor(
  129064. /**
  129065. * Define the instrumented engine.
  129066. */
  129067. engine: Engine);
  129068. /**
  129069. * Dispose and release associated resources.
  129070. */
  129071. dispose(): void;
  129072. }
  129073. }
  129074. declare module BABYLON {
  129075. /**
  129076. * This class can be used to get instrumentation data from a Babylon engine
  129077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129078. */
  129079. export class SceneInstrumentation implements IDisposable {
  129080. /**
  129081. * Defines the scene to instrument
  129082. */
  129083. scene: Scene;
  129084. private _captureActiveMeshesEvaluationTime;
  129085. private _activeMeshesEvaluationTime;
  129086. private _captureRenderTargetsRenderTime;
  129087. private _renderTargetsRenderTime;
  129088. private _captureFrameTime;
  129089. private _frameTime;
  129090. private _captureRenderTime;
  129091. private _renderTime;
  129092. private _captureInterFrameTime;
  129093. private _interFrameTime;
  129094. private _captureParticlesRenderTime;
  129095. private _particlesRenderTime;
  129096. private _captureSpritesRenderTime;
  129097. private _spritesRenderTime;
  129098. private _capturePhysicsTime;
  129099. private _physicsTime;
  129100. private _captureAnimationsTime;
  129101. private _animationsTime;
  129102. private _captureCameraRenderTime;
  129103. private _cameraRenderTime;
  129104. private _onBeforeActiveMeshesEvaluationObserver;
  129105. private _onAfterActiveMeshesEvaluationObserver;
  129106. private _onBeforeRenderTargetsRenderObserver;
  129107. private _onAfterRenderTargetsRenderObserver;
  129108. private _onAfterRenderObserver;
  129109. private _onBeforeDrawPhaseObserver;
  129110. private _onAfterDrawPhaseObserver;
  129111. private _onBeforeAnimationsObserver;
  129112. private _onBeforeParticlesRenderingObserver;
  129113. private _onAfterParticlesRenderingObserver;
  129114. private _onBeforeSpritesRenderingObserver;
  129115. private _onAfterSpritesRenderingObserver;
  129116. private _onBeforePhysicsObserver;
  129117. private _onAfterPhysicsObserver;
  129118. private _onAfterAnimationsObserver;
  129119. private _onBeforeCameraRenderObserver;
  129120. private _onAfterCameraRenderObserver;
  129121. /**
  129122. * Gets the perf counter used for active meshes evaluation time
  129123. */
  129124. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  129125. /**
  129126. * Gets the active meshes evaluation time capture status
  129127. */
  129128. get captureActiveMeshesEvaluationTime(): boolean;
  129129. /**
  129130. * Enable or disable the active meshes evaluation time capture
  129131. */
  129132. set captureActiveMeshesEvaluationTime(value: boolean);
  129133. /**
  129134. * Gets the perf counter used for render targets render time
  129135. */
  129136. get renderTargetsRenderTimeCounter(): PerfCounter;
  129137. /**
  129138. * Gets the render targets render time capture status
  129139. */
  129140. get captureRenderTargetsRenderTime(): boolean;
  129141. /**
  129142. * Enable or disable the render targets render time capture
  129143. */
  129144. set captureRenderTargetsRenderTime(value: boolean);
  129145. /**
  129146. * Gets the perf counter used for particles render time
  129147. */
  129148. get particlesRenderTimeCounter(): PerfCounter;
  129149. /**
  129150. * Gets the particles render time capture status
  129151. */
  129152. get captureParticlesRenderTime(): boolean;
  129153. /**
  129154. * Enable or disable the particles render time capture
  129155. */
  129156. set captureParticlesRenderTime(value: boolean);
  129157. /**
  129158. * Gets the perf counter used for sprites render time
  129159. */
  129160. get spritesRenderTimeCounter(): PerfCounter;
  129161. /**
  129162. * Gets the sprites render time capture status
  129163. */
  129164. get captureSpritesRenderTime(): boolean;
  129165. /**
  129166. * Enable or disable the sprites render time capture
  129167. */
  129168. set captureSpritesRenderTime(value: boolean);
  129169. /**
  129170. * Gets the perf counter used for physics time
  129171. */
  129172. get physicsTimeCounter(): PerfCounter;
  129173. /**
  129174. * Gets the physics time capture status
  129175. */
  129176. get capturePhysicsTime(): boolean;
  129177. /**
  129178. * Enable or disable the physics time capture
  129179. */
  129180. set capturePhysicsTime(value: boolean);
  129181. /**
  129182. * Gets the perf counter used for animations time
  129183. */
  129184. get animationsTimeCounter(): PerfCounter;
  129185. /**
  129186. * Gets the animations time capture status
  129187. */
  129188. get captureAnimationsTime(): boolean;
  129189. /**
  129190. * Enable or disable the animations time capture
  129191. */
  129192. set captureAnimationsTime(value: boolean);
  129193. /**
  129194. * Gets the perf counter used for frame time capture
  129195. */
  129196. get frameTimeCounter(): PerfCounter;
  129197. /**
  129198. * Gets the frame time capture status
  129199. */
  129200. get captureFrameTime(): boolean;
  129201. /**
  129202. * Enable or disable the frame time capture
  129203. */
  129204. set captureFrameTime(value: boolean);
  129205. /**
  129206. * Gets the perf counter used for inter-frames time capture
  129207. */
  129208. get interFrameTimeCounter(): PerfCounter;
  129209. /**
  129210. * Gets the inter-frames time capture status
  129211. */
  129212. get captureInterFrameTime(): boolean;
  129213. /**
  129214. * Enable or disable the inter-frames time capture
  129215. */
  129216. set captureInterFrameTime(value: boolean);
  129217. /**
  129218. * Gets the perf counter used for render time capture
  129219. */
  129220. get renderTimeCounter(): PerfCounter;
  129221. /**
  129222. * Gets the render time capture status
  129223. */
  129224. get captureRenderTime(): boolean;
  129225. /**
  129226. * Enable or disable the render time capture
  129227. */
  129228. set captureRenderTime(value: boolean);
  129229. /**
  129230. * Gets the perf counter used for camera render time capture
  129231. */
  129232. get cameraRenderTimeCounter(): PerfCounter;
  129233. /**
  129234. * Gets the camera render time capture status
  129235. */
  129236. get captureCameraRenderTime(): boolean;
  129237. /**
  129238. * Enable or disable the camera render time capture
  129239. */
  129240. set captureCameraRenderTime(value: boolean);
  129241. /**
  129242. * Gets the perf counter used for draw calls
  129243. */
  129244. get drawCallsCounter(): PerfCounter;
  129245. /**
  129246. * Instantiates a new scene instrumentation.
  129247. * This class can be used to get instrumentation data from a Babylon engine
  129248. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  129249. * @param scene Defines the scene to instrument
  129250. */
  129251. constructor(
  129252. /**
  129253. * Defines the scene to instrument
  129254. */
  129255. scene: Scene);
  129256. /**
  129257. * Dispose and release associated resources.
  129258. */
  129259. dispose(): void;
  129260. }
  129261. }
  129262. declare module BABYLON {
  129263. /** @hidden */
  129264. export var glowMapGenerationPixelShader: {
  129265. name: string;
  129266. shader: string;
  129267. };
  129268. }
  129269. declare module BABYLON {
  129270. /** @hidden */
  129271. export var glowMapGenerationVertexShader: {
  129272. name: string;
  129273. shader: string;
  129274. };
  129275. }
  129276. declare module BABYLON {
  129277. /**
  129278. * Effect layer options. This helps customizing the behaviour
  129279. * of the effect layer.
  129280. */
  129281. export interface IEffectLayerOptions {
  129282. /**
  129283. * Multiplication factor apply to the canvas size to compute the render target size
  129284. * used to generated the objects (the smaller the faster).
  129285. */
  129286. mainTextureRatio: number;
  129287. /**
  129288. * Enforces a fixed size texture to ensure effect stability across devices.
  129289. */
  129290. mainTextureFixedSize?: number;
  129291. /**
  129292. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  129293. */
  129294. alphaBlendingMode: number;
  129295. /**
  129296. * The camera attached to the layer.
  129297. */
  129298. camera: Nullable<Camera>;
  129299. /**
  129300. * The rendering group to draw the layer in.
  129301. */
  129302. renderingGroupId: number;
  129303. }
  129304. /**
  129305. * The effect layer Helps adding post process effect blended with the main pass.
  129306. *
  129307. * This can be for instance use to generate glow or higlight effects on the scene.
  129308. *
  129309. * The effect layer class can not be used directly and is intented to inherited from to be
  129310. * customized per effects.
  129311. */
  129312. export abstract class EffectLayer {
  129313. private _vertexBuffers;
  129314. private _indexBuffer;
  129315. private _cachedDefines;
  129316. private _effectLayerMapGenerationEffect;
  129317. private _effectLayerOptions;
  129318. private _mergeEffect;
  129319. protected _scene: Scene;
  129320. protected _engine: Engine;
  129321. protected _maxSize: number;
  129322. protected _mainTextureDesiredSize: ISize;
  129323. protected _mainTexture: RenderTargetTexture;
  129324. protected _shouldRender: boolean;
  129325. protected _postProcesses: PostProcess[];
  129326. protected _textures: BaseTexture[];
  129327. protected _emissiveTextureAndColor: {
  129328. texture: Nullable<BaseTexture>;
  129329. color: Color4;
  129330. };
  129331. /**
  129332. * The name of the layer
  129333. */
  129334. name: string;
  129335. /**
  129336. * The clear color of the texture used to generate the glow map.
  129337. */
  129338. neutralColor: Color4;
  129339. /**
  129340. * Specifies whether the highlight layer is enabled or not.
  129341. */
  129342. isEnabled: boolean;
  129343. /**
  129344. * Gets the camera attached to the layer.
  129345. */
  129346. get camera(): Nullable<Camera>;
  129347. /**
  129348. * Gets the rendering group id the layer should render in.
  129349. */
  129350. get renderingGroupId(): number;
  129351. set renderingGroupId(renderingGroupId: number);
  129352. /**
  129353. * An event triggered when the effect layer has been disposed.
  129354. */
  129355. onDisposeObservable: Observable<EffectLayer>;
  129356. /**
  129357. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  129358. */
  129359. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  129360. /**
  129361. * An event triggered when the generated texture is being merged in the scene.
  129362. */
  129363. onBeforeComposeObservable: Observable<EffectLayer>;
  129364. /**
  129365. * An event triggered when the mesh is rendered into the effect render target.
  129366. */
  129367. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  129368. /**
  129369. * An event triggered after the mesh has been rendered into the effect render target.
  129370. */
  129371. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  129372. /**
  129373. * An event triggered when the generated texture has been merged in the scene.
  129374. */
  129375. onAfterComposeObservable: Observable<EffectLayer>;
  129376. /**
  129377. * An event triggered when the efffect layer changes its size.
  129378. */
  129379. onSizeChangedObservable: Observable<EffectLayer>;
  129380. /** @hidden */
  129381. static _SceneComponentInitialization: (scene: Scene) => void;
  129382. /**
  129383. * Instantiates a new effect Layer and references it in the scene.
  129384. * @param name The name of the layer
  129385. * @param scene The scene to use the layer in
  129386. */
  129387. constructor(
  129388. /** The Friendly of the effect in the scene */
  129389. name: string, scene: Scene);
  129390. /**
  129391. * Get the effect name of the layer.
  129392. * @return The effect name
  129393. */
  129394. abstract getEffectName(): string;
  129395. /**
  129396. * Checks for the readiness of the element composing the layer.
  129397. * @param subMesh the mesh to check for
  129398. * @param useInstances specify whether or not to use instances to render the mesh
  129399. * @return true if ready otherwise, false
  129400. */
  129401. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129402. /**
  129403. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129404. * @returns true if the effect requires stencil during the main canvas render pass.
  129405. */
  129406. abstract needStencil(): boolean;
  129407. /**
  129408. * Create the merge effect. This is the shader use to blit the information back
  129409. * to the main canvas at the end of the scene rendering.
  129410. * @returns The effect containing the shader used to merge the effect on the main canvas
  129411. */
  129412. protected abstract _createMergeEffect(): Effect;
  129413. /**
  129414. * Creates the render target textures and post processes used in the effect layer.
  129415. */
  129416. protected abstract _createTextureAndPostProcesses(): void;
  129417. /**
  129418. * Implementation specific of rendering the generating effect on the main canvas.
  129419. * @param effect The effect used to render through
  129420. */
  129421. protected abstract _internalRender(effect: Effect): void;
  129422. /**
  129423. * Sets the required values for both the emissive texture and and the main color.
  129424. */
  129425. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129426. /**
  129427. * Free any resources and references associated to a mesh.
  129428. * Internal use
  129429. * @param mesh The mesh to free.
  129430. */
  129431. abstract _disposeMesh(mesh: Mesh): void;
  129432. /**
  129433. * Serializes this layer (Glow or Highlight for example)
  129434. * @returns a serialized layer object
  129435. */
  129436. abstract serialize?(): any;
  129437. /**
  129438. * Initializes the effect layer with the required options.
  129439. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  129440. */
  129441. protected _init(options: Partial<IEffectLayerOptions>): void;
  129442. /**
  129443. * Generates the index buffer of the full screen quad blending to the main canvas.
  129444. */
  129445. private _generateIndexBuffer;
  129446. /**
  129447. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  129448. */
  129449. private _generateVertexBuffer;
  129450. /**
  129451. * Sets the main texture desired size which is the closest power of two
  129452. * of the engine canvas size.
  129453. */
  129454. private _setMainTextureSize;
  129455. /**
  129456. * Creates the main texture for the effect layer.
  129457. */
  129458. protected _createMainTexture(): void;
  129459. /**
  129460. * Adds specific effects defines.
  129461. * @param defines The defines to add specifics to.
  129462. */
  129463. protected _addCustomEffectDefines(defines: string[]): void;
  129464. /**
  129465. * Checks for the readiness of the element composing the layer.
  129466. * @param subMesh the mesh to check for
  129467. * @param useInstances specify whether or not to use instances to render the mesh
  129468. * @param emissiveTexture the associated emissive texture used to generate the glow
  129469. * @return true if ready otherwise, false
  129470. */
  129471. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  129472. /**
  129473. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  129474. */
  129475. render(): void;
  129476. /**
  129477. * Determine if a given mesh will be used in the current effect.
  129478. * @param mesh mesh to test
  129479. * @returns true if the mesh will be used
  129480. */
  129481. hasMesh(mesh: AbstractMesh): boolean;
  129482. /**
  129483. * Returns true if the layer contains information to display, otherwise false.
  129484. * @returns true if the glow layer should be rendered
  129485. */
  129486. shouldRender(): boolean;
  129487. /**
  129488. * Returns true if the mesh should render, otherwise false.
  129489. * @param mesh The mesh to render
  129490. * @returns true if it should render otherwise false
  129491. */
  129492. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  129493. /**
  129494. * Returns true if the mesh can be rendered, otherwise false.
  129495. * @param mesh The mesh to render
  129496. * @param material The material used on the mesh
  129497. * @returns true if it can be rendered otherwise false
  129498. */
  129499. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129500. /**
  129501. * Returns true if the mesh should render, otherwise false.
  129502. * @param mesh The mesh to render
  129503. * @returns true if it should render otherwise false
  129504. */
  129505. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  129506. /**
  129507. * Renders the submesh passed in parameter to the generation map.
  129508. */
  129509. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  129510. /**
  129511. * Defines whether the current material of the mesh should be use to render the effect.
  129512. * @param mesh defines the current mesh to render
  129513. */
  129514. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129515. /**
  129516. * Rebuild the required buffers.
  129517. * @hidden Internal use only.
  129518. */
  129519. _rebuild(): void;
  129520. /**
  129521. * Dispose only the render target textures and post process.
  129522. */
  129523. private _disposeTextureAndPostProcesses;
  129524. /**
  129525. * Dispose the highlight layer and free resources.
  129526. */
  129527. dispose(): void;
  129528. /**
  129529. * Gets the class name of the effect layer
  129530. * @returns the string with the class name of the effect layer
  129531. */
  129532. getClassName(): string;
  129533. /**
  129534. * Creates an effect layer from parsed effect layer data
  129535. * @param parsedEffectLayer defines effect layer data
  129536. * @param scene defines the current scene
  129537. * @param rootUrl defines the root URL containing the effect layer information
  129538. * @returns a parsed effect Layer
  129539. */
  129540. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  129541. }
  129542. }
  129543. declare module BABYLON {
  129544. interface AbstractScene {
  129545. /**
  129546. * The list of effect layers (highlights/glow) added to the scene
  129547. * @see http://doc.babylonjs.com/how_to/highlight_layer
  129548. * @see http://doc.babylonjs.com/how_to/glow_layer
  129549. */
  129550. effectLayers: Array<EffectLayer>;
  129551. /**
  129552. * Removes the given effect layer from this scene.
  129553. * @param toRemove defines the effect layer to remove
  129554. * @returns the index of the removed effect layer
  129555. */
  129556. removeEffectLayer(toRemove: EffectLayer): number;
  129557. /**
  129558. * Adds the given effect layer to this scene
  129559. * @param newEffectLayer defines the effect layer to add
  129560. */
  129561. addEffectLayer(newEffectLayer: EffectLayer): void;
  129562. }
  129563. /**
  129564. * Defines the layer scene component responsible to manage any effect layers
  129565. * in a given scene.
  129566. */
  129567. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  129568. /**
  129569. * The component name helpfull to identify the component in the list of scene components.
  129570. */
  129571. readonly name: string;
  129572. /**
  129573. * The scene the component belongs to.
  129574. */
  129575. scene: Scene;
  129576. private _engine;
  129577. private _renderEffects;
  129578. private _needStencil;
  129579. private _previousStencilState;
  129580. /**
  129581. * Creates a new instance of the component for the given scene
  129582. * @param scene Defines the scene to register the component in
  129583. */
  129584. constructor(scene: Scene);
  129585. /**
  129586. * Registers the component in a given scene
  129587. */
  129588. register(): void;
  129589. /**
  129590. * Rebuilds the elements related to this component in case of
  129591. * context lost for instance.
  129592. */
  129593. rebuild(): void;
  129594. /**
  129595. * Serializes the component data to the specified json object
  129596. * @param serializationObject The object to serialize to
  129597. */
  129598. serialize(serializationObject: any): void;
  129599. /**
  129600. * Adds all the elements from the container to the scene
  129601. * @param container the container holding the elements
  129602. */
  129603. addFromContainer(container: AbstractScene): void;
  129604. /**
  129605. * Removes all the elements in the container from the scene
  129606. * @param container contains the elements to remove
  129607. * @param dispose if the removed element should be disposed (default: false)
  129608. */
  129609. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129610. /**
  129611. * Disposes the component and the associated ressources.
  129612. */
  129613. dispose(): void;
  129614. private _isReadyForMesh;
  129615. private _renderMainTexture;
  129616. private _setStencil;
  129617. private _setStencilBack;
  129618. private _draw;
  129619. private _drawCamera;
  129620. private _drawRenderingGroup;
  129621. }
  129622. }
  129623. declare module BABYLON {
  129624. /** @hidden */
  129625. export var glowMapMergePixelShader: {
  129626. name: string;
  129627. shader: string;
  129628. };
  129629. }
  129630. declare module BABYLON {
  129631. /** @hidden */
  129632. export var glowMapMergeVertexShader: {
  129633. name: string;
  129634. shader: string;
  129635. };
  129636. }
  129637. declare module BABYLON {
  129638. interface AbstractScene {
  129639. /**
  129640. * Return a the first highlight layer of the scene with a given name.
  129641. * @param name The name of the highlight layer to look for.
  129642. * @return The highlight layer if found otherwise null.
  129643. */
  129644. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  129645. }
  129646. /**
  129647. * Glow layer options. This helps customizing the behaviour
  129648. * of the glow layer.
  129649. */
  129650. export interface IGlowLayerOptions {
  129651. /**
  129652. * Multiplication factor apply to the canvas size to compute the render target size
  129653. * used to generated the glowing objects (the smaller the faster).
  129654. */
  129655. mainTextureRatio: number;
  129656. /**
  129657. * Enforces a fixed size texture to ensure resize independant blur.
  129658. */
  129659. mainTextureFixedSize?: number;
  129660. /**
  129661. * How big is the kernel of the blur texture.
  129662. */
  129663. blurKernelSize: number;
  129664. /**
  129665. * The camera attached to the layer.
  129666. */
  129667. camera: Nullable<Camera>;
  129668. /**
  129669. * Enable MSAA by chosing the number of samples.
  129670. */
  129671. mainTextureSamples?: number;
  129672. /**
  129673. * The rendering group to draw the layer in.
  129674. */
  129675. renderingGroupId: number;
  129676. }
  129677. /**
  129678. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  129679. *
  129680. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  129681. *
  129682. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  129683. */
  129684. export class GlowLayer extends EffectLayer {
  129685. /**
  129686. * Effect Name of the layer.
  129687. */
  129688. static readonly EffectName: string;
  129689. /**
  129690. * The default blur kernel size used for the glow.
  129691. */
  129692. static DefaultBlurKernelSize: number;
  129693. /**
  129694. * The default texture size ratio used for the glow.
  129695. */
  129696. static DefaultTextureRatio: number;
  129697. /**
  129698. * Sets the kernel size of the blur.
  129699. */
  129700. set blurKernelSize(value: number);
  129701. /**
  129702. * Gets the kernel size of the blur.
  129703. */
  129704. get blurKernelSize(): number;
  129705. /**
  129706. * Sets the glow intensity.
  129707. */
  129708. set intensity(value: number);
  129709. /**
  129710. * Gets the glow intensity.
  129711. */
  129712. get intensity(): number;
  129713. private _options;
  129714. private _intensity;
  129715. private _horizontalBlurPostprocess1;
  129716. private _verticalBlurPostprocess1;
  129717. private _horizontalBlurPostprocess2;
  129718. private _verticalBlurPostprocess2;
  129719. private _blurTexture1;
  129720. private _blurTexture2;
  129721. private _postProcesses1;
  129722. private _postProcesses2;
  129723. private _includedOnlyMeshes;
  129724. private _excludedMeshes;
  129725. private _meshesUsingTheirOwnMaterials;
  129726. /**
  129727. * Callback used to let the user override the color selection on a per mesh basis
  129728. */
  129729. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  129730. /**
  129731. * Callback used to let the user override the texture selection on a per mesh basis
  129732. */
  129733. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  129734. /**
  129735. * Instantiates a new glow Layer and references it to the scene.
  129736. * @param name The name of the layer
  129737. * @param scene The scene to use the layer in
  129738. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  129739. */
  129740. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  129741. /**
  129742. * Get the effect name of the layer.
  129743. * @return The effect name
  129744. */
  129745. getEffectName(): string;
  129746. /**
  129747. * Create the merge effect. This is the shader use to blit the information back
  129748. * to the main canvas at the end of the scene rendering.
  129749. */
  129750. protected _createMergeEffect(): Effect;
  129751. /**
  129752. * Creates the render target textures and post processes used in the glow layer.
  129753. */
  129754. protected _createTextureAndPostProcesses(): void;
  129755. /**
  129756. * Checks for the readiness of the element composing the layer.
  129757. * @param subMesh the mesh to check for
  129758. * @param useInstances specify wether or not to use instances to render the mesh
  129759. * @param emissiveTexture the associated emissive texture used to generate the glow
  129760. * @return true if ready otherwise, false
  129761. */
  129762. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129763. /**
  129764. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  129765. */
  129766. needStencil(): boolean;
  129767. /**
  129768. * Returns true if the mesh can be rendered, otherwise false.
  129769. * @param mesh The mesh to render
  129770. * @param material The material used on the mesh
  129771. * @returns true if it can be rendered otherwise false
  129772. */
  129773. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  129774. /**
  129775. * Implementation specific of rendering the generating effect on the main canvas.
  129776. * @param effect The effect used to render through
  129777. */
  129778. protected _internalRender(effect: Effect): void;
  129779. /**
  129780. * Sets the required values for both the emissive texture and and the main color.
  129781. */
  129782. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  129783. /**
  129784. * Returns true if the mesh should render, otherwise false.
  129785. * @param mesh The mesh to render
  129786. * @returns true if it should render otherwise false
  129787. */
  129788. protected _shouldRenderMesh(mesh: Mesh): boolean;
  129789. /**
  129790. * Adds specific effects defines.
  129791. * @param defines The defines to add specifics to.
  129792. */
  129793. protected _addCustomEffectDefines(defines: string[]): void;
  129794. /**
  129795. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  129796. * @param mesh The mesh to exclude from the glow layer
  129797. */
  129798. addExcludedMesh(mesh: Mesh): void;
  129799. /**
  129800. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  129801. * @param mesh The mesh to remove
  129802. */
  129803. removeExcludedMesh(mesh: Mesh): void;
  129804. /**
  129805. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  129806. * @param mesh The mesh to include in the glow layer
  129807. */
  129808. addIncludedOnlyMesh(mesh: Mesh): void;
  129809. /**
  129810. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  129811. * @param mesh The mesh to remove
  129812. */
  129813. removeIncludedOnlyMesh(mesh: Mesh): void;
  129814. /**
  129815. * Determine if a given mesh will be used in the glow layer
  129816. * @param mesh The mesh to test
  129817. * @returns true if the mesh will be highlighted by the current glow layer
  129818. */
  129819. hasMesh(mesh: AbstractMesh): boolean;
  129820. /**
  129821. * Defines whether the current material of the mesh should be use to render the effect.
  129822. * @param mesh defines the current mesh to render
  129823. */
  129824. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  129825. /**
  129826. * Add a mesh to be rendered through its own material and not with emissive only.
  129827. * @param mesh The mesh for which we need to use its material
  129828. */
  129829. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  129830. /**
  129831. * Remove a mesh from being rendered through its own material and not with emissive only.
  129832. * @param mesh The mesh for which we need to not use its material
  129833. */
  129834. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  129835. /**
  129836. * Free any resources and references associated to a mesh.
  129837. * Internal use
  129838. * @param mesh The mesh to free.
  129839. * @hidden
  129840. */
  129841. _disposeMesh(mesh: Mesh): void;
  129842. /**
  129843. * Gets the class name of the effect layer
  129844. * @returns the string with the class name of the effect layer
  129845. */
  129846. getClassName(): string;
  129847. /**
  129848. * Serializes this glow layer
  129849. * @returns a serialized glow layer object
  129850. */
  129851. serialize(): any;
  129852. /**
  129853. * Creates a Glow Layer from parsed glow layer data
  129854. * @param parsedGlowLayer defines glow layer data
  129855. * @param scene defines the current scene
  129856. * @param rootUrl defines the root URL containing the glow layer information
  129857. * @returns a parsed Glow Layer
  129858. */
  129859. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  129860. }
  129861. }
  129862. declare module BABYLON {
  129863. /** @hidden */
  129864. export var glowBlurPostProcessPixelShader: {
  129865. name: string;
  129866. shader: string;
  129867. };
  129868. }
  129869. declare module BABYLON {
  129870. interface AbstractScene {
  129871. /**
  129872. * Return a the first highlight layer of the scene with a given name.
  129873. * @param name The name of the highlight layer to look for.
  129874. * @return The highlight layer if found otherwise null.
  129875. */
  129876. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  129877. }
  129878. /**
  129879. * Highlight layer options. This helps customizing the behaviour
  129880. * of the highlight layer.
  129881. */
  129882. export interface IHighlightLayerOptions {
  129883. /**
  129884. * Multiplication factor apply to the canvas size to compute the render target size
  129885. * used to generated the glowing objects (the smaller the faster).
  129886. */
  129887. mainTextureRatio: number;
  129888. /**
  129889. * Enforces a fixed size texture to ensure resize independant blur.
  129890. */
  129891. mainTextureFixedSize?: number;
  129892. /**
  129893. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  129894. * of the picture to blur (the smaller the faster).
  129895. */
  129896. blurTextureSizeRatio: number;
  129897. /**
  129898. * How big in texel of the blur texture is the vertical blur.
  129899. */
  129900. blurVerticalSize: number;
  129901. /**
  129902. * How big in texel of the blur texture is the horizontal blur.
  129903. */
  129904. blurHorizontalSize: number;
  129905. /**
  129906. * Alpha blending mode used to apply the blur. Default is combine.
  129907. */
  129908. alphaBlendingMode: number;
  129909. /**
  129910. * The camera attached to the layer.
  129911. */
  129912. camera: Nullable<Camera>;
  129913. /**
  129914. * Should we display highlight as a solid stroke?
  129915. */
  129916. isStroke?: boolean;
  129917. /**
  129918. * The rendering group to draw the layer in.
  129919. */
  129920. renderingGroupId: number;
  129921. }
  129922. /**
  129923. * The highlight layer Helps adding a glow effect around a mesh.
  129924. *
  129925. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  129926. * glowy meshes to your scene.
  129927. *
  129928. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  129929. */
  129930. export class HighlightLayer extends EffectLayer {
  129931. name: string;
  129932. /**
  129933. * Effect Name of the highlight layer.
  129934. */
  129935. static readonly EffectName: string;
  129936. /**
  129937. * The neutral color used during the preparation of the glow effect.
  129938. * This is black by default as the blend operation is a blend operation.
  129939. */
  129940. static NeutralColor: Color4;
  129941. /**
  129942. * Stencil value used for glowing meshes.
  129943. */
  129944. static GlowingMeshStencilReference: number;
  129945. /**
  129946. * Stencil value used for the other meshes in the scene.
  129947. */
  129948. static NormalMeshStencilReference: number;
  129949. /**
  129950. * Specifies whether or not the inner glow is ACTIVE in the layer.
  129951. */
  129952. innerGlow: boolean;
  129953. /**
  129954. * Specifies whether or not the outer glow is ACTIVE in the layer.
  129955. */
  129956. outerGlow: boolean;
  129957. /**
  129958. * Specifies the horizontal size of the blur.
  129959. */
  129960. set blurHorizontalSize(value: number);
  129961. /**
  129962. * Specifies the vertical size of the blur.
  129963. */
  129964. set blurVerticalSize(value: number);
  129965. /**
  129966. * Gets the horizontal size of the blur.
  129967. */
  129968. get blurHorizontalSize(): number;
  129969. /**
  129970. * Gets the vertical size of the blur.
  129971. */
  129972. get blurVerticalSize(): number;
  129973. /**
  129974. * An event triggered when the highlight layer is being blurred.
  129975. */
  129976. onBeforeBlurObservable: Observable<HighlightLayer>;
  129977. /**
  129978. * An event triggered when the highlight layer has been blurred.
  129979. */
  129980. onAfterBlurObservable: Observable<HighlightLayer>;
  129981. private _instanceGlowingMeshStencilReference;
  129982. private _options;
  129983. private _downSamplePostprocess;
  129984. private _horizontalBlurPostprocess;
  129985. private _verticalBlurPostprocess;
  129986. private _blurTexture;
  129987. private _meshes;
  129988. private _excludedMeshes;
  129989. /**
  129990. * Instantiates a new highlight Layer and references it to the scene..
  129991. * @param name The name of the layer
  129992. * @param scene The scene to use the layer in
  129993. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  129994. */
  129995. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  129996. /**
  129997. * Get the effect name of the layer.
  129998. * @return The effect name
  129999. */
  130000. getEffectName(): string;
  130001. /**
  130002. * Create the merge effect. This is the shader use to blit the information back
  130003. * to the main canvas at the end of the scene rendering.
  130004. */
  130005. protected _createMergeEffect(): Effect;
  130006. /**
  130007. * Creates the render target textures and post processes used in the highlight layer.
  130008. */
  130009. protected _createTextureAndPostProcesses(): void;
  130010. /**
  130011. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  130012. */
  130013. needStencil(): boolean;
  130014. /**
  130015. * Checks for the readiness of the element composing the layer.
  130016. * @param subMesh the mesh to check for
  130017. * @param useInstances specify wether or not to use instances to render the mesh
  130018. * @param emissiveTexture the associated emissive texture used to generate the glow
  130019. * @return true if ready otherwise, false
  130020. */
  130021. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130022. /**
  130023. * Implementation specific of rendering the generating effect on the main canvas.
  130024. * @param effect The effect used to render through
  130025. */
  130026. protected _internalRender(effect: Effect): void;
  130027. /**
  130028. * Returns true if the layer contains information to display, otherwise false.
  130029. */
  130030. shouldRender(): boolean;
  130031. /**
  130032. * Returns true if the mesh should render, otherwise false.
  130033. * @param mesh The mesh to render
  130034. * @returns true if it should render otherwise false
  130035. */
  130036. protected _shouldRenderMesh(mesh: Mesh): boolean;
  130037. /**
  130038. * Adds specific effects defines.
  130039. * @param defines The defines to add specifics to.
  130040. */
  130041. protected _addCustomEffectDefines(defines: string[]): void;
  130042. /**
  130043. * Sets the required values for both the emissive texture and and the main color.
  130044. */
  130045. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  130046. /**
  130047. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  130048. * @param mesh The mesh to exclude from the highlight layer
  130049. */
  130050. addExcludedMesh(mesh: Mesh): void;
  130051. /**
  130052. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  130053. * @param mesh The mesh to highlight
  130054. */
  130055. removeExcludedMesh(mesh: Mesh): void;
  130056. /**
  130057. * Determine if a given mesh will be highlighted by the current HighlightLayer
  130058. * @param mesh mesh to test
  130059. * @returns true if the mesh will be highlighted by the current HighlightLayer
  130060. */
  130061. hasMesh(mesh: AbstractMesh): boolean;
  130062. /**
  130063. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  130064. * @param mesh The mesh to highlight
  130065. * @param color The color of the highlight
  130066. * @param glowEmissiveOnly Extract the glow from the emissive texture
  130067. */
  130068. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  130069. /**
  130070. * Remove a mesh from the highlight layer in order to make it stop glowing.
  130071. * @param mesh The mesh to highlight
  130072. */
  130073. removeMesh(mesh: Mesh): void;
  130074. /**
  130075. * Remove all the meshes currently referenced in the highlight layer
  130076. */
  130077. removeAllMeshes(): void;
  130078. /**
  130079. * Force the stencil to the normal expected value for none glowing parts
  130080. */
  130081. private _defaultStencilReference;
  130082. /**
  130083. * Free any resources and references associated to a mesh.
  130084. * Internal use
  130085. * @param mesh The mesh to free.
  130086. * @hidden
  130087. */
  130088. _disposeMesh(mesh: Mesh): void;
  130089. /**
  130090. * Dispose the highlight layer and free resources.
  130091. */
  130092. dispose(): void;
  130093. /**
  130094. * Gets the class name of the effect layer
  130095. * @returns the string with the class name of the effect layer
  130096. */
  130097. getClassName(): string;
  130098. /**
  130099. * Serializes this Highlight layer
  130100. * @returns a serialized Highlight layer object
  130101. */
  130102. serialize(): any;
  130103. /**
  130104. * Creates a Highlight layer from parsed Highlight layer data
  130105. * @param parsedHightlightLayer defines the Highlight layer data
  130106. * @param scene defines the current scene
  130107. * @param rootUrl defines the root URL containing the Highlight layer information
  130108. * @returns a parsed Highlight layer
  130109. */
  130110. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  130111. }
  130112. }
  130113. declare module BABYLON {
  130114. interface AbstractScene {
  130115. /**
  130116. * The list of layers (background and foreground) of the scene
  130117. */
  130118. layers: Array<Layer>;
  130119. }
  130120. /**
  130121. * Defines the layer scene component responsible to manage any layers
  130122. * in a given scene.
  130123. */
  130124. export class LayerSceneComponent implements ISceneComponent {
  130125. /**
  130126. * The component name helpfull to identify the component in the list of scene components.
  130127. */
  130128. readonly name: string;
  130129. /**
  130130. * The scene the component belongs to.
  130131. */
  130132. scene: Scene;
  130133. private _engine;
  130134. /**
  130135. * Creates a new instance of the component for the given scene
  130136. * @param scene Defines the scene to register the component in
  130137. */
  130138. constructor(scene: Scene);
  130139. /**
  130140. * Registers the component in a given scene
  130141. */
  130142. register(): void;
  130143. /**
  130144. * Rebuilds the elements related to this component in case of
  130145. * context lost for instance.
  130146. */
  130147. rebuild(): void;
  130148. /**
  130149. * Disposes the component and the associated ressources.
  130150. */
  130151. dispose(): void;
  130152. private _draw;
  130153. private _drawCameraPredicate;
  130154. private _drawCameraBackground;
  130155. private _drawCameraForeground;
  130156. private _drawRenderTargetPredicate;
  130157. private _drawRenderTargetBackground;
  130158. private _drawRenderTargetForeground;
  130159. /**
  130160. * Adds all the elements from the container to the scene
  130161. * @param container the container holding the elements
  130162. */
  130163. addFromContainer(container: AbstractScene): void;
  130164. /**
  130165. * Removes all the elements in the container from the scene
  130166. * @param container contains the elements to remove
  130167. * @param dispose if the removed element should be disposed (default: false)
  130168. */
  130169. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130170. }
  130171. }
  130172. declare module BABYLON {
  130173. /** @hidden */
  130174. export var layerPixelShader: {
  130175. name: string;
  130176. shader: string;
  130177. };
  130178. }
  130179. declare module BABYLON {
  130180. /** @hidden */
  130181. export var layerVertexShader: {
  130182. name: string;
  130183. shader: string;
  130184. };
  130185. }
  130186. declare module BABYLON {
  130187. /**
  130188. * This represents a full screen 2d layer.
  130189. * This can be useful to display a picture in the background of your scene for instance.
  130190. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130191. */
  130192. export class Layer {
  130193. /**
  130194. * Define the name of the layer.
  130195. */
  130196. name: string;
  130197. /**
  130198. * Define the texture the layer should display.
  130199. */
  130200. texture: Nullable<Texture>;
  130201. /**
  130202. * Is the layer in background or foreground.
  130203. */
  130204. isBackground: boolean;
  130205. /**
  130206. * Define the color of the layer (instead of texture).
  130207. */
  130208. color: Color4;
  130209. /**
  130210. * Define the scale of the layer in order to zoom in out of the texture.
  130211. */
  130212. scale: Vector2;
  130213. /**
  130214. * Define an offset for the layer in order to shift the texture.
  130215. */
  130216. offset: Vector2;
  130217. /**
  130218. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  130219. */
  130220. alphaBlendingMode: number;
  130221. /**
  130222. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  130223. * Alpha test will not mix with the background color in case of transparency.
  130224. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  130225. */
  130226. alphaTest: boolean;
  130227. /**
  130228. * Define a mask to restrict the layer to only some of the scene cameras.
  130229. */
  130230. layerMask: number;
  130231. /**
  130232. * Define the list of render target the layer is visible into.
  130233. */
  130234. renderTargetTextures: RenderTargetTexture[];
  130235. /**
  130236. * Define if the layer is only used in renderTarget or if it also
  130237. * renders in the main frame buffer of the canvas.
  130238. */
  130239. renderOnlyInRenderTargetTextures: boolean;
  130240. private _scene;
  130241. private _vertexBuffers;
  130242. private _indexBuffer;
  130243. private _effect;
  130244. private _previousDefines;
  130245. /**
  130246. * An event triggered when the layer is disposed.
  130247. */
  130248. onDisposeObservable: Observable<Layer>;
  130249. private _onDisposeObserver;
  130250. /**
  130251. * Back compatibility with callback before the onDisposeObservable existed.
  130252. * The set callback will be triggered when the layer has been disposed.
  130253. */
  130254. set onDispose(callback: () => void);
  130255. /**
  130256. * An event triggered before rendering the scene
  130257. */
  130258. onBeforeRenderObservable: Observable<Layer>;
  130259. private _onBeforeRenderObserver;
  130260. /**
  130261. * Back compatibility with callback before the onBeforeRenderObservable existed.
  130262. * The set callback will be triggered just before rendering the layer.
  130263. */
  130264. set onBeforeRender(callback: () => void);
  130265. /**
  130266. * An event triggered after rendering the scene
  130267. */
  130268. onAfterRenderObservable: Observable<Layer>;
  130269. private _onAfterRenderObserver;
  130270. /**
  130271. * Back compatibility with callback before the onAfterRenderObservable existed.
  130272. * The set callback will be triggered just after rendering the layer.
  130273. */
  130274. set onAfterRender(callback: () => void);
  130275. /**
  130276. * Instantiates a new layer.
  130277. * This represents a full screen 2d layer.
  130278. * This can be useful to display a picture in the background of your scene for instance.
  130279. * @see https://www.babylonjs-playground.com/#08A2BS#1
  130280. * @param name Define the name of the layer in the scene
  130281. * @param imgUrl Define the url of the texture to display in the layer
  130282. * @param scene Define the scene the layer belongs to
  130283. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  130284. * @param color Defines a color for the layer
  130285. */
  130286. constructor(
  130287. /**
  130288. * Define the name of the layer.
  130289. */
  130290. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  130291. private _createIndexBuffer;
  130292. /** @hidden */
  130293. _rebuild(): void;
  130294. /**
  130295. * Renders the layer in the scene.
  130296. */
  130297. render(): void;
  130298. /**
  130299. * Disposes and releases the associated ressources.
  130300. */
  130301. dispose(): void;
  130302. }
  130303. }
  130304. declare module BABYLON {
  130305. /** @hidden */
  130306. export var lensFlarePixelShader: {
  130307. name: string;
  130308. shader: string;
  130309. };
  130310. }
  130311. declare module BABYLON {
  130312. /** @hidden */
  130313. export var lensFlareVertexShader: {
  130314. name: string;
  130315. shader: string;
  130316. };
  130317. }
  130318. declare module BABYLON {
  130319. /**
  130320. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130321. * It is usually composed of several `lensFlare`.
  130322. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130323. */
  130324. export class LensFlareSystem {
  130325. /**
  130326. * Define the name of the lens flare system
  130327. */
  130328. name: string;
  130329. /**
  130330. * List of lens flares used in this system.
  130331. */
  130332. lensFlares: LensFlare[];
  130333. /**
  130334. * Define a limit from the border the lens flare can be visible.
  130335. */
  130336. borderLimit: number;
  130337. /**
  130338. * Define a viewport border we do not want to see the lens flare in.
  130339. */
  130340. viewportBorder: number;
  130341. /**
  130342. * Define a predicate which could limit the list of meshes able to occlude the effect.
  130343. */
  130344. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130345. /**
  130346. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  130347. */
  130348. layerMask: number;
  130349. /**
  130350. * Define the id of the lens flare system in the scene.
  130351. * (equal to name by default)
  130352. */
  130353. id: string;
  130354. private _scene;
  130355. private _emitter;
  130356. private _vertexBuffers;
  130357. private _indexBuffer;
  130358. private _effect;
  130359. private _positionX;
  130360. private _positionY;
  130361. private _isEnabled;
  130362. /** @hidden */
  130363. static _SceneComponentInitialization: (scene: Scene) => void;
  130364. /**
  130365. * Instantiates a lens flare system.
  130366. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  130367. * It is usually composed of several `lensFlare`.
  130368. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130369. * @param name Define the name of the lens flare system in the scene
  130370. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  130371. * @param scene Define the scene the lens flare system belongs to
  130372. */
  130373. constructor(
  130374. /**
  130375. * Define the name of the lens flare system
  130376. */
  130377. name: string, emitter: any, scene: Scene);
  130378. /**
  130379. * Define if the lens flare system is enabled.
  130380. */
  130381. get isEnabled(): boolean;
  130382. set isEnabled(value: boolean);
  130383. /**
  130384. * Get the scene the effects belongs to.
  130385. * @returns the scene holding the lens flare system
  130386. */
  130387. getScene(): Scene;
  130388. /**
  130389. * Get the emitter of the lens flare system.
  130390. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130391. * @returns the emitter of the lens flare system
  130392. */
  130393. getEmitter(): any;
  130394. /**
  130395. * Set the emitter of the lens flare system.
  130396. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  130397. * @param newEmitter Define the new emitter of the system
  130398. */
  130399. setEmitter(newEmitter: any): void;
  130400. /**
  130401. * Get the lens flare system emitter position.
  130402. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  130403. * @returns the position
  130404. */
  130405. getEmitterPosition(): Vector3;
  130406. /**
  130407. * @hidden
  130408. */
  130409. computeEffectivePosition(globalViewport: Viewport): boolean;
  130410. /** @hidden */
  130411. _isVisible(): boolean;
  130412. /**
  130413. * @hidden
  130414. */
  130415. render(): boolean;
  130416. /**
  130417. * Dispose and release the lens flare with its associated resources.
  130418. */
  130419. dispose(): void;
  130420. /**
  130421. * Parse a lens flare system from a JSON repressentation
  130422. * @param parsedLensFlareSystem Define the JSON to parse
  130423. * @param scene Define the scene the parsed system should be instantiated in
  130424. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  130425. * @returns the parsed system
  130426. */
  130427. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  130428. /**
  130429. * Serialize the current Lens Flare System into a JSON representation.
  130430. * @returns the serialized JSON
  130431. */
  130432. serialize(): any;
  130433. }
  130434. }
  130435. declare module BABYLON {
  130436. /**
  130437. * This represents one of the lens effect in a `lensFlareSystem`.
  130438. * It controls one of the indiviual texture used in the effect.
  130439. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130440. */
  130441. export class LensFlare {
  130442. /**
  130443. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130444. */
  130445. size: number;
  130446. /**
  130447. * 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.
  130448. */
  130449. position: number;
  130450. /**
  130451. * Define the lens color.
  130452. */
  130453. color: Color3;
  130454. /**
  130455. * Define the lens texture.
  130456. */
  130457. texture: Nullable<Texture>;
  130458. /**
  130459. * Define the alpha mode to render this particular lens.
  130460. */
  130461. alphaMode: number;
  130462. private _system;
  130463. /**
  130464. * Creates a new Lens Flare.
  130465. * This represents one of the lens effect in a `lensFlareSystem`.
  130466. * It controls one of the indiviual texture used in the effect.
  130467. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130468. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  130469. * @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.
  130470. * @param color Define the lens color
  130471. * @param imgUrl Define the lens texture url
  130472. * @param system Define the `lensFlareSystem` this flare is part of
  130473. * @returns The newly created Lens Flare
  130474. */
  130475. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  130476. /**
  130477. * Instantiates a new Lens Flare.
  130478. * This represents one of the lens effect in a `lensFlareSystem`.
  130479. * It controls one of the indiviual texture used in the effect.
  130480. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130481. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  130482. * @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.
  130483. * @param color Define the lens color
  130484. * @param imgUrl Define the lens texture url
  130485. * @param system Define the `lensFlareSystem` this flare is part of
  130486. */
  130487. constructor(
  130488. /**
  130489. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  130490. */
  130491. size: number,
  130492. /**
  130493. * 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.
  130494. */
  130495. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  130496. /**
  130497. * Dispose and release the lens flare with its associated resources.
  130498. */
  130499. dispose(): void;
  130500. }
  130501. }
  130502. declare module BABYLON {
  130503. interface AbstractScene {
  130504. /**
  130505. * The list of lens flare system added to the scene
  130506. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  130507. */
  130508. lensFlareSystems: Array<LensFlareSystem>;
  130509. /**
  130510. * Removes the given lens flare system from this scene.
  130511. * @param toRemove The lens flare system to remove
  130512. * @returns The index of the removed lens flare system
  130513. */
  130514. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  130515. /**
  130516. * Adds the given lens flare system to this scene
  130517. * @param newLensFlareSystem The lens flare system to add
  130518. */
  130519. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  130520. /**
  130521. * Gets a lens flare system using its name
  130522. * @param name defines the name to look for
  130523. * @returns the lens flare system or null if not found
  130524. */
  130525. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  130526. /**
  130527. * Gets a lens flare system using its id
  130528. * @param id defines the id to look for
  130529. * @returns the lens flare system or null if not found
  130530. */
  130531. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  130532. }
  130533. /**
  130534. * Defines the lens flare scene component responsible to manage any lens flares
  130535. * in a given scene.
  130536. */
  130537. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  130538. /**
  130539. * The component name helpfull to identify the component in the list of scene components.
  130540. */
  130541. readonly name: string;
  130542. /**
  130543. * The scene the component belongs to.
  130544. */
  130545. scene: Scene;
  130546. /**
  130547. * Creates a new instance of the component for the given scene
  130548. * @param scene Defines the scene to register the component in
  130549. */
  130550. constructor(scene: Scene);
  130551. /**
  130552. * Registers the component in a given scene
  130553. */
  130554. register(): void;
  130555. /**
  130556. * Rebuilds the elements related to this component in case of
  130557. * context lost for instance.
  130558. */
  130559. rebuild(): void;
  130560. /**
  130561. * Adds all the elements from the container to the scene
  130562. * @param container the container holding the elements
  130563. */
  130564. addFromContainer(container: AbstractScene): void;
  130565. /**
  130566. * Removes all the elements in the container from the scene
  130567. * @param container contains the elements to remove
  130568. * @param dispose if the removed element should be disposed (default: false)
  130569. */
  130570. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  130571. /**
  130572. * Serializes the component data to the specified json object
  130573. * @param serializationObject The object to serialize to
  130574. */
  130575. serialize(serializationObject: any): void;
  130576. /**
  130577. * Disposes the component and the associated ressources.
  130578. */
  130579. dispose(): void;
  130580. private _draw;
  130581. }
  130582. }
  130583. declare module BABYLON {
  130584. /** @hidden */
  130585. export var depthPixelShader: {
  130586. name: string;
  130587. shader: string;
  130588. };
  130589. }
  130590. declare module BABYLON {
  130591. /** @hidden */
  130592. export var depthVertexShader: {
  130593. name: string;
  130594. shader: string;
  130595. };
  130596. }
  130597. declare module BABYLON {
  130598. /**
  130599. * This represents a depth renderer in Babylon.
  130600. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  130601. */
  130602. export class DepthRenderer {
  130603. private _scene;
  130604. private _depthMap;
  130605. private _effect;
  130606. private readonly _storeNonLinearDepth;
  130607. private readonly _clearColor;
  130608. /** Get if the depth renderer is using packed depth or not */
  130609. readonly isPacked: boolean;
  130610. private _cachedDefines;
  130611. private _camera;
  130612. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  130613. enabled: boolean;
  130614. /**
  130615. * Specifiess that the depth renderer will only be used within
  130616. * the camera it is created for.
  130617. * This can help forcing its rendering during the camera processing.
  130618. */
  130619. useOnlyInActiveCamera: boolean;
  130620. /** @hidden */
  130621. static _SceneComponentInitialization: (scene: Scene) => void;
  130622. /**
  130623. * Instantiates a depth renderer
  130624. * @param scene The scene the renderer belongs to
  130625. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  130626. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  130627. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  130628. */
  130629. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  130630. /**
  130631. * Creates the depth rendering effect and checks if the effect is ready.
  130632. * @param subMesh The submesh to be used to render the depth map of
  130633. * @param useInstances If multiple world instances should be used
  130634. * @returns if the depth renderer is ready to render the depth map
  130635. */
  130636. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130637. /**
  130638. * Gets the texture which the depth map will be written to.
  130639. * @returns The depth map texture
  130640. */
  130641. getDepthMap(): RenderTargetTexture;
  130642. /**
  130643. * Disposes of the depth renderer.
  130644. */
  130645. dispose(): void;
  130646. }
  130647. }
  130648. declare module BABYLON {
  130649. /** @hidden */
  130650. export var minmaxReduxPixelShader: {
  130651. name: string;
  130652. shader: string;
  130653. };
  130654. }
  130655. declare module BABYLON {
  130656. /**
  130657. * This class computes a min/max reduction from a texture: it means it computes the minimum
  130658. * and maximum values from all values of the texture.
  130659. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  130660. * The source values are read from the red channel of the texture.
  130661. */
  130662. export class MinMaxReducer {
  130663. /**
  130664. * Observable triggered when the computation has been performed
  130665. */
  130666. onAfterReductionPerformed: Observable<{
  130667. min: number;
  130668. max: number;
  130669. }>;
  130670. protected _camera: Camera;
  130671. protected _sourceTexture: Nullable<RenderTargetTexture>;
  130672. protected _reductionSteps: Nullable<Array<PostProcess>>;
  130673. protected _postProcessManager: PostProcessManager;
  130674. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  130675. protected _forceFullscreenViewport: boolean;
  130676. /**
  130677. * Creates a min/max reducer
  130678. * @param camera The camera to use for the post processes
  130679. */
  130680. constructor(camera: Camera);
  130681. /**
  130682. * Gets the texture used to read the values from.
  130683. */
  130684. get sourceTexture(): Nullable<RenderTargetTexture>;
  130685. /**
  130686. * Sets the source texture to read the values from.
  130687. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  130688. * because in such textures '1' value must not be taken into account to compute the maximum
  130689. * as this value is used to clear the texture.
  130690. * Note that the computation is not activated by calling this function, you must call activate() for that!
  130691. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  130692. * @param depthRedux Indicates if the texture is a depth texture or not
  130693. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  130694. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130695. */
  130696. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130697. /**
  130698. * Defines the refresh rate of the computation.
  130699. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  130700. */
  130701. get refreshRate(): number;
  130702. set refreshRate(value: number);
  130703. protected _activated: boolean;
  130704. /**
  130705. * Gets the activation status of the reducer
  130706. */
  130707. get activated(): boolean;
  130708. /**
  130709. * Activates the reduction computation.
  130710. * When activated, the observers registered in onAfterReductionPerformed are
  130711. * called after the compuation is performed
  130712. */
  130713. activate(): void;
  130714. /**
  130715. * Deactivates the reduction computation.
  130716. */
  130717. deactivate(): void;
  130718. /**
  130719. * Disposes the min/max reducer
  130720. * @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.
  130721. */
  130722. dispose(disposeAll?: boolean): void;
  130723. }
  130724. }
  130725. declare module BABYLON {
  130726. /**
  130727. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  130728. */
  130729. export class DepthReducer extends MinMaxReducer {
  130730. private _depthRenderer;
  130731. private _depthRendererId;
  130732. /**
  130733. * Gets the depth renderer used for the computation.
  130734. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  130735. */
  130736. get depthRenderer(): Nullable<DepthRenderer>;
  130737. /**
  130738. * Creates a depth reducer
  130739. * @param camera The camera used to render the depth texture
  130740. */
  130741. constructor(camera: Camera);
  130742. /**
  130743. * Sets the depth renderer to use to generate the depth map
  130744. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  130745. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  130746. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  130747. */
  130748. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  130749. /** @hidden */
  130750. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  130751. /**
  130752. * Activates the reduction computation.
  130753. * When activated, the observers registered in onAfterReductionPerformed are
  130754. * called after the compuation is performed
  130755. */
  130756. activate(): void;
  130757. /**
  130758. * Deactivates the reduction computation.
  130759. */
  130760. deactivate(): void;
  130761. /**
  130762. * Disposes the depth reducer
  130763. * @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.
  130764. */
  130765. dispose(disposeAll?: boolean): void;
  130766. }
  130767. }
  130768. declare module BABYLON {
  130769. /**
  130770. * A CSM implementation allowing casting shadows on large scenes.
  130771. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  130772. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  130773. */
  130774. export class CascadedShadowGenerator extends ShadowGenerator {
  130775. private static readonly frustumCornersNDCSpace;
  130776. /**
  130777. * Name of the CSM class
  130778. */
  130779. static CLASSNAME: string;
  130780. /**
  130781. * Defines the default number of cascades used by the CSM.
  130782. */
  130783. static readonly DEFAULT_CASCADES_COUNT: number;
  130784. /**
  130785. * Defines the minimum number of cascades used by the CSM.
  130786. */
  130787. static readonly MIN_CASCADES_COUNT: number;
  130788. /**
  130789. * Defines the maximum number of cascades used by the CSM.
  130790. */
  130791. static readonly MAX_CASCADES_COUNT: number;
  130792. protected _validateFilter(filter: number): number;
  130793. /**
  130794. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  130795. */
  130796. penumbraDarkness: number;
  130797. private _numCascades;
  130798. /**
  130799. * Gets or set the number of cascades used by the CSM.
  130800. */
  130801. get numCascades(): number;
  130802. set numCascades(value: number);
  130803. /**
  130804. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  130805. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  130806. */
  130807. stabilizeCascades: boolean;
  130808. private _freezeShadowCastersBoundingInfo;
  130809. private _freezeShadowCastersBoundingInfoObservable;
  130810. /**
  130811. * Enables or disables the shadow casters bounding info computation.
  130812. * If your shadow casters don't move, you can disable this feature.
  130813. * If it is enabled, the bounding box computation is done every frame.
  130814. */
  130815. get freezeShadowCastersBoundingInfo(): boolean;
  130816. set freezeShadowCastersBoundingInfo(freeze: boolean);
  130817. private _scbiMin;
  130818. private _scbiMax;
  130819. protected _computeShadowCastersBoundingInfo(): void;
  130820. protected _shadowCastersBoundingInfo: BoundingInfo;
  130821. /**
  130822. * Gets or sets the shadow casters bounding info.
  130823. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  130824. * so that the system won't overwrite the bounds you provide
  130825. */
  130826. get shadowCastersBoundingInfo(): BoundingInfo;
  130827. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  130828. protected _breaksAreDirty: boolean;
  130829. protected _minDistance: number;
  130830. protected _maxDistance: number;
  130831. /**
  130832. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  130833. *
  130834. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  130835. * If you don't know these values, simply leave them to their defaults and don't call this function.
  130836. * @param min minimal distance for the breaks (default to 0.)
  130837. * @param max maximal distance for the breaks (default to 1.)
  130838. */
  130839. setMinMaxDistance(min: number, max: number): void;
  130840. /** Gets the minimal distance used in the cascade break computation */
  130841. get minDistance(): number;
  130842. /** Gets the maximal distance used in the cascade break computation */
  130843. get maxDistance(): number;
  130844. /**
  130845. * Gets the class name of that object
  130846. * @returns "CascadedShadowGenerator"
  130847. */
  130848. getClassName(): string;
  130849. private _cascadeMinExtents;
  130850. private _cascadeMaxExtents;
  130851. /**
  130852. * Gets a cascade minimum extents
  130853. * @param cascadeIndex index of the cascade
  130854. * @returns the minimum cascade extents
  130855. */
  130856. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  130857. /**
  130858. * Gets a cascade maximum extents
  130859. * @param cascadeIndex index of the cascade
  130860. * @returns the maximum cascade extents
  130861. */
  130862. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  130863. private _cascades;
  130864. private _currentLayer;
  130865. private _viewSpaceFrustumsZ;
  130866. private _viewMatrices;
  130867. private _projectionMatrices;
  130868. private _transformMatrices;
  130869. private _transformMatricesAsArray;
  130870. private _frustumLengths;
  130871. private _lightSizeUVCorrection;
  130872. private _depthCorrection;
  130873. private _frustumCornersWorldSpace;
  130874. private _frustumCenter;
  130875. private _shadowCameraPos;
  130876. private _shadowMaxZ;
  130877. /**
  130878. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  130879. * It defaults to camera.maxZ
  130880. */
  130881. get shadowMaxZ(): number;
  130882. /**
  130883. * Sets the shadow max z distance.
  130884. */
  130885. set shadowMaxZ(value: number);
  130886. protected _debug: boolean;
  130887. /**
  130888. * Gets or sets the debug flag.
  130889. * When enabled, the cascades are materialized by different colors on the screen.
  130890. */
  130891. get debug(): boolean;
  130892. set debug(dbg: boolean);
  130893. private _depthClamp;
  130894. /**
  130895. * Gets or sets the depth clamping value.
  130896. *
  130897. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  130898. * to account for the shadow casters far away.
  130899. *
  130900. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  130901. */
  130902. get depthClamp(): boolean;
  130903. set depthClamp(value: boolean);
  130904. private _cascadeBlendPercentage;
  130905. /**
  130906. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  130907. * It defaults to 0.1 (10% blending).
  130908. */
  130909. get cascadeBlendPercentage(): number;
  130910. set cascadeBlendPercentage(value: number);
  130911. private _lambda;
  130912. /**
  130913. * Gets or set the lambda parameter.
  130914. * This parameter is used to split the camera frustum and create the cascades.
  130915. * 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.
  130916. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  130917. */
  130918. get lambda(): number;
  130919. set lambda(value: number);
  130920. /**
  130921. * Gets the view matrix corresponding to a given cascade
  130922. * @param cascadeNum cascade to retrieve the view matrix from
  130923. * @returns the cascade view matrix
  130924. */
  130925. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  130926. /**
  130927. * Gets the projection matrix corresponding to a given cascade
  130928. * @param cascadeNum cascade to retrieve the projection matrix from
  130929. * @returns the cascade projection matrix
  130930. */
  130931. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  130932. /**
  130933. * Gets the transformation matrix corresponding to a given cascade
  130934. * @param cascadeNum cascade to retrieve the transformation matrix from
  130935. * @returns the cascade transformation matrix
  130936. */
  130937. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  130938. private _depthRenderer;
  130939. /**
  130940. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  130941. *
  130942. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  130943. *
  130944. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  130945. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  130946. * @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
  130947. */
  130948. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  130949. private _depthReducer;
  130950. private _autoCalcDepthBounds;
  130951. /**
  130952. * Gets or sets the autoCalcDepthBounds property.
  130953. *
  130954. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  130955. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  130956. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  130957. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  130958. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  130959. */
  130960. get autoCalcDepthBounds(): boolean;
  130961. set autoCalcDepthBounds(value: boolean);
  130962. /**
  130963. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  130964. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  130965. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  130966. * for setting the refresh rate on the renderer yourself!
  130967. */
  130968. get autoCalcDepthBoundsRefreshRate(): number;
  130969. set autoCalcDepthBoundsRefreshRate(value: number);
  130970. /**
  130971. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  130972. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  130973. * you change the camera near/far planes!
  130974. */
  130975. splitFrustum(): void;
  130976. private _splitFrustum;
  130977. private _computeMatrices;
  130978. private _computeFrustumInWorldSpace;
  130979. private _computeCascadeFrustum;
  130980. /**
  130981. * Support test.
  130982. */
  130983. static get IsSupported(): boolean;
  130984. /** @hidden */
  130985. static _SceneComponentInitialization: (scene: Scene) => void;
  130986. /**
  130987. * Creates a Cascaded Shadow Generator object.
  130988. * A ShadowGenerator is the required tool to use the shadows.
  130989. * Each directional light casting shadows needs to use its own ShadowGenerator.
  130990. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  130991. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  130992. * @param light The directional light object generating the shadows.
  130993. * @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.
  130994. */
  130995. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  130996. protected _initializeGenerator(): void;
  130997. protected _createTargetRenderTexture(): void;
  130998. protected _initializeShadowMap(): void;
  130999. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  131000. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  131001. /**
  131002. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  131003. * @param defines Defines of the material we want to update
  131004. * @param lightIndex Index of the light in the enabled light list of the material
  131005. */
  131006. prepareDefines(defines: any, lightIndex: number): void;
  131007. /**
  131008. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  131009. * defined in the generator but impacting the effect).
  131010. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  131011. * @param effect The effect we are binfing the information for
  131012. */
  131013. bindShadowLight(lightIndex: string, effect: Effect): void;
  131014. /**
  131015. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  131016. * (eq to view projection * shadow projection matrices)
  131017. * @returns The transform matrix used to create the shadow map
  131018. */
  131019. getTransformMatrix(): Matrix;
  131020. /**
  131021. * Disposes the ShadowGenerator.
  131022. * Returns nothing.
  131023. */
  131024. dispose(): void;
  131025. /**
  131026. * Serializes the shadow generator setup to a json object.
  131027. * @returns The serialized JSON object
  131028. */
  131029. serialize(): any;
  131030. /**
  131031. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  131032. * @param parsedShadowGenerator The JSON object to parse
  131033. * @param scene The scene to create the shadow map for
  131034. * @returns The parsed shadow generator
  131035. */
  131036. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  131037. }
  131038. }
  131039. declare module BABYLON {
  131040. /**
  131041. * Defines the shadow generator component responsible to manage any shadow generators
  131042. * in a given scene.
  131043. */
  131044. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  131045. /**
  131046. * The component name helpfull to identify the component in the list of scene components.
  131047. */
  131048. readonly name: string;
  131049. /**
  131050. * The scene the component belongs to.
  131051. */
  131052. scene: Scene;
  131053. /**
  131054. * Creates a new instance of the component for the given scene
  131055. * @param scene Defines the scene to register the component in
  131056. */
  131057. constructor(scene: Scene);
  131058. /**
  131059. * Registers the component in a given scene
  131060. */
  131061. register(): void;
  131062. /**
  131063. * Rebuilds the elements related to this component in case of
  131064. * context lost for instance.
  131065. */
  131066. rebuild(): void;
  131067. /**
  131068. * Serializes the component data to the specified json object
  131069. * @param serializationObject The object to serialize to
  131070. */
  131071. serialize(serializationObject: any): void;
  131072. /**
  131073. * Adds all the elements from the container to the scene
  131074. * @param container the container holding the elements
  131075. */
  131076. addFromContainer(container: AbstractScene): void;
  131077. /**
  131078. * Removes all the elements in the container from the scene
  131079. * @param container contains the elements to remove
  131080. * @param dispose if the removed element should be disposed (default: false)
  131081. */
  131082. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  131083. /**
  131084. * Rebuilds the elements related to this component in case of
  131085. * context lost for instance.
  131086. */
  131087. dispose(): void;
  131088. private _gatherRenderTargets;
  131089. }
  131090. }
  131091. declare module BABYLON {
  131092. /**
  131093. * A point light is a light defined by an unique point in world space.
  131094. * The light is emitted in every direction from this point.
  131095. * A good example of a point light is a standard light bulb.
  131096. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131097. */
  131098. export class PointLight extends ShadowLight {
  131099. private _shadowAngle;
  131100. /**
  131101. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131102. * This specifies what angle the shadow will use to be created.
  131103. *
  131104. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131105. */
  131106. get shadowAngle(): number;
  131107. /**
  131108. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131109. * This specifies what angle the shadow will use to be created.
  131110. *
  131111. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  131112. */
  131113. set shadowAngle(value: number);
  131114. /**
  131115. * Gets the direction if it has been set.
  131116. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131117. */
  131118. get direction(): Vector3;
  131119. /**
  131120. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  131121. */
  131122. set direction(value: Vector3);
  131123. /**
  131124. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  131125. * A PointLight emits the light in every direction.
  131126. * It can cast shadows.
  131127. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  131128. * ```javascript
  131129. * var pointLight = new PointLight("pl", camera.position, scene);
  131130. * ```
  131131. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131132. * @param name The light friendly name
  131133. * @param position The position of the point light in the scene
  131134. * @param scene The scene the lights belongs to
  131135. */
  131136. constructor(name: string, position: Vector3, scene: Scene);
  131137. /**
  131138. * Returns the string "PointLight"
  131139. * @returns the class name
  131140. */
  131141. getClassName(): string;
  131142. /**
  131143. * Returns the integer 0.
  131144. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131145. */
  131146. getTypeID(): number;
  131147. /**
  131148. * Specifies wether or not the shadowmap should be a cube texture.
  131149. * @returns true if the shadowmap needs to be a cube texture.
  131150. */
  131151. needCube(): boolean;
  131152. /**
  131153. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  131154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  131155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  131156. */
  131157. getShadowDirection(faceIndex?: number): Vector3;
  131158. /**
  131159. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  131160. * - fov = PI / 2
  131161. * - aspect ratio : 1.0
  131162. * - z-near and far equal to the active camera minZ and maxZ.
  131163. * Returns the PointLight.
  131164. */
  131165. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131166. protected _buildUniformLayout(): void;
  131167. /**
  131168. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  131169. * @param effect The effect to update
  131170. * @param lightIndex The index of the light in the effect to update
  131171. * @returns The point light
  131172. */
  131173. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  131174. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131175. /**
  131176. * Prepares the list of defines specific to the light type.
  131177. * @param defines the list of defines
  131178. * @param lightIndex defines the index of the light for the effect
  131179. */
  131180. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131181. }
  131182. }
  131183. declare module BABYLON {
  131184. /**
  131185. * Header information of HDR texture files.
  131186. */
  131187. export interface HDRInfo {
  131188. /**
  131189. * The height of the texture in pixels.
  131190. */
  131191. height: number;
  131192. /**
  131193. * The width of the texture in pixels.
  131194. */
  131195. width: number;
  131196. /**
  131197. * The index of the beginning of the data in the binary file.
  131198. */
  131199. dataPosition: number;
  131200. }
  131201. /**
  131202. * This groups tools to convert HDR texture to native colors array.
  131203. */
  131204. export class HDRTools {
  131205. private static Ldexp;
  131206. private static Rgbe2float;
  131207. private static readStringLine;
  131208. /**
  131209. * Reads header information from an RGBE texture stored in a native array.
  131210. * More information on this format are available here:
  131211. * https://en.wikipedia.org/wiki/RGBE_image_format
  131212. *
  131213. * @param uint8array The binary file stored in native array.
  131214. * @return The header information.
  131215. */
  131216. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  131217. /**
  131218. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  131219. * This RGBE texture needs to store the information as a panorama.
  131220. *
  131221. * More information on this format are available here:
  131222. * https://en.wikipedia.org/wiki/RGBE_image_format
  131223. *
  131224. * @param buffer The binary file stored in an array buffer.
  131225. * @param size The expected size of the extracted cubemap.
  131226. * @return The Cube Map information.
  131227. */
  131228. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  131229. /**
  131230. * Returns the pixels data extracted from an RGBE texture.
  131231. * This pixels will be stored left to right up to down in the R G B order in one array.
  131232. *
  131233. * More information on this format are available here:
  131234. * https://en.wikipedia.org/wiki/RGBE_image_format
  131235. *
  131236. * @param uint8array The binary file stored in an array buffer.
  131237. * @param hdrInfo The header information of the file.
  131238. * @return The pixels data in RGB right to left up to down order.
  131239. */
  131240. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  131241. private static RGBE_ReadPixels_RLE;
  131242. }
  131243. }
  131244. declare module BABYLON {
  131245. /**
  131246. * This represents a texture coming from an HDR input.
  131247. *
  131248. * The only supported format is currently panorama picture stored in RGBE format.
  131249. * Example of such files can be found on HDRLib: http://hdrlib.com/
  131250. */
  131251. export class HDRCubeTexture extends BaseTexture {
  131252. private static _facesMapping;
  131253. private _generateHarmonics;
  131254. private _noMipmap;
  131255. private _textureMatrix;
  131256. private _size;
  131257. private _onLoad;
  131258. private _onError;
  131259. /**
  131260. * The texture URL.
  131261. */
  131262. url: string;
  131263. /**
  131264. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  131265. */
  131266. coordinatesMode: number;
  131267. protected _isBlocking: boolean;
  131268. /**
  131269. * Sets wether or not the texture is blocking during loading.
  131270. */
  131271. set isBlocking(value: boolean);
  131272. /**
  131273. * Gets wether or not the texture is blocking during loading.
  131274. */
  131275. get isBlocking(): boolean;
  131276. protected _rotationY: number;
  131277. /**
  131278. * Sets texture matrix rotation angle around Y axis in radians.
  131279. */
  131280. set rotationY(value: number);
  131281. /**
  131282. * Gets texture matrix rotation angle around Y axis radians.
  131283. */
  131284. get rotationY(): number;
  131285. /**
  131286. * Gets or sets the center of the bounding box associated with the cube texture
  131287. * It must define where the camera used to render the texture was set
  131288. */
  131289. boundingBoxPosition: Vector3;
  131290. private _boundingBoxSize;
  131291. /**
  131292. * Gets or sets the size of the bounding box associated with the cube texture
  131293. * When defined, the cubemap will switch to local mode
  131294. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  131295. * @example https://www.babylonjs-playground.com/#RNASML
  131296. */
  131297. set boundingBoxSize(value: Vector3);
  131298. get boundingBoxSize(): Vector3;
  131299. /**
  131300. * Instantiates an HDRTexture from the following parameters.
  131301. *
  131302. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  131303. * @param scene The scene the texture will be used in
  131304. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  131305. * @param noMipmap Forces to not generate the mipmap if true
  131306. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  131307. * @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)
  131308. * @param reserved Reserved flag for internal use.
  131309. */
  131310. 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>);
  131311. /**
  131312. * Get the current class name of the texture useful for serialization or dynamic coding.
  131313. * @returns "HDRCubeTexture"
  131314. */
  131315. getClassName(): string;
  131316. /**
  131317. * Occurs when the file is raw .hdr file.
  131318. */
  131319. private loadTexture;
  131320. clone(): HDRCubeTexture;
  131321. delayLoad(): void;
  131322. /**
  131323. * Get the texture reflection matrix used to rotate/transform the reflection.
  131324. * @returns the reflection matrix
  131325. */
  131326. getReflectionTextureMatrix(): Matrix;
  131327. /**
  131328. * Set the texture reflection matrix used to rotate/transform the reflection.
  131329. * @param value Define the reflection matrix to set
  131330. */
  131331. setReflectionTextureMatrix(value: Matrix): void;
  131332. /**
  131333. * Parses a JSON representation of an HDR Texture in order to create the texture
  131334. * @param parsedTexture Define the JSON representation
  131335. * @param scene Define the scene the texture should be created in
  131336. * @param rootUrl Define the root url in case we need to load relative dependencies
  131337. * @returns the newly created texture after parsing
  131338. */
  131339. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  131340. serialize(): any;
  131341. }
  131342. }
  131343. declare module BABYLON {
  131344. /**
  131345. * Class used to control physics engine
  131346. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  131347. */
  131348. export class PhysicsEngine implements IPhysicsEngine {
  131349. private _physicsPlugin;
  131350. /**
  131351. * Global value used to control the smallest number supported by the simulation
  131352. */
  131353. static Epsilon: number;
  131354. private _impostors;
  131355. private _joints;
  131356. private _subTimeStep;
  131357. /**
  131358. * Gets the gravity vector used by the simulation
  131359. */
  131360. gravity: Vector3;
  131361. /**
  131362. * Factory used to create the default physics plugin.
  131363. * @returns The default physics plugin
  131364. */
  131365. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  131366. /**
  131367. * Creates a new Physics Engine
  131368. * @param gravity defines the gravity vector used by the simulation
  131369. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  131370. */
  131371. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  131372. /**
  131373. * Sets the gravity vector used by the simulation
  131374. * @param gravity defines the gravity vector to use
  131375. */
  131376. setGravity(gravity: Vector3): void;
  131377. /**
  131378. * Set the time step of the physics engine.
  131379. * Default is 1/60.
  131380. * To slow it down, enter 1/600 for example.
  131381. * To speed it up, 1/30
  131382. * @param newTimeStep defines the new timestep to apply to this world.
  131383. */
  131384. setTimeStep(newTimeStep?: number): void;
  131385. /**
  131386. * Get the time step of the physics engine.
  131387. * @returns the current time step
  131388. */
  131389. getTimeStep(): number;
  131390. /**
  131391. * Set the sub time step of the physics engine.
  131392. * Default is 0 meaning there is no sub steps
  131393. * To increase physics resolution precision, set a small value (like 1 ms)
  131394. * @param subTimeStep defines the new sub timestep used for physics resolution.
  131395. */
  131396. setSubTimeStep(subTimeStep?: number): void;
  131397. /**
  131398. * Get the sub time step of the physics engine.
  131399. * @returns the current sub time step
  131400. */
  131401. getSubTimeStep(): number;
  131402. /**
  131403. * Release all resources
  131404. */
  131405. dispose(): void;
  131406. /**
  131407. * Gets the name of the current physics plugin
  131408. * @returns the name of the plugin
  131409. */
  131410. getPhysicsPluginName(): string;
  131411. /**
  131412. * Adding a new impostor for the impostor tracking.
  131413. * This will be done by the impostor itself.
  131414. * @param impostor the impostor to add
  131415. */
  131416. addImpostor(impostor: PhysicsImpostor): void;
  131417. /**
  131418. * Remove an impostor from the engine.
  131419. * This impostor and its mesh will not longer be updated by the physics engine.
  131420. * @param impostor the impostor to remove
  131421. */
  131422. removeImpostor(impostor: PhysicsImpostor): void;
  131423. /**
  131424. * Add a joint to the physics engine
  131425. * @param mainImpostor defines the main impostor to which the joint is added.
  131426. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  131427. * @param joint defines the joint that will connect both impostors.
  131428. */
  131429. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131430. /**
  131431. * Removes a joint from the simulation
  131432. * @param mainImpostor defines the impostor used with the joint
  131433. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  131434. * @param joint defines the joint to remove
  131435. */
  131436. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  131437. /**
  131438. * Called by the scene. No need to call it.
  131439. * @param delta defines the timespam between frames
  131440. */
  131441. _step(delta: number): void;
  131442. /**
  131443. * Gets the current plugin used to run the simulation
  131444. * @returns current plugin
  131445. */
  131446. getPhysicsPlugin(): IPhysicsEnginePlugin;
  131447. /**
  131448. * Gets the list of physic impostors
  131449. * @returns an array of PhysicsImpostor
  131450. */
  131451. getImpostors(): Array<PhysicsImpostor>;
  131452. /**
  131453. * Gets the impostor for a physics enabled object
  131454. * @param object defines the object impersonated by the impostor
  131455. * @returns the PhysicsImpostor or null if not found
  131456. */
  131457. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  131458. /**
  131459. * Gets the impostor for a physics body object
  131460. * @param body defines physics body used by the impostor
  131461. * @returns the PhysicsImpostor or null if not found
  131462. */
  131463. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  131464. /**
  131465. * Does a raycast in the physics world
  131466. * @param from when should the ray start?
  131467. * @param to when should the ray end?
  131468. * @returns PhysicsRaycastResult
  131469. */
  131470. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131471. }
  131472. }
  131473. declare module BABYLON {
  131474. /** @hidden */
  131475. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  131476. private _useDeltaForWorldStep;
  131477. world: any;
  131478. name: string;
  131479. private _physicsMaterials;
  131480. private _fixedTimeStep;
  131481. private _cannonRaycastResult;
  131482. private _raycastResult;
  131483. private _physicsBodysToRemoveAfterStep;
  131484. BJSCANNON: any;
  131485. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  131486. setGravity(gravity: Vector3): void;
  131487. setTimeStep(timeStep: number): void;
  131488. getTimeStep(): number;
  131489. executeStep(delta: number): void;
  131490. private _removeMarkedPhysicsBodiesFromWorld;
  131491. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131492. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131493. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131494. private _processChildMeshes;
  131495. removePhysicsBody(impostor: PhysicsImpostor): void;
  131496. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131497. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131498. private _addMaterial;
  131499. private _checkWithEpsilon;
  131500. private _createShape;
  131501. private _createHeightmap;
  131502. private _minus90X;
  131503. private _plus90X;
  131504. private _tmpPosition;
  131505. private _tmpDeltaPosition;
  131506. private _tmpUnityRotation;
  131507. private _updatePhysicsBodyTransformation;
  131508. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131509. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131510. isSupported(): boolean;
  131511. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131512. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131513. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131514. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131515. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131516. getBodyMass(impostor: PhysicsImpostor): number;
  131517. getBodyFriction(impostor: PhysicsImpostor): number;
  131518. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131519. getBodyRestitution(impostor: PhysicsImpostor): number;
  131520. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131521. sleepBody(impostor: PhysicsImpostor): void;
  131522. wakeUpBody(impostor: PhysicsImpostor): void;
  131523. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  131524. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  131525. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  131526. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131527. getRadius(impostor: PhysicsImpostor): number;
  131528. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131529. dispose(): void;
  131530. private _extendNamespace;
  131531. /**
  131532. * Does a raycast in the physics world
  131533. * @param from when should the ray start?
  131534. * @param to when should the ray end?
  131535. * @returns PhysicsRaycastResult
  131536. */
  131537. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131538. }
  131539. }
  131540. declare module BABYLON {
  131541. /** @hidden */
  131542. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  131543. private _useDeltaForWorldStep;
  131544. world: any;
  131545. name: string;
  131546. BJSOIMO: any;
  131547. private _raycastResult;
  131548. private _fixedTimeStep;
  131549. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  131550. setGravity(gravity: Vector3): void;
  131551. setTimeStep(timeStep: number): void;
  131552. getTimeStep(): number;
  131553. private _tmpImpostorsArray;
  131554. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131555. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131556. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131557. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131558. private _tmpPositionVector;
  131559. removePhysicsBody(impostor: PhysicsImpostor): void;
  131560. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131561. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131562. isSupported(): boolean;
  131563. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131564. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131565. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131566. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131567. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131568. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131569. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131570. getBodyMass(impostor: PhysicsImpostor): number;
  131571. getBodyFriction(impostor: PhysicsImpostor): number;
  131572. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131573. getBodyRestitution(impostor: PhysicsImpostor): number;
  131574. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131575. sleepBody(impostor: PhysicsImpostor): void;
  131576. wakeUpBody(impostor: PhysicsImpostor): void;
  131577. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  131578. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  131579. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  131580. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  131581. getRadius(impostor: PhysicsImpostor): number;
  131582. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  131583. dispose(): void;
  131584. /**
  131585. * Does a raycast in the physics world
  131586. * @param from when should the ray start?
  131587. * @param to when should the ray end?
  131588. * @returns PhysicsRaycastResult
  131589. */
  131590. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  131591. }
  131592. }
  131593. declare module BABYLON {
  131594. /**
  131595. * Class containing static functions to help procedurally build meshes
  131596. */
  131597. export class RibbonBuilder {
  131598. /**
  131599. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131600. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131601. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131602. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131603. * * 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
  131604. * * 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
  131605. * * 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
  131606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131609. * * 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
  131610. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131611. * * 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
  131612. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131614. * @param name defines the name of the mesh
  131615. * @param options defines the options used to create the mesh
  131616. * @param scene defines the hosting scene
  131617. * @returns the ribbon mesh
  131618. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131619. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131620. */
  131621. static CreateRibbon(name: string, options: {
  131622. pathArray: Vector3[][];
  131623. closeArray?: boolean;
  131624. closePath?: boolean;
  131625. offset?: number;
  131626. updatable?: boolean;
  131627. sideOrientation?: number;
  131628. frontUVs?: Vector4;
  131629. backUVs?: Vector4;
  131630. instance?: Mesh;
  131631. invertUV?: boolean;
  131632. uvs?: Vector2[];
  131633. colors?: Color4[];
  131634. }, scene?: Nullable<Scene>): Mesh;
  131635. }
  131636. }
  131637. declare module BABYLON {
  131638. /**
  131639. * Class containing static functions to help procedurally build meshes
  131640. */
  131641. export class ShapeBuilder {
  131642. /**
  131643. * 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.
  131644. * * 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.
  131645. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131646. * * 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.
  131647. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131648. * * 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
  131649. * * 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
  131650. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131653. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131655. * @param name defines the name of the mesh
  131656. * @param options defines the options used to create the mesh
  131657. * @param scene defines the hosting scene
  131658. * @returns the extruded shape mesh
  131659. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131661. */
  131662. static ExtrudeShape(name: string, options: {
  131663. shape: Vector3[];
  131664. path: Vector3[];
  131665. scale?: number;
  131666. rotation?: number;
  131667. cap?: number;
  131668. updatable?: boolean;
  131669. sideOrientation?: number;
  131670. frontUVs?: Vector4;
  131671. backUVs?: Vector4;
  131672. instance?: Mesh;
  131673. invertUV?: boolean;
  131674. }, scene?: Nullable<Scene>): Mesh;
  131675. /**
  131676. * Creates an custom extruded shape mesh.
  131677. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131678. * * 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.
  131679. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131680. * * 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
  131681. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131682. * * 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
  131683. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131684. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131685. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131686. * * 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
  131687. * * 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
  131688. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131693. * @param name defines the name of the mesh
  131694. * @param options defines the options used to create the mesh
  131695. * @param scene defines the hosting scene
  131696. * @returns the custom extruded shape mesh
  131697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131698. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131699. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131700. */
  131701. static ExtrudeShapeCustom(name: string, options: {
  131702. shape: Vector3[];
  131703. path: Vector3[];
  131704. scaleFunction?: any;
  131705. rotationFunction?: any;
  131706. ribbonCloseArray?: boolean;
  131707. ribbonClosePath?: boolean;
  131708. cap?: number;
  131709. updatable?: boolean;
  131710. sideOrientation?: number;
  131711. frontUVs?: Vector4;
  131712. backUVs?: Vector4;
  131713. instance?: Mesh;
  131714. invertUV?: boolean;
  131715. }, scene?: Nullable<Scene>): Mesh;
  131716. private static _ExtrudeShapeGeneric;
  131717. }
  131718. }
  131719. declare module BABYLON {
  131720. /**
  131721. * AmmoJS Physics plugin
  131722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  131723. * @see https://github.com/kripken/ammo.js/
  131724. */
  131725. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  131726. private _useDeltaForWorldStep;
  131727. /**
  131728. * Reference to the Ammo library
  131729. */
  131730. bjsAMMO: any;
  131731. /**
  131732. * Created ammoJS world which physics bodies are added to
  131733. */
  131734. world: any;
  131735. /**
  131736. * Name of the plugin
  131737. */
  131738. name: string;
  131739. private _timeStep;
  131740. private _fixedTimeStep;
  131741. private _maxSteps;
  131742. private _tmpQuaternion;
  131743. private _tmpAmmoTransform;
  131744. private _tmpAmmoQuaternion;
  131745. private _tmpAmmoConcreteContactResultCallback;
  131746. private _collisionConfiguration;
  131747. private _dispatcher;
  131748. private _overlappingPairCache;
  131749. private _solver;
  131750. private _softBodySolver;
  131751. private _tmpAmmoVectorA;
  131752. private _tmpAmmoVectorB;
  131753. private _tmpAmmoVectorC;
  131754. private _tmpAmmoVectorD;
  131755. private _tmpContactCallbackResult;
  131756. private _tmpAmmoVectorRCA;
  131757. private _tmpAmmoVectorRCB;
  131758. private _raycastResult;
  131759. private static readonly DISABLE_COLLISION_FLAG;
  131760. private static readonly KINEMATIC_FLAG;
  131761. private static readonly DISABLE_DEACTIVATION_FLAG;
  131762. /**
  131763. * Initializes the ammoJS plugin
  131764. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  131765. * @param ammoInjection can be used to inject your own ammo reference
  131766. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  131767. */
  131768. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  131769. /**
  131770. * Sets the gravity of the physics world (m/(s^2))
  131771. * @param gravity Gravity to set
  131772. */
  131773. setGravity(gravity: Vector3): void;
  131774. /**
  131775. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  131776. * @param timeStep timestep to use in seconds
  131777. */
  131778. setTimeStep(timeStep: number): void;
  131779. /**
  131780. * 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)
  131781. * @param fixedTimeStep fixedTimeStep to use in seconds
  131782. */
  131783. setFixedTimeStep(fixedTimeStep: number): void;
  131784. /**
  131785. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  131786. * @param maxSteps the maximum number of steps by the physics engine per frame
  131787. */
  131788. setMaxSteps(maxSteps: number): void;
  131789. /**
  131790. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  131791. * @returns the current timestep in seconds
  131792. */
  131793. getTimeStep(): number;
  131794. /**
  131795. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  131796. */
  131797. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  131798. private _isImpostorInContact;
  131799. private _isImpostorPairInContact;
  131800. private _stepSimulation;
  131801. /**
  131802. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  131803. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  131804. * After the step the babylon meshes are set to the position of the physics imposters
  131805. * @param delta amount of time to step forward
  131806. * @param impostors array of imposters to update before/after the step
  131807. */
  131808. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  131809. /**
  131810. * Update babylon mesh to match physics world object
  131811. * @param impostor imposter to match
  131812. */
  131813. private _afterSoftStep;
  131814. /**
  131815. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  131816. * @param impostor imposter to match
  131817. */
  131818. private _ropeStep;
  131819. /**
  131820. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  131821. * @param impostor imposter to match
  131822. */
  131823. private _softbodyOrClothStep;
  131824. private _tmpMatrix;
  131825. /**
  131826. * Applies an impulse on the imposter
  131827. * @param impostor imposter to apply impulse to
  131828. * @param force amount of force to be applied to the imposter
  131829. * @param contactPoint the location to apply the impulse on the imposter
  131830. */
  131831. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131832. /**
  131833. * Applies a force on the imposter
  131834. * @param impostor imposter to apply force
  131835. * @param force amount of force to be applied to the imposter
  131836. * @param contactPoint the location to apply the force on the imposter
  131837. */
  131838. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  131839. /**
  131840. * Creates a physics body using the plugin
  131841. * @param impostor the imposter to create the physics body on
  131842. */
  131843. generatePhysicsBody(impostor: PhysicsImpostor): void;
  131844. /**
  131845. * Removes the physics body from the imposter and disposes of the body's memory
  131846. * @param impostor imposter to remove the physics body from
  131847. */
  131848. removePhysicsBody(impostor: PhysicsImpostor): void;
  131849. /**
  131850. * Generates a joint
  131851. * @param impostorJoint the imposter joint to create the joint with
  131852. */
  131853. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  131854. /**
  131855. * Removes a joint
  131856. * @param impostorJoint the imposter joint to remove the joint from
  131857. */
  131858. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  131859. private _addMeshVerts;
  131860. /**
  131861. * Initialise the soft body vertices to match its object's (mesh) vertices
  131862. * Softbody vertices (nodes) are in world space and to match this
  131863. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  131864. * @param impostor to create the softbody for
  131865. */
  131866. private _softVertexData;
  131867. /**
  131868. * Create an impostor's soft body
  131869. * @param impostor to create the softbody for
  131870. */
  131871. private _createSoftbody;
  131872. /**
  131873. * Create cloth for an impostor
  131874. * @param impostor to create the softbody for
  131875. */
  131876. private _createCloth;
  131877. /**
  131878. * Create rope for an impostor
  131879. * @param impostor to create the softbody for
  131880. */
  131881. private _createRope;
  131882. /**
  131883. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  131884. * @param impostor to create the custom physics shape for
  131885. */
  131886. private _createCustom;
  131887. private _addHullVerts;
  131888. private _createShape;
  131889. /**
  131890. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  131891. * @param impostor imposter containing the physics body and babylon object
  131892. */
  131893. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  131894. /**
  131895. * Sets the babylon object's position/rotation from the physics body's position/rotation
  131896. * @param impostor imposter containing the physics body and babylon object
  131897. * @param newPosition new position
  131898. * @param newRotation new rotation
  131899. */
  131900. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  131901. /**
  131902. * If this plugin is supported
  131903. * @returns true if its supported
  131904. */
  131905. isSupported(): boolean;
  131906. /**
  131907. * Sets the linear velocity of the physics body
  131908. * @param impostor imposter to set the velocity on
  131909. * @param velocity velocity to set
  131910. */
  131911. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131912. /**
  131913. * Sets the angular velocity of the physics body
  131914. * @param impostor imposter to set the velocity on
  131915. * @param velocity velocity to set
  131916. */
  131917. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  131918. /**
  131919. * gets the linear velocity
  131920. * @param impostor imposter to get linear velocity from
  131921. * @returns linear velocity
  131922. */
  131923. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131924. /**
  131925. * gets the angular velocity
  131926. * @param impostor imposter to get angular velocity from
  131927. * @returns angular velocity
  131928. */
  131929. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  131930. /**
  131931. * Sets the mass of physics body
  131932. * @param impostor imposter to set the mass on
  131933. * @param mass mass to set
  131934. */
  131935. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  131936. /**
  131937. * Gets the mass of the physics body
  131938. * @param impostor imposter to get the mass from
  131939. * @returns mass
  131940. */
  131941. getBodyMass(impostor: PhysicsImpostor): number;
  131942. /**
  131943. * Gets friction of the impostor
  131944. * @param impostor impostor to get friction from
  131945. * @returns friction value
  131946. */
  131947. getBodyFriction(impostor: PhysicsImpostor): number;
  131948. /**
  131949. * Sets friction of the impostor
  131950. * @param impostor impostor to set friction on
  131951. * @param friction friction value
  131952. */
  131953. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  131954. /**
  131955. * Gets restitution of the impostor
  131956. * @param impostor impostor to get restitution from
  131957. * @returns restitution value
  131958. */
  131959. getBodyRestitution(impostor: PhysicsImpostor): number;
  131960. /**
  131961. * Sets resitution of the impostor
  131962. * @param impostor impostor to set resitution on
  131963. * @param restitution resitution value
  131964. */
  131965. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  131966. /**
  131967. * Gets pressure inside the impostor
  131968. * @param impostor impostor to get pressure from
  131969. * @returns pressure value
  131970. */
  131971. getBodyPressure(impostor: PhysicsImpostor): number;
  131972. /**
  131973. * Sets pressure inside a soft body impostor
  131974. * Cloth and rope must remain 0 pressure
  131975. * @param impostor impostor to set pressure on
  131976. * @param pressure pressure value
  131977. */
  131978. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  131979. /**
  131980. * Gets stiffness of the impostor
  131981. * @param impostor impostor to get stiffness from
  131982. * @returns pressure value
  131983. */
  131984. getBodyStiffness(impostor: PhysicsImpostor): number;
  131985. /**
  131986. * Sets stiffness of the impostor
  131987. * @param impostor impostor to set stiffness on
  131988. * @param stiffness stiffness value from 0 to 1
  131989. */
  131990. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  131991. /**
  131992. * Gets velocityIterations of the impostor
  131993. * @param impostor impostor to get velocity iterations from
  131994. * @returns velocityIterations value
  131995. */
  131996. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  131997. /**
  131998. * Sets velocityIterations of the impostor
  131999. * @param impostor impostor to set velocity iterations on
  132000. * @param velocityIterations velocityIterations value
  132001. */
  132002. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  132003. /**
  132004. * Gets positionIterations of the impostor
  132005. * @param impostor impostor to get position iterations from
  132006. * @returns positionIterations value
  132007. */
  132008. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  132009. /**
  132010. * Sets positionIterations of the impostor
  132011. * @param impostor impostor to set position on
  132012. * @param positionIterations positionIterations value
  132013. */
  132014. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  132015. /**
  132016. * Append an anchor to a cloth object
  132017. * @param impostor is the cloth impostor to add anchor to
  132018. * @param otherImpostor is the rigid impostor to anchor to
  132019. * @param width ratio across width from 0 to 1
  132020. * @param height ratio up height from 0 to 1
  132021. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  132022. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132023. */
  132024. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132025. /**
  132026. * Append an hook to a rope object
  132027. * @param impostor is the rope impostor to add hook to
  132028. * @param otherImpostor is the rigid impostor to hook to
  132029. * @param length ratio along the rope from 0 to 1
  132030. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  132031. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  132032. */
  132033. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  132034. /**
  132035. * Sleeps the physics body and stops it from being active
  132036. * @param impostor impostor to sleep
  132037. */
  132038. sleepBody(impostor: PhysicsImpostor): void;
  132039. /**
  132040. * Activates the physics body
  132041. * @param impostor impostor to activate
  132042. */
  132043. wakeUpBody(impostor: PhysicsImpostor): void;
  132044. /**
  132045. * Updates the distance parameters of the joint
  132046. * @param joint joint to update
  132047. * @param maxDistance maximum distance of the joint
  132048. * @param minDistance minimum distance of the joint
  132049. */
  132050. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  132051. /**
  132052. * Sets a motor on the joint
  132053. * @param joint joint to set motor on
  132054. * @param speed speed of the motor
  132055. * @param maxForce maximum force of the motor
  132056. * @param motorIndex index of the motor
  132057. */
  132058. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  132059. /**
  132060. * Sets the motors limit
  132061. * @param joint joint to set limit on
  132062. * @param upperLimit upper limit
  132063. * @param lowerLimit lower limit
  132064. */
  132065. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  132066. /**
  132067. * Syncs the position and rotation of a mesh with the impostor
  132068. * @param mesh mesh to sync
  132069. * @param impostor impostor to update the mesh with
  132070. */
  132071. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  132072. /**
  132073. * Gets the radius of the impostor
  132074. * @param impostor impostor to get radius from
  132075. * @returns the radius
  132076. */
  132077. getRadius(impostor: PhysicsImpostor): number;
  132078. /**
  132079. * Gets the box size of the impostor
  132080. * @param impostor impostor to get box size from
  132081. * @param result the resulting box size
  132082. */
  132083. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  132084. /**
  132085. * Disposes of the impostor
  132086. */
  132087. dispose(): void;
  132088. /**
  132089. * Does a raycast in the physics world
  132090. * @param from when should the ray start?
  132091. * @param to when should the ray end?
  132092. * @returns PhysicsRaycastResult
  132093. */
  132094. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  132095. }
  132096. }
  132097. declare module BABYLON {
  132098. interface AbstractScene {
  132099. /**
  132100. * The list of reflection probes added to the scene
  132101. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132102. */
  132103. reflectionProbes: Array<ReflectionProbe>;
  132104. /**
  132105. * Removes the given reflection probe from this scene.
  132106. * @param toRemove The reflection probe to remove
  132107. * @returns The index of the removed reflection probe
  132108. */
  132109. removeReflectionProbe(toRemove: ReflectionProbe): number;
  132110. /**
  132111. * Adds the given reflection probe to this scene.
  132112. * @param newReflectionProbe The reflection probe to add
  132113. */
  132114. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  132115. }
  132116. /**
  132117. * Class used to generate realtime reflection / refraction cube textures
  132118. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  132119. */
  132120. export class ReflectionProbe {
  132121. /** defines the name of the probe */
  132122. name: string;
  132123. private _scene;
  132124. private _renderTargetTexture;
  132125. private _projectionMatrix;
  132126. private _viewMatrix;
  132127. private _target;
  132128. private _add;
  132129. private _attachedMesh;
  132130. private _invertYAxis;
  132131. /** Gets or sets probe position (center of the cube map) */
  132132. position: Vector3;
  132133. /**
  132134. * Creates a new reflection probe
  132135. * @param name defines the name of the probe
  132136. * @param size defines the texture resolution (for each face)
  132137. * @param scene defines the hosting scene
  132138. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  132139. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  132140. */
  132141. constructor(
  132142. /** defines the name of the probe */
  132143. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  132144. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  132145. get samples(): number;
  132146. set samples(value: number);
  132147. /** Gets or sets the refresh rate to use (on every frame by default) */
  132148. get refreshRate(): number;
  132149. set refreshRate(value: number);
  132150. /**
  132151. * Gets the hosting scene
  132152. * @returns a Scene
  132153. */
  132154. getScene(): Scene;
  132155. /** Gets the internal CubeTexture used to render to */
  132156. get cubeTexture(): RenderTargetTexture;
  132157. /** Gets the list of meshes to render */
  132158. get renderList(): Nullable<AbstractMesh[]>;
  132159. /**
  132160. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  132161. * @param mesh defines the mesh to attach to
  132162. */
  132163. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132164. /**
  132165. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  132166. * @param renderingGroupId The rendering group id corresponding to its index
  132167. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  132168. */
  132169. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  132170. /**
  132171. * Clean all associated resources
  132172. */
  132173. dispose(): void;
  132174. /**
  132175. * Converts the reflection probe information to a readable string for debug purpose.
  132176. * @param fullDetails Supports for multiple levels of logging within scene loading
  132177. * @returns the human readable reflection probe info
  132178. */
  132179. toString(fullDetails?: boolean): string;
  132180. /**
  132181. * Get the class name of the relfection probe.
  132182. * @returns "ReflectionProbe"
  132183. */
  132184. getClassName(): string;
  132185. /**
  132186. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  132187. * @returns The JSON representation of the texture
  132188. */
  132189. serialize(): any;
  132190. /**
  132191. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  132192. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  132193. * @param scene Define the scene the parsed reflection probe should be instantiated in
  132194. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  132195. * @returns The parsed reflection probe if successful
  132196. */
  132197. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  132198. }
  132199. }
  132200. declare module BABYLON {
  132201. /** @hidden */
  132202. export var _BabylonLoaderRegistered: boolean;
  132203. /**
  132204. * Helps setting up some configuration for the babylon file loader.
  132205. */
  132206. export class BabylonFileLoaderConfiguration {
  132207. /**
  132208. * The loader does not allow injecting custom physix engine into the plugins.
  132209. * Unfortunately in ES6, we need to manually inject them into the plugin.
  132210. * So you could set this variable to your engine import to make it work.
  132211. */
  132212. static LoaderInjectedPhysicsEngine: any;
  132213. }
  132214. }
  132215. declare module BABYLON {
  132216. /**
  132217. * The Physically based simple base material of BJS.
  132218. *
  132219. * This enables better naming and convention enforcements on top of the pbrMaterial.
  132220. * It is used as the base class for both the specGloss and metalRough conventions.
  132221. */
  132222. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  132223. /**
  132224. * Number of Simultaneous lights allowed on the material.
  132225. */
  132226. maxSimultaneousLights: number;
  132227. /**
  132228. * If sets to true, disables all the lights affecting the material.
  132229. */
  132230. disableLighting: boolean;
  132231. /**
  132232. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  132233. */
  132234. environmentTexture: BaseTexture;
  132235. /**
  132236. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  132237. */
  132238. invertNormalMapX: boolean;
  132239. /**
  132240. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  132241. */
  132242. invertNormalMapY: boolean;
  132243. /**
  132244. * Normal map used in the model.
  132245. */
  132246. normalTexture: BaseTexture;
  132247. /**
  132248. * Emissivie color used to self-illuminate the model.
  132249. */
  132250. emissiveColor: Color3;
  132251. /**
  132252. * Emissivie texture used to self-illuminate the model.
  132253. */
  132254. emissiveTexture: BaseTexture;
  132255. /**
  132256. * Occlusion Channel Strenght.
  132257. */
  132258. occlusionStrength: number;
  132259. /**
  132260. * Occlusion Texture of the material (adding extra occlusion effects).
  132261. */
  132262. occlusionTexture: BaseTexture;
  132263. /**
  132264. * Defines the alpha limits in alpha test mode.
  132265. */
  132266. alphaCutOff: number;
  132267. /**
  132268. * Gets the current double sided mode.
  132269. */
  132270. get doubleSided(): boolean;
  132271. /**
  132272. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132273. */
  132274. set doubleSided(value: boolean);
  132275. /**
  132276. * Stores the pre-calculated light information of a mesh in a texture.
  132277. */
  132278. lightmapTexture: BaseTexture;
  132279. /**
  132280. * If true, the light map contains occlusion information instead of lighting info.
  132281. */
  132282. useLightmapAsShadowmap: boolean;
  132283. /**
  132284. * Instantiates a new PBRMaterial instance.
  132285. *
  132286. * @param name The material name
  132287. * @param scene The scene the material will be use in.
  132288. */
  132289. constructor(name: string, scene: Scene);
  132290. getClassName(): string;
  132291. }
  132292. }
  132293. declare module BABYLON {
  132294. /**
  132295. * The PBR material of BJS following the metal roughness convention.
  132296. *
  132297. * This fits to the PBR convention in the GLTF definition:
  132298. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  132299. */
  132300. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  132301. /**
  132302. * The base color has two different interpretations depending on the value of metalness.
  132303. * When the material is a metal, the base color is the specific measured reflectance value
  132304. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  132305. * of the material.
  132306. */
  132307. baseColor: Color3;
  132308. /**
  132309. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  132310. * well as opacity information in the alpha channel.
  132311. */
  132312. baseTexture: BaseTexture;
  132313. /**
  132314. * Specifies the metallic scalar value of the material.
  132315. * Can also be used to scale the metalness values of the metallic texture.
  132316. */
  132317. metallic: number;
  132318. /**
  132319. * Specifies the roughness scalar value of the material.
  132320. * Can also be used to scale the roughness values of the metallic texture.
  132321. */
  132322. roughness: number;
  132323. /**
  132324. * Texture containing both the metallic value in the B channel and the
  132325. * roughness value in the G channel to keep better precision.
  132326. */
  132327. metallicRoughnessTexture: BaseTexture;
  132328. /**
  132329. * Instantiates a new PBRMetalRoughnessMaterial instance.
  132330. *
  132331. * @param name The material name
  132332. * @param scene The scene the material will be use in.
  132333. */
  132334. constructor(name: string, scene: Scene);
  132335. /**
  132336. * Return the currrent class name of the material.
  132337. */
  132338. getClassName(): string;
  132339. /**
  132340. * Makes a duplicate of the current material.
  132341. * @param name - name to use for the new material.
  132342. */
  132343. clone(name: string): PBRMetallicRoughnessMaterial;
  132344. /**
  132345. * Serialize the material to a parsable JSON object.
  132346. */
  132347. serialize(): any;
  132348. /**
  132349. * Parses a JSON object correponding to the serialize function.
  132350. */
  132351. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  132352. }
  132353. }
  132354. declare module BABYLON {
  132355. /**
  132356. * The PBR material of BJS following the specular glossiness convention.
  132357. *
  132358. * This fits to the PBR convention in the GLTF definition:
  132359. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  132360. */
  132361. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  132362. /**
  132363. * Specifies the diffuse color of the material.
  132364. */
  132365. diffuseColor: Color3;
  132366. /**
  132367. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  132368. * channel.
  132369. */
  132370. diffuseTexture: BaseTexture;
  132371. /**
  132372. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  132373. */
  132374. specularColor: Color3;
  132375. /**
  132376. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  132377. */
  132378. glossiness: number;
  132379. /**
  132380. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  132381. */
  132382. specularGlossinessTexture: BaseTexture;
  132383. /**
  132384. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  132385. *
  132386. * @param name The material name
  132387. * @param scene The scene the material will be use in.
  132388. */
  132389. constructor(name: string, scene: Scene);
  132390. /**
  132391. * Return the currrent class name of the material.
  132392. */
  132393. getClassName(): string;
  132394. /**
  132395. * Makes a duplicate of the current material.
  132396. * @param name - name to use for the new material.
  132397. */
  132398. clone(name: string): PBRSpecularGlossinessMaterial;
  132399. /**
  132400. * Serialize the material to a parsable JSON object.
  132401. */
  132402. serialize(): any;
  132403. /**
  132404. * Parses a JSON object correponding to the serialize function.
  132405. */
  132406. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  132407. }
  132408. }
  132409. declare module BABYLON {
  132410. /**
  132411. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  132412. * It can help converting any input color in a desired output one. This can then be used to create effects
  132413. * from sepia, black and white to sixties or futuristic rendering...
  132414. *
  132415. * The only supported format is currently 3dl.
  132416. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  132417. */
  132418. export class ColorGradingTexture extends BaseTexture {
  132419. /**
  132420. * The texture URL.
  132421. */
  132422. url: string;
  132423. /**
  132424. * Empty line regex stored for GC.
  132425. */
  132426. private static _noneEmptyLineRegex;
  132427. private _textureMatrix;
  132428. private _engine;
  132429. private _onLoad;
  132430. /**
  132431. * Instantiates a ColorGradingTexture from the following parameters.
  132432. *
  132433. * @param url The location of the color gradind data (currently only supporting 3dl)
  132434. * @param sceneOrEngine The scene or engine the texture will be used in
  132435. * @param onLoad defines a callback triggered when the texture has been loaded
  132436. */
  132437. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  132438. /**
  132439. * Fires the onload event from the constructor if requested.
  132440. */
  132441. private _triggerOnLoad;
  132442. /**
  132443. * Returns the texture matrix used in most of the material.
  132444. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  132445. */
  132446. getTextureMatrix(): Matrix;
  132447. /**
  132448. * Occurs when the file being loaded is a .3dl LUT file.
  132449. */
  132450. private load3dlTexture;
  132451. /**
  132452. * Starts the loading process of the texture.
  132453. */
  132454. private loadTexture;
  132455. /**
  132456. * Clones the color gradind texture.
  132457. */
  132458. clone(): ColorGradingTexture;
  132459. /**
  132460. * Called during delayed load for textures.
  132461. */
  132462. delayLoad(): void;
  132463. /**
  132464. * Parses a color grading texture serialized by Babylon.
  132465. * @param parsedTexture The texture information being parsedTexture
  132466. * @param scene The scene to load the texture in
  132467. * @param rootUrl The root url of the data assets to load
  132468. * @return A color gradind texture
  132469. */
  132470. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  132471. /**
  132472. * Serializes the LUT texture to json format.
  132473. */
  132474. serialize(): any;
  132475. /**
  132476. * Returns true if the passed parameter is a scene object (can be use for typings)
  132477. * @param sceneOrEngine The object to test.
  132478. */
  132479. private static _isScene;
  132480. }
  132481. }
  132482. declare module BABYLON {
  132483. /**
  132484. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  132485. */
  132486. export class EquiRectangularCubeTexture extends BaseTexture {
  132487. /** The six faces of the cube. */
  132488. private static _FacesMapping;
  132489. private _noMipmap;
  132490. private _onLoad;
  132491. private _onError;
  132492. /** The size of the cubemap. */
  132493. private _size;
  132494. /** The buffer of the image. */
  132495. private _buffer;
  132496. /** The width of the input image. */
  132497. private _width;
  132498. /** The height of the input image. */
  132499. private _height;
  132500. /** The URL to the image. */
  132501. url: string;
  132502. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  132503. coordinatesMode: number;
  132504. /**
  132505. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  132506. * @param url The location of the image
  132507. * @param scene The scene the texture will be used in
  132508. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  132509. * @param noMipmap Forces to not generate the mipmap if true
  132510. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132511. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132512. * @param onLoad — defines a callback called when texture is loaded
  132513. * @param onError — defines a callback called if there is an error
  132514. */
  132515. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  132516. /**
  132517. * Load the image data, by putting the image on a canvas and extracting its buffer.
  132518. */
  132519. private loadImage;
  132520. /**
  132521. * Convert the image buffer into a cubemap and create a CubeTexture.
  132522. */
  132523. private loadTexture;
  132524. /**
  132525. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  132526. * @param buffer The ArrayBuffer that should be converted.
  132527. * @returns The buffer as Float32Array.
  132528. */
  132529. private getFloat32ArrayFromArrayBuffer;
  132530. /**
  132531. * Get the current class name of the texture useful for serialization or dynamic coding.
  132532. * @returns "EquiRectangularCubeTexture"
  132533. */
  132534. getClassName(): string;
  132535. /**
  132536. * Create a clone of the current EquiRectangularCubeTexture and return it.
  132537. * @returns A clone of the current EquiRectangularCubeTexture.
  132538. */
  132539. clone(): EquiRectangularCubeTexture;
  132540. }
  132541. }
  132542. declare module BABYLON {
  132543. /**
  132544. * Based on jsTGALoader - Javascript loader for TGA file
  132545. * By Vincent Thibault
  132546. * @see http://blog.robrowser.com/javascript-tga-loader.html
  132547. */
  132548. export class TGATools {
  132549. private static _TYPE_INDEXED;
  132550. private static _TYPE_RGB;
  132551. private static _TYPE_GREY;
  132552. private static _TYPE_RLE_INDEXED;
  132553. private static _TYPE_RLE_RGB;
  132554. private static _TYPE_RLE_GREY;
  132555. private static _ORIGIN_MASK;
  132556. private static _ORIGIN_SHIFT;
  132557. private static _ORIGIN_BL;
  132558. private static _ORIGIN_BR;
  132559. private static _ORIGIN_UL;
  132560. private static _ORIGIN_UR;
  132561. /**
  132562. * Gets the header of a TGA file
  132563. * @param data defines the TGA data
  132564. * @returns the header
  132565. */
  132566. static GetTGAHeader(data: Uint8Array): any;
  132567. /**
  132568. * Uploads TGA content to a Babylon Texture
  132569. * @hidden
  132570. */
  132571. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  132572. /** @hidden */
  132573. 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;
  132574. /** @hidden */
  132575. 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;
  132576. /** @hidden */
  132577. 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;
  132578. /** @hidden */
  132579. 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;
  132580. /** @hidden */
  132581. 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;
  132582. /** @hidden */
  132583. 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;
  132584. }
  132585. }
  132586. declare module BABYLON {
  132587. /**
  132588. * Implementation of the TGA Texture Loader.
  132589. * @hidden
  132590. */
  132591. export class _TGATextureLoader implements IInternalTextureLoader {
  132592. /**
  132593. * Defines wether the loader supports cascade loading the different faces.
  132594. */
  132595. readonly supportCascades: boolean;
  132596. /**
  132597. * This returns if the loader support the current file information.
  132598. * @param extension defines the file extension of the file being loaded
  132599. * @returns true if the loader can load the specified file
  132600. */
  132601. canLoad(extension: string): boolean;
  132602. /**
  132603. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132604. * @param data contains the texture data
  132605. * @param texture defines the BabylonJS internal texture
  132606. * @param createPolynomials will be true if polynomials have been requested
  132607. * @param onLoad defines the callback to trigger once the texture is ready
  132608. * @param onError defines the callback to trigger in case of error
  132609. */
  132610. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132611. /**
  132612. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132613. * @param data contains the texture data
  132614. * @param texture defines the BabylonJS internal texture
  132615. * @param callback defines the method to call once ready to upload
  132616. */
  132617. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132618. }
  132619. }
  132620. declare module BABYLON {
  132621. /**
  132622. * Info about the .basis files
  132623. */
  132624. class BasisFileInfo {
  132625. /**
  132626. * If the file has alpha
  132627. */
  132628. hasAlpha: boolean;
  132629. /**
  132630. * Info about each image of the basis file
  132631. */
  132632. images: Array<{
  132633. levels: Array<{
  132634. width: number;
  132635. height: number;
  132636. transcodedPixels: ArrayBufferView;
  132637. }>;
  132638. }>;
  132639. }
  132640. /**
  132641. * Result of transcoding a basis file
  132642. */
  132643. class TranscodeResult {
  132644. /**
  132645. * Info about the .basis file
  132646. */
  132647. fileInfo: BasisFileInfo;
  132648. /**
  132649. * Format to use when loading the file
  132650. */
  132651. format: number;
  132652. }
  132653. /**
  132654. * Configuration options for the Basis transcoder
  132655. */
  132656. export class BasisTranscodeConfiguration {
  132657. /**
  132658. * Supported compression formats used to determine the supported output format of the transcoder
  132659. */
  132660. supportedCompressionFormats?: {
  132661. /**
  132662. * etc1 compression format
  132663. */
  132664. etc1?: boolean;
  132665. /**
  132666. * s3tc compression format
  132667. */
  132668. s3tc?: boolean;
  132669. /**
  132670. * pvrtc compression format
  132671. */
  132672. pvrtc?: boolean;
  132673. /**
  132674. * etc2 compression format
  132675. */
  132676. etc2?: boolean;
  132677. };
  132678. /**
  132679. * If mipmap levels should be loaded for transcoded images (Default: true)
  132680. */
  132681. loadMipmapLevels?: boolean;
  132682. /**
  132683. * Index of a single image to load (Default: all images)
  132684. */
  132685. loadSingleImage?: number;
  132686. }
  132687. /**
  132688. * Used to load .Basis files
  132689. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  132690. */
  132691. export class BasisTools {
  132692. private static _IgnoreSupportedFormats;
  132693. /**
  132694. * URL to use when loading the basis transcoder
  132695. */
  132696. static JSModuleURL: string;
  132697. /**
  132698. * URL to use when loading the wasm module for the transcoder
  132699. */
  132700. static WasmModuleURL: string;
  132701. /**
  132702. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  132703. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  132704. * @returns internal format corresponding to the Basis format
  132705. */
  132706. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  132707. private static _WorkerPromise;
  132708. private static _Worker;
  132709. private static _actionId;
  132710. private static _CreateWorkerAsync;
  132711. /**
  132712. * Transcodes a loaded image file to compressed pixel data
  132713. * @param data image data to transcode
  132714. * @param config configuration options for the transcoding
  132715. * @returns a promise resulting in the transcoded image
  132716. */
  132717. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  132718. /**
  132719. * Loads a texture from the transcode result
  132720. * @param texture texture load to
  132721. * @param transcodeResult the result of transcoding the basis file to load from
  132722. */
  132723. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  132724. }
  132725. }
  132726. declare module BABYLON {
  132727. /**
  132728. * Loader for .basis file format
  132729. */
  132730. export class _BasisTextureLoader implements IInternalTextureLoader {
  132731. /**
  132732. * Defines whether the loader supports cascade loading the different faces.
  132733. */
  132734. readonly supportCascades: boolean;
  132735. /**
  132736. * This returns if the loader support the current file information.
  132737. * @param extension defines the file extension of the file being loaded
  132738. * @returns true if the loader can load the specified file
  132739. */
  132740. canLoad(extension: string): boolean;
  132741. /**
  132742. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  132743. * @param data contains the texture data
  132744. * @param texture defines the BabylonJS internal texture
  132745. * @param createPolynomials will be true if polynomials have been requested
  132746. * @param onLoad defines the callback to trigger once the texture is ready
  132747. * @param onError defines the callback to trigger in case of error
  132748. */
  132749. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  132750. /**
  132751. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  132752. * @param data contains the texture data
  132753. * @param texture defines the BabylonJS internal texture
  132754. * @param callback defines the method to call once ready to upload
  132755. */
  132756. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  132757. }
  132758. }
  132759. declare module BABYLON {
  132760. /**
  132761. * 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.
  132762. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  132763. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  132764. */
  132765. export class CustomProceduralTexture extends ProceduralTexture {
  132766. private _animate;
  132767. private _time;
  132768. private _config;
  132769. private _texturePath;
  132770. /**
  132771. * Instantiates a new Custom Procedural Texture.
  132772. * 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.
  132773. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  132774. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  132775. * @param name Define the name of the texture
  132776. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  132777. * @param size Define the size of the texture to create
  132778. * @param scene Define the scene the texture belongs to
  132779. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  132780. * @param generateMipMaps Define if the texture should creates mip maps or not
  132781. */
  132782. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  132783. private _loadJson;
  132784. /**
  132785. * Is the texture ready to be used ? (rendered at least once)
  132786. * @returns true if ready, otherwise, false.
  132787. */
  132788. isReady(): boolean;
  132789. /**
  132790. * Render the texture to its associated render target.
  132791. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  132792. */
  132793. render(useCameraPostProcess?: boolean): void;
  132794. /**
  132795. * Update the list of dependant textures samplers in the shader.
  132796. */
  132797. updateTextures(): void;
  132798. /**
  132799. * Update the uniform values of the procedural texture in the shader.
  132800. */
  132801. updateShaderUniforms(): void;
  132802. /**
  132803. * Define if the texture animates or not.
  132804. */
  132805. get animate(): boolean;
  132806. set animate(value: boolean);
  132807. }
  132808. }
  132809. declare module BABYLON {
  132810. /** @hidden */
  132811. export var noisePixelShader: {
  132812. name: string;
  132813. shader: string;
  132814. };
  132815. }
  132816. declare module BABYLON {
  132817. /**
  132818. * Class used to generate noise procedural textures
  132819. */
  132820. export class NoiseProceduralTexture extends ProceduralTexture {
  132821. private _time;
  132822. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  132823. brightness: number;
  132824. /** Defines the number of octaves to process */
  132825. octaves: number;
  132826. /** Defines the level of persistence (0.8 by default) */
  132827. persistence: number;
  132828. /** Gets or sets animation speed factor (default is 1) */
  132829. animationSpeedFactor: number;
  132830. /**
  132831. * Creates a new NoiseProceduralTexture
  132832. * @param name defines the name fo the texture
  132833. * @param size defines the size of the texture (default is 256)
  132834. * @param scene defines the hosting scene
  132835. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  132836. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  132837. */
  132838. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  132839. private _updateShaderUniforms;
  132840. protected _getDefines(): string;
  132841. /** Generate the current state of the procedural texture */
  132842. render(useCameraPostProcess?: boolean): void;
  132843. /**
  132844. * Serializes this noise procedural texture
  132845. * @returns a serialized noise procedural texture object
  132846. */
  132847. serialize(): any;
  132848. /**
  132849. * Clone the texture.
  132850. * @returns the cloned texture
  132851. */
  132852. clone(): NoiseProceduralTexture;
  132853. /**
  132854. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  132855. * @param parsedTexture defines parsed texture data
  132856. * @param scene defines the current scene
  132857. * @param rootUrl defines the root URL containing noise procedural texture information
  132858. * @returns a parsed NoiseProceduralTexture
  132859. */
  132860. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  132861. }
  132862. }
  132863. declare module BABYLON {
  132864. /**
  132865. * Raw cube texture where the raw buffers are passed in
  132866. */
  132867. export class RawCubeTexture extends CubeTexture {
  132868. /**
  132869. * Creates a cube texture where the raw buffers are passed in.
  132870. * @param scene defines the scene the texture is attached to
  132871. * @param data defines the array of data to use to create each face
  132872. * @param size defines the size of the textures
  132873. * @param format defines the format of the data
  132874. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  132875. * @param generateMipMaps defines if the engine should generate the mip levels
  132876. * @param invertY defines if data must be stored with Y axis inverted
  132877. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  132878. * @param compression defines the compression used (null by default)
  132879. */
  132880. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  132881. /**
  132882. * Updates the raw cube texture.
  132883. * @param data defines the data to store
  132884. * @param format defines the data format
  132885. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  132886. * @param invertY defines if data must be stored with Y axis inverted
  132887. * @param compression defines the compression used (null by default)
  132888. * @param level defines which level of the texture to update
  132889. */
  132890. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  132891. /**
  132892. * Updates a raw cube texture with RGBD encoded data.
  132893. * @param data defines the array of data [mipmap][face] to use to create each face
  132894. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  132895. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132896. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132897. * @returns a promsie that resolves when the operation is complete
  132898. */
  132899. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  132900. /**
  132901. * Clones the raw cube texture.
  132902. * @return a new cube texture
  132903. */
  132904. clone(): CubeTexture;
  132905. /** @hidden */
  132906. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132907. }
  132908. }
  132909. declare module BABYLON {
  132910. /**
  132911. * Class used to store 3D textures containing user data
  132912. */
  132913. export class RawTexture3D extends Texture {
  132914. /** Gets or sets the texture format to use */
  132915. format: number;
  132916. private _engine;
  132917. /**
  132918. * Create a new RawTexture3D
  132919. * @param data defines the data of the texture
  132920. * @param width defines the width of the texture
  132921. * @param height defines the height of the texture
  132922. * @param depth defines the depth of the texture
  132923. * @param format defines the texture format to use
  132924. * @param scene defines the hosting scene
  132925. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  132926. * @param invertY defines if texture must be stored with Y axis inverted
  132927. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132928. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  132929. */
  132930. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  132931. /** Gets or sets the texture format to use */
  132932. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  132933. /**
  132934. * Update the texture with new data
  132935. * @param data defines the data to store in the texture
  132936. */
  132937. update(data: ArrayBufferView): void;
  132938. }
  132939. }
  132940. declare module BABYLON {
  132941. /**
  132942. * Class used to store 2D array textures containing user data
  132943. */
  132944. export class RawTexture2DArray extends Texture {
  132945. /** Gets or sets the texture format to use */
  132946. format: number;
  132947. private _engine;
  132948. /**
  132949. * Create a new RawTexture2DArray
  132950. * @param data defines the data of the texture
  132951. * @param width defines the width of the texture
  132952. * @param height defines the height of the texture
  132953. * @param depth defines the number of layers of the texture
  132954. * @param format defines the texture format to use
  132955. * @param scene defines the hosting scene
  132956. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  132957. * @param invertY defines if texture must be stored with Y axis inverted
  132958. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132959. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  132960. */
  132961. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  132962. /** Gets or sets the texture format to use */
  132963. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  132964. /**
  132965. * Update the texture with new data
  132966. * @param data defines the data to store in the texture
  132967. */
  132968. update(data: ArrayBufferView): void;
  132969. }
  132970. }
  132971. declare module BABYLON {
  132972. /**
  132973. * Creates a refraction texture used by refraction channel of the standard material.
  132974. * It is like a mirror but to see through a material.
  132975. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  132976. */
  132977. export class RefractionTexture extends RenderTargetTexture {
  132978. /**
  132979. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  132980. * 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.
  132981. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  132982. */
  132983. refractionPlane: Plane;
  132984. /**
  132985. * Define how deep under the surface we should see.
  132986. */
  132987. depth: number;
  132988. /**
  132989. * Creates a refraction texture used by refraction channel of the standard material.
  132990. * It is like a mirror but to see through a material.
  132991. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  132992. * @param name Define the texture name
  132993. * @param size Define the size of the underlying texture
  132994. * @param scene Define the scene the refraction belongs to
  132995. * @param generateMipMaps Define if we need to generate mips level for the refraction
  132996. */
  132997. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  132998. /**
  132999. * Clone the refraction texture.
  133000. * @returns the cloned texture
  133001. */
  133002. clone(): RefractionTexture;
  133003. /**
  133004. * Serialize the texture to a JSON representation you could use in Parse later on
  133005. * @returns the serialized JSON representation
  133006. */
  133007. serialize(): any;
  133008. }
  133009. }
  133010. declare module BABYLON {
  133011. /**
  133012. * Defines the options related to the creation of an HtmlElementTexture
  133013. */
  133014. export interface IHtmlElementTextureOptions {
  133015. /**
  133016. * Defines wether mip maps should be created or not.
  133017. */
  133018. generateMipMaps?: boolean;
  133019. /**
  133020. * Defines the sampling mode of the texture.
  133021. */
  133022. samplingMode?: number;
  133023. /**
  133024. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  133025. */
  133026. engine: Nullable<ThinEngine>;
  133027. /**
  133028. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  133029. */
  133030. scene: Nullable<Scene>;
  133031. }
  133032. /**
  133033. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  133034. * To be as efficient as possible depending on your constraints nothing aside the first upload
  133035. * is automatically managed.
  133036. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  133037. * in your application.
  133038. *
  133039. * As the update is not automatic, you need to call them manually.
  133040. */
  133041. export class HtmlElementTexture extends BaseTexture {
  133042. /**
  133043. * The texture URL.
  133044. */
  133045. element: HTMLVideoElement | HTMLCanvasElement;
  133046. private static readonly DefaultOptions;
  133047. private _textureMatrix;
  133048. private _engine;
  133049. private _isVideo;
  133050. private _generateMipMaps;
  133051. private _samplingMode;
  133052. /**
  133053. * Instantiates a HtmlElementTexture from the following parameters.
  133054. *
  133055. * @param name Defines the name of the texture
  133056. * @param element Defines the video or canvas the texture is filled with
  133057. * @param options Defines the other none mandatory texture creation options
  133058. */
  133059. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  133060. private _createInternalTexture;
  133061. /**
  133062. * Returns the texture matrix used in most of the material.
  133063. */
  133064. getTextureMatrix(): Matrix;
  133065. /**
  133066. * Updates the content of the texture.
  133067. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  133068. */
  133069. update(invertY?: Nullable<boolean>): void;
  133070. }
  133071. }
  133072. declare module BABYLON {
  133073. /**
  133074. * Defines the basic options interface of a TexturePacker Frame
  133075. */
  133076. export interface ITexturePackerFrame {
  133077. /**
  133078. * The frame ID
  133079. */
  133080. id: number;
  133081. /**
  133082. * The frames Scale
  133083. */
  133084. scale: Vector2;
  133085. /**
  133086. * The Frames offset
  133087. */
  133088. offset: Vector2;
  133089. }
  133090. /**
  133091. * This is a support class for frame Data on texture packer sets.
  133092. */
  133093. export class TexturePackerFrame implements ITexturePackerFrame {
  133094. /**
  133095. * The frame ID
  133096. */
  133097. id: number;
  133098. /**
  133099. * The frames Scale
  133100. */
  133101. scale: Vector2;
  133102. /**
  133103. * The Frames offset
  133104. */
  133105. offset: Vector2;
  133106. /**
  133107. * Initializes a texture package frame.
  133108. * @param id The numerical frame identifier
  133109. * @param scale Scalar Vector2 for UV frame
  133110. * @param offset Vector2 for the frame position in UV units.
  133111. * @returns TexturePackerFrame
  133112. */
  133113. constructor(id: number, scale: Vector2, offset: Vector2);
  133114. }
  133115. }
  133116. declare module BABYLON {
  133117. /**
  133118. * Defines the basic options interface of a TexturePacker
  133119. */
  133120. export interface ITexturePackerOptions {
  133121. /**
  133122. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  133123. */
  133124. map?: string[];
  133125. /**
  133126. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133127. */
  133128. uvsIn?: string;
  133129. /**
  133130. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  133131. */
  133132. uvsOut?: string;
  133133. /**
  133134. * number representing the layout style. Defaults to LAYOUT_STRIP
  133135. */
  133136. layout?: number;
  133137. /**
  133138. * number of columns if using custom column count layout(2). This defaults to 4.
  133139. */
  133140. colnum?: number;
  133141. /**
  133142. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  133143. */
  133144. updateInputMeshes?: boolean;
  133145. /**
  133146. * boolean flag to dispose all the source textures. Defaults to true.
  133147. */
  133148. disposeSources?: boolean;
  133149. /**
  133150. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  133151. */
  133152. fillBlanks?: boolean;
  133153. /**
  133154. * string value representing the context fill style color. Defaults to 'black'.
  133155. */
  133156. customFillColor?: string;
  133157. /**
  133158. * Width and Height Value of each Frame in the TexturePacker Sets
  133159. */
  133160. frameSize?: number;
  133161. /**
  133162. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  133163. */
  133164. paddingRatio?: number;
  133165. /**
  133166. * Number that declares the fill method for the padding gutter.
  133167. */
  133168. paddingMode?: number;
  133169. /**
  133170. * If in SUBUV_COLOR padding mode what color to use.
  133171. */
  133172. paddingColor?: Color3 | Color4;
  133173. }
  133174. /**
  133175. * Defines the basic interface of a TexturePacker JSON File
  133176. */
  133177. export interface ITexturePackerJSON {
  133178. /**
  133179. * The frame ID
  133180. */
  133181. name: string;
  133182. /**
  133183. * The base64 channel data
  133184. */
  133185. sets: any;
  133186. /**
  133187. * The options of the Packer
  133188. */
  133189. options: ITexturePackerOptions;
  133190. /**
  133191. * The frame data of the Packer
  133192. */
  133193. frames: Array<number>;
  133194. }
  133195. /**
  133196. * This is a support class that generates a series of packed texture sets.
  133197. * @see https://doc.babylonjs.com/babylon101/materials
  133198. */
  133199. export class TexturePacker {
  133200. /** Packer Layout Constant 0 */
  133201. static readonly LAYOUT_STRIP: number;
  133202. /** Packer Layout Constant 1 */
  133203. static readonly LAYOUT_POWER2: number;
  133204. /** Packer Layout Constant 2 */
  133205. static readonly LAYOUT_COLNUM: number;
  133206. /** Packer Layout Constant 0 */
  133207. static readonly SUBUV_WRAP: number;
  133208. /** Packer Layout Constant 1 */
  133209. static readonly SUBUV_EXTEND: number;
  133210. /** Packer Layout Constant 2 */
  133211. static readonly SUBUV_COLOR: number;
  133212. /** The Name of the Texture Package */
  133213. name: string;
  133214. /** The scene scope of the TexturePacker */
  133215. scene: Scene;
  133216. /** The Meshes to target */
  133217. meshes: AbstractMesh[];
  133218. /** Arguments passed with the Constructor */
  133219. options: ITexturePackerOptions;
  133220. /** The promise that is started upon initialization */
  133221. promise: Nullable<Promise<TexturePacker | string>>;
  133222. /** The Container object for the channel sets that are generated */
  133223. sets: object;
  133224. /** The Container array for the frames that are generated */
  133225. frames: TexturePackerFrame[];
  133226. /** The expected number of textures the system is parsing. */
  133227. private _expecting;
  133228. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  133229. private _paddingValue;
  133230. /**
  133231. * Initializes a texture package series from an array of meshes or a single mesh.
  133232. * @param name The name of the package
  133233. * @param meshes The target meshes to compose the package from
  133234. * @param options The arguments that texture packer should follow while building.
  133235. * @param scene The scene which the textures are scoped to.
  133236. * @returns TexturePacker
  133237. */
  133238. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  133239. /**
  133240. * Starts the package process
  133241. * @param resolve The promises resolution function
  133242. * @returns TexturePacker
  133243. */
  133244. private _createFrames;
  133245. /**
  133246. * Calculates the Size of the Channel Sets
  133247. * @returns Vector2
  133248. */
  133249. private _calculateSize;
  133250. /**
  133251. * Calculates the UV data for the frames.
  133252. * @param baseSize the base frameSize
  133253. * @param padding the base frame padding
  133254. * @param dtSize size of the Dynamic Texture for that channel
  133255. * @param dtUnits is 1/dtSize
  133256. * @param update flag to update the input meshes
  133257. */
  133258. private _calculateMeshUVFrames;
  133259. /**
  133260. * Calculates the frames Offset.
  133261. * @param index of the frame
  133262. * @returns Vector2
  133263. */
  133264. private _getFrameOffset;
  133265. /**
  133266. * Updates a Mesh to the frame data
  133267. * @param mesh that is the target
  133268. * @param frameID or the frame index
  133269. */
  133270. private _updateMeshUV;
  133271. /**
  133272. * Updates a Meshes materials to use the texture packer channels
  133273. * @param m is the mesh to target
  133274. * @param force all channels on the packer to be set.
  133275. */
  133276. private _updateTextureReferences;
  133277. /**
  133278. * Public method to set a Mesh to a frame
  133279. * @param m that is the target
  133280. * @param frameID or the frame index
  133281. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  133282. */
  133283. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  133284. /**
  133285. * Starts the async promise to compile the texture packer.
  133286. * @returns Promise<void>
  133287. */
  133288. processAsync(): Promise<void>;
  133289. /**
  133290. * Disposes all textures associated with this packer
  133291. */
  133292. dispose(): void;
  133293. /**
  133294. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  133295. * @param imageType is the image type to use.
  133296. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  133297. */
  133298. download(imageType?: string, quality?: number): void;
  133299. /**
  133300. * Public method to load a texturePacker JSON file.
  133301. * @param data of the JSON file in string format.
  133302. */
  133303. updateFromJSON(data: string): void;
  133304. }
  133305. }
  133306. declare module BABYLON {
  133307. /**
  133308. * Enum used to define the target of a block
  133309. */
  133310. export enum NodeMaterialBlockTargets {
  133311. /** Vertex shader */
  133312. Vertex = 1,
  133313. /** Fragment shader */
  133314. Fragment = 2,
  133315. /** Neutral */
  133316. Neutral = 4,
  133317. /** Vertex and Fragment */
  133318. VertexAndFragment = 3
  133319. }
  133320. }
  133321. declare module BABYLON {
  133322. /**
  133323. * Defines the kind of connection point for node based material
  133324. */
  133325. export enum NodeMaterialBlockConnectionPointTypes {
  133326. /** Float */
  133327. Float = 1,
  133328. /** Int */
  133329. Int = 2,
  133330. /** Vector2 */
  133331. Vector2 = 4,
  133332. /** Vector3 */
  133333. Vector3 = 8,
  133334. /** Vector4 */
  133335. Vector4 = 16,
  133336. /** Color3 */
  133337. Color3 = 32,
  133338. /** Color4 */
  133339. Color4 = 64,
  133340. /** Matrix */
  133341. Matrix = 128,
  133342. /** Custom object */
  133343. Object = 256,
  133344. /** Detect type based on connection */
  133345. AutoDetect = 1024,
  133346. /** Output type that will be defined by input type */
  133347. BasedOnInput = 2048
  133348. }
  133349. }
  133350. declare module BABYLON {
  133351. /**
  133352. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  133353. */
  133354. export enum NodeMaterialBlockConnectionPointMode {
  133355. /** Value is an uniform */
  133356. Uniform = 0,
  133357. /** Value is a mesh attribute */
  133358. Attribute = 1,
  133359. /** Value is a varying between vertex and fragment shaders */
  133360. Varying = 2,
  133361. /** Mode is undefined */
  133362. Undefined = 3
  133363. }
  133364. }
  133365. declare module BABYLON {
  133366. /**
  133367. * Enum used to define system values e.g. values automatically provided by the system
  133368. */
  133369. export enum NodeMaterialSystemValues {
  133370. /** World */
  133371. World = 1,
  133372. /** View */
  133373. View = 2,
  133374. /** Projection */
  133375. Projection = 3,
  133376. /** ViewProjection */
  133377. ViewProjection = 4,
  133378. /** WorldView */
  133379. WorldView = 5,
  133380. /** WorldViewProjection */
  133381. WorldViewProjection = 6,
  133382. /** CameraPosition */
  133383. CameraPosition = 7,
  133384. /** Fog Color */
  133385. FogColor = 8,
  133386. /** Delta time */
  133387. DeltaTime = 9
  133388. }
  133389. }
  133390. declare module BABYLON {
  133391. /**
  133392. * Root class for all node material optimizers
  133393. */
  133394. export class NodeMaterialOptimizer {
  133395. /**
  133396. * Function used to optimize a NodeMaterial graph
  133397. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  133398. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  133399. */
  133400. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  133401. }
  133402. }
  133403. declare module BABYLON {
  133404. /**
  133405. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  133406. */
  133407. export class TransformBlock extends NodeMaterialBlock {
  133408. /**
  133409. * Defines the value to use to complement W value to transform it to a Vector4
  133410. */
  133411. complementW: number;
  133412. /**
  133413. * Defines the value to use to complement z value to transform it to a Vector4
  133414. */
  133415. complementZ: number;
  133416. /**
  133417. * Creates a new TransformBlock
  133418. * @param name defines the block name
  133419. */
  133420. constructor(name: string);
  133421. /**
  133422. * Gets the current class name
  133423. * @returns the class name
  133424. */
  133425. getClassName(): string;
  133426. /**
  133427. * Gets the vector input
  133428. */
  133429. get vector(): NodeMaterialConnectionPoint;
  133430. /**
  133431. * Gets the output component
  133432. */
  133433. get output(): NodeMaterialConnectionPoint;
  133434. /**
  133435. * Gets the xyz output component
  133436. */
  133437. get xyz(): NodeMaterialConnectionPoint;
  133438. /**
  133439. * Gets the matrix transform input
  133440. */
  133441. get transform(): NodeMaterialConnectionPoint;
  133442. protected _buildBlock(state: NodeMaterialBuildState): this;
  133443. serialize(): any;
  133444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133445. protected _dumpPropertiesCode(): string;
  133446. }
  133447. }
  133448. declare module BABYLON {
  133449. /**
  133450. * Block used to output the vertex position
  133451. */
  133452. export class VertexOutputBlock extends NodeMaterialBlock {
  133453. /**
  133454. * Creates a new VertexOutputBlock
  133455. * @param name defines the block name
  133456. */
  133457. constructor(name: string);
  133458. /**
  133459. * Gets the current class name
  133460. * @returns the class name
  133461. */
  133462. getClassName(): string;
  133463. /**
  133464. * Gets the vector input component
  133465. */
  133466. get vector(): NodeMaterialConnectionPoint;
  133467. protected _buildBlock(state: NodeMaterialBuildState): this;
  133468. }
  133469. }
  133470. declare module BABYLON {
  133471. /**
  133472. * Block used to output the final color
  133473. */
  133474. export class FragmentOutputBlock extends NodeMaterialBlock {
  133475. /**
  133476. * Create a new FragmentOutputBlock
  133477. * @param name defines the block name
  133478. */
  133479. constructor(name: string);
  133480. /**
  133481. * Gets the current class name
  133482. * @returns the class name
  133483. */
  133484. getClassName(): string;
  133485. /**
  133486. * Gets the rgba input component
  133487. */
  133488. get rgba(): NodeMaterialConnectionPoint;
  133489. /**
  133490. * Gets the rgb input component
  133491. */
  133492. get rgb(): NodeMaterialConnectionPoint;
  133493. /**
  133494. * Gets the a input component
  133495. */
  133496. get a(): NodeMaterialConnectionPoint;
  133497. protected _buildBlock(state: NodeMaterialBuildState): this;
  133498. }
  133499. }
  133500. declare module BABYLON {
  133501. /**
  133502. * Base block used to read a reflection texture from a sampler
  133503. */
  133504. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  133505. /** @hidden */
  133506. _define3DName: string;
  133507. /** @hidden */
  133508. _defineCubicName: string;
  133509. /** @hidden */
  133510. _defineExplicitName: string;
  133511. /** @hidden */
  133512. _defineProjectionName: string;
  133513. /** @hidden */
  133514. _defineLocalCubicName: string;
  133515. /** @hidden */
  133516. _defineSphericalName: string;
  133517. /** @hidden */
  133518. _definePlanarName: string;
  133519. /** @hidden */
  133520. _defineEquirectangularName: string;
  133521. /** @hidden */
  133522. _defineMirroredEquirectangularFixedName: string;
  133523. /** @hidden */
  133524. _defineEquirectangularFixedName: string;
  133525. /** @hidden */
  133526. _defineSkyboxName: string;
  133527. /** @hidden */
  133528. _defineOppositeZ: string;
  133529. /** @hidden */
  133530. _cubeSamplerName: string;
  133531. /** @hidden */
  133532. _2DSamplerName: string;
  133533. protected _positionUVWName: string;
  133534. protected _directionWName: string;
  133535. protected _reflectionVectorName: string;
  133536. /** @hidden */
  133537. _reflectionCoordsName: string;
  133538. /** @hidden */
  133539. _reflectionMatrixName: string;
  133540. protected _reflectionColorName: string;
  133541. /**
  133542. * Gets or sets the texture associated with the node
  133543. */
  133544. texture: Nullable<BaseTexture>;
  133545. /**
  133546. * Create a new ReflectionTextureBaseBlock
  133547. * @param name defines the block name
  133548. */
  133549. constructor(name: string);
  133550. /**
  133551. * Gets the current class name
  133552. * @returns the class name
  133553. */
  133554. getClassName(): string;
  133555. /**
  133556. * Gets the world position input component
  133557. */
  133558. abstract get position(): NodeMaterialConnectionPoint;
  133559. /**
  133560. * Gets the world position input component
  133561. */
  133562. abstract get worldPosition(): NodeMaterialConnectionPoint;
  133563. /**
  133564. * Gets the world normal input component
  133565. */
  133566. abstract get worldNormal(): NodeMaterialConnectionPoint;
  133567. /**
  133568. * Gets the world input component
  133569. */
  133570. abstract get world(): NodeMaterialConnectionPoint;
  133571. /**
  133572. * Gets the camera (or eye) position component
  133573. */
  133574. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  133575. /**
  133576. * Gets the view input component
  133577. */
  133578. abstract get view(): NodeMaterialConnectionPoint;
  133579. protected _getTexture(): Nullable<BaseTexture>;
  133580. autoConfigure(material: NodeMaterial): void;
  133581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133582. isReady(): boolean;
  133583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133584. /**
  133585. * Gets the code to inject in the vertex shader
  133586. * @param state current state of the node material building
  133587. * @returns the shader code
  133588. */
  133589. handleVertexSide(state: NodeMaterialBuildState): string;
  133590. /**
  133591. * Handles the inits for the fragment code path
  133592. * @param state node material build state
  133593. */
  133594. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  133595. /**
  133596. * Generates the reflection coords code for the fragment code path
  133597. * @param worldNormalVarName name of the world normal variable
  133598. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  133599. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  133600. * @returns the shader code
  133601. */
  133602. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  133603. /**
  133604. * Generates the reflection color code for the fragment code path
  133605. * @param lodVarName name of the lod variable
  133606. * @param swizzleLookupTexture swizzle to use for the final color variable
  133607. * @returns the shader code
  133608. */
  133609. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  133610. /**
  133611. * Generates the code corresponding to the connected output points
  133612. * @param state node material build state
  133613. * @param varName name of the variable to output
  133614. * @returns the shader code
  133615. */
  133616. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  133617. protected _buildBlock(state: NodeMaterialBuildState): this;
  133618. protected _dumpPropertiesCode(): string;
  133619. serialize(): any;
  133620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133621. }
  133622. }
  133623. declare module BABYLON {
  133624. /**
  133625. * Defines a connection point to be used for points with a custom object type
  133626. */
  133627. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  133628. private _blockType;
  133629. private _blockName;
  133630. private _nameForCheking?;
  133631. /**
  133632. * Creates a new connection point
  133633. * @param name defines the connection point name
  133634. * @param ownerBlock defines the block hosting this connection point
  133635. * @param direction defines the direction of the connection point
  133636. */
  133637. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  133638. /**
  133639. * Gets a number indicating if the current point can be connected to another point
  133640. * @param connectionPoint defines the other connection point
  133641. * @returns a number defining the compatibility state
  133642. */
  133643. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  133644. /**
  133645. * Creates a block suitable to be used as an input for this input point.
  133646. * If null is returned, a block based on the point type will be created.
  133647. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  133648. */
  133649. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  133650. }
  133651. }
  133652. declare module BABYLON {
  133653. /**
  133654. * Enum defining the type of properties that can be edited in the property pages in the NME
  133655. */
  133656. export enum PropertyTypeForEdition {
  133657. /** property is a boolean */
  133658. Boolean = 0,
  133659. /** property is a float */
  133660. Float = 1,
  133661. /** property is a Vector2 */
  133662. Vector2 = 2,
  133663. /** property is a list of values */
  133664. List = 3
  133665. }
  133666. /**
  133667. * Interface that defines an option in a variable of type list
  133668. */
  133669. export interface IEditablePropertyListOption {
  133670. /** label of the option */
  133671. "label": string;
  133672. /** value of the option */
  133673. "value": number;
  133674. }
  133675. /**
  133676. * Interface that defines the options available for an editable property
  133677. */
  133678. export interface IEditablePropertyOption {
  133679. /** min value */
  133680. "min"?: number;
  133681. /** max value */
  133682. "max"?: number;
  133683. /** notifiers: indicates which actions to take when the property is changed */
  133684. "notifiers"?: {
  133685. /** the material should be rebuilt */
  133686. "rebuild"?: boolean;
  133687. /** the preview should be updated */
  133688. "update"?: boolean;
  133689. };
  133690. /** list of the options for a variable of type list */
  133691. "options"?: IEditablePropertyListOption[];
  133692. }
  133693. /**
  133694. * Interface that describes an editable property
  133695. */
  133696. export interface IPropertyDescriptionForEdition {
  133697. /** name of the property */
  133698. "propertyName": string;
  133699. /** display name of the property */
  133700. "displayName": string;
  133701. /** type of the property */
  133702. "type": PropertyTypeForEdition;
  133703. /** group of the property - all properties with the same group value will be displayed in a specific section */
  133704. "groupName": string;
  133705. /** options for the property */
  133706. "options": IEditablePropertyOption;
  133707. }
  133708. /**
  133709. * Decorator that flags a property in a node material block as being editable
  133710. */
  133711. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  133712. }
  133713. declare module BABYLON {
  133714. /**
  133715. * Block used to implement the refraction part of the sub surface module of the PBR material
  133716. */
  133717. export class RefractionBlock extends NodeMaterialBlock {
  133718. /** @hidden */
  133719. _define3DName: string;
  133720. /** @hidden */
  133721. _refractionMatrixName: string;
  133722. /** @hidden */
  133723. _defineLODRefractionAlpha: string;
  133724. /** @hidden */
  133725. _defineLinearSpecularRefraction: string;
  133726. /** @hidden */
  133727. _defineOppositeZ: string;
  133728. /** @hidden */
  133729. _cubeSamplerName: string;
  133730. /** @hidden */
  133731. _2DSamplerName: string;
  133732. /** @hidden */
  133733. _vRefractionMicrosurfaceInfosName: string;
  133734. /** @hidden */
  133735. _vRefractionInfosName: string;
  133736. private _scene;
  133737. /**
  133738. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133739. * Materials half opaque for instance using refraction could benefit from this control.
  133740. */
  133741. linkRefractionWithTransparency: boolean;
  133742. /**
  133743. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133744. */
  133745. invertRefractionY: boolean;
  133746. /**
  133747. * Gets or sets the texture associated with the node
  133748. */
  133749. texture: Nullable<BaseTexture>;
  133750. /**
  133751. * Create a new RefractionBlock
  133752. * @param name defines the block name
  133753. */
  133754. constructor(name: string);
  133755. /**
  133756. * Gets the current class name
  133757. * @returns the class name
  133758. */
  133759. getClassName(): string;
  133760. /**
  133761. * Gets the intensity input component
  133762. */
  133763. get intensity(): NodeMaterialConnectionPoint;
  133764. /**
  133765. * Gets the index of refraction input component
  133766. */
  133767. get indexOfRefraction(): NodeMaterialConnectionPoint;
  133768. /**
  133769. * Gets the tint at distance input component
  133770. */
  133771. get tintAtDistance(): NodeMaterialConnectionPoint;
  133772. /**
  133773. * Gets the view input component
  133774. */
  133775. get view(): NodeMaterialConnectionPoint;
  133776. /**
  133777. * Gets the refraction object output component
  133778. */
  133779. get refraction(): NodeMaterialConnectionPoint;
  133780. /**
  133781. * Returns true if the block has a texture
  133782. */
  133783. get hasTexture(): boolean;
  133784. protected _getTexture(): Nullable<BaseTexture>;
  133785. autoConfigure(material: NodeMaterial): void;
  133786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133787. isReady(): boolean;
  133788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  133789. /**
  133790. * Gets the main code of the block (fragment side)
  133791. * @param state current state of the node material building
  133792. * @returns the shader code
  133793. */
  133794. getCode(state: NodeMaterialBuildState): string;
  133795. protected _buildBlock(state: NodeMaterialBuildState): this;
  133796. protected _dumpPropertiesCode(): string;
  133797. serialize(): any;
  133798. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133799. }
  133800. }
  133801. declare module BABYLON {
  133802. /**
  133803. * Interface used to configure the node material editor
  133804. */
  133805. export interface INodeMaterialEditorOptions {
  133806. /** Define the URl to load node editor script */
  133807. editorURL?: string;
  133808. }
  133809. /** @hidden */
  133810. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  133811. NORMAL: boolean;
  133812. TANGENT: boolean;
  133813. UV1: boolean;
  133814. /** BONES */
  133815. NUM_BONE_INFLUENCERS: number;
  133816. BonesPerMesh: number;
  133817. BONETEXTURE: boolean;
  133818. /** MORPH TARGETS */
  133819. MORPHTARGETS: boolean;
  133820. MORPHTARGETS_NORMAL: boolean;
  133821. MORPHTARGETS_TANGENT: boolean;
  133822. MORPHTARGETS_UV: boolean;
  133823. NUM_MORPH_INFLUENCERS: number;
  133824. /** IMAGE PROCESSING */
  133825. IMAGEPROCESSING: boolean;
  133826. VIGNETTE: boolean;
  133827. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133828. VIGNETTEBLENDMODEOPAQUE: boolean;
  133829. TONEMAPPING: boolean;
  133830. TONEMAPPING_ACES: boolean;
  133831. CONTRAST: boolean;
  133832. EXPOSURE: boolean;
  133833. COLORCURVES: boolean;
  133834. COLORGRADING: boolean;
  133835. COLORGRADING3D: boolean;
  133836. SAMPLER3DGREENDEPTH: boolean;
  133837. SAMPLER3DBGRMAP: boolean;
  133838. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133839. /** MISC. */
  133840. BUMPDIRECTUV: number;
  133841. constructor();
  133842. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  133843. }
  133844. /**
  133845. * Class used to configure NodeMaterial
  133846. */
  133847. export interface INodeMaterialOptions {
  133848. /**
  133849. * Defines if blocks should emit comments
  133850. */
  133851. emitComments: boolean;
  133852. }
  133853. /**
  133854. * Class used to create a node based material built by assembling shader blocks
  133855. */
  133856. export class NodeMaterial extends PushMaterial {
  133857. private static _BuildIdGenerator;
  133858. private _options;
  133859. private _vertexCompilationState;
  133860. private _fragmentCompilationState;
  133861. private _sharedData;
  133862. private _buildId;
  133863. private _buildWasSuccessful;
  133864. private _cachedWorldViewMatrix;
  133865. private _cachedWorldViewProjectionMatrix;
  133866. private _optimizers;
  133867. private _animationFrame;
  133868. /** Define the Url to load node editor script */
  133869. static EditorURL: string;
  133870. /** Define the Url to load snippets */
  133871. static SnippetUrl: string;
  133872. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  133873. static IgnoreTexturesAtLoadTime: boolean;
  133874. private BJSNODEMATERIALEDITOR;
  133875. /** Get the inspector from bundle or global */
  133876. private _getGlobalNodeMaterialEditor;
  133877. /**
  133878. * Snippet ID if the material was created from the snippet server
  133879. */
  133880. snippetId: string;
  133881. /**
  133882. * Gets or sets data used by visual editor
  133883. * @see https://nme.babylonjs.com
  133884. */
  133885. editorData: any;
  133886. /**
  133887. * 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)
  133888. */
  133889. ignoreAlpha: boolean;
  133890. /**
  133891. * Defines the maximum number of lights that can be used in the material
  133892. */
  133893. maxSimultaneousLights: number;
  133894. /**
  133895. * Observable raised when the material is built
  133896. */
  133897. onBuildObservable: Observable<NodeMaterial>;
  133898. /**
  133899. * Gets or sets the root nodes of the material vertex shader
  133900. */
  133901. _vertexOutputNodes: NodeMaterialBlock[];
  133902. /**
  133903. * Gets or sets the root nodes of the material fragment (pixel) shader
  133904. */
  133905. _fragmentOutputNodes: NodeMaterialBlock[];
  133906. /** Gets or sets options to control the node material overall behavior */
  133907. get options(): INodeMaterialOptions;
  133908. set options(options: INodeMaterialOptions);
  133909. /**
  133910. * Default configuration related to image processing available in the standard Material.
  133911. */
  133912. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133913. /**
  133914. * Gets the image processing configuration used either in this material.
  133915. */
  133916. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  133917. /**
  133918. * Sets the Default image processing configuration used either in the this material.
  133919. *
  133920. * If sets to null, the scene one is in use.
  133921. */
  133922. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  133923. /**
  133924. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  133925. */
  133926. attachedBlocks: NodeMaterialBlock[];
  133927. /**
  133928. * Create a new node based material
  133929. * @param name defines the material name
  133930. * @param scene defines the hosting scene
  133931. * @param options defines creation option
  133932. */
  133933. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  133934. /**
  133935. * Gets the current class name of the material e.g. "NodeMaterial"
  133936. * @returns the class name
  133937. */
  133938. getClassName(): string;
  133939. /**
  133940. * Keep track of the image processing observer to allow dispose and replace.
  133941. */
  133942. private _imageProcessingObserver;
  133943. /**
  133944. * Attaches a new image processing configuration to the Standard Material.
  133945. * @param configuration
  133946. */
  133947. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133948. /**
  133949. * Get a block by its name
  133950. * @param name defines the name of the block to retrieve
  133951. * @returns the required block or null if not found
  133952. */
  133953. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  133954. /**
  133955. * Get a block by its name
  133956. * @param predicate defines the predicate used to find the good candidate
  133957. * @returns the required block or null if not found
  133958. */
  133959. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  133960. /**
  133961. * Get an input block by its name
  133962. * @param predicate defines the predicate used to find the good candidate
  133963. * @returns the required input block or null if not found
  133964. */
  133965. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  133966. /**
  133967. * Gets the list of input blocks attached to this material
  133968. * @returns an array of InputBlocks
  133969. */
  133970. getInputBlocks(): InputBlock[];
  133971. /**
  133972. * Adds a new optimizer to the list of optimizers
  133973. * @param optimizer defines the optimizers to add
  133974. * @returns the current material
  133975. */
  133976. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  133977. /**
  133978. * Remove an optimizer from the list of optimizers
  133979. * @param optimizer defines the optimizers to remove
  133980. * @returns the current material
  133981. */
  133982. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  133983. /**
  133984. * Add a new block to the list of output nodes
  133985. * @param node defines the node to add
  133986. * @returns the current material
  133987. */
  133988. addOutputNode(node: NodeMaterialBlock): this;
  133989. /**
  133990. * Remove a block from the list of root nodes
  133991. * @param node defines the node to remove
  133992. * @returns the current material
  133993. */
  133994. removeOutputNode(node: NodeMaterialBlock): this;
  133995. private _addVertexOutputNode;
  133996. private _removeVertexOutputNode;
  133997. private _addFragmentOutputNode;
  133998. private _removeFragmentOutputNode;
  133999. /**
  134000. * Specifies if the material will require alpha blending
  134001. * @returns a boolean specifying if alpha blending is needed
  134002. */
  134003. needAlphaBlending(): boolean;
  134004. /**
  134005. * Specifies if this material should be rendered in alpha test mode
  134006. * @returns a boolean specifying if an alpha test is needed.
  134007. */
  134008. needAlphaTesting(): boolean;
  134009. private _initializeBlock;
  134010. private _resetDualBlocks;
  134011. /**
  134012. * Remove a block from the current node material
  134013. * @param block defines the block to remove
  134014. */
  134015. removeBlock(block: NodeMaterialBlock): void;
  134016. /**
  134017. * Build the material and generates the inner effect
  134018. * @param verbose defines if the build should log activity
  134019. */
  134020. build(verbose?: boolean): void;
  134021. /**
  134022. * Runs an otpimization phase to try to improve the shader code
  134023. */
  134024. optimize(): void;
  134025. private _prepareDefinesForAttributes;
  134026. /**
  134027. * Get if the submesh is ready to be used and all its information available.
  134028. * Child classes can use it to update shaders
  134029. * @param mesh defines the mesh to check
  134030. * @param subMesh defines which submesh to check
  134031. * @param useInstances specifies that instances should be used
  134032. * @returns a boolean indicating that the submesh is ready or not
  134033. */
  134034. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134035. /**
  134036. * Get a string representing the shaders built by the current node graph
  134037. */
  134038. get compiledShaders(): string;
  134039. /**
  134040. * Binds the world matrix to the material
  134041. * @param world defines the world transformation matrix
  134042. */
  134043. bindOnlyWorldMatrix(world: Matrix): void;
  134044. /**
  134045. * Binds the submesh to this material by preparing the effect and shader to draw
  134046. * @param world defines the world transformation matrix
  134047. * @param mesh defines the mesh containing the submesh
  134048. * @param subMesh defines the submesh to bind the material to
  134049. */
  134050. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134051. /**
  134052. * Gets the active textures from the material
  134053. * @returns an array of textures
  134054. */
  134055. getActiveTextures(): BaseTexture[];
  134056. /**
  134057. * Gets the list of texture blocks
  134058. * @returns an array of texture blocks
  134059. */
  134060. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock)[];
  134061. /**
  134062. * Specifies if the material uses a texture
  134063. * @param texture defines the texture to check against the material
  134064. * @returns a boolean specifying if the material uses the texture
  134065. */
  134066. hasTexture(texture: BaseTexture): boolean;
  134067. /**
  134068. * Disposes the material
  134069. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  134070. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  134071. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  134072. */
  134073. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  134074. /** Creates the node editor window. */
  134075. private _createNodeEditor;
  134076. /**
  134077. * Launch the node material editor
  134078. * @param config Define the configuration of the editor
  134079. * @return a promise fulfilled when the node editor is visible
  134080. */
  134081. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  134082. /**
  134083. * Clear the current material
  134084. */
  134085. clear(): void;
  134086. /**
  134087. * Clear the current material and set it to a default state
  134088. */
  134089. setToDefault(): void;
  134090. /**
  134091. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  134092. * @param url defines the url to load from
  134093. * @returns a promise that will fullfil when the material is fully loaded
  134094. */
  134095. loadAsync(url: string): Promise<void>;
  134096. private _gatherBlocks;
  134097. /**
  134098. * Generate a string containing the code declaration required to create an equivalent of this material
  134099. * @returns a string
  134100. */
  134101. generateCode(): string;
  134102. /**
  134103. * Serializes this material in a JSON representation
  134104. * @returns the serialized material object
  134105. */
  134106. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  134107. private _restoreConnections;
  134108. /**
  134109. * Clear the current graph and load a new one from a serialization object
  134110. * @param source defines the JSON representation of the material
  134111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134112. */
  134113. loadFromSerialization(source: any, rootUrl?: string): void;
  134114. /**
  134115. * Makes a duplicate of the current material.
  134116. * @param name - name to use for the new material.
  134117. */
  134118. clone(name: string): NodeMaterial;
  134119. /**
  134120. * Creates a node material from parsed material data
  134121. * @param source defines the JSON representation of the material
  134122. * @param scene defines the hosting scene
  134123. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134124. * @returns a new node material
  134125. */
  134126. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  134127. /**
  134128. * Creates a node material from a snippet saved in a remote file
  134129. * @param name defines the name of the material to create
  134130. * @param url defines the url to load from
  134131. * @param scene defines the hosting scene
  134132. * @returns a promise that will resolve to the new node material
  134133. */
  134134. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  134135. /**
  134136. * Creates a node material from a snippet saved by the node material editor
  134137. * @param snippetId defines the snippet to load
  134138. * @param scene defines the hosting scene
  134139. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134140. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  134141. * @returns a promise that will resolve to the new node material
  134142. */
  134143. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  134144. /**
  134145. * Creates a new node material set to default basic configuration
  134146. * @param name defines the name of the material
  134147. * @param scene defines the hosting scene
  134148. * @returns a new NodeMaterial
  134149. */
  134150. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  134151. }
  134152. }
  134153. declare module BABYLON {
  134154. /**
  134155. * Block used to read a texture from a sampler
  134156. */
  134157. export class TextureBlock extends NodeMaterialBlock {
  134158. private _defineName;
  134159. private _linearDefineName;
  134160. private _gammaDefineName;
  134161. private _tempTextureRead;
  134162. private _samplerName;
  134163. private _transformedUVName;
  134164. private _textureTransformName;
  134165. private _textureInfoName;
  134166. private _mainUVName;
  134167. private _mainUVDefineName;
  134168. /**
  134169. * Gets or sets the texture associated with the node
  134170. */
  134171. texture: Nullable<Texture>;
  134172. /**
  134173. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  134174. */
  134175. convertToGammaSpace: boolean;
  134176. /**
  134177. * Gets or sets a boolean indicating if content needs to be converted to linear space
  134178. */
  134179. convertToLinearSpace: boolean;
  134180. /**
  134181. * Create a new TextureBlock
  134182. * @param name defines the block name
  134183. */
  134184. constructor(name: string);
  134185. /**
  134186. * Gets the current class name
  134187. * @returns the class name
  134188. */
  134189. getClassName(): string;
  134190. /**
  134191. * Gets the uv input component
  134192. */
  134193. get uv(): NodeMaterialConnectionPoint;
  134194. /**
  134195. * Gets the rgba output component
  134196. */
  134197. get rgba(): NodeMaterialConnectionPoint;
  134198. /**
  134199. * Gets the rgb output component
  134200. */
  134201. get rgb(): NodeMaterialConnectionPoint;
  134202. /**
  134203. * Gets the r output component
  134204. */
  134205. get r(): NodeMaterialConnectionPoint;
  134206. /**
  134207. * Gets the g output component
  134208. */
  134209. get g(): NodeMaterialConnectionPoint;
  134210. /**
  134211. * Gets the b output component
  134212. */
  134213. get b(): NodeMaterialConnectionPoint;
  134214. /**
  134215. * Gets the a output component
  134216. */
  134217. get a(): NodeMaterialConnectionPoint;
  134218. get target(): NodeMaterialBlockTargets;
  134219. autoConfigure(material: NodeMaterial): void;
  134220. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  134222. isReady(): boolean;
  134223. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  134224. private get _isMixed();
  134225. private _injectVertexCode;
  134226. private _writeTextureRead;
  134227. private _writeOutput;
  134228. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134229. protected _dumpPropertiesCode(): string;
  134230. serialize(): any;
  134231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134232. }
  134233. }
  134234. declare module BABYLON {
  134235. /**
  134236. * Class used to store shared data between 2 NodeMaterialBuildState
  134237. */
  134238. export class NodeMaterialBuildStateSharedData {
  134239. /**
  134240. * Gets the list of emitted varyings
  134241. */
  134242. temps: string[];
  134243. /**
  134244. * Gets the list of emitted varyings
  134245. */
  134246. varyings: string[];
  134247. /**
  134248. * Gets the varying declaration string
  134249. */
  134250. varyingDeclaration: string;
  134251. /**
  134252. * Input blocks
  134253. */
  134254. inputBlocks: InputBlock[];
  134255. /**
  134256. * Input blocks
  134257. */
  134258. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock)[];
  134259. /**
  134260. * Bindable blocks (Blocks that need to set data to the effect)
  134261. */
  134262. bindableBlocks: NodeMaterialBlock[];
  134263. /**
  134264. * List of blocks that can provide a compilation fallback
  134265. */
  134266. blocksWithFallbacks: NodeMaterialBlock[];
  134267. /**
  134268. * List of blocks that can provide a define update
  134269. */
  134270. blocksWithDefines: NodeMaterialBlock[];
  134271. /**
  134272. * List of blocks that can provide a repeatable content
  134273. */
  134274. repeatableContentBlocks: NodeMaterialBlock[];
  134275. /**
  134276. * List of blocks that can provide a dynamic list of uniforms
  134277. */
  134278. dynamicUniformBlocks: NodeMaterialBlock[];
  134279. /**
  134280. * List of blocks that can block the isReady function for the material
  134281. */
  134282. blockingBlocks: NodeMaterialBlock[];
  134283. /**
  134284. * Gets the list of animated inputs
  134285. */
  134286. animatedInputs: InputBlock[];
  134287. /**
  134288. * Build Id used to avoid multiple recompilations
  134289. */
  134290. buildId: number;
  134291. /** List of emitted variables */
  134292. variableNames: {
  134293. [key: string]: number;
  134294. };
  134295. /** List of emitted defines */
  134296. defineNames: {
  134297. [key: string]: number;
  134298. };
  134299. /** Should emit comments? */
  134300. emitComments: boolean;
  134301. /** Emit build activity */
  134302. verbose: boolean;
  134303. /** Gets or sets the hosting scene */
  134304. scene: Scene;
  134305. /**
  134306. * Gets the compilation hints emitted at compilation time
  134307. */
  134308. hints: {
  134309. needWorldViewMatrix: boolean;
  134310. needWorldViewProjectionMatrix: boolean;
  134311. needAlphaBlending: boolean;
  134312. needAlphaTesting: boolean;
  134313. };
  134314. /**
  134315. * List of compilation checks
  134316. */
  134317. checks: {
  134318. emitVertex: boolean;
  134319. emitFragment: boolean;
  134320. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  134321. };
  134322. /** Creates a new shared data */
  134323. constructor();
  134324. /**
  134325. * Emits console errors and exceptions if there is a failing check
  134326. */
  134327. emitErrors(): void;
  134328. }
  134329. }
  134330. declare module BABYLON {
  134331. /**
  134332. * Class used to store node based material build state
  134333. */
  134334. export class NodeMaterialBuildState {
  134335. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  134336. supportUniformBuffers: boolean;
  134337. /**
  134338. * Gets the list of emitted attributes
  134339. */
  134340. attributes: string[];
  134341. /**
  134342. * Gets the list of emitted uniforms
  134343. */
  134344. uniforms: string[];
  134345. /**
  134346. * Gets the list of emitted constants
  134347. */
  134348. constants: string[];
  134349. /**
  134350. * Gets the list of emitted samplers
  134351. */
  134352. samplers: string[];
  134353. /**
  134354. * Gets the list of emitted functions
  134355. */
  134356. functions: {
  134357. [key: string]: string;
  134358. };
  134359. /**
  134360. * Gets the list of emitted extensions
  134361. */
  134362. extensions: {
  134363. [key: string]: string;
  134364. };
  134365. /**
  134366. * Gets the target of the compilation state
  134367. */
  134368. target: NodeMaterialBlockTargets;
  134369. /**
  134370. * Gets the list of emitted counters
  134371. */
  134372. counters: {
  134373. [key: string]: number;
  134374. };
  134375. /**
  134376. * Shared data between multiple NodeMaterialBuildState instances
  134377. */
  134378. sharedData: NodeMaterialBuildStateSharedData;
  134379. /** @hidden */
  134380. _vertexState: NodeMaterialBuildState;
  134381. /** @hidden */
  134382. _attributeDeclaration: string;
  134383. /** @hidden */
  134384. _uniformDeclaration: string;
  134385. /** @hidden */
  134386. _constantDeclaration: string;
  134387. /** @hidden */
  134388. _samplerDeclaration: string;
  134389. /** @hidden */
  134390. _varyingTransfer: string;
  134391. /** @hidden */
  134392. _injectAtEnd: string;
  134393. private _repeatableContentAnchorIndex;
  134394. /** @hidden */
  134395. _builtCompilationString: string;
  134396. /**
  134397. * Gets the emitted compilation strings
  134398. */
  134399. compilationString: string;
  134400. /**
  134401. * Finalize the compilation strings
  134402. * @param state defines the current compilation state
  134403. */
  134404. finalize(state: NodeMaterialBuildState): void;
  134405. /** @hidden */
  134406. get _repeatableContentAnchor(): string;
  134407. /** @hidden */
  134408. _getFreeVariableName(prefix: string): string;
  134409. /** @hidden */
  134410. _getFreeDefineName(prefix: string): string;
  134411. /** @hidden */
  134412. _excludeVariableName(name: string): void;
  134413. /** @hidden */
  134414. _emit2DSampler(name: string): void;
  134415. /** @hidden */
  134416. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  134417. /** @hidden */
  134418. _emitExtension(name: string, extension: string): void;
  134419. /** @hidden */
  134420. _emitFunction(name: string, code: string, comments: string): void;
  134421. /** @hidden */
  134422. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  134423. replaceStrings?: {
  134424. search: RegExp;
  134425. replace: string;
  134426. }[];
  134427. repeatKey?: string;
  134428. }): string;
  134429. /** @hidden */
  134430. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  134431. repeatKey?: string;
  134432. removeAttributes?: boolean;
  134433. removeUniforms?: boolean;
  134434. removeVaryings?: boolean;
  134435. removeIfDef?: boolean;
  134436. replaceStrings?: {
  134437. search: RegExp;
  134438. replace: string;
  134439. }[];
  134440. }, storeKey?: string): void;
  134441. /** @hidden */
  134442. _registerTempVariable(name: string): boolean;
  134443. /** @hidden */
  134444. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  134445. /** @hidden */
  134446. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  134447. /** @hidden */
  134448. _emitFloat(value: number): string;
  134449. }
  134450. }
  134451. declare module BABYLON {
  134452. /**
  134453. * Defines a block that can be used inside a node based material
  134454. */
  134455. export class NodeMaterialBlock {
  134456. private _buildId;
  134457. private _buildTarget;
  134458. private _target;
  134459. private _isFinalMerger;
  134460. private _isInput;
  134461. protected _isUnique: boolean;
  134462. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  134463. inputsAreExclusive: boolean;
  134464. /** @hidden */
  134465. _codeVariableName: string;
  134466. /** @hidden */
  134467. _inputs: NodeMaterialConnectionPoint[];
  134468. /** @hidden */
  134469. _outputs: NodeMaterialConnectionPoint[];
  134470. /** @hidden */
  134471. _preparationId: number;
  134472. /**
  134473. * Gets or sets the name of the block
  134474. */
  134475. name: string;
  134476. /**
  134477. * Gets or sets the unique id of the node
  134478. */
  134479. uniqueId: number;
  134480. /**
  134481. * Gets or sets the comments associated with this block
  134482. */
  134483. comments: string;
  134484. /**
  134485. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  134486. */
  134487. get isUnique(): boolean;
  134488. /**
  134489. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  134490. */
  134491. get isFinalMerger(): boolean;
  134492. /**
  134493. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  134494. */
  134495. get isInput(): boolean;
  134496. /**
  134497. * Gets or sets the build Id
  134498. */
  134499. get buildId(): number;
  134500. set buildId(value: number);
  134501. /**
  134502. * Gets or sets the target of the block
  134503. */
  134504. get target(): NodeMaterialBlockTargets;
  134505. set target(value: NodeMaterialBlockTargets);
  134506. /**
  134507. * Gets the list of input points
  134508. */
  134509. get inputs(): NodeMaterialConnectionPoint[];
  134510. /** Gets the list of output points */
  134511. get outputs(): NodeMaterialConnectionPoint[];
  134512. /**
  134513. * Find an input by its name
  134514. * @param name defines the name of the input to look for
  134515. * @returns the input or null if not found
  134516. */
  134517. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  134518. /**
  134519. * Find an output by its name
  134520. * @param name defines the name of the outputto look for
  134521. * @returns the output or null if not found
  134522. */
  134523. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  134524. /**
  134525. * Creates a new NodeMaterialBlock
  134526. * @param name defines the block name
  134527. * @param target defines the target of that block (Vertex by default)
  134528. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  134529. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  134530. */
  134531. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  134532. /**
  134533. * Initialize the block and prepare the context for build
  134534. * @param state defines the state that will be used for the build
  134535. */
  134536. initialize(state: NodeMaterialBuildState): void;
  134537. /**
  134538. * Bind data to effect. Will only be called for blocks with isBindable === true
  134539. * @param effect defines the effect to bind data to
  134540. * @param nodeMaterial defines the hosting NodeMaterial
  134541. * @param mesh defines the mesh that will be rendered
  134542. * @param subMesh defines the submesh that will be rendered
  134543. */
  134544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  134545. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  134546. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  134547. protected _writeFloat(value: number): string;
  134548. /**
  134549. * Gets the current class name e.g. "NodeMaterialBlock"
  134550. * @returns the class name
  134551. */
  134552. getClassName(): string;
  134553. /**
  134554. * Register a new input. Must be called inside a block constructor
  134555. * @param name defines the connection point name
  134556. * @param type defines the connection point type
  134557. * @param isOptional defines a boolean indicating that this input can be omitted
  134558. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  134559. * @param point an already created connection point. If not provided, create a new one
  134560. * @returns the current block
  134561. */
  134562. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  134563. /**
  134564. * Register a new output. Must be called inside a block constructor
  134565. * @param name defines the connection point name
  134566. * @param type defines the connection point type
  134567. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  134568. * @param point an already created connection point. If not provided, create a new one
  134569. * @returns the current block
  134570. */
  134571. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  134572. /**
  134573. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  134574. * @param forOutput defines an optional connection point to check compatibility with
  134575. * @returns the first available input or null
  134576. */
  134577. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  134578. /**
  134579. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  134580. * @param forBlock defines an optional block to check compatibility with
  134581. * @returns the first available input or null
  134582. */
  134583. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  134584. /**
  134585. * Gets the sibling of the given output
  134586. * @param current defines the current output
  134587. * @returns the next output in the list or null
  134588. */
  134589. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  134590. /**
  134591. * Connect current block with another block
  134592. * @param other defines the block to connect with
  134593. * @param options define the various options to help pick the right connections
  134594. * @returns the current block
  134595. */
  134596. connectTo(other: NodeMaterialBlock, options?: {
  134597. input?: string;
  134598. output?: string;
  134599. outputSwizzle?: string;
  134600. }): this | undefined;
  134601. protected _buildBlock(state: NodeMaterialBuildState): void;
  134602. /**
  134603. * Add uniforms, samplers and uniform buffers at compilation time
  134604. * @param state defines the state to update
  134605. * @param nodeMaterial defines the node material requesting the update
  134606. * @param defines defines the material defines to update
  134607. * @param uniformBuffers defines the list of uniform buffer names
  134608. */
  134609. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  134610. /**
  134611. * Add potential fallbacks if shader compilation fails
  134612. * @param mesh defines the mesh to be rendered
  134613. * @param fallbacks defines the current prioritized list of fallbacks
  134614. */
  134615. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  134616. /**
  134617. * Initialize defines for shader compilation
  134618. * @param mesh defines the mesh to be rendered
  134619. * @param nodeMaterial defines the node material requesting the update
  134620. * @param defines defines the material defines to update
  134621. * @param useInstances specifies that instances should be used
  134622. */
  134623. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134624. /**
  134625. * Update defines for shader compilation
  134626. * @param mesh defines the mesh to be rendered
  134627. * @param nodeMaterial defines the node material requesting the update
  134628. * @param defines defines the material defines to update
  134629. * @param useInstances specifies that instances should be used
  134630. */
  134631. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  134632. /**
  134633. * Lets the block try to connect some inputs automatically
  134634. * @param material defines the hosting NodeMaterial
  134635. */
  134636. autoConfigure(material: NodeMaterial): void;
  134637. /**
  134638. * Function called when a block is declared as repeatable content generator
  134639. * @param vertexShaderState defines the current compilation state for the vertex shader
  134640. * @param fragmentShaderState defines the current compilation state for the fragment shader
  134641. * @param mesh defines the mesh to be rendered
  134642. * @param defines defines the material defines to update
  134643. */
  134644. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  134645. /**
  134646. * Checks if the block is ready
  134647. * @param mesh defines the mesh to be rendered
  134648. * @param nodeMaterial defines the node material requesting the update
  134649. * @param defines defines the material defines to update
  134650. * @param useInstances specifies that instances should be used
  134651. * @returns true if the block is ready
  134652. */
  134653. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  134654. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  134655. private _processBuild;
  134656. /**
  134657. * Compile the current node and generate the shader code
  134658. * @param state defines the current compilation state (uniforms, samplers, current string)
  134659. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  134660. * @returns true if already built
  134661. */
  134662. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  134663. protected _inputRename(name: string): string;
  134664. protected _outputRename(name: string): string;
  134665. protected _dumpPropertiesCode(): string;
  134666. /** @hidden */
  134667. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  134668. /** @hidden */
  134669. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  134670. /**
  134671. * Clone the current block to a new identical block
  134672. * @param scene defines the hosting scene
  134673. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  134674. * @returns a copy of the current block
  134675. */
  134676. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  134677. /**
  134678. * Serializes this block in a JSON representation
  134679. * @returns the serialized block object
  134680. */
  134681. serialize(): any;
  134682. /** @hidden */
  134683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134684. private _deserializePortDisplayNames;
  134685. /**
  134686. * Release resources
  134687. */
  134688. dispose(): void;
  134689. }
  134690. }
  134691. declare module BABYLON {
  134692. /**
  134693. * Enum defining the type of animations supported by InputBlock
  134694. */
  134695. export enum AnimatedInputBlockTypes {
  134696. /** No animation */
  134697. None = 0,
  134698. /** Time based animation. Will only work for floats */
  134699. Time = 1
  134700. }
  134701. }
  134702. declare module BABYLON {
  134703. /**
  134704. * Block used to expose an input value
  134705. */
  134706. export class InputBlock extends NodeMaterialBlock {
  134707. private _mode;
  134708. private _associatedVariableName;
  134709. private _storedValue;
  134710. private _valueCallback;
  134711. private _type;
  134712. private _animationType;
  134713. /** Gets or set a value used to limit the range of float values */
  134714. min: number;
  134715. /** Gets or set a value used to limit the range of float values */
  134716. max: number;
  134717. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  134718. isBoolean: boolean;
  134719. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  134720. matrixMode: number;
  134721. /** @hidden */
  134722. _systemValue: Nullable<NodeMaterialSystemValues>;
  134723. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  134724. visibleInInspector: boolean;
  134725. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  134726. isConstant: boolean;
  134727. /** Gets or sets the group to use to display this block in the Inspector */
  134728. groupInInspector: string;
  134729. /** Gets an observable raised when the value is changed */
  134730. onValueChangedObservable: Observable<InputBlock>;
  134731. /**
  134732. * Gets or sets the connection point type (default is float)
  134733. */
  134734. get type(): NodeMaterialBlockConnectionPointTypes;
  134735. /**
  134736. * Creates a new InputBlock
  134737. * @param name defines the block name
  134738. * @param target defines the target of that block (Vertex by default)
  134739. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  134740. */
  134741. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  134742. /**
  134743. * Gets the output component
  134744. */
  134745. get output(): NodeMaterialConnectionPoint;
  134746. /**
  134747. * Set the source of this connection point to a vertex attribute
  134748. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  134749. * @returns the current connection point
  134750. */
  134751. setAsAttribute(attributeName?: string): InputBlock;
  134752. /**
  134753. * Set the source of this connection point to a system value
  134754. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  134755. * @returns the current connection point
  134756. */
  134757. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  134758. /**
  134759. * Gets or sets the value of that point.
  134760. * Please note that this value will be ignored if valueCallback is defined
  134761. */
  134762. get value(): any;
  134763. set value(value: any);
  134764. /**
  134765. * Gets or sets a callback used to get the value of that point.
  134766. * Please note that setting this value will force the connection point to ignore the value property
  134767. */
  134768. get valueCallback(): () => any;
  134769. set valueCallback(value: () => any);
  134770. /**
  134771. * Gets or sets the associated variable name in the shader
  134772. */
  134773. get associatedVariableName(): string;
  134774. set associatedVariableName(value: string);
  134775. /** Gets or sets the type of animation applied to the input */
  134776. get animationType(): AnimatedInputBlockTypes;
  134777. set animationType(value: AnimatedInputBlockTypes);
  134778. /**
  134779. * Gets a boolean indicating that this connection point not defined yet
  134780. */
  134781. get isUndefined(): boolean;
  134782. /**
  134783. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  134784. * In this case the connection point name must be the name of the uniform to use.
  134785. * Can only be set on inputs
  134786. */
  134787. get isUniform(): boolean;
  134788. set isUniform(value: boolean);
  134789. /**
  134790. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  134791. * In this case the connection point name must be the name of the attribute to use
  134792. * Can only be set on inputs
  134793. */
  134794. get isAttribute(): boolean;
  134795. set isAttribute(value: boolean);
  134796. /**
  134797. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  134798. * Can only be set on exit points
  134799. */
  134800. get isVarying(): boolean;
  134801. set isVarying(value: boolean);
  134802. /**
  134803. * Gets a boolean indicating that the current connection point is a system value
  134804. */
  134805. get isSystemValue(): boolean;
  134806. /**
  134807. * Gets or sets the current well known value or null if not defined as a system value
  134808. */
  134809. get systemValue(): Nullable<NodeMaterialSystemValues>;
  134810. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  134811. /**
  134812. * Gets the current class name
  134813. * @returns the class name
  134814. */
  134815. getClassName(): string;
  134816. /**
  134817. * Animate the input if animationType !== None
  134818. * @param scene defines the rendering scene
  134819. */
  134820. animate(scene: Scene): void;
  134821. private _emitDefine;
  134822. initialize(state: NodeMaterialBuildState): void;
  134823. /**
  134824. * Set the input block to its default value (based on its type)
  134825. */
  134826. setDefaultValue(): void;
  134827. private _emitConstant;
  134828. private _emit;
  134829. /** @hidden */
  134830. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  134831. /** @hidden */
  134832. _transmit(effect: Effect, scene: Scene): void;
  134833. protected _buildBlock(state: NodeMaterialBuildState): void;
  134834. protected _dumpPropertiesCode(): string;
  134835. dispose(): void;
  134836. serialize(): any;
  134837. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134838. }
  134839. }
  134840. declare module BABYLON {
  134841. /**
  134842. * Enum used to define the compatibility state between two connection points
  134843. */
  134844. export enum NodeMaterialConnectionPointCompatibilityStates {
  134845. /** Points are compatibles */
  134846. Compatible = 0,
  134847. /** Points are incompatible because of their types */
  134848. TypeIncompatible = 1,
  134849. /** Points are incompatible because of their targets (vertex vs fragment) */
  134850. TargetIncompatible = 2
  134851. }
  134852. /**
  134853. * Defines the direction of a connection point
  134854. */
  134855. export enum NodeMaterialConnectionPointDirection {
  134856. /** Input */
  134857. Input = 0,
  134858. /** Output */
  134859. Output = 1
  134860. }
  134861. /**
  134862. * Defines a connection point for a block
  134863. */
  134864. export class NodeMaterialConnectionPoint {
  134865. /** @hidden */
  134866. _ownerBlock: NodeMaterialBlock;
  134867. /** @hidden */
  134868. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  134869. private _endpoints;
  134870. private _associatedVariableName;
  134871. private _direction;
  134872. /** @hidden */
  134873. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  134874. /** @hidden */
  134875. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  134876. private _type;
  134877. /** @hidden */
  134878. _enforceAssociatedVariableName: boolean;
  134879. /** Gets the direction of the point */
  134880. get direction(): NodeMaterialConnectionPointDirection;
  134881. /** Indicates that this connection point needs dual validation before being connected to another point */
  134882. needDualDirectionValidation: boolean;
  134883. /**
  134884. * Gets or sets the additional types supported by this connection point
  134885. */
  134886. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  134887. /**
  134888. * Gets or sets the additional types excluded by this connection point
  134889. */
  134890. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  134891. /**
  134892. * Observable triggered when this point is connected
  134893. */
  134894. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  134895. /**
  134896. * Gets or sets the associated variable name in the shader
  134897. */
  134898. get associatedVariableName(): string;
  134899. set associatedVariableName(value: string);
  134900. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  134901. get innerType(): NodeMaterialBlockConnectionPointTypes;
  134902. /**
  134903. * Gets or sets the connection point type (default is float)
  134904. */
  134905. get type(): NodeMaterialBlockConnectionPointTypes;
  134906. set type(value: NodeMaterialBlockConnectionPointTypes);
  134907. /**
  134908. * Gets or sets the connection point name
  134909. */
  134910. name: string;
  134911. /**
  134912. * Gets or sets the connection point name
  134913. */
  134914. displayName: string;
  134915. /**
  134916. * Gets or sets a boolean indicating that this connection point can be omitted
  134917. */
  134918. isOptional: boolean;
  134919. /**
  134920. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  134921. */
  134922. define: string;
  134923. /** @hidden */
  134924. _prioritizeVertex: boolean;
  134925. private _target;
  134926. /** Gets or sets the target of that connection point */
  134927. get target(): NodeMaterialBlockTargets;
  134928. set target(value: NodeMaterialBlockTargets);
  134929. /**
  134930. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  134931. */
  134932. get isConnected(): boolean;
  134933. /**
  134934. * Gets a boolean indicating that the current point is connected to an input block
  134935. */
  134936. get isConnectedToInputBlock(): boolean;
  134937. /**
  134938. * Gets a the connected input block (if any)
  134939. */
  134940. get connectInputBlock(): Nullable<InputBlock>;
  134941. /** Get the other side of the connection (if any) */
  134942. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  134943. /** Get the block that owns this connection point */
  134944. get ownerBlock(): NodeMaterialBlock;
  134945. /** Get the block connected on the other side of this connection (if any) */
  134946. get sourceBlock(): Nullable<NodeMaterialBlock>;
  134947. /** Get the block connected on the endpoints of this connection (if any) */
  134948. get connectedBlocks(): Array<NodeMaterialBlock>;
  134949. /** Gets the list of connected endpoints */
  134950. get endpoints(): NodeMaterialConnectionPoint[];
  134951. /** Gets a boolean indicating if that output point is connected to at least one input */
  134952. get hasEndpoints(): boolean;
  134953. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  134954. get isConnectedInVertexShader(): boolean;
  134955. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  134956. get isConnectedInFragmentShader(): boolean;
  134957. /**
  134958. * Creates a block suitable to be used as an input for this input point.
  134959. * If null is returned, a block based on the point type will be created.
  134960. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  134961. */
  134962. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  134963. /**
  134964. * Creates a new connection point
  134965. * @param name defines the connection point name
  134966. * @param ownerBlock defines the block hosting this connection point
  134967. * @param direction defines the direction of the connection point
  134968. */
  134969. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  134970. /**
  134971. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  134972. * @returns the class name
  134973. */
  134974. getClassName(): string;
  134975. /**
  134976. * Gets a boolean indicating if the current point can be connected to another point
  134977. * @param connectionPoint defines the other connection point
  134978. * @returns a boolean
  134979. */
  134980. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  134981. /**
  134982. * Gets a number indicating if the current point can be connected to another point
  134983. * @param connectionPoint defines the other connection point
  134984. * @returns a number defining the compatibility state
  134985. */
  134986. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  134987. /**
  134988. * Connect this point to another connection point
  134989. * @param connectionPoint defines the other connection point
  134990. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  134991. * @returns the current connection point
  134992. */
  134993. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  134994. /**
  134995. * Disconnect this point from one of his endpoint
  134996. * @param endpoint defines the other connection point
  134997. * @returns the current connection point
  134998. */
  134999. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  135000. /**
  135001. * Serializes this point in a JSON representation
  135002. * @param isInput defines if the connection point is an input (default is true)
  135003. * @returns the serialized point object
  135004. */
  135005. serialize(isInput?: boolean): any;
  135006. /**
  135007. * Release resources
  135008. */
  135009. dispose(): void;
  135010. }
  135011. }
  135012. declare module BABYLON {
  135013. /**
  135014. * Block used to add support for vertex skinning (bones)
  135015. */
  135016. export class BonesBlock extends NodeMaterialBlock {
  135017. /**
  135018. * Creates a new BonesBlock
  135019. * @param name defines the block name
  135020. */
  135021. constructor(name: string);
  135022. /**
  135023. * Initialize the block and prepare the context for build
  135024. * @param state defines the state that will be used for the build
  135025. */
  135026. initialize(state: NodeMaterialBuildState): void;
  135027. /**
  135028. * Gets the current class name
  135029. * @returns the class name
  135030. */
  135031. getClassName(): string;
  135032. /**
  135033. * Gets the matrix indices input component
  135034. */
  135035. get matricesIndices(): NodeMaterialConnectionPoint;
  135036. /**
  135037. * Gets the matrix weights input component
  135038. */
  135039. get matricesWeights(): NodeMaterialConnectionPoint;
  135040. /**
  135041. * Gets the extra matrix indices input component
  135042. */
  135043. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  135044. /**
  135045. * Gets the extra matrix weights input component
  135046. */
  135047. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  135048. /**
  135049. * Gets the world input component
  135050. */
  135051. get world(): NodeMaterialConnectionPoint;
  135052. /**
  135053. * Gets the output component
  135054. */
  135055. get output(): NodeMaterialConnectionPoint;
  135056. autoConfigure(material: NodeMaterial): void;
  135057. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  135058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135060. protected _buildBlock(state: NodeMaterialBuildState): this;
  135061. }
  135062. }
  135063. declare module BABYLON {
  135064. /**
  135065. * Block used to add support for instances
  135066. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  135067. */
  135068. export class InstancesBlock extends NodeMaterialBlock {
  135069. /**
  135070. * Creates a new InstancesBlock
  135071. * @param name defines the block name
  135072. */
  135073. constructor(name: string);
  135074. /**
  135075. * Gets the current class name
  135076. * @returns the class name
  135077. */
  135078. getClassName(): string;
  135079. /**
  135080. * Gets the first world row input component
  135081. */
  135082. get world0(): NodeMaterialConnectionPoint;
  135083. /**
  135084. * Gets the second world row input component
  135085. */
  135086. get world1(): NodeMaterialConnectionPoint;
  135087. /**
  135088. * Gets the third world row input component
  135089. */
  135090. get world2(): NodeMaterialConnectionPoint;
  135091. /**
  135092. * Gets the forth world row input component
  135093. */
  135094. get world3(): NodeMaterialConnectionPoint;
  135095. /**
  135096. * Gets the world input component
  135097. */
  135098. get world(): NodeMaterialConnectionPoint;
  135099. /**
  135100. * Gets the output component
  135101. */
  135102. get output(): NodeMaterialConnectionPoint;
  135103. /**
  135104. * Gets the isntanceID component
  135105. */
  135106. get instanceID(): NodeMaterialConnectionPoint;
  135107. autoConfigure(material: NodeMaterial): void;
  135108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  135109. protected _buildBlock(state: NodeMaterialBuildState): this;
  135110. }
  135111. }
  135112. declare module BABYLON {
  135113. /**
  135114. * Block used to add morph targets support to vertex shader
  135115. */
  135116. export class MorphTargetsBlock extends NodeMaterialBlock {
  135117. private _repeatableContentAnchor;
  135118. /**
  135119. * Create a new MorphTargetsBlock
  135120. * @param name defines the block name
  135121. */
  135122. constructor(name: string);
  135123. /**
  135124. * Gets the current class name
  135125. * @returns the class name
  135126. */
  135127. getClassName(): string;
  135128. /**
  135129. * Gets the position input component
  135130. */
  135131. get position(): NodeMaterialConnectionPoint;
  135132. /**
  135133. * Gets the normal input component
  135134. */
  135135. get normal(): NodeMaterialConnectionPoint;
  135136. /**
  135137. * Gets the tangent input component
  135138. */
  135139. get tangent(): NodeMaterialConnectionPoint;
  135140. /**
  135141. * Gets the tangent input component
  135142. */
  135143. get uv(): NodeMaterialConnectionPoint;
  135144. /**
  135145. * Gets the position output component
  135146. */
  135147. get positionOutput(): NodeMaterialConnectionPoint;
  135148. /**
  135149. * Gets the normal output component
  135150. */
  135151. get normalOutput(): NodeMaterialConnectionPoint;
  135152. /**
  135153. * Gets the tangent output component
  135154. */
  135155. get tangentOutput(): NodeMaterialConnectionPoint;
  135156. /**
  135157. * Gets the tangent output component
  135158. */
  135159. get uvOutput(): NodeMaterialConnectionPoint;
  135160. initialize(state: NodeMaterialBuildState): void;
  135161. autoConfigure(material: NodeMaterial): void;
  135162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135164. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  135165. protected _buildBlock(state: NodeMaterialBuildState): this;
  135166. }
  135167. }
  135168. declare module BABYLON {
  135169. /**
  135170. * Block used to get data information from a light
  135171. */
  135172. export class LightInformationBlock extends NodeMaterialBlock {
  135173. private _lightDataUniformName;
  135174. private _lightColorUniformName;
  135175. private _lightTypeDefineName;
  135176. /**
  135177. * Gets or sets the light associated with this block
  135178. */
  135179. light: Nullable<Light>;
  135180. /**
  135181. * Creates a new LightInformationBlock
  135182. * @param name defines the block name
  135183. */
  135184. constructor(name: string);
  135185. /**
  135186. * Gets the current class name
  135187. * @returns the class name
  135188. */
  135189. getClassName(): string;
  135190. /**
  135191. * Gets the world position input component
  135192. */
  135193. get worldPosition(): NodeMaterialConnectionPoint;
  135194. /**
  135195. * Gets the direction output component
  135196. */
  135197. get direction(): NodeMaterialConnectionPoint;
  135198. /**
  135199. * Gets the direction output component
  135200. */
  135201. get color(): NodeMaterialConnectionPoint;
  135202. /**
  135203. * Gets the direction output component
  135204. */
  135205. get intensity(): NodeMaterialConnectionPoint;
  135206. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135208. protected _buildBlock(state: NodeMaterialBuildState): this;
  135209. serialize(): any;
  135210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135211. }
  135212. }
  135213. declare module BABYLON {
  135214. /**
  135215. * Block used to add image processing support to fragment shader
  135216. */
  135217. export class ImageProcessingBlock extends NodeMaterialBlock {
  135218. /**
  135219. * Create a new ImageProcessingBlock
  135220. * @param name defines the block name
  135221. */
  135222. constructor(name: string);
  135223. /**
  135224. * Gets the current class name
  135225. * @returns the class name
  135226. */
  135227. getClassName(): string;
  135228. /**
  135229. * Gets the color input component
  135230. */
  135231. get color(): NodeMaterialConnectionPoint;
  135232. /**
  135233. * Gets the output component
  135234. */
  135235. get output(): NodeMaterialConnectionPoint;
  135236. /**
  135237. * Initialize the block and prepare the context for build
  135238. * @param state defines the state that will be used for the build
  135239. */
  135240. initialize(state: NodeMaterialBuildState): void;
  135241. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  135242. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135243. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135244. protected _buildBlock(state: NodeMaterialBuildState): this;
  135245. }
  135246. }
  135247. declare module BABYLON {
  135248. /**
  135249. * Block used to pertub normals based on a normal map
  135250. */
  135251. export class PerturbNormalBlock extends NodeMaterialBlock {
  135252. private _tangentSpaceParameterName;
  135253. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  135254. invertX: boolean;
  135255. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  135256. invertY: boolean;
  135257. /**
  135258. * Create a new PerturbNormalBlock
  135259. * @param name defines the block name
  135260. */
  135261. constructor(name: string);
  135262. /**
  135263. * Gets the current class name
  135264. * @returns the class name
  135265. */
  135266. getClassName(): string;
  135267. /**
  135268. * Gets the world position input component
  135269. */
  135270. get worldPosition(): NodeMaterialConnectionPoint;
  135271. /**
  135272. * Gets the world normal input component
  135273. */
  135274. get worldNormal(): NodeMaterialConnectionPoint;
  135275. /**
  135276. * Gets the world tangent input component
  135277. */
  135278. get worldTangent(): NodeMaterialConnectionPoint;
  135279. /**
  135280. * Gets the uv input component
  135281. */
  135282. get uv(): NodeMaterialConnectionPoint;
  135283. /**
  135284. * Gets the normal map color input component
  135285. */
  135286. get normalMapColor(): NodeMaterialConnectionPoint;
  135287. /**
  135288. * Gets the strength input component
  135289. */
  135290. get strength(): NodeMaterialConnectionPoint;
  135291. /**
  135292. * Gets the output component
  135293. */
  135294. get output(): NodeMaterialConnectionPoint;
  135295. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135296. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135297. autoConfigure(material: NodeMaterial): void;
  135298. protected _buildBlock(state: NodeMaterialBuildState): this;
  135299. protected _dumpPropertiesCode(): string;
  135300. serialize(): any;
  135301. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135302. }
  135303. }
  135304. declare module BABYLON {
  135305. /**
  135306. * Block used to discard a pixel if a value is smaller than a cutoff
  135307. */
  135308. export class DiscardBlock extends NodeMaterialBlock {
  135309. /**
  135310. * Create a new DiscardBlock
  135311. * @param name defines the block name
  135312. */
  135313. constructor(name: string);
  135314. /**
  135315. * Gets the current class name
  135316. * @returns the class name
  135317. */
  135318. getClassName(): string;
  135319. /**
  135320. * Gets the color input component
  135321. */
  135322. get value(): NodeMaterialConnectionPoint;
  135323. /**
  135324. * Gets the cutoff input component
  135325. */
  135326. get cutoff(): NodeMaterialConnectionPoint;
  135327. protected _buildBlock(state: NodeMaterialBuildState): this;
  135328. }
  135329. }
  135330. declare module BABYLON {
  135331. /**
  135332. * Block used to test if the fragment shader is front facing
  135333. */
  135334. export class FrontFacingBlock extends NodeMaterialBlock {
  135335. /**
  135336. * Creates a new FrontFacingBlock
  135337. * @param name defines the block name
  135338. */
  135339. constructor(name: string);
  135340. /**
  135341. * Gets the current class name
  135342. * @returns the class name
  135343. */
  135344. getClassName(): string;
  135345. /**
  135346. * Gets the output component
  135347. */
  135348. get output(): NodeMaterialConnectionPoint;
  135349. protected _buildBlock(state: NodeMaterialBuildState): this;
  135350. }
  135351. }
  135352. declare module BABYLON {
  135353. /**
  135354. * Block used to get the derivative value on x and y of a given input
  135355. */
  135356. export class DerivativeBlock extends NodeMaterialBlock {
  135357. /**
  135358. * Create a new DerivativeBlock
  135359. * @param name defines the block name
  135360. */
  135361. constructor(name: string);
  135362. /**
  135363. * Gets the current class name
  135364. * @returns the class name
  135365. */
  135366. getClassName(): string;
  135367. /**
  135368. * Gets the input component
  135369. */
  135370. get input(): NodeMaterialConnectionPoint;
  135371. /**
  135372. * Gets the derivative output on x
  135373. */
  135374. get dx(): NodeMaterialConnectionPoint;
  135375. /**
  135376. * Gets the derivative output on y
  135377. */
  135378. get dy(): NodeMaterialConnectionPoint;
  135379. protected _buildBlock(state: NodeMaterialBuildState): this;
  135380. }
  135381. }
  135382. declare module BABYLON {
  135383. /**
  135384. * Block used to add support for scene fog
  135385. */
  135386. export class FogBlock extends NodeMaterialBlock {
  135387. private _fogDistanceName;
  135388. private _fogParameters;
  135389. /**
  135390. * Create a new FogBlock
  135391. * @param name defines the block name
  135392. */
  135393. constructor(name: string);
  135394. /**
  135395. * Gets the current class name
  135396. * @returns the class name
  135397. */
  135398. getClassName(): string;
  135399. /**
  135400. * Gets the world position input component
  135401. */
  135402. get worldPosition(): NodeMaterialConnectionPoint;
  135403. /**
  135404. * Gets the view input component
  135405. */
  135406. get view(): NodeMaterialConnectionPoint;
  135407. /**
  135408. * Gets the color input component
  135409. */
  135410. get input(): NodeMaterialConnectionPoint;
  135411. /**
  135412. * Gets the fog color input component
  135413. */
  135414. get fogColor(): NodeMaterialConnectionPoint;
  135415. /**
  135416. * Gets the output component
  135417. */
  135418. get output(): NodeMaterialConnectionPoint;
  135419. autoConfigure(material: NodeMaterial): void;
  135420. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135421. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135422. protected _buildBlock(state: NodeMaterialBuildState): this;
  135423. }
  135424. }
  135425. declare module BABYLON {
  135426. /**
  135427. * Block used to add light in the fragment shader
  135428. */
  135429. export class LightBlock extends NodeMaterialBlock {
  135430. private _lightId;
  135431. /**
  135432. * Gets or sets the light associated with this block
  135433. */
  135434. light: Nullable<Light>;
  135435. /**
  135436. * Create a new LightBlock
  135437. * @param name defines the block name
  135438. */
  135439. constructor(name: string);
  135440. /**
  135441. * Gets the current class name
  135442. * @returns the class name
  135443. */
  135444. getClassName(): string;
  135445. /**
  135446. * Gets the world position input component
  135447. */
  135448. get worldPosition(): NodeMaterialConnectionPoint;
  135449. /**
  135450. * Gets the world normal input component
  135451. */
  135452. get worldNormal(): NodeMaterialConnectionPoint;
  135453. /**
  135454. * Gets the camera (or eye) position component
  135455. */
  135456. get cameraPosition(): NodeMaterialConnectionPoint;
  135457. /**
  135458. * Gets the glossiness component
  135459. */
  135460. get glossiness(): NodeMaterialConnectionPoint;
  135461. /**
  135462. * Gets the glossinness power component
  135463. */
  135464. get glossPower(): NodeMaterialConnectionPoint;
  135465. /**
  135466. * Gets the diffuse color component
  135467. */
  135468. get diffuseColor(): NodeMaterialConnectionPoint;
  135469. /**
  135470. * Gets the specular color component
  135471. */
  135472. get specularColor(): NodeMaterialConnectionPoint;
  135473. /**
  135474. * Gets the diffuse output component
  135475. */
  135476. get diffuseOutput(): NodeMaterialConnectionPoint;
  135477. /**
  135478. * Gets the specular output component
  135479. */
  135480. get specularOutput(): NodeMaterialConnectionPoint;
  135481. /**
  135482. * Gets the shadow output component
  135483. */
  135484. get shadow(): NodeMaterialConnectionPoint;
  135485. autoConfigure(material: NodeMaterial): void;
  135486. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  135487. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  135488. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  135489. private _injectVertexCode;
  135490. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  135491. serialize(): any;
  135492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135493. }
  135494. }
  135495. declare module BABYLON {
  135496. /**
  135497. * Block used to read a reflection texture from a sampler
  135498. */
  135499. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  135500. /**
  135501. * Create a new ReflectionTextureBlock
  135502. * @param name defines the block name
  135503. */
  135504. constructor(name: string);
  135505. /**
  135506. * Gets the current class name
  135507. * @returns the class name
  135508. */
  135509. getClassName(): string;
  135510. /**
  135511. * Gets the world position input component
  135512. */
  135513. get position(): NodeMaterialConnectionPoint;
  135514. /**
  135515. * Gets the world position input component
  135516. */
  135517. get worldPosition(): NodeMaterialConnectionPoint;
  135518. /**
  135519. * Gets the world normal input component
  135520. */
  135521. get worldNormal(): NodeMaterialConnectionPoint;
  135522. /**
  135523. * Gets the world input component
  135524. */
  135525. get world(): NodeMaterialConnectionPoint;
  135526. /**
  135527. * Gets the camera (or eye) position component
  135528. */
  135529. get cameraPosition(): NodeMaterialConnectionPoint;
  135530. /**
  135531. * Gets the view input component
  135532. */
  135533. get view(): NodeMaterialConnectionPoint;
  135534. /**
  135535. * Gets the rgb output component
  135536. */
  135537. get rgb(): NodeMaterialConnectionPoint;
  135538. /**
  135539. * Gets the r output component
  135540. */
  135541. get r(): NodeMaterialConnectionPoint;
  135542. /**
  135543. * Gets the g output component
  135544. */
  135545. get g(): NodeMaterialConnectionPoint;
  135546. /**
  135547. * Gets the b output component
  135548. */
  135549. get b(): NodeMaterialConnectionPoint;
  135550. autoConfigure(material: NodeMaterial): void;
  135551. protected _buildBlock(state: NodeMaterialBuildState): this;
  135552. }
  135553. }
  135554. declare module BABYLON {
  135555. /**
  135556. * Block used to multiply 2 values
  135557. */
  135558. export class MultiplyBlock extends NodeMaterialBlock {
  135559. /**
  135560. * Creates a new MultiplyBlock
  135561. * @param name defines the block name
  135562. */
  135563. constructor(name: string);
  135564. /**
  135565. * Gets the current class name
  135566. * @returns the class name
  135567. */
  135568. getClassName(): string;
  135569. /**
  135570. * Gets the left operand input component
  135571. */
  135572. get left(): NodeMaterialConnectionPoint;
  135573. /**
  135574. * Gets the right operand input component
  135575. */
  135576. get right(): NodeMaterialConnectionPoint;
  135577. /**
  135578. * Gets the output component
  135579. */
  135580. get output(): NodeMaterialConnectionPoint;
  135581. protected _buildBlock(state: NodeMaterialBuildState): this;
  135582. }
  135583. }
  135584. declare module BABYLON {
  135585. /**
  135586. * Block used to add 2 vectors
  135587. */
  135588. export class AddBlock extends NodeMaterialBlock {
  135589. /**
  135590. * Creates a new AddBlock
  135591. * @param name defines the block name
  135592. */
  135593. constructor(name: string);
  135594. /**
  135595. * Gets the current class name
  135596. * @returns the class name
  135597. */
  135598. getClassName(): string;
  135599. /**
  135600. * Gets the left operand input component
  135601. */
  135602. get left(): NodeMaterialConnectionPoint;
  135603. /**
  135604. * Gets the right operand input component
  135605. */
  135606. get right(): NodeMaterialConnectionPoint;
  135607. /**
  135608. * Gets the output component
  135609. */
  135610. get output(): NodeMaterialConnectionPoint;
  135611. protected _buildBlock(state: NodeMaterialBuildState): this;
  135612. }
  135613. }
  135614. declare module BABYLON {
  135615. /**
  135616. * Block used to scale a vector by a float
  135617. */
  135618. export class ScaleBlock extends NodeMaterialBlock {
  135619. /**
  135620. * Creates a new ScaleBlock
  135621. * @param name defines the block name
  135622. */
  135623. constructor(name: string);
  135624. /**
  135625. * Gets the current class name
  135626. * @returns the class name
  135627. */
  135628. getClassName(): string;
  135629. /**
  135630. * Gets the input component
  135631. */
  135632. get input(): NodeMaterialConnectionPoint;
  135633. /**
  135634. * Gets the factor input component
  135635. */
  135636. get factor(): NodeMaterialConnectionPoint;
  135637. /**
  135638. * Gets the output component
  135639. */
  135640. get output(): NodeMaterialConnectionPoint;
  135641. protected _buildBlock(state: NodeMaterialBuildState): this;
  135642. }
  135643. }
  135644. declare module BABYLON {
  135645. /**
  135646. * Block used to clamp a float
  135647. */
  135648. export class ClampBlock extends NodeMaterialBlock {
  135649. /** Gets or sets the minimum range */
  135650. minimum: number;
  135651. /** Gets or sets the maximum range */
  135652. maximum: number;
  135653. /**
  135654. * Creates a new ClampBlock
  135655. * @param name defines the block name
  135656. */
  135657. constructor(name: string);
  135658. /**
  135659. * Gets the current class name
  135660. * @returns the class name
  135661. */
  135662. getClassName(): string;
  135663. /**
  135664. * Gets the value input component
  135665. */
  135666. get value(): NodeMaterialConnectionPoint;
  135667. /**
  135668. * Gets the output component
  135669. */
  135670. get output(): NodeMaterialConnectionPoint;
  135671. protected _buildBlock(state: NodeMaterialBuildState): this;
  135672. protected _dumpPropertiesCode(): string;
  135673. serialize(): any;
  135674. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135675. }
  135676. }
  135677. declare module BABYLON {
  135678. /**
  135679. * Block used to apply a cross product between 2 vectors
  135680. */
  135681. export class CrossBlock extends NodeMaterialBlock {
  135682. /**
  135683. * Creates a new CrossBlock
  135684. * @param name defines the block name
  135685. */
  135686. constructor(name: string);
  135687. /**
  135688. * Gets the current class name
  135689. * @returns the class name
  135690. */
  135691. getClassName(): string;
  135692. /**
  135693. * Gets the left operand input component
  135694. */
  135695. get left(): NodeMaterialConnectionPoint;
  135696. /**
  135697. * Gets the right operand input component
  135698. */
  135699. get right(): NodeMaterialConnectionPoint;
  135700. /**
  135701. * Gets the output component
  135702. */
  135703. get output(): NodeMaterialConnectionPoint;
  135704. protected _buildBlock(state: NodeMaterialBuildState): this;
  135705. }
  135706. }
  135707. declare module BABYLON {
  135708. /**
  135709. * Block used to apply a dot product between 2 vectors
  135710. */
  135711. export class DotBlock extends NodeMaterialBlock {
  135712. /**
  135713. * Creates a new DotBlock
  135714. * @param name defines the block name
  135715. */
  135716. constructor(name: string);
  135717. /**
  135718. * Gets the current class name
  135719. * @returns the class name
  135720. */
  135721. getClassName(): string;
  135722. /**
  135723. * Gets the left operand input component
  135724. */
  135725. get left(): NodeMaterialConnectionPoint;
  135726. /**
  135727. * Gets the right operand input component
  135728. */
  135729. get right(): NodeMaterialConnectionPoint;
  135730. /**
  135731. * Gets the output component
  135732. */
  135733. get output(): NodeMaterialConnectionPoint;
  135734. protected _buildBlock(state: NodeMaterialBuildState): this;
  135735. }
  135736. }
  135737. declare module BABYLON {
  135738. /**
  135739. * Block used to remap a float from a range to a new one
  135740. */
  135741. export class RemapBlock extends NodeMaterialBlock {
  135742. /**
  135743. * Gets or sets the source range
  135744. */
  135745. sourceRange: Vector2;
  135746. /**
  135747. * Gets or sets the target range
  135748. */
  135749. targetRange: Vector2;
  135750. /**
  135751. * Creates a new RemapBlock
  135752. * @param name defines the block name
  135753. */
  135754. constructor(name: string);
  135755. /**
  135756. * Gets the current class name
  135757. * @returns the class name
  135758. */
  135759. getClassName(): string;
  135760. /**
  135761. * Gets the input component
  135762. */
  135763. get input(): NodeMaterialConnectionPoint;
  135764. /**
  135765. * Gets the source min input component
  135766. */
  135767. get sourceMin(): NodeMaterialConnectionPoint;
  135768. /**
  135769. * Gets the source max input component
  135770. */
  135771. get sourceMax(): NodeMaterialConnectionPoint;
  135772. /**
  135773. * Gets the target min input component
  135774. */
  135775. get targetMin(): NodeMaterialConnectionPoint;
  135776. /**
  135777. * Gets the target max input component
  135778. */
  135779. get targetMax(): NodeMaterialConnectionPoint;
  135780. /**
  135781. * Gets the output component
  135782. */
  135783. get output(): NodeMaterialConnectionPoint;
  135784. protected _buildBlock(state: NodeMaterialBuildState): this;
  135785. protected _dumpPropertiesCode(): string;
  135786. serialize(): any;
  135787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135788. }
  135789. }
  135790. declare module BABYLON {
  135791. /**
  135792. * Block used to normalize a vector
  135793. */
  135794. export class NormalizeBlock extends NodeMaterialBlock {
  135795. /**
  135796. * Creates a new NormalizeBlock
  135797. * @param name defines the block name
  135798. */
  135799. constructor(name: string);
  135800. /**
  135801. * Gets the current class name
  135802. * @returns the class name
  135803. */
  135804. getClassName(): string;
  135805. /**
  135806. * Gets the input component
  135807. */
  135808. get input(): NodeMaterialConnectionPoint;
  135809. /**
  135810. * Gets the output component
  135811. */
  135812. get output(): NodeMaterialConnectionPoint;
  135813. protected _buildBlock(state: NodeMaterialBuildState): this;
  135814. }
  135815. }
  135816. declare module BABYLON {
  135817. /**
  135818. * Operations supported by the Trigonometry block
  135819. */
  135820. export enum TrigonometryBlockOperations {
  135821. /** Cos */
  135822. Cos = 0,
  135823. /** Sin */
  135824. Sin = 1,
  135825. /** Abs */
  135826. Abs = 2,
  135827. /** Exp */
  135828. Exp = 3,
  135829. /** Exp2 */
  135830. Exp2 = 4,
  135831. /** Round */
  135832. Round = 5,
  135833. /** Floor */
  135834. Floor = 6,
  135835. /** Ceiling */
  135836. Ceiling = 7,
  135837. /** Square root */
  135838. Sqrt = 8,
  135839. /** Log */
  135840. Log = 9,
  135841. /** Tangent */
  135842. Tan = 10,
  135843. /** Arc tangent */
  135844. ArcTan = 11,
  135845. /** Arc cosinus */
  135846. ArcCos = 12,
  135847. /** Arc sinus */
  135848. ArcSin = 13,
  135849. /** Fraction */
  135850. Fract = 14,
  135851. /** Sign */
  135852. Sign = 15,
  135853. /** To radians (from degrees) */
  135854. Radians = 16,
  135855. /** To degrees (from radians) */
  135856. Degrees = 17
  135857. }
  135858. /**
  135859. * Block used to apply trigonometry operation to floats
  135860. */
  135861. export class TrigonometryBlock extends NodeMaterialBlock {
  135862. /**
  135863. * Gets or sets the operation applied by the block
  135864. */
  135865. operation: TrigonometryBlockOperations;
  135866. /**
  135867. * Creates a new TrigonometryBlock
  135868. * @param name defines the block name
  135869. */
  135870. constructor(name: string);
  135871. /**
  135872. * Gets the current class name
  135873. * @returns the class name
  135874. */
  135875. getClassName(): string;
  135876. /**
  135877. * Gets the input component
  135878. */
  135879. get input(): NodeMaterialConnectionPoint;
  135880. /**
  135881. * Gets the output component
  135882. */
  135883. get output(): NodeMaterialConnectionPoint;
  135884. protected _buildBlock(state: NodeMaterialBuildState): this;
  135885. serialize(): any;
  135886. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  135887. protected _dumpPropertiesCode(): string;
  135888. }
  135889. }
  135890. declare module BABYLON {
  135891. /**
  135892. * Block used to create a Color3/4 out of individual inputs (one for each component)
  135893. */
  135894. export class ColorMergerBlock extends NodeMaterialBlock {
  135895. /**
  135896. * Create a new ColorMergerBlock
  135897. * @param name defines the block name
  135898. */
  135899. constructor(name: string);
  135900. /**
  135901. * Gets the current class name
  135902. * @returns the class name
  135903. */
  135904. getClassName(): string;
  135905. /**
  135906. * Gets the rgb component (input)
  135907. */
  135908. get rgbIn(): NodeMaterialConnectionPoint;
  135909. /**
  135910. * Gets the r component (input)
  135911. */
  135912. get r(): NodeMaterialConnectionPoint;
  135913. /**
  135914. * Gets the g component (input)
  135915. */
  135916. get g(): NodeMaterialConnectionPoint;
  135917. /**
  135918. * Gets the b component (input)
  135919. */
  135920. get b(): NodeMaterialConnectionPoint;
  135921. /**
  135922. * Gets the a component (input)
  135923. */
  135924. get a(): NodeMaterialConnectionPoint;
  135925. /**
  135926. * Gets the rgba component (output)
  135927. */
  135928. get rgba(): NodeMaterialConnectionPoint;
  135929. /**
  135930. * Gets the rgb component (output)
  135931. */
  135932. get rgbOut(): NodeMaterialConnectionPoint;
  135933. /**
  135934. * Gets the rgb component (output)
  135935. * @deprecated Please use rgbOut instead.
  135936. */
  135937. get rgb(): NodeMaterialConnectionPoint;
  135938. protected _buildBlock(state: NodeMaterialBuildState): this;
  135939. }
  135940. }
  135941. declare module BABYLON {
  135942. /**
  135943. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  135944. */
  135945. export class VectorMergerBlock extends NodeMaterialBlock {
  135946. /**
  135947. * Create a new VectorMergerBlock
  135948. * @param name defines the block name
  135949. */
  135950. constructor(name: string);
  135951. /**
  135952. * Gets the current class name
  135953. * @returns the class name
  135954. */
  135955. getClassName(): string;
  135956. /**
  135957. * Gets the xyz component (input)
  135958. */
  135959. get xyzIn(): NodeMaterialConnectionPoint;
  135960. /**
  135961. * Gets the xy component (input)
  135962. */
  135963. get xyIn(): NodeMaterialConnectionPoint;
  135964. /**
  135965. * Gets the x component (input)
  135966. */
  135967. get x(): NodeMaterialConnectionPoint;
  135968. /**
  135969. * Gets the y component (input)
  135970. */
  135971. get y(): NodeMaterialConnectionPoint;
  135972. /**
  135973. * Gets the z component (input)
  135974. */
  135975. get z(): NodeMaterialConnectionPoint;
  135976. /**
  135977. * Gets the w component (input)
  135978. */
  135979. get w(): NodeMaterialConnectionPoint;
  135980. /**
  135981. * Gets the xyzw component (output)
  135982. */
  135983. get xyzw(): NodeMaterialConnectionPoint;
  135984. /**
  135985. * Gets the xyz component (output)
  135986. */
  135987. get xyzOut(): NodeMaterialConnectionPoint;
  135988. /**
  135989. * Gets the xy component (output)
  135990. */
  135991. get xyOut(): NodeMaterialConnectionPoint;
  135992. /**
  135993. * Gets the xy component (output)
  135994. * @deprecated Please use xyOut instead.
  135995. */
  135996. get xy(): NodeMaterialConnectionPoint;
  135997. /**
  135998. * Gets the xyz component (output)
  135999. * @deprecated Please use xyzOut instead.
  136000. */
  136001. get xyz(): NodeMaterialConnectionPoint;
  136002. protected _buildBlock(state: NodeMaterialBuildState): this;
  136003. }
  136004. }
  136005. declare module BABYLON {
  136006. /**
  136007. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  136008. */
  136009. export class ColorSplitterBlock extends NodeMaterialBlock {
  136010. /**
  136011. * Create a new ColorSplitterBlock
  136012. * @param name defines the block name
  136013. */
  136014. constructor(name: string);
  136015. /**
  136016. * Gets the current class name
  136017. * @returns the class name
  136018. */
  136019. getClassName(): string;
  136020. /**
  136021. * Gets the rgba component (input)
  136022. */
  136023. get rgba(): NodeMaterialConnectionPoint;
  136024. /**
  136025. * Gets the rgb component (input)
  136026. */
  136027. get rgbIn(): NodeMaterialConnectionPoint;
  136028. /**
  136029. * Gets the rgb component (output)
  136030. */
  136031. get rgbOut(): NodeMaterialConnectionPoint;
  136032. /**
  136033. * Gets the r component (output)
  136034. */
  136035. get r(): NodeMaterialConnectionPoint;
  136036. /**
  136037. * Gets the g component (output)
  136038. */
  136039. get g(): NodeMaterialConnectionPoint;
  136040. /**
  136041. * Gets the b component (output)
  136042. */
  136043. get b(): NodeMaterialConnectionPoint;
  136044. /**
  136045. * Gets the a component (output)
  136046. */
  136047. get a(): NodeMaterialConnectionPoint;
  136048. protected _inputRename(name: string): string;
  136049. protected _outputRename(name: string): string;
  136050. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136051. }
  136052. }
  136053. declare module BABYLON {
  136054. /**
  136055. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  136056. */
  136057. export class VectorSplitterBlock extends NodeMaterialBlock {
  136058. /**
  136059. * Create a new VectorSplitterBlock
  136060. * @param name defines the block name
  136061. */
  136062. constructor(name: string);
  136063. /**
  136064. * Gets the current class name
  136065. * @returns the class name
  136066. */
  136067. getClassName(): string;
  136068. /**
  136069. * Gets the xyzw component (input)
  136070. */
  136071. get xyzw(): NodeMaterialConnectionPoint;
  136072. /**
  136073. * Gets the xyz component (input)
  136074. */
  136075. get xyzIn(): NodeMaterialConnectionPoint;
  136076. /**
  136077. * Gets the xy component (input)
  136078. */
  136079. get xyIn(): NodeMaterialConnectionPoint;
  136080. /**
  136081. * Gets the xyz component (output)
  136082. */
  136083. get xyzOut(): NodeMaterialConnectionPoint;
  136084. /**
  136085. * Gets the xy component (output)
  136086. */
  136087. get xyOut(): NodeMaterialConnectionPoint;
  136088. /**
  136089. * Gets the x component (output)
  136090. */
  136091. get x(): NodeMaterialConnectionPoint;
  136092. /**
  136093. * Gets the y component (output)
  136094. */
  136095. get y(): NodeMaterialConnectionPoint;
  136096. /**
  136097. * Gets the z component (output)
  136098. */
  136099. get z(): NodeMaterialConnectionPoint;
  136100. /**
  136101. * Gets the w component (output)
  136102. */
  136103. get w(): NodeMaterialConnectionPoint;
  136104. protected _inputRename(name: string): string;
  136105. protected _outputRename(name: string): string;
  136106. protected _buildBlock(state: NodeMaterialBuildState): this;
  136107. }
  136108. }
  136109. declare module BABYLON {
  136110. /**
  136111. * Block used to lerp between 2 values
  136112. */
  136113. export class LerpBlock extends NodeMaterialBlock {
  136114. /**
  136115. * Creates a new LerpBlock
  136116. * @param name defines the block name
  136117. */
  136118. constructor(name: string);
  136119. /**
  136120. * Gets the current class name
  136121. * @returns the class name
  136122. */
  136123. getClassName(): string;
  136124. /**
  136125. * Gets the left operand input component
  136126. */
  136127. get left(): NodeMaterialConnectionPoint;
  136128. /**
  136129. * Gets the right operand input component
  136130. */
  136131. get right(): NodeMaterialConnectionPoint;
  136132. /**
  136133. * Gets the gradient operand input component
  136134. */
  136135. get gradient(): NodeMaterialConnectionPoint;
  136136. /**
  136137. * Gets the output component
  136138. */
  136139. get output(): NodeMaterialConnectionPoint;
  136140. protected _buildBlock(state: NodeMaterialBuildState): this;
  136141. }
  136142. }
  136143. declare module BABYLON {
  136144. /**
  136145. * Block used to divide 2 vectors
  136146. */
  136147. export class DivideBlock extends NodeMaterialBlock {
  136148. /**
  136149. * Creates a new DivideBlock
  136150. * @param name defines the block name
  136151. */
  136152. constructor(name: string);
  136153. /**
  136154. * Gets the current class name
  136155. * @returns the class name
  136156. */
  136157. getClassName(): string;
  136158. /**
  136159. * Gets the left operand input component
  136160. */
  136161. get left(): NodeMaterialConnectionPoint;
  136162. /**
  136163. * Gets the right operand input component
  136164. */
  136165. get right(): NodeMaterialConnectionPoint;
  136166. /**
  136167. * Gets the output component
  136168. */
  136169. get output(): NodeMaterialConnectionPoint;
  136170. protected _buildBlock(state: NodeMaterialBuildState): this;
  136171. }
  136172. }
  136173. declare module BABYLON {
  136174. /**
  136175. * Block used to subtract 2 vectors
  136176. */
  136177. export class SubtractBlock extends NodeMaterialBlock {
  136178. /**
  136179. * Creates a new SubtractBlock
  136180. * @param name defines the block name
  136181. */
  136182. constructor(name: string);
  136183. /**
  136184. * Gets the current class name
  136185. * @returns the class name
  136186. */
  136187. getClassName(): string;
  136188. /**
  136189. * Gets the left operand input component
  136190. */
  136191. get left(): NodeMaterialConnectionPoint;
  136192. /**
  136193. * Gets the right operand input component
  136194. */
  136195. get right(): NodeMaterialConnectionPoint;
  136196. /**
  136197. * Gets the output component
  136198. */
  136199. get output(): NodeMaterialConnectionPoint;
  136200. protected _buildBlock(state: NodeMaterialBuildState): this;
  136201. }
  136202. }
  136203. declare module BABYLON {
  136204. /**
  136205. * Block used to step a value
  136206. */
  136207. export class StepBlock extends NodeMaterialBlock {
  136208. /**
  136209. * Creates a new StepBlock
  136210. * @param name defines the block name
  136211. */
  136212. constructor(name: string);
  136213. /**
  136214. * Gets the current class name
  136215. * @returns the class name
  136216. */
  136217. getClassName(): string;
  136218. /**
  136219. * Gets the value operand input component
  136220. */
  136221. get value(): NodeMaterialConnectionPoint;
  136222. /**
  136223. * Gets the edge operand input component
  136224. */
  136225. get edge(): NodeMaterialConnectionPoint;
  136226. /**
  136227. * Gets the output component
  136228. */
  136229. get output(): NodeMaterialConnectionPoint;
  136230. protected _buildBlock(state: NodeMaterialBuildState): this;
  136231. }
  136232. }
  136233. declare module BABYLON {
  136234. /**
  136235. * Block used to get the opposite (1 - x) of a value
  136236. */
  136237. export class OneMinusBlock extends NodeMaterialBlock {
  136238. /**
  136239. * Creates a new OneMinusBlock
  136240. * @param name defines the block name
  136241. */
  136242. constructor(name: string);
  136243. /**
  136244. * Gets the current class name
  136245. * @returns the class name
  136246. */
  136247. getClassName(): string;
  136248. /**
  136249. * Gets the input component
  136250. */
  136251. get input(): NodeMaterialConnectionPoint;
  136252. /**
  136253. * Gets the output component
  136254. */
  136255. get output(): NodeMaterialConnectionPoint;
  136256. protected _buildBlock(state: NodeMaterialBuildState): this;
  136257. }
  136258. }
  136259. declare module BABYLON {
  136260. /**
  136261. * Block used to get the view direction
  136262. */
  136263. export class ViewDirectionBlock extends NodeMaterialBlock {
  136264. /**
  136265. * Creates a new ViewDirectionBlock
  136266. * @param name defines the block name
  136267. */
  136268. constructor(name: string);
  136269. /**
  136270. * Gets the current class name
  136271. * @returns the class name
  136272. */
  136273. getClassName(): string;
  136274. /**
  136275. * Gets the world position component
  136276. */
  136277. get worldPosition(): NodeMaterialConnectionPoint;
  136278. /**
  136279. * Gets the camera position component
  136280. */
  136281. get cameraPosition(): NodeMaterialConnectionPoint;
  136282. /**
  136283. * Gets the output component
  136284. */
  136285. get output(): NodeMaterialConnectionPoint;
  136286. autoConfigure(material: NodeMaterial): void;
  136287. protected _buildBlock(state: NodeMaterialBuildState): this;
  136288. }
  136289. }
  136290. declare module BABYLON {
  136291. /**
  136292. * Block used to compute fresnel value
  136293. */
  136294. export class FresnelBlock extends NodeMaterialBlock {
  136295. /**
  136296. * Create a new FresnelBlock
  136297. * @param name defines the block name
  136298. */
  136299. constructor(name: string);
  136300. /**
  136301. * Gets the current class name
  136302. * @returns the class name
  136303. */
  136304. getClassName(): string;
  136305. /**
  136306. * Gets the world normal input component
  136307. */
  136308. get worldNormal(): NodeMaterialConnectionPoint;
  136309. /**
  136310. * Gets the view direction input component
  136311. */
  136312. get viewDirection(): NodeMaterialConnectionPoint;
  136313. /**
  136314. * Gets the bias input component
  136315. */
  136316. get bias(): NodeMaterialConnectionPoint;
  136317. /**
  136318. * Gets the camera (or eye) position component
  136319. */
  136320. get power(): NodeMaterialConnectionPoint;
  136321. /**
  136322. * Gets the fresnel output component
  136323. */
  136324. get fresnel(): NodeMaterialConnectionPoint;
  136325. autoConfigure(material: NodeMaterial): void;
  136326. protected _buildBlock(state: NodeMaterialBuildState): this;
  136327. }
  136328. }
  136329. declare module BABYLON {
  136330. /**
  136331. * Block used to get the max of 2 values
  136332. */
  136333. export class MaxBlock extends NodeMaterialBlock {
  136334. /**
  136335. * Creates a new MaxBlock
  136336. * @param name defines the block name
  136337. */
  136338. constructor(name: string);
  136339. /**
  136340. * Gets the current class name
  136341. * @returns the class name
  136342. */
  136343. getClassName(): string;
  136344. /**
  136345. * Gets the left operand input component
  136346. */
  136347. get left(): NodeMaterialConnectionPoint;
  136348. /**
  136349. * Gets the right operand input component
  136350. */
  136351. get right(): NodeMaterialConnectionPoint;
  136352. /**
  136353. * Gets the output component
  136354. */
  136355. get output(): NodeMaterialConnectionPoint;
  136356. protected _buildBlock(state: NodeMaterialBuildState): this;
  136357. }
  136358. }
  136359. declare module BABYLON {
  136360. /**
  136361. * Block used to get the min of 2 values
  136362. */
  136363. export class MinBlock extends NodeMaterialBlock {
  136364. /**
  136365. * Creates a new MinBlock
  136366. * @param name defines the block name
  136367. */
  136368. constructor(name: string);
  136369. /**
  136370. * Gets the current class name
  136371. * @returns the class name
  136372. */
  136373. getClassName(): string;
  136374. /**
  136375. * Gets the left operand input component
  136376. */
  136377. get left(): NodeMaterialConnectionPoint;
  136378. /**
  136379. * Gets the right operand input component
  136380. */
  136381. get right(): NodeMaterialConnectionPoint;
  136382. /**
  136383. * Gets the output component
  136384. */
  136385. get output(): NodeMaterialConnectionPoint;
  136386. protected _buildBlock(state: NodeMaterialBuildState): this;
  136387. }
  136388. }
  136389. declare module BABYLON {
  136390. /**
  136391. * Block used to get the distance between 2 values
  136392. */
  136393. export class DistanceBlock extends NodeMaterialBlock {
  136394. /**
  136395. * Creates a new DistanceBlock
  136396. * @param name defines the block name
  136397. */
  136398. constructor(name: string);
  136399. /**
  136400. * Gets the current class name
  136401. * @returns the class name
  136402. */
  136403. getClassName(): string;
  136404. /**
  136405. * Gets the left operand input component
  136406. */
  136407. get left(): NodeMaterialConnectionPoint;
  136408. /**
  136409. * Gets the right operand input component
  136410. */
  136411. get right(): NodeMaterialConnectionPoint;
  136412. /**
  136413. * Gets the output component
  136414. */
  136415. get output(): NodeMaterialConnectionPoint;
  136416. protected _buildBlock(state: NodeMaterialBuildState): this;
  136417. }
  136418. }
  136419. declare module BABYLON {
  136420. /**
  136421. * Block used to get the length of a vector
  136422. */
  136423. export class LengthBlock extends NodeMaterialBlock {
  136424. /**
  136425. * Creates a new LengthBlock
  136426. * @param name defines the block name
  136427. */
  136428. constructor(name: string);
  136429. /**
  136430. * Gets the current class name
  136431. * @returns the class name
  136432. */
  136433. getClassName(): string;
  136434. /**
  136435. * Gets the value input component
  136436. */
  136437. get value(): NodeMaterialConnectionPoint;
  136438. /**
  136439. * Gets the output component
  136440. */
  136441. get output(): NodeMaterialConnectionPoint;
  136442. protected _buildBlock(state: NodeMaterialBuildState): this;
  136443. }
  136444. }
  136445. declare module BABYLON {
  136446. /**
  136447. * Block used to get negative version of a value (i.e. x * -1)
  136448. */
  136449. export class NegateBlock extends NodeMaterialBlock {
  136450. /**
  136451. * Creates a new NegateBlock
  136452. * @param name defines the block name
  136453. */
  136454. constructor(name: string);
  136455. /**
  136456. * Gets the current class name
  136457. * @returns the class name
  136458. */
  136459. getClassName(): string;
  136460. /**
  136461. * Gets the value input component
  136462. */
  136463. get value(): NodeMaterialConnectionPoint;
  136464. /**
  136465. * Gets the output component
  136466. */
  136467. get output(): NodeMaterialConnectionPoint;
  136468. protected _buildBlock(state: NodeMaterialBuildState): this;
  136469. }
  136470. }
  136471. declare module BABYLON {
  136472. /**
  136473. * Block used to get the value of the first parameter raised to the power of the second
  136474. */
  136475. export class PowBlock extends NodeMaterialBlock {
  136476. /**
  136477. * Creates a new PowBlock
  136478. * @param name defines the block name
  136479. */
  136480. constructor(name: string);
  136481. /**
  136482. * Gets the current class name
  136483. * @returns the class name
  136484. */
  136485. getClassName(): string;
  136486. /**
  136487. * Gets the value operand input component
  136488. */
  136489. get value(): NodeMaterialConnectionPoint;
  136490. /**
  136491. * Gets the power operand input component
  136492. */
  136493. get power(): NodeMaterialConnectionPoint;
  136494. /**
  136495. * Gets the output component
  136496. */
  136497. get output(): NodeMaterialConnectionPoint;
  136498. protected _buildBlock(state: NodeMaterialBuildState): this;
  136499. }
  136500. }
  136501. declare module BABYLON {
  136502. /**
  136503. * Block used to get a random number
  136504. */
  136505. export class RandomNumberBlock extends NodeMaterialBlock {
  136506. /**
  136507. * Creates a new RandomNumberBlock
  136508. * @param name defines the block name
  136509. */
  136510. constructor(name: string);
  136511. /**
  136512. * Gets the current class name
  136513. * @returns the class name
  136514. */
  136515. getClassName(): string;
  136516. /**
  136517. * Gets the seed input component
  136518. */
  136519. get seed(): NodeMaterialConnectionPoint;
  136520. /**
  136521. * Gets the output component
  136522. */
  136523. get output(): NodeMaterialConnectionPoint;
  136524. protected _buildBlock(state: NodeMaterialBuildState): this;
  136525. }
  136526. }
  136527. declare module BABYLON {
  136528. /**
  136529. * Block used to compute arc tangent of 2 values
  136530. */
  136531. export class ArcTan2Block extends NodeMaterialBlock {
  136532. /**
  136533. * Creates a new ArcTan2Block
  136534. * @param name defines the block name
  136535. */
  136536. constructor(name: string);
  136537. /**
  136538. * Gets the current class name
  136539. * @returns the class name
  136540. */
  136541. getClassName(): string;
  136542. /**
  136543. * Gets the x operand input component
  136544. */
  136545. get x(): NodeMaterialConnectionPoint;
  136546. /**
  136547. * Gets the y operand input component
  136548. */
  136549. get y(): NodeMaterialConnectionPoint;
  136550. /**
  136551. * Gets the output component
  136552. */
  136553. get output(): NodeMaterialConnectionPoint;
  136554. protected _buildBlock(state: NodeMaterialBuildState): this;
  136555. }
  136556. }
  136557. declare module BABYLON {
  136558. /**
  136559. * Block used to smooth step a value
  136560. */
  136561. export class SmoothStepBlock extends NodeMaterialBlock {
  136562. /**
  136563. * Creates a new SmoothStepBlock
  136564. * @param name defines the block name
  136565. */
  136566. constructor(name: string);
  136567. /**
  136568. * Gets the current class name
  136569. * @returns the class name
  136570. */
  136571. getClassName(): string;
  136572. /**
  136573. * Gets the value operand input component
  136574. */
  136575. get value(): NodeMaterialConnectionPoint;
  136576. /**
  136577. * Gets the first edge operand input component
  136578. */
  136579. get edge0(): NodeMaterialConnectionPoint;
  136580. /**
  136581. * Gets the second edge operand input component
  136582. */
  136583. get edge1(): NodeMaterialConnectionPoint;
  136584. /**
  136585. * Gets the output component
  136586. */
  136587. get output(): NodeMaterialConnectionPoint;
  136588. protected _buildBlock(state: NodeMaterialBuildState): this;
  136589. }
  136590. }
  136591. declare module BABYLON {
  136592. /**
  136593. * Block used to get the reciprocal (1 / x) of a value
  136594. */
  136595. export class ReciprocalBlock extends NodeMaterialBlock {
  136596. /**
  136597. * Creates a new ReciprocalBlock
  136598. * @param name defines the block name
  136599. */
  136600. constructor(name: string);
  136601. /**
  136602. * Gets the current class name
  136603. * @returns the class name
  136604. */
  136605. getClassName(): string;
  136606. /**
  136607. * Gets the input component
  136608. */
  136609. get input(): NodeMaterialConnectionPoint;
  136610. /**
  136611. * Gets the output component
  136612. */
  136613. get output(): NodeMaterialConnectionPoint;
  136614. protected _buildBlock(state: NodeMaterialBuildState): this;
  136615. }
  136616. }
  136617. declare module BABYLON {
  136618. /**
  136619. * Block used to replace a color by another one
  136620. */
  136621. export class ReplaceColorBlock extends NodeMaterialBlock {
  136622. /**
  136623. * Creates a new ReplaceColorBlock
  136624. * @param name defines the block name
  136625. */
  136626. constructor(name: string);
  136627. /**
  136628. * Gets the current class name
  136629. * @returns the class name
  136630. */
  136631. getClassName(): string;
  136632. /**
  136633. * Gets the value input component
  136634. */
  136635. get value(): NodeMaterialConnectionPoint;
  136636. /**
  136637. * Gets the reference input component
  136638. */
  136639. get reference(): NodeMaterialConnectionPoint;
  136640. /**
  136641. * Gets the distance input component
  136642. */
  136643. get distance(): NodeMaterialConnectionPoint;
  136644. /**
  136645. * Gets the replacement input component
  136646. */
  136647. get replacement(): NodeMaterialConnectionPoint;
  136648. /**
  136649. * Gets the output component
  136650. */
  136651. get output(): NodeMaterialConnectionPoint;
  136652. protected _buildBlock(state: NodeMaterialBuildState): this;
  136653. }
  136654. }
  136655. declare module BABYLON {
  136656. /**
  136657. * Block used to posterize a value
  136658. * @see https://en.wikipedia.org/wiki/Posterization
  136659. */
  136660. export class PosterizeBlock extends NodeMaterialBlock {
  136661. /**
  136662. * Creates a new PosterizeBlock
  136663. * @param name defines the block name
  136664. */
  136665. constructor(name: string);
  136666. /**
  136667. * Gets the current class name
  136668. * @returns the class name
  136669. */
  136670. getClassName(): string;
  136671. /**
  136672. * Gets the value input component
  136673. */
  136674. get value(): NodeMaterialConnectionPoint;
  136675. /**
  136676. * Gets the steps input component
  136677. */
  136678. get steps(): NodeMaterialConnectionPoint;
  136679. /**
  136680. * Gets the output component
  136681. */
  136682. get output(): NodeMaterialConnectionPoint;
  136683. protected _buildBlock(state: NodeMaterialBuildState): this;
  136684. }
  136685. }
  136686. declare module BABYLON {
  136687. /**
  136688. * Operations supported by the Wave block
  136689. */
  136690. export enum WaveBlockKind {
  136691. /** SawTooth */
  136692. SawTooth = 0,
  136693. /** Square */
  136694. Square = 1,
  136695. /** Triangle */
  136696. Triangle = 2
  136697. }
  136698. /**
  136699. * Block used to apply wave operation to floats
  136700. */
  136701. export class WaveBlock extends NodeMaterialBlock {
  136702. /**
  136703. * Gets or sets the kibnd of wave to be applied by the block
  136704. */
  136705. kind: WaveBlockKind;
  136706. /**
  136707. * Creates a new WaveBlock
  136708. * @param name defines the block name
  136709. */
  136710. constructor(name: string);
  136711. /**
  136712. * Gets the current class name
  136713. * @returns the class name
  136714. */
  136715. getClassName(): string;
  136716. /**
  136717. * Gets the input component
  136718. */
  136719. get input(): NodeMaterialConnectionPoint;
  136720. /**
  136721. * Gets the output component
  136722. */
  136723. get output(): NodeMaterialConnectionPoint;
  136724. protected _buildBlock(state: NodeMaterialBuildState): this;
  136725. serialize(): any;
  136726. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136727. }
  136728. }
  136729. declare module BABYLON {
  136730. /**
  136731. * Class used to store a color step for the GradientBlock
  136732. */
  136733. export class GradientBlockColorStep {
  136734. /**
  136735. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  136736. */
  136737. step: number;
  136738. /**
  136739. * Gets or sets the color associated with this step
  136740. */
  136741. color: Color3;
  136742. /**
  136743. * Creates a new GradientBlockColorStep
  136744. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  136745. * @param color defines the color associated with this step
  136746. */
  136747. constructor(
  136748. /**
  136749. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  136750. */
  136751. step: number,
  136752. /**
  136753. * Gets or sets the color associated with this step
  136754. */
  136755. color: Color3);
  136756. }
  136757. /**
  136758. * Block used to return a color from a gradient based on an input value between 0 and 1
  136759. */
  136760. export class GradientBlock extends NodeMaterialBlock {
  136761. /**
  136762. * Gets or sets the list of color steps
  136763. */
  136764. colorSteps: GradientBlockColorStep[];
  136765. /**
  136766. * Creates a new GradientBlock
  136767. * @param name defines the block name
  136768. */
  136769. constructor(name: string);
  136770. /**
  136771. * Gets the current class name
  136772. * @returns the class name
  136773. */
  136774. getClassName(): string;
  136775. /**
  136776. * Gets the gradient input component
  136777. */
  136778. get gradient(): NodeMaterialConnectionPoint;
  136779. /**
  136780. * Gets the output component
  136781. */
  136782. get output(): NodeMaterialConnectionPoint;
  136783. private _writeColorConstant;
  136784. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136785. serialize(): any;
  136786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136787. protected _dumpPropertiesCode(): string;
  136788. }
  136789. }
  136790. declare module BABYLON {
  136791. /**
  136792. * Block used to normalize lerp between 2 values
  136793. */
  136794. export class NLerpBlock extends NodeMaterialBlock {
  136795. /**
  136796. * Creates a new NLerpBlock
  136797. * @param name defines the block name
  136798. */
  136799. constructor(name: string);
  136800. /**
  136801. * Gets the current class name
  136802. * @returns the class name
  136803. */
  136804. getClassName(): string;
  136805. /**
  136806. * Gets the left operand input component
  136807. */
  136808. get left(): NodeMaterialConnectionPoint;
  136809. /**
  136810. * Gets the right operand input component
  136811. */
  136812. get right(): NodeMaterialConnectionPoint;
  136813. /**
  136814. * Gets the gradient operand input component
  136815. */
  136816. get gradient(): NodeMaterialConnectionPoint;
  136817. /**
  136818. * Gets the output component
  136819. */
  136820. get output(): NodeMaterialConnectionPoint;
  136821. protected _buildBlock(state: NodeMaterialBuildState): this;
  136822. }
  136823. }
  136824. declare module BABYLON {
  136825. /**
  136826. * block used to Generate a Worley Noise 3D Noise Pattern
  136827. */
  136828. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  136829. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  136830. manhattanDistance: boolean;
  136831. /**
  136832. * Creates a new WorleyNoise3DBlock
  136833. * @param name defines the block name
  136834. */
  136835. constructor(name: string);
  136836. /**
  136837. * Gets the current class name
  136838. * @returns the class name
  136839. */
  136840. getClassName(): string;
  136841. /**
  136842. * Gets the seed input component
  136843. */
  136844. get seed(): NodeMaterialConnectionPoint;
  136845. /**
  136846. * Gets the jitter input component
  136847. */
  136848. get jitter(): NodeMaterialConnectionPoint;
  136849. /**
  136850. * Gets the output component
  136851. */
  136852. get output(): NodeMaterialConnectionPoint;
  136853. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136854. /**
  136855. * Exposes the properties to the UI?
  136856. */
  136857. protected _dumpPropertiesCode(): string;
  136858. /**
  136859. * Exposes the properties to the Seralize?
  136860. */
  136861. serialize(): any;
  136862. /**
  136863. * Exposes the properties to the deseralize?
  136864. */
  136865. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  136866. }
  136867. }
  136868. declare module BABYLON {
  136869. /**
  136870. * block used to Generate a Simplex Perlin 3d Noise Pattern
  136871. */
  136872. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  136873. /**
  136874. * Creates a new SimplexPerlin3DBlock
  136875. * @param name defines the block name
  136876. */
  136877. constructor(name: string);
  136878. /**
  136879. * Gets the current class name
  136880. * @returns the class name
  136881. */
  136882. getClassName(): string;
  136883. /**
  136884. * Gets the seed operand input component
  136885. */
  136886. get seed(): NodeMaterialConnectionPoint;
  136887. /**
  136888. * Gets the output component
  136889. */
  136890. get output(): NodeMaterialConnectionPoint;
  136891. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  136892. }
  136893. }
  136894. declare module BABYLON {
  136895. /**
  136896. * Block used to blend normals
  136897. */
  136898. export class NormalBlendBlock extends NodeMaterialBlock {
  136899. /**
  136900. * Creates a new NormalBlendBlock
  136901. * @param name defines the block name
  136902. */
  136903. constructor(name: string);
  136904. /**
  136905. * Gets the current class name
  136906. * @returns the class name
  136907. */
  136908. getClassName(): string;
  136909. /**
  136910. * Gets the first input component
  136911. */
  136912. get normalMap0(): NodeMaterialConnectionPoint;
  136913. /**
  136914. * Gets the second input component
  136915. */
  136916. get normalMap1(): NodeMaterialConnectionPoint;
  136917. /**
  136918. * Gets the output component
  136919. */
  136920. get output(): NodeMaterialConnectionPoint;
  136921. protected _buildBlock(state: NodeMaterialBuildState): this;
  136922. }
  136923. }
  136924. declare module BABYLON {
  136925. /**
  136926. * Block used to rotate a 2d vector by a given angle
  136927. */
  136928. export class Rotate2dBlock extends NodeMaterialBlock {
  136929. /**
  136930. * Creates a new Rotate2dBlock
  136931. * @param name defines the block name
  136932. */
  136933. constructor(name: string);
  136934. /**
  136935. * Gets the current class name
  136936. * @returns the class name
  136937. */
  136938. getClassName(): string;
  136939. /**
  136940. * Gets the input vector
  136941. */
  136942. get input(): NodeMaterialConnectionPoint;
  136943. /**
  136944. * Gets the input angle
  136945. */
  136946. get angle(): NodeMaterialConnectionPoint;
  136947. /**
  136948. * Gets the output component
  136949. */
  136950. get output(): NodeMaterialConnectionPoint;
  136951. autoConfigure(material: NodeMaterial): void;
  136952. protected _buildBlock(state: NodeMaterialBuildState): this;
  136953. }
  136954. }
  136955. declare module BABYLON {
  136956. /**
  136957. * Block used to get the reflected vector from a direction and a normal
  136958. */
  136959. export class ReflectBlock extends NodeMaterialBlock {
  136960. /**
  136961. * Creates a new ReflectBlock
  136962. * @param name defines the block name
  136963. */
  136964. constructor(name: string);
  136965. /**
  136966. * Gets the current class name
  136967. * @returns the class name
  136968. */
  136969. getClassName(): string;
  136970. /**
  136971. * Gets the incident component
  136972. */
  136973. get incident(): NodeMaterialConnectionPoint;
  136974. /**
  136975. * Gets the normal component
  136976. */
  136977. get normal(): NodeMaterialConnectionPoint;
  136978. /**
  136979. * Gets the output component
  136980. */
  136981. get output(): NodeMaterialConnectionPoint;
  136982. protected _buildBlock(state: NodeMaterialBuildState): this;
  136983. }
  136984. }
  136985. declare module BABYLON {
  136986. /**
  136987. * Block used to get the refracted vector from a direction and a normal
  136988. */
  136989. export class RefractBlock extends NodeMaterialBlock {
  136990. /**
  136991. * Creates a new RefractBlock
  136992. * @param name defines the block name
  136993. */
  136994. constructor(name: string);
  136995. /**
  136996. * Gets the current class name
  136997. * @returns the class name
  136998. */
  136999. getClassName(): string;
  137000. /**
  137001. * Gets the incident component
  137002. */
  137003. get incident(): NodeMaterialConnectionPoint;
  137004. /**
  137005. * Gets the normal component
  137006. */
  137007. get normal(): NodeMaterialConnectionPoint;
  137008. /**
  137009. * Gets the index of refraction component
  137010. */
  137011. get ior(): NodeMaterialConnectionPoint;
  137012. /**
  137013. * Gets the output component
  137014. */
  137015. get output(): NodeMaterialConnectionPoint;
  137016. protected _buildBlock(state: NodeMaterialBuildState): this;
  137017. }
  137018. }
  137019. declare module BABYLON {
  137020. /**
  137021. * Block used to desaturate a color
  137022. */
  137023. export class DesaturateBlock extends NodeMaterialBlock {
  137024. /**
  137025. * Creates a new DesaturateBlock
  137026. * @param name defines the block name
  137027. */
  137028. constructor(name: string);
  137029. /**
  137030. * Gets the current class name
  137031. * @returns the class name
  137032. */
  137033. getClassName(): string;
  137034. /**
  137035. * Gets the color operand input component
  137036. */
  137037. get color(): NodeMaterialConnectionPoint;
  137038. /**
  137039. * Gets the level operand input component
  137040. */
  137041. get level(): NodeMaterialConnectionPoint;
  137042. /**
  137043. * Gets the output component
  137044. */
  137045. get output(): NodeMaterialConnectionPoint;
  137046. protected _buildBlock(state: NodeMaterialBuildState): this;
  137047. }
  137048. }
  137049. declare module BABYLON {
  137050. /**
  137051. * Block used to implement the ambient occlusion module of the PBR material
  137052. */
  137053. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  137054. /**
  137055. * Create a new AmbientOcclusionBlock
  137056. * @param name defines the block name
  137057. */
  137058. constructor(name: string);
  137059. /**
  137060. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137061. */
  137062. useAmbientInGrayScale: boolean;
  137063. /**
  137064. * Initialize the block and prepare the context for build
  137065. * @param state defines the state that will be used for the build
  137066. */
  137067. initialize(state: NodeMaterialBuildState): void;
  137068. /**
  137069. * Gets the current class name
  137070. * @returns the class name
  137071. */
  137072. getClassName(): string;
  137073. /**
  137074. * Gets the texture input component
  137075. */
  137076. get texture(): NodeMaterialConnectionPoint;
  137077. /**
  137078. * Gets the texture intensity component
  137079. */
  137080. get intensity(): NodeMaterialConnectionPoint;
  137081. /**
  137082. * Gets the direct light intensity input component
  137083. */
  137084. get directLightIntensity(): NodeMaterialConnectionPoint;
  137085. /**
  137086. * Gets the ambient occlusion object output component
  137087. */
  137088. get ambientOcclusion(): NodeMaterialConnectionPoint;
  137089. /**
  137090. * Gets the main code of the block (fragment side)
  137091. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  137092. * @returns the shader code
  137093. */
  137094. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  137095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137096. protected _buildBlock(state: NodeMaterialBuildState): this;
  137097. protected _dumpPropertiesCode(): string;
  137098. serialize(): any;
  137099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137100. }
  137101. }
  137102. declare module BABYLON {
  137103. /**
  137104. * Block used to implement the reflection module of the PBR material
  137105. */
  137106. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  137107. /** @hidden */
  137108. _defineLODReflectionAlpha: string;
  137109. /** @hidden */
  137110. _defineLinearSpecularReflection: string;
  137111. private _vEnvironmentIrradianceName;
  137112. /** @hidden */
  137113. _vReflectionMicrosurfaceInfosName: string;
  137114. /** @hidden */
  137115. _vReflectionInfosName: string;
  137116. private _scene;
  137117. /**
  137118. * The three properties below are set by the main PBR block prior to calling methods of this class.
  137119. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137120. * It's less burden on the user side in the editor part.
  137121. */
  137122. /** @hidden */
  137123. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137124. /** @hidden */
  137125. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137126. /** @hidden */
  137127. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  137128. /**
  137129. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  137130. * diffuse part of the IBL.
  137131. */
  137132. useSphericalHarmonics: boolean;
  137133. /**
  137134. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137135. */
  137136. forceIrradianceInFragment: boolean;
  137137. /**
  137138. * Create a new ReflectionBlock
  137139. * @param name defines the block name
  137140. */
  137141. constructor(name: string);
  137142. /**
  137143. * Gets the current class name
  137144. * @returns the class name
  137145. */
  137146. getClassName(): string;
  137147. /**
  137148. * Gets the position input component
  137149. */
  137150. get position(): NodeMaterialConnectionPoint;
  137151. /**
  137152. * Gets the world position input component
  137153. */
  137154. get worldPosition(): NodeMaterialConnectionPoint;
  137155. /**
  137156. * Gets the world normal input component
  137157. */
  137158. get worldNormal(): NodeMaterialConnectionPoint;
  137159. /**
  137160. * Gets the world input component
  137161. */
  137162. get world(): NodeMaterialConnectionPoint;
  137163. /**
  137164. * Gets the camera (or eye) position component
  137165. */
  137166. get cameraPosition(): NodeMaterialConnectionPoint;
  137167. /**
  137168. * Gets the view input component
  137169. */
  137170. get view(): NodeMaterialConnectionPoint;
  137171. /**
  137172. * Gets the color input component
  137173. */
  137174. get color(): NodeMaterialConnectionPoint;
  137175. /**
  137176. * Gets the reflection object output component
  137177. */
  137178. get reflection(): NodeMaterialConnectionPoint;
  137179. /**
  137180. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  137181. */
  137182. get hasTexture(): boolean;
  137183. /**
  137184. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  137185. */
  137186. get reflectionColor(): string;
  137187. protected _getTexture(): Nullable<BaseTexture>;
  137188. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137190. /**
  137191. * Gets the code to inject in the vertex shader
  137192. * @param state current state of the node material building
  137193. * @returns the shader code
  137194. */
  137195. handleVertexSide(state: NodeMaterialBuildState): string;
  137196. /**
  137197. * Gets the main code of the block (fragment side)
  137198. * @param state current state of the node material building
  137199. * @param normalVarName name of the existing variable corresponding to the normal
  137200. * @returns the shader code
  137201. */
  137202. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  137203. protected _buildBlock(state: NodeMaterialBuildState): this;
  137204. protected _dumpPropertiesCode(): string;
  137205. serialize(): any;
  137206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137207. }
  137208. }
  137209. declare module BABYLON {
  137210. /**
  137211. * Block used to implement the sheen module of the PBR material
  137212. */
  137213. export class SheenBlock extends NodeMaterialBlock {
  137214. /**
  137215. * Create a new SheenBlock
  137216. * @param name defines the block name
  137217. */
  137218. constructor(name: string);
  137219. /**
  137220. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  137221. * It allows the strength of the sheen effect to not depend on the base color of the material,
  137222. * making it easier to setup and tweak the effect
  137223. */
  137224. albedoScaling: boolean;
  137225. /**
  137226. * Defines if the sheen is linked to the sheen color.
  137227. */
  137228. linkSheenWithAlbedo: boolean;
  137229. /**
  137230. * Initialize the block and prepare the context for build
  137231. * @param state defines the state that will be used for the build
  137232. */
  137233. initialize(state: NodeMaterialBuildState): void;
  137234. /**
  137235. * Gets the current class name
  137236. * @returns the class name
  137237. */
  137238. getClassName(): string;
  137239. /**
  137240. * Gets the intensity input component
  137241. */
  137242. get intensity(): NodeMaterialConnectionPoint;
  137243. /**
  137244. * Gets the color input component
  137245. */
  137246. get color(): NodeMaterialConnectionPoint;
  137247. /**
  137248. * Gets the roughness input component
  137249. */
  137250. get roughness(): NodeMaterialConnectionPoint;
  137251. /**
  137252. * Gets the texture input component
  137253. */
  137254. get texture(): NodeMaterialConnectionPoint;
  137255. /**
  137256. * Gets the sheen object output component
  137257. */
  137258. get sheen(): NodeMaterialConnectionPoint;
  137259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137260. /**
  137261. * Gets the main code of the block (fragment side)
  137262. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137263. * @returns the shader code
  137264. */
  137265. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  137266. protected _buildBlock(state: NodeMaterialBuildState): this;
  137267. protected _dumpPropertiesCode(): string;
  137268. serialize(): any;
  137269. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137270. }
  137271. }
  137272. declare module BABYLON {
  137273. /**
  137274. * Block used to implement the reflectivity module of the PBR material
  137275. */
  137276. export class ReflectivityBlock extends NodeMaterialBlock {
  137277. /**
  137278. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137279. */
  137280. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137281. /**
  137282. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137283. */
  137284. useMetallnessFromMetallicTextureBlue: boolean;
  137285. /**
  137286. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137287. */
  137288. useRoughnessFromMetallicTextureAlpha: boolean;
  137289. /**
  137290. * Specifies if the metallic texture contains the roughness information in its green channel.
  137291. */
  137292. useRoughnessFromMetallicTextureGreen: boolean;
  137293. /**
  137294. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  137295. */
  137296. useMetallicF0FactorFromMetallicTexture: boolean;
  137297. /**
  137298. * Create a new ReflectivityBlock
  137299. * @param name defines the block name
  137300. */
  137301. constructor(name: string);
  137302. /**
  137303. * Initialize the block and prepare the context for build
  137304. * @param state defines the state that will be used for the build
  137305. */
  137306. initialize(state: NodeMaterialBuildState): void;
  137307. /**
  137308. * Gets the current class name
  137309. * @returns the class name
  137310. */
  137311. getClassName(): string;
  137312. /**
  137313. * Gets the metallic input component
  137314. */
  137315. get metallic(): NodeMaterialConnectionPoint;
  137316. /**
  137317. * Gets the roughness input component
  137318. */
  137319. get roughness(): NodeMaterialConnectionPoint;
  137320. /**
  137321. * Gets the texture input component
  137322. */
  137323. get texture(): NodeMaterialConnectionPoint;
  137324. /**
  137325. * Gets the reflectivity object output component
  137326. */
  137327. get reflectivity(): NodeMaterialConnectionPoint;
  137328. /**
  137329. * Gets the main code of the block (fragment side)
  137330. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  137331. * @returns the shader code
  137332. */
  137333. getCode(aoIntensityVarName: string): string;
  137334. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137335. protected _buildBlock(state: NodeMaterialBuildState): this;
  137336. protected _dumpPropertiesCode(): string;
  137337. serialize(): any;
  137338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137339. }
  137340. }
  137341. declare module BABYLON {
  137342. /**
  137343. * Block used to implement the anisotropy module of the PBR material
  137344. */
  137345. export class AnisotropyBlock extends NodeMaterialBlock {
  137346. /**
  137347. * The two properties below are set by the main PBR block prior to calling methods of this class.
  137348. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  137349. * It's less burden on the user side in the editor part.
  137350. */
  137351. /** @hidden */
  137352. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  137353. /** @hidden */
  137354. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  137355. /**
  137356. * Create a new AnisotropyBlock
  137357. * @param name defines the block name
  137358. */
  137359. constructor(name: string);
  137360. /**
  137361. * Initialize the block and prepare the context for build
  137362. * @param state defines the state that will be used for the build
  137363. */
  137364. initialize(state: NodeMaterialBuildState): void;
  137365. /**
  137366. * Gets the current class name
  137367. * @returns the class name
  137368. */
  137369. getClassName(): string;
  137370. /**
  137371. * Gets the intensity input component
  137372. */
  137373. get intensity(): NodeMaterialConnectionPoint;
  137374. /**
  137375. * Gets the direction input component
  137376. */
  137377. get direction(): NodeMaterialConnectionPoint;
  137378. /**
  137379. * Gets the texture input component
  137380. */
  137381. get texture(): NodeMaterialConnectionPoint;
  137382. /**
  137383. * Gets the uv input component
  137384. */
  137385. get uv(): NodeMaterialConnectionPoint;
  137386. /**
  137387. * Gets the worldTangent input component
  137388. */
  137389. get worldTangent(): NodeMaterialConnectionPoint;
  137390. /**
  137391. * Gets the anisotropy object output component
  137392. */
  137393. get anisotropy(): NodeMaterialConnectionPoint;
  137394. private _generateTBNSpace;
  137395. /**
  137396. * Gets the main code of the block (fragment side)
  137397. * @param state current state of the node material building
  137398. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137399. * @returns the shader code
  137400. */
  137401. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  137402. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137403. protected _buildBlock(state: NodeMaterialBuildState): this;
  137404. }
  137405. }
  137406. declare module BABYLON {
  137407. /**
  137408. * Block used to implement the clear coat module of the PBR material
  137409. */
  137410. export class ClearCoatBlock extends NodeMaterialBlock {
  137411. private _scene;
  137412. /**
  137413. * Create a new ClearCoatBlock
  137414. * @param name defines the block name
  137415. */
  137416. constructor(name: string);
  137417. /**
  137418. * Initialize the block and prepare the context for build
  137419. * @param state defines the state that will be used for the build
  137420. */
  137421. initialize(state: NodeMaterialBuildState): void;
  137422. /**
  137423. * Gets the current class name
  137424. * @returns the class name
  137425. */
  137426. getClassName(): string;
  137427. /**
  137428. * Gets the intensity input component
  137429. */
  137430. get intensity(): NodeMaterialConnectionPoint;
  137431. /**
  137432. * Gets the roughness input component
  137433. */
  137434. get roughness(): NodeMaterialConnectionPoint;
  137435. /**
  137436. * Gets the ior input component
  137437. */
  137438. get ior(): NodeMaterialConnectionPoint;
  137439. /**
  137440. * Gets the texture input component
  137441. */
  137442. get texture(): NodeMaterialConnectionPoint;
  137443. /**
  137444. * Gets the bump texture input component
  137445. */
  137446. get bumpTexture(): NodeMaterialConnectionPoint;
  137447. /**
  137448. * Gets the uv input component
  137449. */
  137450. get uv(): NodeMaterialConnectionPoint;
  137451. /**
  137452. * Gets the tint color input component
  137453. */
  137454. get tintColor(): NodeMaterialConnectionPoint;
  137455. /**
  137456. * Gets the tint "at distance" input component
  137457. */
  137458. get tintAtDistance(): NodeMaterialConnectionPoint;
  137459. /**
  137460. * Gets the tint thickness input component
  137461. */
  137462. get tintThickness(): NodeMaterialConnectionPoint;
  137463. /**
  137464. * Gets the tint texture input component
  137465. */
  137466. get tintTexture(): NodeMaterialConnectionPoint;
  137467. /**
  137468. * Gets the world tangent input component
  137469. */
  137470. get worldTangent(): NodeMaterialConnectionPoint;
  137471. /**
  137472. * Gets the clear coat object output component
  137473. */
  137474. get clearcoat(): NodeMaterialConnectionPoint;
  137475. autoConfigure(material: NodeMaterial): void;
  137476. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137477. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  137478. private _generateTBNSpace;
  137479. /**
  137480. * Gets the main code of the block (fragment side)
  137481. * @param state current state of the node material building
  137482. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  137483. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137484. * @param worldPosVarName name of the variable holding the world position
  137485. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  137486. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  137487. * @param worldNormalVarName name of the variable holding the world normal
  137488. * @returns the shader code
  137489. */
  137490. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  137491. protected _buildBlock(state: NodeMaterialBuildState): this;
  137492. }
  137493. }
  137494. declare module BABYLON {
  137495. /**
  137496. * Block used to implement the sub surface module of the PBR material
  137497. */
  137498. export class SubSurfaceBlock extends NodeMaterialBlock {
  137499. /**
  137500. * Create a new SubSurfaceBlock
  137501. * @param name defines the block name
  137502. */
  137503. constructor(name: string);
  137504. /**
  137505. * Stores the intensity of the different subsurface effects in the thickness texture.
  137506. * * the green channel is the translucency intensity.
  137507. * * the blue channel is the scattering intensity.
  137508. * * the alpha channel is the refraction intensity.
  137509. */
  137510. useMaskFromThicknessTexture: boolean;
  137511. /**
  137512. * Initialize the block and prepare the context for build
  137513. * @param state defines the state that will be used for the build
  137514. */
  137515. initialize(state: NodeMaterialBuildState): void;
  137516. /**
  137517. * Gets the current class name
  137518. * @returns the class name
  137519. */
  137520. getClassName(): string;
  137521. /**
  137522. * Gets the min thickness input component
  137523. */
  137524. get minThickness(): NodeMaterialConnectionPoint;
  137525. /**
  137526. * Gets the max thickness input component
  137527. */
  137528. get maxThickness(): NodeMaterialConnectionPoint;
  137529. /**
  137530. * Gets the thickness texture component
  137531. */
  137532. get thicknessTexture(): NodeMaterialConnectionPoint;
  137533. /**
  137534. * Gets the tint color input component
  137535. */
  137536. get tintColor(): NodeMaterialConnectionPoint;
  137537. /**
  137538. * Gets the translucency intensity input component
  137539. */
  137540. get translucencyIntensity(): NodeMaterialConnectionPoint;
  137541. /**
  137542. * Gets the translucency diffusion distance input component
  137543. */
  137544. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  137545. /**
  137546. * Gets the refraction object parameters
  137547. */
  137548. get refraction(): NodeMaterialConnectionPoint;
  137549. /**
  137550. * Gets the sub surface object output component
  137551. */
  137552. get subsurface(): NodeMaterialConnectionPoint;
  137553. autoConfigure(material: NodeMaterial): void;
  137554. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137555. /**
  137556. * Gets the main code of the block (fragment side)
  137557. * @param state current state of the node material building
  137558. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  137559. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  137560. * @param worldPosVarName name of the variable holding the world position
  137561. * @returns the shader code
  137562. */
  137563. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  137564. protected _buildBlock(state: NodeMaterialBuildState): this;
  137565. }
  137566. }
  137567. declare module BABYLON {
  137568. /**
  137569. * Block used to implement the PBR metallic/roughness model
  137570. */
  137571. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  137572. /**
  137573. * Gets or sets the light associated with this block
  137574. */
  137575. light: Nullable<Light>;
  137576. private _lightId;
  137577. private _scene;
  137578. private _environmentBRDFTexture;
  137579. private _environmentBrdfSamplerName;
  137580. private _vNormalWName;
  137581. private _invertNormalName;
  137582. /**
  137583. * Create a new ReflectionBlock
  137584. * @param name defines the block name
  137585. */
  137586. constructor(name: string);
  137587. /**
  137588. * Intensity of the direct lights e.g. the four lights available in your scene.
  137589. * This impacts both the direct diffuse and specular highlights.
  137590. */
  137591. directIntensity: number;
  137592. /**
  137593. * Intensity of the environment e.g. how much the environment will light the object
  137594. * either through harmonics for rough material or through the refelction for shiny ones.
  137595. */
  137596. environmentIntensity: number;
  137597. /**
  137598. * This is a special control allowing the reduction of the specular highlights coming from the
  137599. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137600. */
  137601. specularIntensity: number;
  137602. /**
  137603. * Defines the falloff type used in this material.
  137604. * It by default is Physical.
  137605. */
  137606. lightFalloff: number;
  137607. /**
  137608. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137609. */
  137610. useAlphaFromAlbedoTexture: boolean;
  137611. /**
  137612. * Specifies that alpha test should be used
  137613. */
  137614. useAlphaTest: boolean;
  137615. /**
  137616. * Defines the alpha limits in alpha test mode.
  137617. */
  137618. alphaTestCutoff: number;
  137619. /**
  137620. * Specifies that alpha blending should be used
  137621. */
  137622. useAlphaBlending: boolean;
  137623. /**
  137624. * Defines if the alpha value should be determined via the rgb values.
  137625. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  137626. */
  137627. opacityRGB: boolean;
  137628. /**
  137629. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  137630. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137631. */
  137632. useRadianceOverAlpha: boolean;
  137633. /**
  137634. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  137635. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137636. */
  137637. useSpecularOverAlpha: boolean;
  137638. /**
  137639. * Enables specular anti aliasing in the PBR shader.
  137640. * It will both interacts on the Geometry for analytical and IBL lighting.
  137641. * It also prefilter the roughness map based on the bump values.
  137642. */
  137643. enableSpecularAntiAliasing: boolean;
  137644. /**
  137645. * Defines if the material uses energy conservation.
  137646. */
  137647. useEnergyConservation: boolean;
  137648. /**
  137649. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137650. * too much the area relying on ambient texture to define their ambient occlusion.
  137651. */
  137652. useRadianceOcclusion: boolean;
  137653. /**
  137654. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137655. * makes the reflect vector face the model (under horizon).
  137656. */
  137657. useHorizonOcclusion: boolean;
  137658. /**
  137659. * If set to true, no lighting calculations will be applied.
  137660. */
  137661. unlit: boolean;
  137662. /**
  137663. * Force normal to face away from face.
  137664. */
  137665. forceNormalForward: boolean;
  137666. /**
  137667. * Defines the material debug mode.
  137668. * It helps seeing only some components of the material while troubleshooting.
  137669. */
  137670. debugMode: number;
  137671. /**
  137672. * Specify from where on screen the debug mode should start.
  137673. * The value goes from -1 (full screen) to 1 (not visible)
  137674. * It helps with side by side comparison against the final render
  137675. * This defaults to 0
  137676. */
  137677. debugLimit: number;
  137678. /**
  137679. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137680. * You can use the factor to better multiply the final value.
  137681. */
  137682. debugFactor: number;
  137683. /**
  137684. * Initialize the block and prepare the context for build
  137685. * @param state defines the state that will be used for the build
  137686. */
  137687. initialize(state: NodeMaterialBuildState): void;
  137688. /**
  137689. * Gets the current class name
  137690. * @returns the class name
  137691. */
  137692. getClassName(): string;
  137693. /**
  137694. * Gets the world position input component
  137695. */
  137696. get worldPosition(): NodeMaterialConnectionPoint;
  137697. /**
  137698. * Gets the world normal input component
  137699. */
  137700. get worldNormal(): NodeMaterialConnectionPoint;
  137701. /**
  137702. * Gets the perturbed normal input component
  137703. */
  137704. get perturbedNormal(): NodeMaterialConnectionPoint;
  137705. /**
  137706. * Gets the camera position input component
  137707. */
  137708. get cameraPosition(): NodeMaterialConnectionPoint;
  137709. /**
  137710. * Gets the base color input component
  137711. */
  137712. get baseColor(): NodeMaterialConnectionPoint;
  137713. /**
  137714. * Gets the base texture input component
  137715. */
  137716. get baseTexture(): NodeMaterialConnectionPoint;
  137717. /**
  137718. * Gets the opacity texture input component
  137719. */
  137720. get opacityTexture(): NodeMaterialConnectionPoint;
  137721. /**
  137722. * Gets the ambient color input component
  137723. */
  137724. get ambientColor(): NodeMaterialConnectionPoint;
  137725. /**
  137726. * Gets the reflectivity object parameters
  137727. */
  137728. get reflectivity(): NodeMaterialConnectionPoint;
  137729. /**
  137730. * Gets the ambient occlusion object parameters
  137731. */
  137732. get ambientOcclusion(): NodeMaterialConnectionPoint;
  137733. /**
  137734. * Gets the reflection object parameters
  137735. */
  137736. get reflection(): NodeMaterialConnectionPoint;
  137737. /**
  137738. * Gets the sheen object parameters
  137739. */
  137740. get sheen(): NodeMaterialConnectionPoint;
  137741. /**
  137742. * Gets the clear coat object parameters
  137743. */
  137744. get clearcoat(): NodeMaterialConnectionPoint;
  137745. /**
  137746. * Gets the sub surface object parameters
  137747. */
  137748. get subsurface(): NodeMaterialConnectionPoint;
  137749. /**
  137750. * Gets the anisotropy object parameters
  137751. */
  137752. get anisotropy(): NodeMaterialConnectionPoint;
  137753. /**
  137754. * Gets the ambient output component
  137755. */
  137756. get ambient(): NodeMaterialConnectionPoint;
  137757. /**
  137758. * Gets the diffuse output component
  137759. */
  137760. get diffuse(): NodeMaterialConnectionPoint;
  137761. /**
  137762. * Gets the specular output component
  137763. */
  137764. get specular(): NodeMaterialConnectionPoint;
  137765. /**
  137766. * Gets the sheen output component
  137767. */
  137768. get sheenDir(): NodeMaterialConnectionPoint;
  137769. /**
  137770. * Gets the clear coat output component
  137771. */
  137772. get clearcoatDir(): NodeMaterialConnectionPoint;
  137773. /**
  137774. * Gets the indirect diffuse output component
  137775. */
  137776. get diffuseIndirect(): NodeMaterialConnectionPoint;
  137777. /**
  137778. * Gets the indirect specular output component
  137779. */
  137780. get specularIndirect(): NodeMaterialConnectionPoint;
  137781. /**
  137782. * Gets the indirect sheen output component
  137783. */
  137784. get sheenIndirect(): NodeMaterialConnectionPoint;
  137785. /**
  137786. * Gets the indirect clear coat output component
  137787. */
  137788. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  137789. /**
  137790. * Gets the refraction output component
  137791. */
  137792. get refraction(): NodeMaterialConnectionPoint;
  137793. /**
  137794. * Gets the global lighting output component
  137795. */
  137796. get lighting(): NodeMaterialConnectionPoint;
  137797. /**
  137798. * Gets the shadow output component
  137799. */
  137800. get shadow(): NodeMaterialConnectionPoint;
  137801. /**
  137802. * Gets the alpha output component
  137803. */
  137804. get alpha(): NodeMaterialConnectionPoint;
  137805. autoConfigure(material: NodeMaterial): void;
  137806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  137807. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  137808. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  137809. private _injectVertexCode;
  137810. /**
  137811. * Gets the code corresponding to the albedo/opacity module
  137812. * @returns the shader code
  137813. */
  137814. getAlbedoOpacityCode(): string;
  137815. protected _buildBlock(state: NodeMaterialBuildState): this;
  137816. protected _dumpPropertiesCode(): string;
  137817. serialize(): any;
  137818. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  137819. }
  137820. }
  137821. declare module BABYLON {
  137822. /**
  137823. * Effect Render Options
  137824. */
  137825. export interface IEffectRendererOptions {
  137826. /**
  137827. * Defines the vertices positions.
  137828. */
  137829. positions?: number[];
  137830. /**
  137831. * Defines the indices.
  137832. */
  137833. indices?: number[];
  137834. }
  137835. /**
  137836. * Helper class to render one or more effects.
  137837. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137838. */
  137839. export class EffectRenderer {
  137840. private engine;
  137841. private static _DefaultOptions;
  137842. private _vertexBuffers;
  137843. private _indexBuffer;
  137844. private _fullscreenViewport;
  137845. /**
  137846. * Creates an effect renderer
  137847. * @param engine the engine to use for rendering
  137848. * @param options defines the options of the effect renderer
  137849. */
  137850. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137851. /**
  137852. * Sets the current viewport in normalized coordinates 0-1
  137853. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137854. */
  137855. setViewport(viewport?: Viewport): void;
  137856. /**
  137857. * Binds the embedded attributes buffer to the effect.
  137858. * @param effect Defines the effect to bind the attributes for
  137859. */
  137860. bindBuffers(effect: Effect): void;
  137861. /**
  137862. * Sets the current effect wrapper to use during draw.
  137863. * The effect needs to be ready before calling this api.
  137864. * This also sets the default full screen position attribute.
  137865. * @param effectWrapper Defines the effect to draw with
  137866. */
  137867. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137868. /**
  137869. * Draws a full screen quad.
  137870. */
  137871. draw(): void;
  137872. private isRenderTargetTexture;
  137873. /**
  137874. * renders one or more effects to a specified texture
  137875. * @param effectWrapper the effect to renderer
  137876. * @param outputTexture texture to draw to, if null it will render to the screen.
  137877. */
  137878. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137879. /**
  137880. * Disposes of the effect renderer
  137881. */
  137882. dispose(): void;
  137883. }
  137884. /**
  137885. * Options to create an EffectWrapper
  137886. */
  137887. interface EffectWrapperCreationOptions {
  137888. /**
  137889. * Engine to use to create the effect
  137890. */
  137891. engine: ThinEngine;
  137892. /**
  137893. * Fragment shader for the effect
  137894. */
  137895. fragmentShader: string;
  137896. /**
  137897. * Vertex shader for the effect
  137898. */
  137899. vertexShader?: string;
  137900. /**
  137901. * Attributes to use in the shader
  137902. */
  137903. attributeNames?: Array<string>;
  137904. /**
  137905. * Uniforms to use in the shader
  137906. */
  137907. uniformNames?: Array<string>;
  137908. /**
  137909. * Texture sampler names to use in the shader
  137910. */
  137911. samplerNames?: Array<string>;
  137912. /**
  137913. * The friendly name of the effect displayed in Spector.
  137914. */
  137915. name?: string;
  137916. }
  137917. /**
  137918. * Wraps an effect to be used for rendering
  137919. */
  137920. export class EffectWrapper {
  137921. /**
  137922. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137923. */
  137924. onApplyObservable: Observable<{}>;
  137925. /**
  137926. * The underlying effect
  137927. */
  137928. effect: Effect;
  137929. /**
  137930. * Creates an effect to be renderer
  137931. * @param creationOptions options to create the effect
  137932. */
  137933. constructor(creationOptions: EffectWrapperCreationOptions);
  137934. /**
  137935. * Disposes of the effect wrapper
  137936. */
  137937. dispose(): void;
  137938. }
  137939. }
  137940. declare module BABYLON {
  137941. /**
  137942. * Helper class to push actions to a pool of workers.
  137943. */
  137944. export class WorkerPool implements IDisposable {
  137945. private _workerInfos;
  137946. private _pendingActions;
  137947. /**
  137948. * Constructor
  137949. * @param workers Array of workers to use for actions
  137950. */
  137951. constructor(workers: Array<Worker>);
  137952. /**
  137953. * Terminates all workers and clears any pending actions.
  137954. */
  137955. dispose(): void;
  137956. /**
  137957. * Pushes an action to the worker pool. If all the workers are active, the action will be
  137958. * pended until a worker has completed its action.
  137959. * @param action The action to perform. Call onComplete when the action is complete.
  137960. */
  137961. push(action: (worker: Worker, onComplete: () => void) => void): void;
  137962. private _execute;
  137963. }
  137964. }
  137965. declare module BABYLON {
  137966. /**
  137967. * Configuration for Draco compression
  137968. */
  137969. export interface IDracoCompressionConfiguration {
  137970. /**
  137971. * Configuration for the decoder.
  137972. */
  137973. decoder: {
  137974. /**
  137975. * The url to the WebAssembly module.
  137976. */
  137977. wasmUrl?: string;
  137978. /**
  137979. * The url to the WebAssembly binary.
  137980. */
  137981. wasmBinaryUrl?: string;
  137982. /**
  137983. * The url to the fallback JavaScript module.
  137984. */
  137985. fallbackUrl?: string;
  137986. };
  137987. }
  137988. /**
  137989. * Draco compression (https://google.github.io/draco/)
  137990. *
  137991. * This class wraps the Draco module.
  137992. *
  137993. * **Encoder**
  137994. *
  137995. * The encoder is not currently implemented.
  137996. *
  137997. * **Decoder**
  137998. *
  137999. * 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.
  138000. *
  138001. * To update the configuration, use the following code:
  138002. * ```javascript
  138003. * DracoCompression.Configuration = {
  138004. * decoder: {
  138005. * wasmUrl: "<url to the WebAssembly library>",
  138006. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  138007. * fallbackUrl: "<url to the fallback JavaScript library>",
  138008. * }
  138009. * };
  138010. * ```
  138011. *
  138012. * 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.
  138013. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  138014. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  138015. *
  138016. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  138017. * ```javascript
  138018. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  138019. * ```
  138020. *
  138021. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  138022. */
  138023. export class DracoCompression implements IDisposable {
  138024. private _workerPoolPromise?;
  138025. private _decoderModulePromise?;
  138026. /**
  138027. * The configuration. Defaults to the following urls:
  138028. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  138029. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  138030. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  138031. */
  138032. static Configuration: IDracoCompressionConfiguration;
  138033. /**
  138034. * Returns true if the decoder configuration is available.
  138035. */
  138036. static get DecoderAvailable(): boolean;
  138037. /**
  138038. * Default number of workers to create when creating the draco compression object.
  138039. */
  138040. static DefaultNumWorkers: number;
  138041. private static GetDefaultNumWorkers;
  138042. private static _Default;
  138043. /**
  138044. * Default instance for the draco compression object.
  138045. */
  138046. static get Default(): DracoCompression;
  138047. /**
  138048. * Constructor
  138049. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138050. */
  138051. constructor(numWorkers?: number);
  138052. /**
  138053. * Stop all async operations and release resources.
  138054. */
  138055. dispose(): void;
  138056. /**
  138057. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  138058. * @returns a promise that resolves when ready
  138059. */
  138060. whenReadyAsync(): Promise<void>;
  138061. /**
  138062. * Decode Draco compressed mesh data to vertex data.
  138063. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  138064. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  138065. * @returns A promise that resolves with the decoded vertex data
  138066. */
  138067. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  138068. [kind: string]: number;
  138069. }): Promise<VertexData>;
  138070. }
  138071. }
  138072. declare module BABYLON {
  138073. /**
  138074. * Class for building Constructive Solid Geometry
  138075. */
  138076. export class CSG {
  138077. private polygons;
  138078. /**
  138079. * The world matrix
  138080. */
  138081. matrix: Matrix;
  138082. /**
  138083. * Stores the position
  138084. */
  138085. position: Vector3;
  138086. /**
  138087. * Stores the rotation
  138088. */
  138089. rotation: Vector3;
  138090. /**
  138091. * Stores the rotation quaternion
  138092. */
  138093. rotationQuaternion: Nullable<Quaternion>;
  138094. /**
  138095. * Stores the scaling vector
  138096. */
  138097. scaling: Vector3;
  138098. /**
  138099. * Convert the Mesh to CSG
  138100. * @param mesh The Mesh to convert to CSG
  138101. * @returns A new CSG from the Mesh
  138102. */
  138103. static FromMesh(mesh: Mesh): CSG;
  138104. /**
  138105. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  138106. * @param polygons Polygons used to construct a CSG solid
  138107. */
  138108. private static FromPolygons;
  138109. /**
  138110. * Clones, or makes a deep copy, of the CSG
  138111. * @returns A new CSG
  138112. */
  138113. clone(): CSG;
  138114. /**
  138115. * Unions this CSG with another CSG
  138116. * @param csg The CSG to union against this CSG
  138117. * @returns The unioned CSG
  138118. */
  138119. union(csg: CSG): CSG;
  138120. /**
  138121. * Unions this CSG with another CSG in place
  138122. * @param csg The CSG to union against this CSG
  138123. */
  138124. unionInPlace(csg: CSG): void;
  138125. /**
  138126. * Subtracts this CSG with another CSG
  138127. * @param csg The CSG to subtract against this CSG
  138128. * @returns A new CSG
  138129. */
  138130. subtract(csg: CSG): CSG;
  138131. /**
  138132. * Subtracts this CSG with another CSG in place
  138133. * @param csg The CSG to subtact against this CSG
  138134. */
  138135. subtractInPlace(csg: CSG): void;
  138136. /**
  138137. * Intersect this CSG with another CSG
  138138. * @param csg The CSG to intersect against this CSG
  138139. * @returns A new CSG
  138140. */
  138141. intersect(csg: CSG): CSG;
  138142. /**
  138143. * Intersects this CSG with another CSG in place
  138144. * @param csg The CSG to intersect against this CSG
  138145. */
  138146. intersectInPlace(csg: CSG): void;
  138147. /**
  138148. * Return a new CSG solid with solid and empty space switched. This solid is
  138149. * not modified.
  138150. * @returns A new CSG solid with solid and empty space switched
  138151. */
  138152. inverse(): CSG;
  138153. /**
  138154. * Inverses the CSG in place
  138155. */
  138156. inverseInPlace(): void;
  138157. /**
  138158. * This is used to keep meshes transformations so they can be restored
  138159. * when we build back a Babylon Mesh
  138160. * NB : All CSG operations are performed in world coordinates
  138161. * @param csg The CSG to copy the transform attributes from
  138162. * @returns This CSG
  138163. */
  138164. copyTransformAttributes(csg: CSG): CSG;
  138165. /**
  138166. * Build Raw mesh from CSG
  138167. * Coordinates here are in world space
  138168. * @param name The name of the mesh geometry
  138169. * @param scene The Scene
  138170. * @param keepSubMeshes Specifies if the submeshes should be kept
  138171. * @returns A new Mesh
  138172. */
  138173. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138174. /**
  138175. * Build Mesh from CSG taking material and transforms into account
  138176. * @param name The name of the Mesh
  138177. * @param material The material of the Mesh
  138178. * @param scene The Scene
  138179. * @param keepSubMeshes Specifies if submeshes should be kept
  138180. * @returns The new Mesh
  138181. */
  138182. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  138183. }
  138184. }
  138185. declare module BABYLON {
  138186. /**
  138187. * Class used to create a trail following a mesh
  138188. */
  138189. export class TrailMesh extends Mesh {
  138190. private _generator;
  138191. private _autoStart;
  138192. private _running;
  138193. private _diameter;
  138194. private _length;
  138195. private _sectionPolygonPointsCount;
  138196. private _sectionVectors;
  138197. private _sectionNormalVectors;
  138198. private _beforeRenderObserver;
  138199. /**
  138200. * @constructor
  138201. * @param name The value used by scene.getMeshByName() to do a lookup.
  138202. * @param generator The mesh or transform node to generate a trail.
  138203. * @param scene The scene to add this mesh to.
  138204. * @param diameter Diameter of trailing mesh. Default is 1.
  138205. * @param length Length of trailing mesh. Default is 60.
  138206. * @param autoStart Automatically start trailing mesh. Default true.
  138207. */
  138208. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  138209. /**
  138210. * "TrailMesh"
  138211. * @returns "TrailMesh"
  138212. */
  138213. getClassName(): string;
  138214. private _createMesh;
  138215. /**
  138216. * Start trailing mesh.
  138217. */
  138218. start(): void;
  138219. /**
  138220. * Stop trailing mesh.
  138221. */
  138222. stop(): void;
  138223. /**
  138224. * Update trailing mesh geometry.
  138225. */
  138226. update(): void;
  138227. /**
  138228. * Returns a new TrailMesh object.
  138229. * @param name is a string, the name given to the new mesh
  138230. * @param newGenerator use new generator object for cloned trail mesh
  138231. * @returns a new mesh
  138232. */
  138233. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  138234. /**
  138235. * Serializes this trail mesh
  138236. * @param serializationObject object to write serialization to
  138237. */
  138238. serialize(serializationObject: any): void;
  138239. /**
  138240. * Parses a serialized trail mesh
  138241. * @param parsedMesh the serialized mesh
  138242. * @param scene the scene to create the trail mesh in
  138243. * @returns the created trail mesh
  138244. */
  138245. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  138246. }
  138247. }
  138248. declare module BABYLON {
  138249. /**
  138250. * Class containing static functions to help procedurally build meshes
  138251. */
  138252. export class TiledBoxBuilder {
  138253. /**
  138254. * Creates a box mesh
  138255. * 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)
  138256. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138260. * @param name defines the name of the mesh
  138261. * @param options defines the options used to create the mesh
  138262. * @param scene defines the hosting scene
  138263. * @returns the box mesh
  138264. */
  138265. static CreateTiledBox(name: string, options: {
  138266. pattern?: number;
  138267. width?: number;
  138268. height?: number;
  138269. depth?: number;
  138270. tileSize?: number;
  138271. tileWidth?: number;
  138272. tileHeight?: number;
  138273. alignHorizontal?: number;
  138274. alignVertical?: number;
  138275. faceUV?: Vector4[];
  138276. faceColors?: Color4[];
  138277. sideOrientation?: number;
  138278. updatable?: boolean;
  138279. }, scene?: Nullable<Scene>): Mesh;
  138280. }
  138281. }
  138282. declare module BABYLON {
  138283. /**
  138284. * Class containing static functions to help procedurally build meshes
  138285. */
  138286. export class TorusKnotBuilder {
  138287. /**
  138288. * Creates a torus knot mesh
  138289. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  138290. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  138291. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  138292. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  138293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138296. * @param name defines the name of the mesh
  138297. * @param options defines the options used to create the mesh
  138298. * @param scene defines the hosting scene
  138299. * @returns the torus knot mesh
  138300. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  138301. */
  138302. static CreateTorusKnot(name: string, options: {
  138303. radius?: number;
  138304. tube?: number;
  138305. radialSegments?: number;
  138306. tubularSegments?: number;
  138307. p?: number;
  138308. q?: number;
  138309. updatable?: boolean;
  138310. sideOrientation?: number;
  138311. frontUVs?: Vector4;
  138312. backUVs?: Vector4;
  138313. }, scene: any): Mesh;
  138314. }
  138315. }
  138316. declare module BABYLON {
  138317. /**
  138318. * Polygon
  138319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  138320. */
  138321. export class Polygon {
  138322. /**
  138323. * Creates a rectangle
  138324. * @param xmin bottom X coord
  138325. * @param ymin bottom Y coord
  138326. * @param xmax top X coord
  138327. * @param ymax top Y coord
  138328. * @returns points that make the resulting rectation
  138329. */
  138330. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  138331. /**
  138332. * Creates a circle
  138333. * @param radius radius of circle
  138334. * @param cx scale in x
  138335. * @param cy scale in y
  138336. * @param numberOfSides number of sides that make up the circle
  138337. * @returns points that make the resulting circle
  138338. */
  138339. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  138340. /**
  138341. * Creates a polygon from input string
  138342. * @param input Input polygon data
  138343. * @returns the parsed points
  138344. */
  138345. static Parse(input: string): Vector2[];
  138346. /**
  138347. * Starts building a polygon from x and y coordinates
  138348. * @param x x coordinate
  138349. * @param y y coordinate
  138350. * @returns the started path2
  138351. */
  138352. static StartingAt(x: number, y: number): Path2;
  138353. }
  138354. /**
  138355. * Builds a polygon
  138356. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  138357. */
  138358. export class PolygonMeshBuilder {
  138359. private _points;
  138360. private _outlinepoints;
  138361. private _holes;
  138362. private _name;
  138363. private _scene;
  138364. private _epoints;
  138365. private _eholes;
  138366. private _addToepoint;
  138367. /**
  138368. * Babylon reference to the earcut plugin.
  138369. */
  138370. bjsEarcut: any;
  138371. /**
  138372. * Creates a PolygonMeshBuilder
  138373. * @param name name of the builder
  138374. * @param contours Path of the polygon
  138375. * @param scene scene to add to when creating the mesh
  138376. * @param earcutInjection can be used to inject your own earcut reference
  138377. */
  138378. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  138379. /**
  138380. * Adds a whole within the polygon
  138381. * @param hole Array of points defining the hole
  138382. * @returns this
  138383. */
  138384. addHole(hole: Vector2[]): PolygonMeshBuilder;
  138385. /**
  138386. * Creates the polygon
  138387. * @param updatable If the mesh should be updatable
  138388. * @param depth The depth of the mesh created
  138389. * @returns the created mesh
  138390. */
  138391. build(updatable?: boolean, depth?: number): Mesh;
  138392. /**
  138393. * Creates the polygon
  138394. * @param depth The depth of the mesh created
  138395. * @returns the created VertexData
  138396. */
  138397. buildVertexData(depth?: number): VertexData;
  138398. /**
  138399. * Adds a side to the polygon
  138400. * @param positions points that make the polygon
  138401. * @param normals normals of the polygon
  138402. * @param uvs uvs of the polygon
  138403. * @param indices indices of the polygon
  138404. * @param bounds bounds of the polygon
  138405. * @param points points of the polygon
  138406. * @param depth depth of the polygon
  138407. * @param flip flip of the polygon
  138408. */
  138409. private addSide;
  138410. }
  138411. }
  138412. declare module BABYLON {
  138413. /**
  138414. * Class containing static functions to help procedurally build meshes
  138415. */
  138416. export class PolygonBuilder {
  138417. /**
  138418. * Creates a polygon mesh
  138419. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  138420. * * 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
  138421. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  138424. * * Remember you can only change the shape positions, not their number when updating a polygon
  138425. * @param name defines the name of the mesh
  138426. * @param options defines the options used to create the mesh
  138427. * @param scene defines the hosting scene
  138428. * @param earcutInjection can be used to inject your own earcut reference
  138429. * @returns the polygon mesh
  138430. */
  138431. static CreatePolygon(name: string, options: {
  138432. shape: Vector3[];
  138433. holes?: Vector3[][];
  138434. depth?: number;
  138435. faceUV?: Vector4[];
  138436. faceColors?: Color4[];
  138437. updatable?: boolean;
  138438. sideOrientation?: number;
  138439. frontUVs?: Vector4;
  138440. backUVs?: Vector4;
  138441. wrap?: boolean;
  138442. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138443. /**
  138444. * Creates an extruded polygon mesh, with depth in the Y direction.
  138445. * * 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)
  138446. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138447. * @param name defines the name of the mesh
  138448. * @param options defines the options used to create the mesh
  138449. * @param scene defines the hosting scene
  138450. * @param earcutInjection can be used to inject your own earcut reference
  138451. * @returns the polygon mesh
  138452. */
  138453. static ExtrudePolygon(name: string, options: {
  138454. shape: Vector3[];
  138455. holes?: Vector3[][];
  138456. depth?: number;
  138457. faceUV?: Vector4[];
  138458. faceColors?: Color4[];
  138459. updatable?: boolean;
  138460. sideOrientation?: number;
  138461. frontUVs?: Vector4;
  138462. backUVs?: Vector4;
  138463. wrap?: boolean;
  138464. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  138465. }
  138466. }
  138467. declare module BABYLON {
  138468. /**
  138469. * Class containing static functions to help procedurally build meshes
  138470. */
  138471. export class LatheBuilder {
  138472. /**
  138473. * Creates lathe mesh.
  138474. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  138475. * * 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
  138476. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  138477. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  138478. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  138479. * * 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
  138480. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  138481. * * 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
  138482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138486. * @param name defines the name of the mesh
  138487. * @param options defines the options used to create the mesh
  138488. * @param scene defines the hosting scene
  138489. * @returns the lathe mesh
  138490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  138491. */
  138492. static CreateLathe(name: string, options: {
  138493. shape: Vector3[];
  138494. radius?: number;
  138495. tessellation?: number;
  138496. clip?: number;
  138497. arc?: number;
  138498. closed?: boolean;
  138499. updatable?: boolean;
  138500. sideOrientation?: number;
  138501. frontUVs?: Vector4;
  138502. backUVs?: Vector4;
  138503. cap?: number;
  138504. invertUV?: boolean;
  138505. }, scene?: Nullable<Scene>): Mesh;
  138506. }
  138507. }
  138508. declare module BABYLON {
  138509. /**
  138510. * Class containing static functions to help procedurally build meshes
  138511. */
  138512. export class TiledPlaneBuilder {
  138513. /**
  138514. * Creates a tiled plane mesh
  138515. * * The parameter `pattern` will, depending on value, do nothing or
  138516. * * * flip (reflect about central vertical) alternate tiles across and up
  138517. * * * flip every tile on alternate rows
  138518. * * * rotate (180 degs) alternate tiles across and up
  138519. * * * rotate every tile on alternate rows
  138520. * * * flip and rotate alternate tiles across and up
  138521. * * * flip and rotate every tile on alternate rows
  138522. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  138523. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  138524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  138526. * * 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)
  138527. * * 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)
  138528. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  138529. * @param name defines the name of the mesh
  138530. * @param options defines the options used to create the mesh
  138531. * @param scene defines the hosting scene
  138532. * @returns the box mesh
  138533. */
  138534. static CreateTiledPlane(name: string, options: {
  138535. pattern?: number;
  138536. tileSize?: number;
  138537. tileWidth?: number;
  138538. tileHeight?: number;
  138539. size?: number;
  138540. width?: number;
  138541. height?: number;
  138542. alignHorizontal?: number;
  138543. alignVertical?: number;
  138544. sideOrientation?: number;
  138545. frontUVs?: Vector4;
  138546. backUVs?: Vector4;
  138547. updatable?: boolean;
  138548. }, scene?: Nullable<Scene>): Mesh;
  138549. }
  138550. }
  138551. declare module BABYLON {
  138552. /**
  138553. * Class containing static functions to help procedurally build meshes
  138554. */
  138555. export class TubeBuilder {
  138556. /**
  138557. * Creates a tube mesh.
  138558. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138559. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  138560. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  138561. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  138562. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  138563. * * 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)
  138564. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  138565. * * 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
  138566. * * 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
  138567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138569. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138571. * @param name defines the name of the mesh
  138572. * @param options defines the options used to create the mesh
  138573. * @param scene defines the hosting scene
  138574. * @returns the tube mesh
  138575. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138576. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  138577. */
  138578. static CreateTube(name: string, options: {
  138579. path: Vector3[];
  138580. radius?: number;
  138581. tessellation?: number;
  138582. radiusFunction?: {
  138583. (i: number, distance: number): number;
  138584. };
  138585. cap?: number;
  138586. arc?: number;
  138587. updatable?: boolean;
  138588. sideOrientation?: number;
  138589. frontUVs?: Vector4;
  138590. backUVs?: Vector4;
  138591. instance?: Mesh;
  138592. invertUV?: boolean;
  138593. }, scene?: Nullable<Scene>): Mesh;
  138594. }
  138595. }
  138596. declare module BABYLON {
  138597. /**
  138598. * Class containing static functions to help procedurally build meshes
  138599. */
  138600. export class IcoSphereBuilder {
  138601. /**
  138602. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  138603. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  138604. * * 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`)
  138605. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  138606. * * 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
  138607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138610. * @param name defines the name of the mesh
  138611. * @param options defines the options used to create the mesh
  138612. * @param scene defines the hosting scene
  138613. * @returns the icosahedron mesh
  138614. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  138615. */
  138616. static CreateIcoSphere(name: string, options: {
  138617. radius?: number;
  138618. radiusX?: number;
  138619. radiusY?: number;
  138620. radiusZ?: number;
  138621. flat?: boolean;
  138622. subdivisions?: number;
  138623. sideOrientation?: number;
  138624. frontUVs?: Vector4;
  138625. backUVs?: Vector4;
  138626. updatable?: boolean;
  138627. }, scene?: Nullable<Scene>): Mesh;
  138628. }
  138629. }
  138630. declare module BABYLON {
  138631. /**
  138632. * Class containing static functions to help procedurally build meshes
  138633. */
  138634. export class DecalBuilder {
  138635. /**
  138636. * Creates a decal mesh.
  138637. * 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
  138638. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  138639. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  138640. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  138641. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  138642. * @param name defines the name of the mesh
  138643. * @param sourceMesh defines the mesh where the decal must be applied
  138644. * @param options defines the options used to create the mesh
  138645. * @param scene defines the hosting scene
  138646. * @returns the decal mesh
  138647. * @see https://doc.babylonjs.com/how_to/decals
  138648. */
  138649. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  138650. position?: Vector3;
  138651. normal?: Vector3;
  138652. size?: Vector3;
  138653. angle?: number;
  138654. }): Mesh;
  138655. }
  138656. }
  138657. declare module BABYLON {
  138658. /**
  138659. * Class containing static functions to help procedurally build meshes
  138660. */
  138661. export class MeshBuilder {
  138662. /**
  138663. * Creates a box mesh
  138664. * * The parameter `size` sets the size (float) of each box side (default 1)
  138665. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  138666. * * 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)
  138667. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  138668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138671. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  138672. * @param name defines the name of the mesh
  138673. * @param options defines the options used to create the mesh
  138674. * @param scene defines the hosting scene
  138675. * @returns the box mesh
  138676. */
  138677. static CreateBox(name: string, options: {
  138678. size?: number;
  138679. width?: number;
  138680. height?: number;
  138681. depth?: number;
  138682. faceUV?: Vector4[];
  138683. faceColors?: Color4[];
  138684. sideOrientation?: number;
  138685. frontUVs?: Vector4;
  138686. backUVs?: Vector4;
  138687. wrap?: boolean;
  138688. topBaseAt?: number;
  138689. bottomBaseAt?: number;
  138690. updatable?: boolean;
  138691. }, scene?: Nullable<Scene>): Mesh;
  138692. /**
  138693. * Creates a tiled box mesh
  138694. * * faceTiles sets the pattern, tile size and number of tiles for a face
  138695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138696. * @param name defines the name of the mesh
  138697. * @param options defines the options used to create the mesh
  138698. * @param scene defines the hosting scene
  138699. * @returns the tiled box mesh
  138700. */
  138701. static CreateTiledBox(name: string, options: {
  138702. pattern?: number;
  138703. size?: number;
  138704. width?: number;
  138705. height?: number;
  138706. depth: number;
  138707. tileSize?: number;
  138708. tileWidth?: number;
  138709. tileHeight?: number;
  138710. faceUV?: Vector4[];
  138711. faceColors?: Color4[];
  138712. alignHorizontal?: number;
  138713. alignVertical?: number;
  138714. sideOrientation?: number;
  138715. updatable?: boolean;
  138716. }, scene?: Nullable<Scene>): Mesh;
  138717. /**
  138718. * Creates a sphere mesh
  138719. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  138720. * * 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`)
  138721. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  138722. * * 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
  138723. * * 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)
  138724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138727. * @param name defines the name of the mesh
  138728. * @param options defines the options used to create the mesh
  138729. * @param scene defines the hosting scene
  138730. * @returns the sphere mesh
  138731. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  138732. */
  138733. static CreateSphere(name: string, options: {
  138734. segments?: number;
  138735. diameter?: number;
  138736. diameterX?: number;
  138737. diameterY?: number;
  138738. diameterZ?: number;
  138739. arc?: number;
  138740. slice?: number;
  138741. sideOrientation?: number;
  138742. frontUVs?: Vector4;
  138743. backUVs?: Vector4;
  138744. updatable?: boolean;
  138745. }, scene?: Nullable<Scene>): Mesh;
  138746. /**
  138747. * Creates a plane polygonal mesh. By default, this is a disc
  138748. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  138749. * * 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
  138750. * * 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
  138751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138754. * @param name defines the name of the mesh
  138755. * @param options defines the options used to create the mesh
  138756. * @param scene defines the hosting scene
  138757. * @returns the plane polygonal mesh
  138758. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  138759. */
  138760. static CreateDisc(name: string, options: {
  138761. radius?: number;
  138762. tessellation?: number;
  138763. arc?: number;
  138764. updatable?: boolean;
  138765. sideOrientation?: number;
  138766. frontUVs?: Vector4;
  138767. backUVs?: Vector4;
  138768. }, scene?: Nullable<Scene>): Mesh;
  138769. /**
  138770. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  138771. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  138772. * * 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`)
  138773. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  138774. * * 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
  138775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138778. * @param name defines the name of the mesh
  138779. * @param options defines the options used to create the mesh
  138780. * @param scene defines the hosting scene
  138781. * @returns the icosahedron mesh
  138782. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  138783. */
  138784. static CreateIcoSphere(name: string, options: {
  138785. radius?: number;
  138786. radiusX?: number;
  138787. radiusY?: number;
  138788. radiusZ?: number;
  138789. flat?: boolean;
  138790. subdivisions?: number;
  138791. sideOrientation?: number;
  138792. frontUVs?: Vector4;
  138793. backUVs?: Vector4;
  138794. updatable?: boolean;
  138795. }, scene?: Nullable<Scene>): Mesh;
  138796. /**
  138797. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  138798. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  138799. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  138800. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  138801. * * 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
  138802. * * 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
  138803. * * 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
  138804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138807. * * 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
  138808. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  138809. * * 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
  138810. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  138811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138812. * @param name defines the name of the mesh
  138813. * @param options defines the options used to create the mesh
  138814. * @param scene defines the hosting scene
  138815. * @returns the ribbon mesh
  138816. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  138817. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138818. */
  138819. static CreateRibbon(name: string, options: {
  138820. pathArray: Vector3[][];
  138821. closeArray?: boolean;
  138822. closePath?: boolean;
  138823. offset?: number;
  138824. updatable?: boolean;
  138825. sideOrientation?: number;
  138826. frontUVs?: Vector4;
  138827. backUVs?: Vector4;
  138828. instance?: Mesh;
  138829. invertUV?: boolean;
  138830. uvs?: Vector2[];
  138831. colors?: Color4[];
  138832. }, scene?: Nullable<Scene>): Mesh;
  138833. /**
  138834. * Creates a cylinder or a cone mesh
  138835. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  138836. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  138837. * * 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.
  138838. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  138839. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  138840. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  138841. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  138842. * * 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).
  138843. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  138844. * * 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).
  138845. * * 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
  138846. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  138847. * * 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
  138848. * * 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.
  138849. * * If `enclose` is false, a ring surface is one element.
  138850. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  138851. * * 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
  138852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138855. * @param name defines the name of the mesh
  138856. * @param options defines the options used to create the mesh
  138857. * @param scene defines the hosting scene
  138858. * @returns the cylinder mesh
  138859. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  138860. */
  138861. static CreateCylinder(name: string, options: {
  138862. height?: number;
  138863. diameterTop?: number;
  138864. diameterBottom?: number;
  138865. diameter?: number;
  138866. tessellation?: number;
  138867. subdivisions?: number;
  138868. arc?: number;
  138869. faceColors?: Color4[];
  138870. faceUV?: Vector4[];
  138871. updatable?: boolean;
  138872. hasRings?: boolean;
  138873. enclose?: boolean;
  138874. cap?: number;
  138875. sideOrientation?: number;
  138876. frontUVs?: Vector4;
  138877. backUVs?: Vector4;
  138878. }, scene?: Nullable<Scene>): Mesh;
  138879. /**
  138880. * Creates a torus mesh
  138881. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  138882. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  138883. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  138884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138887. * @param name defines the name of the mesh
  138888. * @param options defines the options used to create the mesh
  138889. * @param scene defines the hosting scene
  138890. * @returns the torus mesh
  138891. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  138892. */
  138893. static CreateTorus(name: string, options: {
  138894. diameter?: number;
  138895. thickness?: number;
  138896. tessellation?: number;
  138897. updatable?: boolean;
  138898. sideOrientation?: number;
  138899. frontUVs?: Vector4;
  138900. backUVs?: Vector4;
  138901. }, scene?: Nullable<Scene>): Mesh;
  138902. /**
  138903. * Creates a torus knot mesh
  138904. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  138905. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  138906. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  138907. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  138908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138911. * @param name defines the name of the mesh
  138912. * @param options defines the options used to create the mesh
  138913. * @param scene defines the hosting scene
  138914. * @returns the torus knot mesh
  138915. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  138916. */
  138917. static CreateTorusKnot(name: string, options: {
  138918. radius?: number;
  138919. tube?: number;
  138920. radialSegments?: number;
  138921. tubularSegments?: number;
  138922. p?: number;
  138923. q?: number;
  138924. updatable?: boolean;
  138925. sideOrientation?: number;
  138926. frontUVs?: Vector4;
  138927. backUVs?: Vector4;
  138928. }, scene?: Nullable<Scene>): Mesh;
  138929. /**
  138930. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  138931. * * 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
  138932. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  138933. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  138934. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  138935. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  138936. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  138937. * * 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
  138938. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  138939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  138941. * @param name defines the name of the new line system
  138942. * @param options defines the options used to create the line system
  138943. * @param scene defines the hosting scene
  138944. * @returns a new line system mesh
  138945. */
  138946. static CreateLineSystem(name: string, options: {
  138947. lines: Vector3[][];
  138948. updatable?: boolean;
  138949. instance?: Nullable<LinesMesh>;
  138950. colors?: Nullable<Color4[][]>;
  138951. useVertexAlpha?: boolean;
  138952. }, scene: Nullable<Scene>): LinesMesh;
  138953. /**
  138954. * Creates a line mesh
  138955. * 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
  138956. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  138957. * * The parameter `points` is an array successive Vector3
  138958. * * 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
  138959. * * The optional parameter `colors` is an array of successive Color4, one per line point
  138960. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  138961. * * When updating an instance, remember that only point positions can change, not the number of points
  138962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  138964. * @param name defines the name of the new line system
  138965. * @param options defines the options used to create the line system
  138966. * @param scene defines the hosting scene
  138967. * @returns a new line mesh
  138968. */
  138969. static CreateLines(name: string, options: {
  138970. points: Vector3[];
  138971. updatable?: boolean;
  138972. instance?: Nullable<LinesMesh>;
  138973. colors?: Color4[];
  138974. useVertexAlpha?: boolean;
  138975. }, scene?: Nullable<Scene>): LinesMesh;
  138976. /**
  138977. * Creates a dashed line mesh
  138978. * * 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
  138979. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  138980. * * The parameter `points` is an array successive Vector3
  138981. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  138982. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  138983. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  138984. * * 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
  138985. * * When updating an instance, remember that only point positions can change, not the number of points
  138986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138987. * @param name defines the name of the mesh
  138988. * @param options defines the options used to create the mesh
  138989. * @param scene defines the hosting scene
  138990. * @returns the dashed line mesh
  138991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  138992. */
  138993. static CreateDashedLines(name: string, options: {
  138994. points: Vector3[];
  138995. dashSize?: number;
  138996. gapSize?: number;
  138997. dashNb?: number;
  138998. updatable?: boolean;
  138999. instance?: LinesMesh;
  139000. }, scene?: Nullable<Scene>): LinesMesh;
  139001. /**
  139002. * 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.
  139003. * * 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.
  139004. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139005. * * 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.
  139006. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  139007. * * 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
  139008. * * 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
  139009. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  139010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139012. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  139013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139014. * @param name defines the name of the mesh
  139015. * @param options defines the options used to create the mesh
  139016. * @param scene defines the hosting scene
  139017. * @returns the extruded shape mesh
  139018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139020. */
  139021. static ExtrudeShape(name: string, options: {
  139022. shape: Vector3[];
  139023. path: Vector3[];
  139024. scale?: number;
  139025. rotation?: number;
  139026. cap?: number;
  139027. updatable?: boolean;
  139028. sideOrientation?: number;
  139029. frontUVs?: Vector4;
  139030. backUVs?: Vector4;
  139031. instance?: Mesh;
  139032. invertUV?: boolean;
  139033. }, scene?: Nullable<Scene>): Mesh;
  139034. /**
  139035. * Creates an custom extruded shape mesh.
  139036. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  139037. * * 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.
  139038. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  139039. * * 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
  139040. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  139041. * * 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
  139042. * * It must returns a float value that will be the scale value applied to the shape on each path point
  139043. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  139044. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  139045. * * 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
  139046. * * 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
  139047. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  139048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139050. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139052. * @param name defines the name of the mesh
  139053. * @param options defines the options used to create the mesh
  139054. * @param scene defines the hosting scene
  139055. * @returns the custom extruded shape mesh
  139056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  139057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  139059. */
  139060. static ExtrudeShapeCustom(name: string, options: {
  139061. shape: Vector3[];
  139062. path: Vector3[];
  139063. scaleFunction?: any;
  139064. rotationFunction?: any;
  139065. ribbonCloseArray?: boolean;
  139066. ribbonClosePath?: boolean;
  139067. cap?: number;
  139068. updatable?: boolean;
  139069. sideOrientation?: number;
  139070. frontUVs?: Vector4;
  139071. backUVs?: Vector4;
  139072. instance?: Mesh;
  139073. invertUV?: boolean;
  139074. }, scene?: Nullable<Scene>): Mesh;
  139075. /**
  139076. * Creates lathe mesh.
  139077. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  139078. * * 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
  139079. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  139080. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  139081. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  139082. * * 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
  139083. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  139084. * * 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
  139085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139087. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139089. * @param name defines the name of the mesh
  139090. * @param options defines the options used to create the mesh
  139091. * @param scene defines the hosting scene
  139092. * @returns the lathe mesh
  139093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  139094. */
  139095. static CreateLathe(name: string, options: {
  139096. shape: Vector3[];
  139097. radius?: number;
  139098. tessellation?: number;
  139099. clip?: number;
  139100. arc?: number;
  139101. closed?: boolean;
  139102. updatable?: boolean;
  139103. sideOrientation?: number;
  139104. frontUVs?: Vector4;
  139105. backUVs?: Vector4;
  139106. cap?: number;
  139107. invertUV?: boolean;
  139108. }, scene?: Nullable<Scene>): Mesh;
  139109. /**
  139110. * Creates a tiled plane mesh
  139111. * * You can set a limited pattern arrangement with the tiles
  139112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139115. * @param name defines the name of the mesh
  139116. * @param options defines the options used to create the mesh
  139117. * @param scene defines the hosting scene
  139118. * @returns the plane mesh
  139119. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139120. */
  139121. static CreateTiledPlane(name: string, options: {
  139122. pattern?: number;
  139123. tileSize?: number;
  139124. tileWidth?: number;
  139125. tileHeight?: number;
  139126. size?: number;
  139127. width?: number;
  139128. height?: number;
  139129. alignHorizontal?: number;
  139130. alignVertical?: number;
  139131. sideOrientation?: number;
  139132. frontUVs?: Vector4;
  139133. backUVs?: Vector4;
  139134. updatable?: boolean;
  139135. }, scene?: Nullable<Scene>): Mesh;
  139136. /**
  139137. * Creates a plane mesh
  139138. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  139139. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  139140. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  139141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139144. * @param name defines the name of the mesh
  139145. * @param options defines the options used to create the mesh
  139146. * @param scene defines the hosting scene
  139147. * @returns the plane mesh
  139148. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  139149. */
  139150. static CreatePlane(name: string, options: {
  139151. size?: number;
  139152. width?: number;
  139153. height?: number;
  139154. sideOrientation?: number;
  139155. frontUVs?: Vector4;
  139156. backUVs?: Vector4;
  139157. updatable?: boolean;
  139158. sourcePlane?: Plane;
  139159. }, scene?: Nullable<Scene>): Mesh;
  139160. /**
  139161. * Creates a ground mesh
  139162. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  139163. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  139164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139165. * @param name defines the name of the mesh
  139166. * @param options defines the options used to create the mesh
  139167. * @param scene defines the hosting scene
  139168. * @returns the ground mesh
  139169. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  139170. */
  139171. static CreateGround(name: string, options: {
  139172. width?: number;
  139173. height?: number;
  139174. subdivisions?: number;
  139175. subdivisionsX?: number;
  139176. subdivisionsY?: number;
  139177. updatable?: boolean;
  139178. }, scene?: Nullable<Scene>): Mesh;
  139179. /**
  139180. * Creates a tiled ground mesh
  139181. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  139182. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  139183. * * 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
  139184. * * 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
  139185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139186. * @param name defines the name of the mesh
  139187. * @param options defines the options used to create the mesh
  139188. * @param scene defines the hosting scene
  139189. * @returns the tiled ground mesh
  139190. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  139191. */
  139192. static CreateTiledGround(name: string, options: {
  139193. xmin: number;
  139194. zmin: number;
  139195. xmax: number;
  139196. zmax: number;
  139197. subdivisions?: {
  139198. w: number;
  139199. h: number;
  139200. };
  139201. precision?: {
  139202. w: number;
  139203. h: number;
  139204. };
  139205. updatable?: boolean;
  139206. }, scene?: Nullable<Scene>): Mesh;
  139207. /**
  139208. * Creates a ground mesh from a height map
  139209. * * The parameter `url` sets the URL of the height map image resource.
  139210. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  139211. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  139212. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  139213. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  139214. * * 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.
  139215. * * 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).
  139216. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  139217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  139218. * @param name defines the name of the mesh
  139219. * @param url defines the url to the height map
  139220. * @param options defines the options used to create the mesh
  139221. * @param scene defines the hosting scene
  139222. * @returns the ground mesh
  139223. * @see https://doc.babylonjs.com/babylon101/height_map
  139224. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  139225. */
  139226. static CreateGroundFromHeightMap(name: string, url: string, options: {
  139227. width?: number;
  139228. height?: number;
  139229. subdivisions?: number;
  139230. minHeight?: number;
  139231. maxHeight?: number;
  139232. colorFilter?: Color3;
  139233. alphaFilter?: number;
  139234. updatable?: boolean;
  139235. onReady?: (mesh: GroundMesh) => void;
  139236. }, scene?: Nullable<Scene>): GroundMesh;
  139237. /**
  139238. * Creates a polygon mesh
  139239. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  139240. * * 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
  139241. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  139242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  139244. * * Remember you can only change the shape positions, not their number when updating a polygon
  139245. * @param name defines the name of the mesh
  139246. * @param options defines the options used to create the mesh
  139247. * @param scene defines the hosting scene
  139248. * @param earcutInjection can be used to inject your own earcut reference
  139249. * @returns the polygon mesh
  139250. */
  139251. static CreatePolygon(name: string, options: {
  139252. shape: Vector3[];
  139253. holes?: Vector3[][];
  139254. depth?: number;
  139255. faceUV?: Vector4[];
  139256. faceColors?: Color4[];
  139257. updatable?: boolean;
  139258. sideOrientation?: number;
  139259. frontUVs?: Vector4;
  139260. backUVs?: Vector4;
  139261. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139262. /**
  139263. * Creates an extruded polygon mesh, with depth in the Y direction.
  139264. * * 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)
  139265. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  139266. * @param name defines the name of the mesh
  139267. * @param options defines the options used to create the mesh
  139268. * @param scene defines the hosting scene
  139269. * @param earcutInjection can be used to inject your own earcut reference
  139270. * @returns the polygon mesh
  139271. */
  139272. static ExtrudePolygon(name: string, options: {
  139273. shape: Vector3[];
  139274. holes?: Vector3[][];
  139275. depth?: number;
  139276. faceUV?: Vector4[];
  139277. faceColors?: Color4[];
  139278. updatable?: boolean;
  139279. sideOrientation?: number;
  139280. frontUVs?: Vector4;
  139281. backUVs?: Vector4;
  139282. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  139283. /**
  139284. * Creates a tube mesh.
  139285. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  139286. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  139287. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  139288. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  139289. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  139290. * * 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)
  139291. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  139292. * * 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
  139293. * * 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
  139294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139296. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  139297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139298. * @param name defines the name of the mesh
  139299. * @param options defines the options used to create the mesh
  139300. * @param scene defines the hosting scene
  139301. * @returns the tube mesh
  139302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  139303. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  139304. */
  139305. static CreateTube(name: string, options: {
  139306. path: Vector3[];
  139307. radius?: number;
  139308. tessellation?: number;
  139309. radiusFunction?: {
  139310. (i: number, distance: number): number;
  139311. };
  139312. cap?: number;
  139313. arc?: number;
  139314. updatable?: boolean;
  139315. sideOrientation?: number;
  139316. frontUVs?: Vector4;
  139317. backUVs?: Vector4;
  139318. instance?: Mesh;
  139319. invertUV?: boolean;
  139320. }, scene?: Nullable<Scene>): Mesh;
  139321. /**
  139322. * Creates a polyhedron mesh
  139323. * * 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
  139324. * * The parameter `size` (positive float, default 1) sets the polygon size
  139325. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  139326. * * 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`
  139327. * * 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
  139328. * * 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)`)
  139329. * * 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
  139330. * * 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
  139331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  139333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139334. * @param name defines the name of the mesh
  139335. * @param options defines the options used to create the mesh
  139336. * @param scene defines the hosting scene
  139337. * @returns the polyhedron mesh
  139338. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  139339. */
  139340. static CreatePolyhedron(name: string, options: {
  139341. type?: number;
  139342. size?: number;
  139343. sizeX?: number;
  139344. sizeY?: number;
  139345. sizeZ?: number;
  139346. custom?: any;
  139347. faceUV?: Vector4[];
  139348. faceColors?: Color4[];
  139349. flat?: boolean;
  139350. updatable?: boolean;
  139351. sideOrientation?: number;
  139352. frontUVs?: Vector4;
  139353. backUVs?: Vector4;
  139354. }, scene?: Nullable<Scene>): Mesh;
  139355. /**
  139356. * Creates a decal mesh.
  139357. * 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
  139358. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  139359. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  139360. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  139361. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  139362. * @param name defines the name of the mesh
  139363. * @param sourceMesh defines the mesh where the decal must be applied
  139364. * @param options defines the options used to create the mesh
  139365. * @param scene defines the hosting scene
  139366. * @returns the decal mesh
  139367. * @see https://doc.babylonjs.com/how_to/decals
  139368. */
  139369. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  139370. position?: Vector3;
  139371. normal?: Vector3;
  139372. size?: Vector3;
  139373. angle?: number;
  139374. }): Mesh;
  139375. }
  139376. }
  139377. declare module BABYLON {
  139378. /**
  139379. * A simplifier interface for future simplification implementations
  139380. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139381. */
  139382. export interface ISimplifier {
  139383. /**
  139384. * Simplification of a given mesh according to the given settings.
  139385. * Since this requires computation, it is assumed that the function runs async.
  139386. * @param settings The settings of the simplification, including quality and distance
  139387. * @param successCallback A callback that will be called after the mesh was simplified.
  139388. * @param errorCallback in case of an error, this callback will be called. optional.
  139389. */
  139390. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  139391. }
  139392. /**
  139393. * Expected simplification settings.
  139394. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  139395. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139396. */
  139397. export interface ISimplificationSettings {
  139398. /**
  139399. * Gets or sets the expected quality
  139400. */
  139401. quality: number;
  139402. /**
  139403. * Gets or sets the distance when this optimized version should be used
  139404. */
  139405. distance: number;
  139406. /**
  139407. * Gets an already optimized mesh
  139408. */
  139409. optimizeMesh?: boolean;
  139410. }
  139411. /**
  139412. * Class used to specify simplification options
  139413. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139414. */
  139415. export class SimplificationSettings implements ISimplificationSettings {
  139416. /** expected quality */
  139417. quality: number;
  139418. /** distance when this optimized version should be used */
  139419. distance: number;
  139420. /** already optimized mesh */
  139421. optimizeMesh?: boolean | undefined;
  139422. /**
  139423. * Creates a SimplificationSettings
  139424. * @param quality expected quality
  139425. * @param distance distance when this optimized version should be used
  139426. * @param optimizeMesh already optimized mesh
  139427. */
  139428. constructor(
  139429. /** expected quality */
  139430. quality: number,
  139431. /** distance when this optimized version should be used */
  139432. distance: number,
  139433. /** already optimized mesh */
  139434. optimizeMesh?: boolean | undefined);
  139435. }
  139436. /**
  139437. * Interface used to define a simplification task
  139438. */
  139439. export interface ISimplificationTask {
  139440. /**
  139441. * Array of settings
  139442. */
  139443. settings: Array<ISimplificationSettings>;
  139444. /**
  139445. * Simplification type
  139446. */
  139447. simplificationType: SimplificationType;
  139448. /**
  139449. * Mesh to simplify
  139450. */
  139451. mesh: Mesh;
  139452. /**
  139453. * Callback called on success
  139454. */
  139455. successCallback?: () => void;
  139456. /**
  139457. * Defines if parallel processing can be used
  139458. */
  139459. parallelProcessing: boolean;
  139460. }
  139461. /**
  139462. * Queue used to order the simplification tasks
  139463. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139464. */
  139465. export class SimplificationQueue {
  139466. private _simplificationArray;
  139467. /**
  139468. * Gets a boolean indicating that the process is still running
  139469. */
  139470. running: boolean;
  139471. /**
  139472. * Creates a new queue
  139473. */
  139474. constructor();
  139475. /**
  139476. * Adds a new simplification task
  139477. * @param task defines a task to add
  139478. */
  139479. addTask(task: ISimplificationTask): void;
  139480. /**
  139481. * Execute next task
  139482. */
  139483. executeNext(): void;
  139484. /**
  139485. * Execute a simplification task
  139486. * @param task defines the task to run
  139487. */
  139488. runSimplification(task: ISimplificationTask): void;
  139489. private getSimplifier;
  139490. }
  139491. /**
  139492. * The implemented types of simplification
  139493. * At the moment only Quadratic Error Decimation is implemented
  139494. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139495. */
  139496. export enum SimplificationType {
  139497. /** Quadratic error decimation */
  139498. QUADRATIC = 0
  139499. }
  139500. /**
  139501. * An implementation of the Quadratic Error simplification algorithm.
  139502. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  139503. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  139504. * @author RaananW
  139505. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139506. */
  139507. export class QuadraticErrorSimplification implements ISimplifier {
  139508. private _mesh;
  139509. private triangles;
  139510. private vertices;
  139511. private references;
  139512. private _reconstructedMesh;
  139513. /** Gets or sets the number pf sync interations */
  139514. syncIterations: number;
  139515. /** Gets or sets the aggressiveness of the simplifier */
  139516. aggressiveness: number;
  139517. /** Gets or sets the number of allowed iterations for decimation */
  139518. decimationIterations: number;
  139519. /** Gets or sets the espilon to use for bounding box computation */
  139520. boundingBoxEpsilon: number;
  139521. /**
  139522. * Creates a new QuadraticErrorSimplification
  139523. * @param _mesh defines the target mesh
  139524. */
  139525. constructor(_mesh: Mesh);
  139526. /**
  139527. * Simplification of a given mesh according to the given settings.
  139528. * Since this requires computation, it is assumed that the function runs async.
  139529. * @param settings The settings of the simplification, including quality and distance
  139530. * @param successCallback A callback that will be called after the mesh was simplified.
  139531. */
  139532. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  139533. private runDecimation;
  139534. private initWithMesh;
  139535. private init;
  139536. private reconstructMesh;
  139537. private initDecimatedMesh;
  139538. private isFlipped;
  139539. private updateTriangles;
  139540. private identifyBorder;
  139541. private updateMesh;
  139542. private vertexError;
  139543. private calculateError;
  139544. }
  139545. }
  139546. declare module BABYLON {
  139547. interface Scene {
  139548. /** @hidden (Backing field) */
  139549. _simplificationQueue: SimplificationQueue;
  139550. /**
  139551. * Gets or sets the simplification queue attached to the scene
  139552. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  139553. */
  139554. simplificationQueue: SimplificationQueue;
  139555. }
  139556. interface Mesh {
  139557. /**
  139558. * Simplify the mesh according to the given array of settings.
  139559. * Function will return immediately and will simplify async
  139560. * @param settings a collection of simplification settings
  139561. * @param parallelProcessing should all levels calculate parallel or one after the other
  139562. * @param simplificationType the type of simplification to run
  139563. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  139564. * @returns the current mesh
  139565. */
  139566. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  139567. }
  139568. /**
  139569. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  139570. * created in a scene
  139571. */
  139572. export class SimplicationQueueSceneComponent implements ISceneComponent {
  139573. /**
  139574. * The component name helpfull to identify the component in the list of scene components.
  139575. */
  139576. readonly name: string;
  139577. /**
  139578. * The scene the component belongs to.
  139579. */
  139580. scene: Scene;
  139581. /**
  139582. * Creates a new instance of the component for the given scene
  139583. * @param scene Defines the scene to register the component in
  139584. */
  139585. constructor(scene: Scene);
  139586. /**
  139587. * Registers the component in a given scene
  139588. */
  139589. register(): void;
  139590. /**
  139591. * Rebuilds the elements related to this component in case of
  139592. * context lost for instance.
  139593. */
  139594. rebuild(): void;
  139595. /**
  139596. * Disposes the component and the associated ressources
  139597. */
  139598. dispose(): void;
  139599. private _beforeCameraUpdate;
  139600. }
  139601. }
  139602. declare module BABYLON {
  139603. /**
  139604. * Navigation plugin interface to add navigation constrained by a navigation mesh
  139605. */
  139606. export interface INavigationEnginePlugin {
  139607. /**
  139608. * plugin name
  139609. */
  139610. name: string;
  139611. /**
  139612. * Creates a navigation mesh
  139613. * @param meshes array of all the geometry used to compute the navigatio mesh
  139614. * @param parameters bunch of parameters used to filter geometry
  139615. */
  139616. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  139617. /**
  139618. * Create a navigation mesh debug mesh
  139619. * @param scene is where the mesh will be added
  139620. * @returns debug display mesh
  139621. */
  139622. createDebugNavMesh(scene: Scene): Mesh;
  139623. /**
  139624. * Get a navigation mesh constrained position, closest to the parameter position
  139625. * @param position world position
  139626. * @returns the closest point to position constrained by the navigation mesh
  139627. */
  139628. getClosestPoint(position: Vector3): Vector3;
  139629. /**
  139630. * Get a navigation mesh constrained position, closest to the parameter position
  139631. * @param position world position
  139632. * @param result output the closest point to position constrained by the navigation mesh
  139633. */
  139634. getClosestPointToRef(position: Vector3, result: Vector3): void;
  139635. /**
  139636. * Get a navigation mesh constrained position, within a particular radius
  139637. * @param position world position
  139638. * @param maxRadius the maximum distance to the constrained world position
  139639. * @returns the closest point to position constrained by the navigation mesh
  139640. */
  139641. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  139642. /**
  139643. * Get a navigation mesh constrained position, within a particular radius
  139644. * @param position world position
  139645. * @param maxRadius the maximum distance to the constrained world position
  139646. * @param result output the closest point to position constrained by the navigation mesh
  139647. */
  139648. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  139649. /**
  139650. * Compute the final position from a segment made of destination-position
  139651. * @param position world position
  139652. * @param destination world position
  139653. * @returns the resulting point along the navmesh
  139654. */
  139655. moveAlong(position: Vector3, destination: Vector3): Vector3;
  139656. /**
  139657. * Compute the final position from a segment made of destination-position
  139658. * @param position world position
  139659. * @param destination world position
  139660. * @param result output the resulting point along the navmesh
  139661. */
  139662. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  139663. /**
  139664. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  139665. * @param start world position
  139666. * @param end world position
  139667. * @returns array containing world position composing the path
  139668. */
  139669. computePath(start: Vector3, end: Vector3): Vector3[];
  139670. /**
  139671. * If this plugin is supported
  139672. * @returns true if plugin is supported
  139673. */
  139674. isSupported(): boolean;
  139675. /**
  139676. * Create a new Crowd so you can add agents
  139677. * @param maxAgents the maximum agent count in the crowd
  139678. * @param maxAgentRadius the maximum radius an agent can have
  139679. * @param scene to attach the crowd to
  139680. * @returns the crowd you can add agents to
  139681. */
  139682. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  139683. /**
  139684. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  139685. * The queries will try to find a solution within those bounds
  139686. * default is (1,1,1)
  139687. * @param extent x,y,z value that define the extent around the queries point of reference
  139688. */
  139689. setDefaultQueryExtent(extent: Vector3): void;
  139690. /**
  139691. * Get the Bounding box extent specified by setDefaultQueryExtent
  139692. * @returns the box extent values
  139693. */
  139694. getDefaultQueryExtent(): Vector3;
  139695. /**
  139696. * build the navmesh from a previously saved state using getNavmeshData
  139697. * @param data the Uint8Array returned by getNavmeshData
  139698. */
  139699. buildFromNavmeshData(data: Uint8Array): void;
  139700. /**
  139701. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  139702. * @returns data the Uint8Array that can be saved and reused
  139703. */
  139704. getNavmeshData(): Uint8Array;
  139705. /**
  139706. * Get the Bounding box extent result specified by setDefaultQueryExtent
  139707. * @param result output the box extent values
  139708. */
  139709. getDefaultQueryExtentToRef(result: Vector3): void;
  139710. /**
  139711. * Release all resources
  139712. */
  139713. dispose(): void;
  139714. }
  139715. /**
  139716. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  139717. */
  139718. export interface ICrowd {
  139719. /**
  139720. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  139721. * You can attach anything to that node. The node position is updated in the scene update tick.
  139722. * @param pos world position that will be constrained by the navigation mesh
  139723. * @param parameters agent parameters
  139724. * @param transform hooked to the agent that will be update by the scene
  139725. * @returns agent index
  139726. */
  139727. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  139728. /**
  139729. * Returns the agent position in world space
  139730. * @param index agent index returned by addAgent
  139731. * @returns world space position
  139732. */
  139733. getAgentPosition(index: number): Vector3;
  139734. /**
  139735. * Gets the agent position result in world space
  139736. * @param index agent index returned by addAgent
  139737. * @param result output world space position
  139738. */
  139739. getAgentPositionToRef(index: number, result: Vector3): void;
  139740. /**
  139741. * Gets the agent velocity in world space
  139742. * @param index agent index returned by addAgent
  139743. * @returns world space velocity
  139744. */
  139745. getAgentVelocity(index: number): Vector3;
  139746. /**
  139747. * Gets the agent velocity result in world space
  139748. * @param index agent index returned by addAgent
  139749. * @param result output world space velocity
  139750. */
  139751. getAgentVelocityToRef(index: number, result: Vector3): void;
  139752. /**
  139753. * remove a particular agent previously created
  139754. * @param index agent index returned by addAgent
  139755. */
  139756. removeAgent(index: number): void;
  139757. /**
  139758. * get the list of all agents attached to this crowd
  139759. * @returns list of agent indices
  139760. */
  139761. getAgents(): number[];
  139762. /**
  139763. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  139764. * @param deltaTime in seconds
  139765. */
  139766. update(deltaTime: number): void;
  139767. /**
  139768. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  139769. * @param index agent index returned by addAgent
  139770. * @param destination targeted world position
  139771. */
  139772. agentGoto(index: number, destination: Vector3): void;
  139773. /**
  139774. * Teleport the agent to a new position
  139775. * @param index agent index returned by addAgent
  139776. * @param destination targeted world position
  139777. */
  139778. agentTeleport(index: number, destination: Vector3): void;
  139779. /**
  139780. * Update agent parameters
  139781. * @param index agent index returned by addAgent
  139782. * @param parameters agent parameters
  139783. */
  139784. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  139785. /**
  139786. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  139787. * The queries will try to find a solution within those bounds
  139788. * default is (1,1,1)
  139789. * @param extent x,y,z value that define the extent around the queries point of reference
  139790. */
  139791. setDefaultQueryExtent(extent: Vector3): void;
  139792. /**
  139793. * Get the Bounding box extent specified by setDefaultQueryExtent
  139794. * @returns the box extent values
  139795. */
  139796. getDefaultQueryExtent(): Vector3;
  139797. /**
  139798. * Get the Bounding box extent result specified by setDefaultQueryExtent
  139799. * @param result output the box extent values
  139800. */
  139801. getDefaultQueryExtentToRef(result: Vector3): void;
  139802. /**
  139803. * Release all resources
  139804. */
  139805. dispose(): void;
  139806. }
  139807. /**
  139808. * Configures an agent
  139809. */
  139810. export interface IAgentParameters {
  139811. /**
  139812. * Agent radius. [Limit: >= 0]
  139813. */
  139814. radius: number;
  139815. /**
  139816. * Agent height. [Limit: > 0]
  139817. */
  139818. height: number;
  139819. /**
  139820. * Maximum allowed acceleration. [Limit: >= 0]
  139821. */
  139822. maxAcceleration: number;
  139823. /**
  139824. * Maximum allowed speed. [Limit: >= 0]
  139825. */
  139826. maxSpeed: number;
  139827. /**
  139828. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  139829. */
  139830. collisionQueryRange: number;
  139831. /**
  139832. * The path visibility optimization range. [Limit: > 0]
  139833. */
  139834. pathOptimizationRange: number;
  139835. /**
  139836. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  139837. */
  139838. separationWeight: number;
  139839. }
  139840. /**
  139841. * Configures the navigation mesh creation
  139842. */
  139843. export interface INavMeshParameters {
  139844. /**
  139845. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  139846. */
  139847. cs: number;
  139848. /**
  139849. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  139850. */
  139851. ch: number;
  139852. /**
  139853. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  139854. */
  139855. walkableSlopeAngle: number;
  139856. /**
  139857. * Minimum floor to 'ceiling' height that will still allow the floor area to
  139858. * be considered walkable. [Limit: >= 3] [Units: vx]
  139859. */
  139860. walkableHeight: number;
  139861. /**
  139862. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  139863. */
  139864. walkableClimb: number;
  139865. /**
  139866. * The distance to erode/shrink the walkable area of the heightfield away from
  139867. * obstructions. [Limit: >=0] [Units: vx]
  139868. */
  139869. walkableRadius: number;
  139870. /**
  139871. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  139872. */
  139873. maxEdgeLen: number;
  139874. /**
  139875. * The maximum distance a simplfied contour's border edges should deviate
  139876. * the original raw contour. [Limit: >=0] [Units: vx]
  139877. */
  139878. maxSimplificationError: number;
  139879. /**
  139880. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  139881. */
  139882. minRegionArea: number;
  139883. /**
  139884. * Any regions with a span count smaller than this value will, if possible,
  139885. * be merged with larger regions. [Limit: >=0] [Units: vx]
  139886. */
  139887. mergeRegionArea: number;
  139888. /**
  139889. * The maximum number of vertices allowed for polygons generated during the
  139890. * contour to polygon conversion process. [Limit: >= 3]
  139891. */
  139892. maxVertsPerPoly: number;
  139893. /**
  139894. * Sets the sampling distance to use when generating the detail mesh.
  139895. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  139896. */
  139897. detailSampleDist: number;
  139898. /**
  139899. * The maximum distance the detail mesh surface should deviate from heightfield
  139900. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  139901. */
  139902. detailSampleMaxError: number;
  139903. }
  139904. }
  139905. declare module BABYLON {
  139906. /**
  139907. * RecastJS navigation plugin
  139908. */
  139909. export class RecastJSPlugin implements INavigationEnginePlugin {
  139910. /**
  139911. * Reference to the Recast library
  139912. */
  139913. bjsRECAST: any;
  139914. /**
  139915. * plugin name
  139916. */
  139917. name: string;
  139918. /**
  139919. * the first navmesh created. We might extend this to support multiple navmeshes
  139920. */
  139921. navMesh: any;
  139922. /**
  139923. * Initializes the recastJS plugin
  139924. * @param recastInjection can be used to inject your own recast reference
  139925. */
  139926. constructor(recastInjection?: any);
  139927. /**
  139928. * Creates a navigation mesh
  139929. * @param meshes array of all the geometry used to compute the navigatio mesh
  139930. * @param parameters bunch of parameters used to filter geometry
  139931. */
  139932. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  139933. /**
  139934. * Create a navigation mesh debug mesh
  139935. * @param scene is where the mesh will be added
  139936. * @returns debug display mesh
  139937. */
  139938. createDebugNavMesh(scene: Scene): Mesh;
  139939. /**
  139940. * Get a navigation mesh constrained position, closest to the parameter position
  139941. * @param position world position
  139942. * @returns the closest point to position constrained by the navigation mesh
  139943. */
  139944. getClosestPoint(position: Vector3): Vector3;
  139945. /**
  139946. * Get a navigation mesh constrained position, closest to the parameter position
  139947. * @param position world position
  139948. * @param result output the closest point to position constrained by the navigation mesh
  139949. */
  139950. getClosestPointToRef(position: Vector3, result: Vector3): void;
  139951. /**
  139952. * Get a navigation mesh constrained position, within a particular radius
  139953. * @param position world position
  139954. * @param maxRadius the maximum distance to the constrained world position
  139955. * @returns the closest point to position constrained by the navigation mesh
  139956. */
  139957. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  139958. /**
  139959. * Get a navigation mesh constrained position, within a particular radius
  139960. * @param position world position
  139961. * @param maxRadius the maximum distance to the constrained world position
  139962. * @param result output the closest point to position constrained by the navigation mesh
  139963. */
  139964. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  139965. /**
  139966. * Compute the final position from a segment made of destination-position
  139967. * @param position world position
  139968. * @param destination world position
  139969. * @returns the resulting point along the navmesh
  139970. */
  139971. moveAlong(position: Vector3, destination: Vector3): Vector3;
  139972. /**
  139973. * Compute the final position from a segment made of destination-position
  139974. * @param position world position
  139975. * @param destination world position
  139976. * @param result output the resulting point along the navmesh
  139977. */
  139978. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  139979. /**
  139980. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  139981. * @param start world position
  139982. * @param end world position
  139983. * @returns array containing world position composing the path
  139984. */
  139985. computePath(start: Vector3, end: Vector3): Vector3[];
  139986. /**
  139987. * Create a new Crowd so you can add agents
  139988. * @param maxAgents the maximum agent count in the crowd
  139989. * @param maxAgentRadius the maximum radius an agent can have
  139990. * @param scene to attach the crowd to
  139991. * @returns the crowd you can add agents to
  139992. */
  139993. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  139994. /**
  139995. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  139996. * The queries will try to find a solution within those bounds
  139997. * default is (1,1,1)
  139998. * @param extent x,y,z value that define the extent around the queries point of reference
  139999. */
  140000. setDefaultQueryExtent(extent: Vector3): void;
  140001. /**
  140002. * Get the Bounding box extent specified by setDefaultQueryExtent
  140003. * @returns the box extent values
  140004. */
  140005. getDefaultQueryExtent(): Vector3;
  140006. /**
  140007. * build the navmesh from a previously saved state using getNavmeshData
  140008. * @param data the Uint8Array returned by getNavmeshData
  140009. */
  140010. buildFromNavmeshData(data: Uint8Array): void;
  140011. /**
  140012. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  140013. * @returns data the Uint8Array that can be saved and reused
  140014. */
  140015. getNavmeshData(): Uint8Array;
  140016. /**
  140017. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140018. * @param result output the box extent values
  140019. */
  140020. getDefaultQueryExtentToRef(result: Vector3): void;
  140021. /**
  140022. * Disposes
  140023. */
  140024. dispose(): void;
  140025. /**
  140026. * If this plugin is supported
  140027. * @returns true if plugin is supported
  140028. */
  140029. isSupported(): boolean;
  140030. }
  140031. /**
  140032. * Recast detour crowd implementation
  140033. */
  140034. export class RecastJSCrowd implements ICrowd {
  140035. /**
  140036. * Recast/detour plugin
  140037. */
  140038. bjsRECASTPlugin: RecastJSPlugin;
  140039. /**
  140040. * Link to the detour crowd
  140041. */
  140042. recastCrowd: any;
  140043. /**
  140044. * One transform per agent
  140045. */
  140046. transforms: TransformNode[];
  140047. /**
  140048. * All agents created
  140049. */
  140050. agents: number[];
  140051. /**
  140052. * Link to the scene is kept to unregister the crowd from the scene
  140053. */
  140054. private _scene;
  140055. /**
  140056. * Observer for crowd updates
  140057. */
  140058. private _onBeforeAnimationsObserver;
  140059. /**
  140060. * Constructor
  140061. * @param plugin recastJS plugin
  140062. * @param maxAgents the maximum agent count in the crowd
  140063. * @param maxAgentRadius the maximum radius an agent can have
  140064. * @param scene to attach the crowd to
  140065. * @returns the crowd you can add agents to
  140066. */
  140067. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  140068. /**
  140069. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  140070. * You can attach anything to that node. The node position is updated in the scene update tick.
  140071. * @param pos world position that will be constrained by the navigation mesh
  140072. * @param parameters agent parameters
  140073. * @param transform hooked to the agent that will be update by the scene
  140074. * @returns agent index
  140075. */
  140076. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  140077. /**
  140078. * Returns the agent position in world space
  140079. * @param index agent index returned by addAgent
  140080. * @returns world space position
  140081. */
  140082. getAgentPosition(index: number): Vector3;
  140083. /**
  140084. * Returns the agent position result in world space
  140085. * @param index agent index returned by addAgent
  140086. * @param result output world space position
  140087. */
  140088. getAgentPositionToRef(index: number, result: Vector3): void;
  140089. /**
  140090. * Returns the agent velocity in world space
  140091. * @param index agent index returned by addAgent
  140092. * @returns world space velocity
  140093. */
  140094. getAgentVelocity(index: number): Vector3;
  140095. /**
  140096. * Returns the agent velocity result in world space
  140097. * @param index agent index returned by addAgent
  140098. * @param result output world space velocity
  140099. */
  140100. getAgentVelocityToRef(index: number, result: Vector3): void;
  140101. /**
  140102. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  140103. * @param index agent index returned by addAgent
  140104. * @param destination targeted world position
  140105. */
  140106. agentGoto(index: number, destination: Vector3): void;
  140107. /**
  140108. * Teleport the agent to a new position
  140109. * @param index agent index returned by addAgent
  140110. * @param destination targeted world position
  140111. */
  140112. agentTeleport(index: number, destination: Vector3): void;
  140113. /**
  140114. * Update agent parameters
  140115. * @param index agent index returned by addAgent
  140116. * @param parameters agent parameters
  140117. */
  140118. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  140119. /**
  140120. * remove a particular agent previously created
  140121. * @param index agent index returned by addAgent
  140122. */
  140123. removeAgent(index: number): void;
  140124. /**
  140125. * get the list of all agents attached to this crowd
  140126. * @returns list of agent indices
  140127. */
  140128. getAgents(): number[];
  140129. /**
  140130. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  140131. * @param deltaTime in seconds
  140132. */
  140133. update(deltaTime: number): void;
  140134. /**
  140135. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  140136. * The queries will try to find a solution within those bounds
  140137. * default is (1,1,1)
  140138. * @param extent x,y,z value that define the extent around the queries point of reference
  140139. */
  140140. setDefaultQueryExtent(extent: Vector3): void;
  140141. /**
  140142. * Get the Bounding box extent specified by setDefaultQueryExtent
  140143. * @returns the box extent values
  140144. */
  140145. getDefaultQueryExtent(): Vector3;
  140146. /**
  140147. * Get the Bounding box extent result specified by setDefaultQueryExtent
  140148. * @param result output the box extent values
  140149. */
  140150. getDefaultQueryExtentToRef(result: Vector3): void;
  140151. /**
  140152. * Release all resources
  140153. */
  140154. dispose(): void;
  140155. }
  140156. }
  140157. declare module BABYLON {
  140158. /**
  140159. * Class used to enable access to IndexedDB
  140160. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  140161. */
  140162. export class Database implements IOfflineProvider {
  140163. private _callbackManifestChecked;
  140164. private _currentSceneUrl;
  140165. private _db;
  140166. private _enableSceneOffline;
  140167. private _enableTexturesOffline;
  140168. private _manifestVersionFound;
  140169. private _mustUpdateRessources;
  140170. private _hasReachedQuota;
  140171. private _isSupported;
  140172. private _idbFactory;
  140173. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  140174. private static IsUASupportingBlobStorage;
  140175. /**
  140176. * Gets a boolean indicating if Database storate is enabled (off by default)
  140177. */
  140178. static IDBStorageEnabled: boolean;
  140179. /**
  140180. * Gets a boolean indicating if scene must be saved in the database
  140181. */
  140182. get enableSceneOffline(): boolean;
  140183. /**
  140184. * Gets a boolean indicating if textures must be saved in the database
  140185. */
  140186. get enableTexturesOffline(): boolean;
  140187. /**
  140188. * Creates a new Database
  140189. * @param urlToScene defines the url to load the scene
  140190. * @param callbackManifestChecked defines the callback to use when manifest is checked
  140191. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  140192. */
  140193. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  140194. private static _ParseURL;
  140195. private static _ReturnFullUrlLocation;
  140196. private _checkManifestFile;
  140197. /**
  140198. * Open the database and make it available
  140199. * @param successCallback defines the callback to call on success
  140200. * @param errorCallback defines the callback to call on error
  140201. */
  140202. open(successCallback: () => void, errorCallback: () => void): void;
  140203. /**
  140204. * Loads an image from the database
  140205. * @param url defines the url to load from
  140206. * @param image defines the target DOM image
  140207. */
  140208. loadImage(url: string, image: HTMLImageElement): void;
  140209. private _loadImageFromDBAsync;
  140210. private _saveImageIntoDBAsync;
  140211. private _checkVersionFromDB;
  140212. private _loadVersionFromDBAsync;
  140213. private _saveVersionIntoDBAsync;
  140214. /**
  140215. * Loads a file from database
  140216. * @param url defines the URL to load from
  140217. * @param sceneLoaded defines a callback to call on success
  140218. * @param progressCallBack defines a callback to call when progress changed
  140219. * @param errorCallback defines a callback to call on error
  140220. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  140221. */
  140222. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  140223. private _loadFileAsync;
  140224. private _saveFileAsync;
  140225. /**
  140226. * Validates if xhr data is correct
  140227. * @param xhr defines the request to validate
  140228. * @param dataType defines the expected data type
  140229. * @returns true if data is correct
  140230. */
  140231. private static _ValidateXHRData;
  140232. }
  140233. }
  140234. declare module BABYLON {
  140235. /** @hidden */
  140236. export var gpuUpdateParticlesPixelShader: {
  140237. name: string;
  140238. shader: string;
  140239. };
  140240. }
  140241. declare module BABYLON {
  140242. /** @hidden */
  140243. export var gpuUpdateParticlesVertexShader: {
  140244. name: string;
  140245. shader: string;
  140246. };
  140247. }
  140248. declare module BABYLON {
  140249. /** @hidden */
  140250. export var clipPlaneFragmentDeclaration2: {
  140251. name: string;
  140252. shader: string;
  140253. };
  140254. }
  140255. declare module BABYLON {
  140256. /** @hidden */
  140257. export var gpuRenderParticlesPixelShader: {
  140258. name: string;
  140259. shader: string;
  140260. };
  140261. }
  140262. declare module BABYLON {
  140263. /** @hidden */
  140264. export var clipPlaneVertexDeclaration2: {
  140265. name: string;
  140266. shader: string;
  140267. };
  140268. }
  140269. declare module BABYLON {
  140270. /** @hidden */
  140271. export var gpuRenderParticlesVertexShader: {
  140272. name: string;
  140273. shader: string;
  140274. };
  140275. }
  140276. declare module BABYLON {
  140277. /**
  140278. * This represents a GPU particle system in Babylon
  140279. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  140280. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  140281. */
  140282. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  140283. /**
  140284. * The layer mask we are rendering the particles through.
  140285. */
  140286. layerMask: number;
  140287. private _capacity;
  140288. private _activeCount;
  140289. private _currentActiveCount;
  140290. private _accumulatedCount;
  140291. private _renderEffect;
  140292. private _updateEffect;
  140293. private _buffer0;
  140294. private _buffer1;
  140295. private _spriteBuffer;
  140296. private _updateVAO;
  140297. private _renderVAO;
  140298. private _targetIndex;
  140299. private _sourceBuffer;
  140300. private _targetBuffer;
  140301. private _engine;
  140302. private _currentRenderId;
  140303. private _started;
  140304. private _stopped;
  140305. private _timeDelta;
  140306. private _randomTexture;
  140307. private _randomTexture2;
  140308. private _attributesStrideSize;
  140309. private _updateEffectOptions;
  140310. private _randomTextureSize;
  140311. private _actualFrame;
  140312. private readonly _rawTextureWidth;
  140313. /**
  140314. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  140315. */
  140316. static get IsSupported(): boolean;
  140317. /**
  140318. * An event triggered when the system is disposed.
  140319. */
  140320. onDisposeObservable: Observable<GPUParticleSystem>;
  140321. /**
  140322. * Gets the maximum number of particles active at the same time.
  140323. * @returns The max number of active particles.
  140324. */
  140325. getCapacity(): number;
  140326. /**
  140327. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  140328. * to override the particles.
  140329. */
  140330. forceDepthWrite: boolean;
  140331. /**
  140332. * Gets or set the number of active particles
  140333. */
  140334. get activeParticleCount(): number;
  140335. set activeParticleCount(value: number);
  140336. private _preWarmDone;
  140337. /**
  140338. * Specifies if the particles are updated in emitter local space or world space.
  140339. */
  140340. isLocal: boolean;
  140341. /**
  140342. * Is this system ready to be used/rendered
  140343. * @return true if the system is ready
  140344. */
  140345. isReady(): boolean;
  140346. /**
  140347. * Gets if the system has been started. (Note: this will still be true after stop is called)
  140348. * @returns True if it has been started, otherwise false.
  140349. */
  140350. isStarted(): boolean;
  140351. /**
  140352. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  140353. * @returns True if it has been stopped, otherwise false.
  140354. */
  140355. isStopped(): boolean;
  140356. /**
  140357. * Gets a boolean indicating that the system is stopping
  140358. * @returns true if the system is currently stopping
  140359. */
  140360. isStopping(): boolean;
  140361. /**
  140362. * Gets the number of particles active at the same time.
  140363. * @returns The number of active particles.
  140364. */
  140365. getActiveCount(): number;
  140366. /**
  140367. * Starts the particle system and begins to emit
  140368. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  140369. */
  140370. start(delay?: number): void;
  140371. /**
  140372. * Stops the particle system.
  140373. */
  140374. stop(): void;
  140375. /**
  140376. * Remove all active particles
  140377. */
  140378. reset(): void;
  140379. /**
  140380. * Returns the string "GPUParticleSystem"
  140381. * @returns a string containing the class name
  140382. */
  140383. getClassName(): string;
  140384. private _colorGradientsTexture;
  140385. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  140386. /**
  140387. * Adds a new color gradient
  140388. * @param gradient defines the gradient to use (between 0 and 1)
  140389. * @param color1 defines the color to affect to the specified gradient
  140390. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  140391. * @returns the current particle system
  140392. */
  140393. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  140394. private _refreshColorGradient;
  140395. /** Force the system to rebuild all gradients that need to be resync */
  140396. forceRefreshGradients(): void;
  140397. /**
  140398. * Remove a specific color gradient
  140399. * @param gradient defines the gradient to remove
  140400. * @returns the current particle system
  140401. */
  140402. removeColorGradient(gradient: number): GPUParticleSystem;
  140403. private _angularSpeedGradientsTexture;
  140404. private _sizeGradientsTexture;
  140405. private _velocityGradientsTexture;
  140406. private _limitVelocityGradientsTexture;
  140407. private _dragGradientsTexture;
  140408. private _addFactorGradient;
  140409. /**
  140410. * Adds a new size gradient
  140411. * @param gradient defines the gradient to use (between 0 and 1)
  140412. * @param factor defines the size factor to affect to the specified gradient
  140413. * @returns the current particle system
  140414. */
  140415. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  140416. /**
  140417. * Remove a specific size gradient
  140418. * @param gradient defines the gradient to remove
  140419. * @returns the current particle system
  140420. */
  140421. removeSizeGradient(gradient: number): GPUParticleSystem;
  140422. private _refreshFactorGradient;
  140423. /**
  140424. * Adds a new angular speed gradient
  140425. * @param gradient defines the gradient to use (between 0 and 1)
  140426. * @param factor defines the angular speed to affect to the specified gradient
  140427. * @returns the current particle system
  140428. */
  140429. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  140430. /**
  140431. * Remove a specific angular speed gradient
  140432. * @param gradient defines the gradient to remove
  140433. * @returns the current particle system
  140434. */
  140435. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  140436. /**
  140437. * Adds a new velocity gradient
  140438. * @param gradient defines the gradient to use (between 0 and 1)
  140439. * @param factor defines the velocity to affect to the specified gradient
  140440. * @returns the current particle system
  140441. */
  140442. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140443. /**
  140444. * Remove a specific velocity gradient
  140445. * @param gradient defines the gradient to remove
  140446. * @returns the current particle system
  140447. */
  140448. removeVelocityGradient(gradient: number): GPUParticleSystem;
  140449. /**
  140450. * Adds a new limit velocity gradient
  140451. * @param gradient defines the gradient to use (between 0 and 1)
  140452. * @param factor defines the limit velocity value to affect to the specified gradient
  140453. * @returns the current particle system
  140454. */
  140455. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  140456. /**
  140457. * Remove a specific limit velocity gradient
  140458. * @param gradient defines the gradient to remove
  140459. * @returns the current particle system
  140460. */
  140461. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  140462. /**
  140463. * Adds a new drag gradient
  140464. * @param gradient defines the gradient to use (between 0 and 1)
  140465. * @param factor defines the drag value to affect to the specified gradient
  140466. * @returns the current particle system
  140467. */
  140468. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  140469. /**
  140470. * Remove a specific drag gradient
  140471. * @param gradient defines the gradient to remove
  140472. * @returns the current particle system
  140473. */
  140474. removeDragGradient(gradient: number): GPUParticleSystem;
  140475. /**
  140476. * Not supported by GPUParticleSystem
  140477. * @param gradient defines the gradient to use (between 0 and 1)
  140478. * @param factor defines the emit rate value to affect to the specified gradient
  140479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140480. * @returns the current particle system
  140481. */
  140482. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140483. /**
  140484. * Not supported by GPUParticleSystem
  140485. * @param gradient defines the gradient to remove
  140486. * @returns the current particle system
  140487. */
  140488. removeEmitRateGradient(gradient: number): IParticleSystem;
  140489. /**
  140490. * Not supported by GPUParticleSystem
  140491. * @param gradient defines the gradient to use (between 0 and 1)
  140492. * @param factor defines the start size value to affect to the specified gradient
  140493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140494. * @returns the current particle system
  140495. */
  140496. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140497. /**
  140498. * Not supported by GPUParticleSystem
  140499. * @param gradient defines the gradient to remove
  140500. * @returns the current particle system
  140501. */
  140502. removeStartSizeGradient(gradient: number): IParticleSystem;
  140503. /**
  140504. * Not supported by GPUParticleSystem
  140505. * @param gradient defines the gradient to use (between 0 and 1)
  140506. * @param min defines the color remap minimal range
  140507. * @param max defines the color remap maximal range
  140508. * @returns the current particle system
  140509. */
  140510. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140511. /**
  140512. * Not supported by GPUParticleSystem
  140513. * @param gradient defines the gradient to remove
  140514. * @returns the current particle system
  140515. */
  140516. removeColorRemapGradient(): IParticleSystem;
  140517. /**
  140518. * Not supported by GPUParticleSystem
  140519. * @param gradient defines the gradient to use (between 0 and 1)
  140520. * @param min defines the alpha remap minimal range
  140521. * @param max defines the alpha remap maximal range
  140522. * @returns the current particle system
  140523. */
  140524. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  140525. /**
  140526. * Not supported by GPUParticleSystem
  140527. * @param gradient defines the gradient to remove
  140528. * @returns the current particle system
  140529. */
  140530. removeAlphaRemapGradient(): IParticleSystem;
  140531. /**
  140532. * Not supported by GPUParticleSystem
  140533. * @param gradient defines the gradient to use (between 0 and 1)
  140534. * @param color defines the color to affect to the specified gradient
  140535. * @returns the current particle system
  140536. */
  140537. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  140538. /**
  140539. * Not supported by GPUParticleSystem
  140540. * @param gradient defines the gradient to remove
  140541. * @returns the current particle system
  140542. */
  140543. removeRampGradient(): IParticleSystem;
  140544. /**
  140545. * Not supported by GPUParticleSystem
  140546. * @returns the list of ramp gradients
  140547. */
  140548. getRampGradients(): Nullable<Array<Color3Gradient>>;
  140549. /**
  140550. * Not supported by GPUParticleSystem
  140551. * Gets or sets a boolean indicating that ramp gradients must be used
  140552. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  140553. */
  140554. get useRampGradients(): boolean;
  140555. set useRampGradients(value: boolean);
  140556. /**
  140557. * Not supported by GPUParticleSystem
  140558. * @param gradient defines the gradient to use (between 0 and 1)
  140559. * @param factor defines the life time factor to affect to the specified gradient
  140560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  140561. * @returns the current particle system
  140562. */
  140563. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  140564. /**
  140565. * Not supported by GPUParticleSystem
  140566. * @param gradient defines the gradient to remove
  140567. * @returns the current particle system
  140568. */
  140569. removeLifeTimeGradient(gradient: number): IParticleSystem;
  140570. /**
  140571. * Instantiates a GPU particle system.
  140572. * 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.
  140573. * @param name The name of the particle system
  140574. * @param options The options used to create the system
  140575. * @param scene The scene the particle system belongs to
  140576. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  140577. */
  140578. constructor(name: string, options: Partial<{
  140579. capacity: number;
  140580. randomTextureSize: number;
  140581. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  140582. protected _reset(): void;
  140583. private _createUpdateVAO;
  140584. private _createRenderVAO;
  140585. private _initialize;
  140586. /** @hidden */
  140587. _recreateUpdateEffect(): void;
  140588. /** @hidden */
  140589. _recreateRenderEffect(): void;
  140590. /**
  140591. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  140592. * @param preWarm defines if we are in the pre-warmimg phase
  140593. */
  140594. animate(preWarm?: boolean): void;
  140595. private _createFactorGradientTexture;
  140596. private _createSizeGradientTexture;
  140597. private _createAngularSpeedGradientTexture;
  140598. private _createVelocityGradientTexture;
  140599. private _createLimitVelocityGradientTexture;
  140600. private _createDragGradientTexture;
  140601. private _createColorGradientTexture;
  140602. /**
  140603. * Renders the particle system in its current state
  140604. * @param preWarm defines if the system should only update the particles but not render them
  140605. * @returns the current number of particles
  140606. */
  140607. render(preWarm?: boolean): number;
  140608. /**
  140609. * Rebuilds the particle system
  140610. */
  140611. rebuild(): void;
  140612. private _releaseBuffers;
  140613. private _releaseVAOs;
  140614. /**
  140615. * Disposes the particle system and free the associated resources
  140616. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  140617. */
  140618. dispose(disposeTexture?: boolean): void;
  140619. /**
  140620. * Clones the particle system.
  140621. * @param name The name of the cloned object
  140622. * @param newEmitter The new emitter to use
  140623. * @returns the cloned particle system
  140624. */
  140625. clone(name: string, newEmitter: any): GPUParticleSystem;
  140626. /**
  140627. * Serializes the particle system to a JSON object
  140628. * @param serializeTexture defines if the texture must be serialized as well
  140629. * @returns the JSON object
  140630. */
  140631. serialize(serializeTexture?: boolean): any;
  140632. /**
  140633. * Parses a JSON object to create a GPU particle system.
  140634. * @param parsedParticleSystem The JSON object to parse
  140635. * @param scene The scene to create the particle system in
  140636. * @param rootUrl The root url to use to load external dependencies like texture
  140637. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  140638. * @returns the parsed GPU particle system
  140639. */
  140640. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  140641. }
  140642. }
  140643. declare module BABYLON {
  140644. /**
  140645. * Represents a set of particle systems working together to create a specific effect
  140646. */
  140647. export class ParticleSystemSet implements IDisposable {
  140648. /**
  140649. * Gets or sets base Assets URL
  140650. */
  140651. static BaseAssetsUrl: string;
  140652. private _emitterCreationOptions;
  140653. private _emitterNode;
  140654. /**
  140655. * Gets the particle system list
  140656. */
  140657. systems: IParticleSystem[];
  140658. /**
  140659. * Gets the emitter node used with this set
  140660. */
  140661. get emitterNode(): Nullable<TransformNode>;
  140662. /**
  140663. * Creates a new emitter mesh as a sphere
  140664. * @param options defines the options used to create the sphere
  140665. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  140666. * @param scene defines the hosting scene
  140667. */
  140668. setEmitterAsSphere(options: {
  140669. diameter: number;
  140670. segments: number;
  140671. color: Color3;
  140672. }, renderingGroupId: number, scene: Scene): void;
  140673. /**
  140674. * Starts all particle systems of the set
  140675. * @param emitter defines an optional mesh to use as emitter for the particle systems
  140676. */
  140677. start(emitter?: AbstractMesh): void;
  140678. /**
  140679. * Release all associated resources
  140680. */
  140681. dispose(): void;
  140682. /**
  140683. * Serialize the set into a JSON compatible object
  140684. * @param serializeTexture defines if the texture must be serialized as well
  140685. * @returns a JSON compatible representation of the set
  140686. */
  140687. serialize(serializeTexture?: boolean): any;
  140688. /**
  140689. * Parse a new ParticleSystemSet from a serialized source
  140690. * @param data defines a JSON compatible representation of the set
  140691. * @param scene defines the hosting scene
  140692. * @param gpu defines if we want GPU particles or CPU particles
  140693. * @returns a new ParticleSystemSet
  140694. */
  140695. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  140696. }
  140697. }
  140698. declare module BABYLON {
  140699. /**
  140700. * This class is made for on one-liner static method to help creating particle system set.
  140701. */
  140702. export class ParticleHelper {
  140703. /**
  140704. * Gets or sets base Assets URL
  140705. */
  140706. static BaseAssetsUrl: string;
  140707. /** Define the Url to load snippets */
  140708. static SnippetUrl: string;
  140709. /**
  140710. * Create a default particle system that you can tweak
  140711. * @param emitter defines the emitter to use
  140712. * @param capacity defines the system capacity (default is 500 particles)
  140713. * @param scene defines the hosting scene
  140714. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  140715. * @returns the new Particle system
  140716. */
  140717. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  140718. /**
  140719. * This is the main static method (one-liner) of this helper to create different particle systems
  140720. * @param type This string represents the type to the particle system to create
  140721. * @param scene The scene where the particle system should live
  140722. * @param gpu If the system will use gpu
  140723. * @returns the ParticleSystemSet created
  140724. */
  140725. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  140726. /**
  140727. * Static function used to export a particle system to a ParticleSystemSet variable.
  140728. * Please note that the emitter shape is not exported
  140729. * @param systems defines the particle systems to export
  140730. * @returns the created particle system set
  140731. */
  140732. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  140733. /**
  140734. * Creates a particle system from a snippet saved in a remote file
  140735. * @param name defines the name of the particle system to create
  140736. * @param url defines the url to load from
  140737. * @param scene defines the hosting scene
  140738. * @param gpu If the system will use gpu
  140739. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  140740. * @returns a promise that will resolve to the new particle system
  140741. */
  140742. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  140743. /**
  140744. * Creates a particle system from a snippet saved by the particle system editor
  140745. * @param snippetId defines the snippet to load
  140746. * @param scene defines the hosting scene
  140747. * @param gpu If the system will use gpu
  140748. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  140749. * @returns a promise that will resolve to the new particle system
  140750. */
  140751. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  140752. }
  140753. }
  140754. declare module BABYLON {
  140755. interface Engine {
  140756. /**
  140757. * Create an effect to use with particle systems.
  140758. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  140759. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  140760. * @param uniformsNames defines a list of attribute names
  140761. * @param samplers defines an array of string used to represent textures
  140762. * @param defines defines the string containing the defines to use to compile the shaders
  140763. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  140764. * @param onCompiled defines a function to call when the effect creation is successful
  140765. * @param onError defines a function to call when the effect creation has failed
  140766. * @returns the new Effect
  140767. */
  140768. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  140769. }
  140770. interface Mesh {
  140771. /**
  140772. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  140773. * @returns an array of IParticleSystem
  140774. */
  140775. getEmittedParticleSystems(): IParticleSystem[];
  140776. /**
  140777. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  140778. * @returns an array of IParticleSystem
  140779. */
  140780. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  140781. }
  140782. /**
  140783. * @hidden
  140784. */
  140785. export var _IDoNeedToBeInTheBuild: number;
  140786. }
  140787. declare module BABYLON {
  140788. /** Defines the 4 color options */
  140789. export enum PointColor {
  140790. /** color value */
  140791. Color = 2,
  140792. /** uv value */
  140793. UV = 1,
  140794. /** random value */
  140795. Random = 0,
  140796. /** stated value */
  140797. Stated = 3
  140798. }
  140799. /**
  140800. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  140801. * 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.
  140802. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  140803. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  140804. *
  140805. * Full documentation here : TO BE ENTERED
  140806. */
  140807. export class PointsCloudSystem implements IDisposable {
  140808. /**
  140809. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  140810. * Example : var p = SPS.particles[i];
  140811. */
  140812. particles: CloudPoint[];
  140813. /**
  140814. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  140815. */
  140816. nbParticles: number;
  140817. /**
  140818. * This a counter for your own usage. It's not set by any SPS functions.
  140819. */
  140820. counter: number;
  140821. /**
  140822. * The PCS name. This name is also given to the underlying mesh.
  140823. */
  140824. name: string;
  140825. /**
  140826. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  140827. */
  140828. mesh: Mesh;
  140829. /**
  140830. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  140831. * Please read :
  140832. */
  140833. vars: any;
  140834. /**
  140835. * @hidden
  140836. */
  140837. _size: number;
  140838. private _scene;
  140839. private _promises;
  140840. private _positions;
  140841. private _indices;
  140842. private _normals;
  140843. private _colors;
  140844. private _uvs;
  140845. private _indices32;
  140846. private _positions32;
  140847. private _colors32;
  140848. private _uvs32;
  140849. private _updatable;
  140850. private _isVisibilityBoxLocked;
  140851. private _alwaysVisible;
  140852. private _groups;
  140853. private _groupCounter;
  140854. private _computeParticleColor;
  140855. private _computeParticleTexture;
  140856. private _computeParticleRotation;
  140857. private _computeBoundingBox;
  140858. private _isReady;
  140859. /**
  140860. * Creates a PCS (Points Cloud System) object
  140861. * @param name (String) is the PCS name, this will be the underlying mesh name
  140862. * @param pointSize (number) is the size for each point
  140863. * @param scene (Scene) is the scene in which the PCS is added
  140864. * @param options defines the options of the PCS e.g.
  140865. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  140866. */
  140867. constructor(name: string, pointSize: number, scene: Scene, options?: {
  140868. updatable?: boolean;
  140869. });
  140870. /**
  140871. * Builds the PCS underlying mesh. Returns a standard Mesh.
  140872. * If no points were added to the PCS, the returned mesh is just a single point.
  140873. * @returns a promise for the created mesh
  140874. */
  140875. buildMeshAsync(): Promise<Mesh>;
  140876. /**
  140877. * @hidden
  140878. */
  140879. private _buildMesh;
  140880. private _addParticle;
  140881. private _randomUnitVector;
  140882. private _getColorIndicesForCoord;
  140883. private _setPointsColorOrUV;
  140884. private _colorFromTexture;
  140885. private _calculateDensity;
  140886. /**
  140887. * Adds points to the PCS in random positions within a unit sphere
  140888. * @param nb (positive integer) the number of particles to be created from this model
  140889. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  140890. * @returns the number of groups in the system
  140891. */
  140892. addPoints(nb: number, pointFunction?: any): number;
  140893. /**
  140894. * Adds points to the PCS from the surface of the model shape
  140895. * @param mesh is any Mesh object that will be used as a surface model for the points
  140896. * @param nb (positive integer) the number of particles to be created from this model
  140897. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  140898. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  140899. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  140900. * @returns the number of groups in the system
  140901. */
  140902. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  140903. /**
  140904. * Adds points to the PCS inside the model shape
  140905. * @param mesh is any Mesh object that will be used as a surface model for the points
  140906. * @param nb (positive integer) the number of particles to be created from this model
  140907. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  140908. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  140909. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  140910. * @returns the number of groups in the system
  140911. */
  140912. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  140913. /**
  140914. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  140915. * This method calls `updateParticle()` for each particle of the SPS.
  140916. * For an animated SPS, it is usually called within the render loop.
  140917. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  140918. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  140919. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  140920. * @returns the PCS.
  140921. */
  140922. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  140923. /**
  140924. * Disposes the PCS.
  140925. */
  140926. dispose(): void;
  140927. /**
  140928. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  140929. * doc :
  140930. * @returns the PCS.
  140931. */
  140932. refreshVisibleSize(): PointsCloudSystem;
  140933. /**
  140934. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  140935. * @param size the size (float) of the visibility box
  140936. * note : this doesn't lock the PCS mesh bounding box.
  140937. * doc :
  140938. */
  140939. setVisibilityBox(size: number): void;
  140940. /**
  140941. * Gets whether the PCS is always visible or not
  140942. * doc :
  140943. */
  140944. get isAlwaysVisible(): boolean;
  140945. /**
  140946. * Sets the PCS as always visible or not
  140947. * doc :
  140948. */
  140949. set isAlwaysVisible(val: boolean);
  140950. /**
  140951. * Tells to `setParticles()` to compute the particle rotations or not
  140952. * Default value : false. The PCS is faster when it's set to false
  140953. * Note : particle rotations are only applied to parent particles
  140954. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  140955. */
  140956. set computeParticleRotation(val: boolean);
  140957. /**
  140958. * Tells to `setParticles()` to compute the particle colors or not.
  140959. * Default value : true. The PCS is faster when it's set to false.
  140960. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  140961. */
  140962. set computeParticleColor(val: boolean);
  140963. set computeParticleTexture(val: boolean);
  140964. /**
  140965. * Gets if `setParticles()` computes the particle colors or not.
  140966. * Default value : false. The PCS is faster when it's set to false.
  140967. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  140968. */
  140969. get computeParticleColor(): boolean;
  140970. /**
  140971. * Gets if `setParticles()` computes the particle textures or not.
  140972. * Default value : false. The PCS is faster when it's set to false.
  140973. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  140974. */
  140975. get computeParticleTexture(): boolean;
  140976. /**
  140977. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  140978. */
  140979. set computeBoundingBox(val: boolean);
  140980. /**
  140981. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  140982. */
  140983. get computeBoundingBox(): boolean;
  140984. /**
  140985. * This function does nothing. It may be overwritten to set all the particle first values.
  140986. * The PCS doesn't call this function, you may have to call it by your own.
  140987. * doc :
  140988. */
  140989. initParticles(): void;
  140990. /**
  140991. * This function does nothing. It may be overwritten to recycle a particle
  140992. * The PCS doesn't call this function, you can to call it
  140993. * doc :
  140994. * @param particle The particle to recycle
  140995. * @returns the recycled particle
  140996. */
  140997. recycleParticle(particle: CloudPoint): CloudPoint;
  140998. /**
  140999. * Updates a particle : this function should be overwritten by the user.
  141000. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  141001. * doc :
  141002. * @example : just set a particle position or velocity and recycle conditions
  141003. * @param particle The particle to update
  141004. * @returns the updated particle
  141005. */
  141006. updateParticle(particle: CloudPoint): CloudPoint;
  141007. /**
  141008. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  141009. * This does nothing and may be overwritten by the user.
  141010. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141011. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141012. * @param update the boolean update value actually passed to setParticles()
  141013. */
  141014. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141015. /**
  141016. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  141017. * This will be passed three parameters.
  141018. * This does nothing and may be overwritten by the user.
  141019. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  141020. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  141021. * @param update the boolean update value actually passed to setParticles()
  141022. */
  141023. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  141024. }
  141025. }
  141026. declare module BABYLON {
  141027. /**
  141028. * Represents one particle of a points cloud system.
  141029. */
  141030. export class CloudPoint {
  141031. /**
  141032. * particle global index
  141033. */
  141034. idx: number;
  141035. /**
  141036. * The color of the particle
  141037. */
  141038. color: Nullable<Color4>;
  141039. /**
  141040. * The world space position of the particle.
  141041. */
  141042. position: Vector3;
  141043. /**
  141044. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  141045. */
  141046. rotation: Vector3;
  141047. /**
  141048. * The world space rotation quaternion of the particle.
  141049. */
  141050. rotationQuaternion: Nullable<Quaternion>;
  141051. /**
  141052. * The uv of the particle.
  141053. */
  141054. uv: Nullable<Vector2>;
  141055. /**
  141056. * The current speed of the particle.
  141057. */
  141058. velocity: Vector3;
  141059. /**
  141060. * The pivot point in the particle local space.
  141061. */
  141062. pivot: Vector3;
  141063. /**
  141064. * Must the particle be translated from its pivot point in its local space ?
  141065. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  141066. * Default : false
  141067. */
  141068. translateFromPivot: boolean;
  141069. /**
  141070. * Index of this particle in the global "positions" array (Internal use)
  141071. * @hidden
  141072. */
  141073. _pos: number;
  141074. /**
  141075. * @hidden Index of this particle in the global "indices" array (Internal use)
  141076. */
  141077. _ind: number;
  141078. /**
  141079. * Group this particle belongs to
  141080. */
  141081. _group: PointsGroup;
  141082. /**
  141083. * Group id of this particle
  141084. */
  141085. groupId: number;
  141086. /**
  141087. * Index of the particle in its group id (Internal use)
  141088. */
  141089. idxInGroup: number;
  141090. /**
  141091. * @hidden Particle BoundingInfo object (Internal use)
  141092. */
  141093. _boundingInfo: BoundingInfo;
  141094. /**
  141095. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  141096. */
  141097. _pcs: PointsCloudSystem;
  141098. /**
  141099. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  141100. */
  141101. _stillInvisible: boolean;
  141102. /**
  141103. * @hidden Last computed particle rotation matrix
  141104. */
  141105. _rotationMatrix: number[];
  141106. /**
  141107. * Parent particle Id, if any.
  141108. * Default null.
  141109. */
  141110. parentId: Nullable<number>;
  141111. /**
  141112. * @hidden Internal global position in the PCS.
  141113. */
  141114. _globalPosition: Vector3;
  141115. /**
  141116. * Creates a Point Cloud object.
  141117. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  141118. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  141119. * @param group (PointsGroup) is the group the particle belongs to
  141120. * @param groupId (integer) is the group identifier in the PCS.
  141121. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  141122. * @param pcs defines the PCS it is associated to
  141123. */
  141124. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  141125. /**
  141126. * get point size
  141127. */
  141128. get size(): Vector3;
  141129. /**
  141130. * Set point size
  141131. */
  141132. set size(scale: Vector3);
  141133. /**
  141134. * Legacy support, changed quaternion to rotationQuaternion
  141135. */
  141136. get quaternion(): Nullable<Quaternion>;
  141137. /**
  141138. * Legacy support, changed quaternion to rotationQuaternion
  141139. */
  141140. set quaternion(q: Nullable<Quaternion>);
  141141. /**
  141142. * Returns a boolean. True if the particle intersects a mesh, else false
  141143. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  141144. * @param target is the object (point or mesh) what the intersection is computed against
  141145. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  141146. * @returns true if it intersects
  141147. */
  141148. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  141149. /**
  141150. * get the rotation matrix of the particle
  141151. * @hidden
  141152. */
  141153. getRotationMatrix(m: Matrix): void;
  141154. }
  141155. /**
  141156. * Represents a group of points in a points cloud system
  141157. * * PCS internal tool, don't use it manually.
  141158. */
  141159. export class PointsGroup {
  141160. /**
  141161. * The group id
  141162. * @hidden
  141163. */
  141164. groupID: number;
  141165. /**
  141166. * image data for group (internal use)
  141167. * @hidden
  141168. */
  141169. _groupImageData: Nullable<ArrayBufferView>;
  141170. /**
  141171. * Image Width (internal use)
  141172. * @hidden
  141173. */
  141174. _groupImgWidth: number;
  141175. /**
  141176. * Image Height (internal use)
  141177. * @hidden
  141178. */
  141179. _groupImgHeight: number;
  141180. /**
  141181. * Custom position function (internal use)
  141182. * @hidden
  141183. */
  141184. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  141185. /**
  141186. * density per facet for surface points
  141187. * @hidden
  141188. */
  141189. _groupDensity: number[];
  141190. /**
  141191. * Only when points are colored by texture carries pointer to texture list array
  141192. * @hidden
  141193. */
  141194. _textureNb: number;
  141195. /**
  141196. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  141197. * PCS internal tool, don't use it manually.
  141198. * @hidden
  141199. */
  141200. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  141201. }
  141202. }
  141203. declare module BABYLON {
  141204. interface Scene {
  141205. /** @hidden (Backing field) */
  141206. _physicsEngine: Nullable<IPhysicsEngine>;
  141207. /** @hidden */
  141208. _physicsTimeAccumulator: number;
  141209. /**
  141210. * Gets the current physics engine
  141211. * @returns a IPhysicsEngine or null if none attached
  141212. */
  141213. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  141214. /**
  141215. * Enables physics to the current scene
  141216. * @param gravity defines the scene's gravity for the physics engine
  141217. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  141218. * @return a boolean indicating if the physics engine was initialized
  141219. */
  141220. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  141221. /**
  141222. * Disables and disposes the physics engine associated with the scene
  141223. */
  141224. disablePhysicsEngine(): void;
  141225. /**
  141226. * Gets a boolean indicating if there is an active physics engine
  141227. * @returns a boolean indicating if there is an active physics engine
  141228. */
  141229. isPhysicsEnabled(): boolean;
  141230. /**
  141231. * Deletes a physics compound impostor
  141232. * @param compound defines the compound to delete
  141233. */
  141234. deleteCompoundImpostor(compound: any): void;
  141235. /**
  141236. * An event triggered when physic simulation is about to be run
  141237. */
  141238. onBeforePhysicsObservable: Observable<Scene>;
  141239. /**
  141240. * An event triggered when physic simulation has been done
  141241. */
  141242. onAfterPhysicsObservable: Observable<Scene>;
  141243. }
  141244. interface AbstractMesh {
  141245. /** @hidden */
  141246. _physicsImpostor: Nullable<PhysicsImpostor>;
  141247. /**
  141248. * Gets or sets impostor used for physic simulation
  141249. * @see http://doc.babylonjs.com/features/physics_engine
  141250. */
  141251. physicsImpostor: Nullable<PhysicsImpostor>;
  141252. /**
  141253. * Gets the current physics impostor
  141254. * @see http://doc.babylonjs.com/features/physics_engine
  141255. * @returns a physics impostor or null
  141256. */
  141257. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  141258. /** Apply a physic impulse to the mesh
  141259. * @param force defines the force to apply
  141260. * @param contactPoint defines where to apply the force
  141261. * @returns the current mesh
  141262. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  141263. */
  141264. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  141265. /**
  141266. * Creates a physic joint between two meshes
  141267. * @param otherMesh defines the other mesh to use
  141268. * @param pivot1 defines the pivot to use on this mesh
  141269. * @param pivot2 defines the pivot to use on the other mesh
  141270. * @param options defines additional options (can be plugin dependent)
  141271. * @returns the current mesh
  141272. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  141273. */
  141274. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  141275. /** @hidden */
  141276. _disposePhysicsObserver: Nullable<Observer<Node>>;
  141277. }
  141278. /**
  141279. * Defines the physics engine scene component responsible to manage a physics engine
  141280. */
  141281. export class PhysicsEngineSceneComponent implements ISceneComponent {
  141282. /**
  141283. * The component name helpful to identify the component in the list of scene components.
  141284. */
  141285. readonly name: string;
  141286. /**
  141287. * The scene the component belongs to.
  141288. */
  141289. scene: Scene;
  141290. /**
  141291. * Creates a new instance of the component for the given scene
  141292. * @param scene Defines the scene to register the component in
  141293. */
  141294. constructor(scene: Scene);
  141295. /**
  141296. * Registers the component in a given scene
  141297. */
  141298. register(): void;
  141299. /**
  141300. * Rebuilds the elements related to this component in case of
  141301. * context lost for instance.
  141302. */
  141303. rebuild(): void;
  141304. /**
  141305. * Disposes the component and the associated ressources
  141306. */
  141307. dispose(): void;
  141308. }
  141309. }
  141310. declare module BABYLON {
  141311. /**
  141312. * A helper for physics simulations
  141313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141314. */
  141315. export class PhysicsHelper {
  141316. private _scene;
  141317. private _physicsEngine;
  141318. /**
  141319. * Initializes the Physics helper
  141320. * @param scene Babylon.js scene
  141321. */
  141322. constructor(scene: Scene);
  141323. /**
  141324. * Applies a radial explosion impulse
  141325. * @param origin the origin of the explosion
  141326. * @param radiusOrEventOptions the radius or the options of radial explosion
  141327. * @param strength the explosion strength
  141328. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141329. * @returns A physics radial explosion event, or null
  141330. */
  141331. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141332. /**
  141333. * Applies a radial explosion force
  141334. * @param origin the origin of the explosion
  141335. * @param radiusOrEventOptions the radius or the options of radial explosion
  141336. * @param strength the explosion strength
  141337. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141338. * @returns A physics radial explosion event, or null
  141339. */
  141340. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  141341. /**
  141342. * Creates a gravitational field
  141343. * @param origin the origin of the explosion
  141344. * @param radiusOrEventOptions the radius or the options of radial explosion
  141345. * @param strength the explosion strength
  141346. * @param falloff possible options: Constant & Linear. Defaults to Constant
  141347. * @returns A physics gravitational field event, or null
  141348. */
  141349. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  141350. /**
  141351. * Creates a physics updraft event
  141352. * @param origin the origin of the updraft
  141353. * @param radiusOrEventOptions the radius or the options of the updraft
  141354. * @param strength the strength of the updraft
  141355. * @param height the height of the updraft
  141356. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  141357. * @returns A physics updraft event, or null
  141358. */
  141359. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  141360. /**
  141361. * Creates a physics vortex event
  141362. * @param origin the of the vortex
  141363. * @param radiusOrEventOptions the radius or the options of the vortex
  141364. * @param strength the strength of the vortex
  141365. * @param height the height of the vortex
  141366. * @returns a Physics vortex event, or null
  141367. * A physics vortex event or null
  141368. */
  141369. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  141370. }
  141371. /**
  141372. * Represents a physics radial explosion event
  141373. */
  141374. class PhysicsRadialExplosionEvent {
  141375. private _scene;
  141376. private _options;
  141377. private _sphere;
  141378. private _dataFetched;
  141379. /**
  141380. * Initializes a radial explosioin event
  141381. * @param _scene BabylonJS scene
  141382. * @param _options The options for the vortex event
  141383. */
  141384. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  141385. /**
  141386. * Returns the data related to the radial explosion event (sphere).
  141387. * @returns The radial explosion event data
  141388. */
  141389. getData(): PhysicsRadialExplosionEventData;
  141390. /**
  141391. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  141392. * @param impostor A physics imposter
  141393. * @param origin the origin of the explosion
  141394. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  141395. */
  141396. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  141397. /**
  141398. * Triggers affecterd impostors callbacks
  141399. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  141400. */
  141401. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  141402. /**
  141403. * Disposes the sphere.
  141404. * @param force Specifies if the sphere should be disposed by force
  141405. */
  141406. dispose(force?: boolean): void;
  141407. /*** Helpers ***/
  141408. private _prepareSphere;
  141409. private _intersectsWithSphere;
  141410. }
  141411. /**
  141412. * Represents a gravitational field event
  141413. */
  141414. class PhysicsGravitationalFieldEvent {
  141415. private _physicsHelper;
  141416. private _scene;
  141417. private _origin;
  141418. private _options;
  141419. private _tickCallback;
  141420. private _sphere;
  141421. private _dataFetched;
  141422. /**
  141423. * Initializes the physics gravitational field event
  141424. * @param _physicsHelper A physics helper
  141425. * @param _scene BabylonJS scene
  141426. * @param _origin The origin position of the gravitational field event
  141427. * @param _options The options for the vortex event
  141428. */
  141429. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  141430. /**
  141431. * Returns the data related to the gravitational field event (sphere).
  141432. * @returns A gravitational field event
  141433. */
  141434. getData(): PhysicsGravitationalFieldEventData;
  141435. /**
  141436. * Enables the gravitational field.
  141437. */
  141438. enable(): void;
  141439. /**
  141440. * Disables the gravitational field.
  141441. */
  141442. disable(): void;
  141443. /**
  141444. * Disposes the sphere.
  141445. * @param force The force to dispose from the gravitational field event
  141446. */
  141447. dispose(force?: boolean): void;
  141448. private _tick;
  141449. }
  141450. /**
  141451. * Represents a physics updraft event
  141452. */
  141453. class PhysicsUpdraftEvent {
  141454. private _scene;
  141455. private _origin;
  141456. private _options;
  141457. private _physicsEngine;
  141458. private _originTop;
  141459. private _originDirection;
  141460. private _tickCallback;
  141461. private _cylinder;
  141462. private _cylinderPosition;
  141463. private _dataFetched;
  141464. /**
  141465. * Initializes the physics updraft event
  141466. * @param _scene BabylonJS scene
  141467. * @param _origin The origin position of the updraft
  141468. * @param _options The options for the updraft event
  141469. */
  141470. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  141471. /**
  141472. * Returns the data related to the updraft event (cylinder).
  141473. * @returns A physics updraft event
  141474. */
  141475. getData(): PhysicsUpdraftEventData;
  141476. /**
  141477. * Enables the updraft.
  141478. */
  141479. enable(): void;
  141480. /**
  141481. * Disables the updraft.
  141482. */
  141483. disable(): void;
  141484. /**
  141485. * Disposes the cylinder.
  141486. * @param force Specifies if the updraft should be disposed by force
  141487. */
  141488. dispose(force?: boolean): void;
  141489. private getImpostorHitData;
  141490. private _tick;
  141491. /*** Helpers ***/
  141492. private _prepareCylinder;
  141493. private _intersectsWithCylinder;
  141494. }
  141495. /**
  141496. * Represents a physics vortex event
  141497. */
  141498. class PhysicsVortexEvent {
  141499. private _scene;
  141500. private _origin;
  141501. private _options;
  141502. private _physicsEngine;
  141503. private _originTop;
  141504. private _tickCallback;
  141505. private _cylinder;
  141506. private _cylinderPosition;
  141507. private _dataFetched;
  141508. /**
  141509. * Initializes the physics vortex event
  141510. * @param _scene The BabylonJS scene
  141511. * @param _origin The origin position of the vortex
  141512. * @param _options The options for the vortex event
  141513. */
  141514. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  141515. /**
  141516. * Returns the data related to the vortex event (cylinder).
  141517. * @returns The physics vortex event data
  141518. */
  141519. getData(): PhysicsVortexEventData;
  141520. /**
  141521. * Enables the vortex.
  141522. */
  141523. enable(): void;
  141524. /**
  141525. * Disables the cortex.
  141526. */
  141527. disable(): void;
  141528. /**
  141529. * Disposes the sphere.
  141530. * @param force
  141531. */
  141532. dispose(force?: boolean): void;
  141533. private getImpostorHitData;
  141534. private _tick;
  141535. /*** Helpers ***/
  141536. private _prepareCylinder;
  141537. private _intersectsWithCylinder;
  141538. }
  141539. /**
  141540. * Options fot the radial explosion event
  141541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141542. */
  141543. export class PhysicsRadialExplosionEventOptions {
  141544. /**
  141545. * The radius of the sphere for the radial explosion.
  141546. */
  141547. radius: number;
  141548. /**
  141549. * The strenth of the explosion.
  141550. */
  141551. strength: number;
  141552. /**
  141553. * The strenght of the force in correspondence to the distance of the affected object
  141554. */
  141555. falloff: PhysicsRadialImpulseFalloff;
  141556. /**
  141557. * Sphere options for the radial explosion.
  141558. */
  141559. sphere: {
  141560. segments: number;
  141561. diameter: number;
  141562. };
  141563. /**
  141564. * Sphere options for the radial explosion.
  141565. */
  141566. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  141567. }
  141568. /**
  141569. * Options fot the updraft event
  141570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141571. */
  141572. export class PhysicsUpdraftEventOptions {
  141573. /**
  141574. * The radius of the cylinder for the vortex
  141575. */
  141576. radius: number;
  141577. /**
  141578. * The strenth of the updraft.
  141579. */
  141580. strength: number;
  141581. /**
  141582. * The height of the cylinder for the updraft.
  141583. */
  141584. height: number;
  141585. /**
  141586. * The mode for the the updraft.
  141587. */
  141588. updraftMode: PhysicsUpdraftMode;
  141589. }
  141590. /**
  141591. * Options fot the vortex event
  141592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141593. */
  141594. export class PhysicsVortexEventOptions {
  141595. /**
  141596. * The radius of the cylinder for the vortex
  141597. */
  141598. radius: number;
  141599. /**
  141600. * The strenth of the vortex.
  141601. */
  141602. strength: number;
  141603. /**
  141604. * The height of the cylinder for the vortex.
  141605. */
  141606. height: number;
  141607. /**
  141608. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  141609. */
  141610. centripetalForceThreshold: number;
  141611. /**
  141612. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  141613. */
  141614. centripetalForceMultiplier: number;
  141615. /**
  141616. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  141617. */
  141618. centrifugalForceMultiplier: number;
  141619. /**
  141620. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  141621. */
  141622. updraftForceMultiplier: number;
  141623. }
  141624. /**
  141625. * The strenght of the force in correspondence to the distance of the affected object
  141626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141627. */
  141628. export enum PhysicsRadialImpulseFalloff {
  141629. /** Defines that impulse is constant in strength across it's whole radius */
  141630. Constant = 0,
  141631. /** Defines that impulse gets weaker if it's further from the origin */
  141632. Linear = 1
  141633. }
  141634. /**
  141635. * The strength of the force in correspondence to the distance of the affected object
  141636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141637. */
  141638. export enum PhysicsUpdraftMode {
  141639. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  141640. Center = 0,
  141641. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  141642. Perpendicular = 1
  141643. }
  141644. /**
  141645. * Interface for a physics hit data
  141646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141647. */
  141648. export interface PhysicsHitData {
  141649. /**
  141650. * The force applied at the contact point
  141651. */
  141652. force: Vector3;
  141653. /**
  141654. * The contact point
  141655. */
  141656. contactPoint: Vector3;
  141657. /**
  141658. * The distance from the origin to the contact point
  141659. */
  141660. distanceFromOrigin: number;
  141661. }
  141662. /**
  141663. * Interface for radial explosion event data
  141664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141665. */
  141666. export interface PhysicsRadialExplosionEventData {
  141667. /**
  141668. * A sphere used for the radial explosion event
  141669. */
  141670. sphere: Mesh;
  141671. }
  141672. /**
  141673. * Interface for gravitational field event data
  141674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141675. */
  141676. export interface PhysicsGravitationalFieldEventData {
  141677. /**
  141678. * A sphere mesh used for the gravitational field event
  141679. */
  141680. sphere: Mesh;
  141681. }
  141682. /**
  141683. * Interface for updraft event data
  141684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141685. */
  141686. export interface PhysicsUpdraftEventData {
  141687. /**
  141688. * A cylinder used for the updraft event
  141689. */
  141690. cylinder: Mesh;
  141691. }
  141692. /**
  141693. * Interface for vortex event data
  141694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141695. */
  141696. export interface PhysicsVortexEventData {
  141697. /**
  141698. * A cylinder used for the vortex event
  141699. */
  141700. cylinder: Mesh;
  141701. }
  141702. /**
  141703. * Interface for an affected physics impostor
  141704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  141705. */
  141706. export interface PhysicsAffectedImpostorWithData {
  141707. /**
  141708. * The impostor affected by the effect
  141709. */
  141710. impostor: PhysicsImpostor;
  141711. /**
  141712. * The data about the hit/horce from the explosion
  141713. */
  141714. hitData: PhysicsHitData;
  141715. }
  141716. }
  141717. declare module BABYLON {
  141718. /** @hidden */
  141719. export var blackAndWhitePixelShader: {
  141720. name: string;
  141721. shader: string;
  141722. };
  141723. }
  141724. declare module BABYLON {
  141725. /**
  141726. * Post process used to render in black and white
  141727. */
  141728. export class BlackAndWhitePostProcess extends PostProcess {
  141729. /**
  141730. * Linear about to convert he result to black and white (default: 1)
  141731. */
  141732. degree: number;
  141733. /**
  141734. * Creates a black and white post process
  141735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  141736. * @param name The name of the effect.
  141737. * @param options The required width/height ratio to downsize to before computing the render pass.
  141738. * @param camera The camera to apply the render pass to.
  141739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141740. * @param engine The engine which the post process will be applied. (default: current engine)
  141741. * @param reusable If the post process can be reused on the same frame. (default: false)
  141742. */
  141743. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  141744. }
  141745. }
  141746. declare module BABYLON {
  141747. /**
  141748. * This represents a set of one or more post processes in Babylon.
  141749. * A post process can be used to apply a shader to a texture after it is rendered.
  141750. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  141751. */
  141752. export class PostProcessRenderEffect {
  141753. private _postProcesses;
  141754. private _getPostProcesses;
  141755. private _singleInstance;
  141756. private _cameras;
  141757. private _indicesForCamera;
  141758. /**
  141759. * Name of the effect
  141760. * @hidden
  141761. */
  141762. _name: string;
  141763. /**
  141764. * Instantiates a post process render effect.
  141765. * A post process can be used to apply a shader to a texture after it is rendered.
  141766. * @param engine The engine the effect is tied to
  141767. * @param name The name of the effect
  141768. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  141769. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  141770. */
  141771. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  141772. /**
  141773. * Checks if all the post processes in the effect are supported.
  141774. */
  141775. get isSupported(): boolean;
  141776. /**
  141777. * Updates the current state of the effect
  141778. * @hidden
  141779. */
  141780. _update(): void;
  141781. /**
  141782. * Attaches the effect on cameras
  141783. * @param cameras The camera to attach to.
  141784. * @hidden
  141785. */
  141786. _attachCameras(cameras: Camera): void;
  141787. /**
  141788. * Attaches the effect on cameras
  141789. * @param cameras The camera to attach to.
  141790. * @hidden
  141791. */
  141792. _attachCameras(cameras: Camera[]): void;
  141793. /**
  141794. * Detaches the effect on cameras
  141795. * @param cameras The camera to detatch from.
  141796. * @hidden
  141797. */
  141798. _detachCameras(cameras: Camera): void;
  141799. /**
  141800. * Detatches the effect on cameras
  141801. * @param cameras The camera to detatch from.
  141802. * @hidden
  141803. */
  141804. _detachCameras(cameras: Camera[]): void;
  141805. /**
  141806. * Enables the effect on given cameras
  141807. * @param cameras The camera to enable.
  141808. * @hidden
  141809. */
  141810. _enable(cameras: Camera): void;
  141811. /**
  141812. * Enables the effect on given cameras
  141813. * @param cameras The camera to enable.
  141814. * @hidden
  141815. */
  141816. _enable(cameras: Nullable<Camera[]>): void;
  141817. /**
  141818. * Disables the effect on the given cameras
  141819. * @param cameras The camera to disable.
  141820. * @hidden
  141821. */
  141822. _disable(cameras: Camera): void;
  141823. /**
  141824. * Disables the effect on the given cameras
  141825. * @param cameras The camera to disable.
  141826. * @hidden
  141827. */
  141828. _disable(cameras: Nullable<Camera[]>): void;
  141829. /**
  141830. * Gets a list of the post processes contained in the effect.
  141831. * @param camera The camera to get the post processes on.
  141832. * @returns The list of the post processes in the effect.
  141833. */
  141834. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  141835. }
  141836. }
  141837. declare module BABYLON {
  141838. /** @hidden */
  141839. export var extractHighlightsPixelShader: {
  141840. name: string;
  141841. shader: string;
  141842. };
  141843. }
  141844. declare module BABYLON {
  141845. /**
  141846. * 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.
  141847. */
  141848. export class ExtractHighlightsPostProcess extends PostProcess {
  141849. /**
  141850. * The luminance threshold, pixels below this value will be set to black.
  141851. */
  141852. threshold: number;
  141853. /** @hidden */
  141854. _exposure: number;
  141855. /**
  141856. * Post process which has the input texture to be used when performing highlight extraction
  141857. * @hidden
  141858. */
  141859. _inputPostProcess: Nullable<PostProcess>;
  141860. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141861. }
  141862. }
  141863. declare module BABYLON {
  141864. /** @hidden */
  141865. export var bloomMergePixelShader: {
  141866. name: string;
  141867. shader: string;
  141868. };
  141869. }
  141870. declare module BABYLON {
  141871. /**
  141872. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  141873. */
  141874. export class BloomMergePostProcess extends PostProcess {
  141875. /** Weight of the bloom to be added to the original input. */
  141876. weight: number;
  141877. /**
  141878. * Creates a new instance of @see BloomMergePostProcess
  141879. * @param name The name of the effect.
  141880. * @param originalFromInput Post process which's input will be used for the merge.
  141881. * @param blurred Blurred highlights post process which's output will be used.
  141882. * @param weight Weight of the bloom to be added to the original input.
  141883. * @param options The required width/height ratio to downsize to before computing the render pass.
  141884. * @param camera The camera to apply the render pass to.
  141885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141886. * @param engine The engine which the post process will be applied. (default: current engine)
  141887. * @param reusable If the post process can be reused on the same frame. (default: false)
  141888. * @param textureType Type of textures used when performing the post process. (default: 0)
  141889. * @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)
  141890. */
  141891. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  141892. /** Weight of the bloom to be added to the original input. */
  141893. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141894. }
  141895. }
  141896. declare module BABYLON {
  141897. /**
  141898. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  141899. */
  141900. export class BloomEffect extends PostProcessRenderEffect {
  141901. private bloomScale;
  141902. /**
  141903. * @hidden Internal
  141904. */
  141905. _effects: Array<PostProcess>;
  141906. /**
  141907. * @hidden Internal
  141908. */
  141909. _downscale: ExtractHighlightsPostProcess;
  141910. private _blurX;
  141911. private _blurY;
  141912. private _merge;
  141913. /**
  141914. * The luminance threshold to find bright areas of the image to bloom.
  141915. */
  141916. get threshold(): number;
  141917. set threshold(value: number);
  141918. /**
  141919. * The strength of the bloom.
  141920. */
  141921. get weight(): number;
  141922. set weight(value: number);
  141923. /**
  141924. * Specifies the size of the bloom blur kernel, relative to the final output size
  141925. */
  141926. get kernel(): number;
  141927. set kernel(value: number);
  141928. /**
  141929. * Creates a new instance of @see BloomEffect
  141930. * @param scene The scene the effect belongs to.
  141931. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  141932. * @param bloomKernel The size of the kernel to be used when applying the blur.
  141933. * @param bloomWeight The the strength of bloom.
  141934. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  141935. * @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)
  141936. */
  141937. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  141938. /**
  141939. * Disposes each of the internal effects for a given camera.
  141940. * @param camera The camera to dispose the effect on.
  141941. */
  141942. disposeEffects(camera: Camera): void;
  141943. /**
  141944. * @hidden Internal
  141945. */
  141946. _updateEffects(): void;
  141947. /**
  141948. * Internal
  141949. * @returns if all the contained post processes are ready.
  141950. * @hidden
  141951. */
  141952. _isReady(): boolean;
  141953. }
  141954. }
  141955. declare module BABYLON {
  141956. /** @hidden */
  141957. export var chromaticAberrationPixelShader: {
  141958. name: string;
  141959. shader: string;
  141960. };
  141961. }
  141962. declare module BABYLON {
  141963. /**
  141964. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  141965. */
  141966. export class ChromaticAberrationPostProcess extends PostProcess {
  141967. /**
  141968. * The amount of seperation of rgb channels (default: 30)
  141969. */
  141970. aberrationAmount: number;
  141971. /**
  141972. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  141973. */
  141974. radialIntensity: number;
  141975. /**
  141976. * 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))
  141977. */
  141978. direction: Vector2;
  141979. /**
  141980. * 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))
  141981. */
  141982. centerPosition: Vector2;
  141983. /**
  141984. * Creates a new instance ChromaticAberrationPostProcess
  141985. * @param name The name of the effect.
  141986. * @param screenWidth The width of the screen to apply the effect on.
  141987. * @param screenHeight The height of the screen to apply the effect on.
  141988. * @param options The required width/height ratio to downsize to before computing the render pass.
  141989. * @param camera The camera to apply the render pass to.
  141990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  141991. * @param engine The engine which the post process will be applied. (default: current engine)
  141992. * @param reusable If the post process can be reused on the same frame. (default: false)
  141993. * @param textureType Type of textures used when performing the post process. (default: 0)
  141994. * @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)
  141995. */
  141996. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  141997. }
  141998. }
  141999. declare module BABYLON {
  142000. /** @hidden */
  142001. export var circleOfConfusionPixelShader: {
  142002. name: string;
  142003. shader: string;
  142004. };
  142005. }
  142006. declare module BABYLON {
  142007. /**
  142008. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  142009. */
  142010. export class CircleOfConfusionPostProcess extends PostProcess {
  142011. /**
  142012. * 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.
  142013. */
  142014. lensSize: number;
  142015. /**
  142016. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142017. */
  142018. fStop: number;
  142019. /**
  142020. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142021. */
  142022. focusDistance: number;
  142023. /**
  142024. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  142025. */
  142026. focalLength: number;
  142027. private _depthTexture;
  142028. /**
  142029. * Creates a new instance CircleOfConfusionPostProcess
  142030. * @param name The name of the effect.
  142031. * @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.
  142032. * @param options The required width/height ratio to downsize to before computing the render pass.
  142033. * @param camera The camera to apply the render pass to.
  142034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142035. * @param engine The engine which the post process will be applied. (default: current engine)
  142036. * @param reusable If the post process can be reused on the same frame. (default: false)
  142037. * @param textureType Type of textures used when performing the post process. (default: 0)
  142038. * @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)
  142039. */
  142040. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142041. /**
  142042. * 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.
  142043. */
  142044. set depthTexture(value: RenderTargetTexture);
  142045. }
  142046. }
  142047. declare module BABYLON {
  142048. /** @hidden */
  142049. export var colorCorrectionPixelShader: {
  142050. name: string;
  142051. shader: string;
  142052. };
  142053. }
  142054. declare module BABYLON {
  142055. /**
  142056. *
  142057. * This post-process allows the modification of rendered colors by using
  142058. * a 'look-up table' (LUT). This effect is also called Color Grading.
  142059. *
  142060. * The object needs to be provided an url to a texture containing the color
  142061. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  142062. * Use an image editing software to tweak the LUT to match your needs.
  142063. *
  142064. * For an example of a color LUT, see here:
  142065. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  142066. * For explanations on color grading, see here:
  142067. * @see http://udn.epicgames.com/Three/ColorGrading.html
  142068. *
  142069. */
  142070. export class ColorCorrectionPostProcess extends PostProcess {
  142071. private _colorTableTexture;
  142072. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142073. }
  142074. }
  142075. declare module BABYLON {
  142076. /** @hidden */
  142077. export var convolutionPixelShader: {
  142078. name: string;
  142079. shader: string;
  142080. };
  142081. }
  142082. declare module BABYLON {
  142083. /**
  142084. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  142085. * input texture to perform effects such as edge detection or sharpening
  142086. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  142087. */
  142088. export class ConvolutionPostProcess extends PostProcess {
  142089. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142090. kernel: number[];
  142091. /**
  142092. * Creates a new instance ConvolutionPostProcess
  142093. * @param name The name of the effect.
  142094. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  142095. * @param options The required width/height ratio to downsize to before computing the render pass.
  142096. * @param camera The camera to apply the render pass to.
  142097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142098. * @param engine The engine which the post process will be applied. (default: current engine)
  142099. * @param reusable If the post process can be reused on the same frame. (default: false)
  142100. * @param textureType Type of textures used when performing the post process. (default: 0)
  142101. */
  142102. constructor(name: string,
  142103. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  142104. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142105. /**
  142106. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142107. */
  142108. static EdgeDetect0Kernel: number[];
  142109. /**
  142110. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142111. */
  142112. static EdgeDetect1Kernel: number[];
  142113. /**
  142114. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142115. */
  142116. static EdgeDetect2Kernel: number[];
  142117. /**
  142118. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142119. */
  142120. static SharpenKernel: number[];
  142121. /**
  142122. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142123. */
  142124. static EmbossKernel: number[];
  142125. /**
  142126. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  142127. */
  142128. static GaussianKernel: number[];
  142129. }
  142130. }
  142131. declare module BABYLON {
  142132. /**
  142133. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  142134. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  142135. * based on samples that have a large difference in distance than the center pixel.
  142136. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  142137. */
  142138. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  142139. direction: Vector2;
  142140. /**
  142141. * Creates a new instance CircleOfConfusionPostProcess
  142142. * @param name The name of the effect.
  142143. * @param scene The scene the effect belongs to.
  142144. * @param direction The direction the blur should be applied.
  142145. * @param kernel The size of the kernel used to blur.
  142146. * @param options The required width/height ratio to downsize to before computing the render pass.
  142147. * @param camera The camera to apply the render pass to.
  142148. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  142149. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  142150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142151. * @param engine The engine which the post process will be applied. (default: current engine)
  142152. * @param reusable If the post process can be reused on the same frame. (default: false)
  142153. * @param textureType Type of textures used when performing the post process. (default: 0)
  142154. * @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)
  142155. */
  142156. 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);
  142157. }
  142158. }
  142159. declare module BABYLON {
  142160. /** @hidden */
  142161. export var depthOfFieldMergePixelShader: {
  142162. name: string;
  142163. shader: string;
  142164. };
  142165. }
  142166. declare module BABYLON {
  142167. /**
  142168. * Options to be set when merging outputs from the default pipeline.
  142169. */
  142170. export class DepthOfFieldMergePostProcessOptions {
  142171. /**
  142172. * The original image to merge on top of
  142173. */
  142174. originalFromInput: PostProcess;
  142175. /**
  142176. * Parameters to perform the merge of the depth of field effect
  142177. */
  142178. depthOfField?: {
  142179. circleOfConfusion: PostProcess;
  142180. blurSteps: Array<PostProcess>;
  142181. };
  142182. /**
  142183. * Parameters to perform the merge of bloom effect
  142184. */
  142185. bloom?: {
  142186. blurred: PostProcess;
  142187. weight: number;
  142188. };
  142189. }
  142190. /**
  142191. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  142192. */
  142193. export class DepthOfFieldMergePostProcess extends PostProcess {
  142194. private blurSteps;
  142195. /**
  142196. * Creates a new instance of DepthOfFieldMergePostProcess
  142197. * @param name The name of the effect.
  142198. * @param originalFromInput Post process which's input will be used for the merge.
  142199. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  142200. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  142201. * @param options The required width/height ratio to downsize to before computing the render pass.
  142202. * @param camera The camera to apply the render pass to.
  142203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142204. * @param engine The engine which the post process will be applied. (default: current engine)
  142205. * @param reusable If the post process can be reused on the same frame. (default: false)
  142206. * @param textureType Type of textures used when performing the post process. (default: 0)
  142207. * @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)
  142208. */
  142209. 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);
  142210. /**
  142211. * Updates the effect with the current post process compile time values and recompiles the shader.
  142212. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  142213. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  142214. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  142215. * @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
  142216. * @param onCompiled Called when the shader has been compiled.
  142217. * @param onError Called if there is an error when compiling a shader.
  142218. */
  142219. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  142220. }
  142221. }
  142222. declare module BABYLON {
  142223. /**
  142224. * Specifies the level of max blur that should be applied when using the depth of field effect
  142225. */
  142226. export enum DepthOfFieldEffectBlurLevel {
  142227. /**
  142228. * Subtle blur
  142229. */
  142230. Low = 0,
  142231. /**
  142232. * Medium blur
  142233. */
  142234. Medium = 1,
  142235. /**
  142236. * Large blur
  142237. */
  142238. High = 2
  142239. }
  142240. /**
  142241. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  142242. */
  142243. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  142244. private _circleOfConfusion;
  142245. /**
  142246. * @hidden Internal, blurs from high to low
  142247. */
  142248. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  142249. private _depthOfFieldBlurY;
  142250. private _dofMerge;
  142251. /**
  142252. * @hidden Internal post processes in depth of field effect
  142253. */
  142254. _effects: Array<PostProcess>;
  142255. /**
  142256. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  142257. */
  142258. set focalLength(value: number);
  142259. get focalLength(): number;
  142260. /**
  142261. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  142262. */
  142263. set fStop(value: number);
  142264. get fStop(): number;
  142265. /**
  142266. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  142267. */
  142268. set focusDistance(value: number);
  142269. get focusDistance(): number;
  142270. /**
  142271. * 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.
  142272. */
  142273. set lensSize(value: number);
  142274. get lensSize(): number;
  142275. /**
  142276. * Creates a new instance DepthOfFieldEffect
  142277. * @param scene The scene the effect belongs to.
  142278. * @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.
  142279. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  142280. * @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)
  142281. */
  142282. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  142283. /**
  142284. * Get the current class name of the current effet
  142285. * @returns "DepthOfFieldEffect"
  142286. */
  142287. getClassName(): string;
  142288. /**
  142289. * 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.
  142290. */
  142291. set depthTexture(value: RenderTargetTexture);
  142292. /**
  142293. * Disposes each of the internal effects for a given camera.
  142294. * @param camera The camera to dispose the effect on.
  142295. */
  142296. disposeEffects(camera: Camera): void;
  142297. /**
  142298. * @hidden Internal
  142299. */
  142300. _updateEffects(): void;
  142301. /**
  142302. * Internal
  142303. * @returns if all the contained post processes are ready.
  142304. * @hidden
  142305. */
  142306. _isReady(): boolean;
  142307. }
  142308. }
  142309. declare module BABYLON {
  142310. /** @hidden */
  142311. export var displayPassPixelShader: {
  142312. name: string;
  142313. shader: string;
  142314. };
  142315. }
  142316. declare module BABYLON {
  142317. /**
  142318. * DisplayPassPostProcess which produces an output the same as it's input
  142319. */
  142320. export class DisplayPassPostProcess extends PostProcess {
  142321. /**
  142322. * Creates the DisplayPassPostProcess
  142323. * @param name The name of the effect.
  142324. * @param options The required width/height ratio to downsize to before computing the render pass.
  142325. * @param camera The camera to apply the render pass to.
  142326. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142327. * @param engine The engine which the post process will be applied. (default: current engine)
  142328. * @param reusable If the post process can be reused on the same frame. (default: false)
  142329. */
  142330. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142331. }
  142332. }
  142333. declare module BABYLON {
  142334. /** @hidden */
  142335. export var filterPixelShader: {
  142336. name: string;
  142337. shader: string;
  142338. };
  142339. }
  142340. declare module BABYLON {
  142341. /**
  142342. * Applies a kernel filter to the image
  142343. */
  142344. export class FilterPostProcess extends PostProcess {
  142345. /** The matrix to be applied to the image */
  142346. kernelMatrix: Matrix;
  142347. /**
  142348. *
  142349. * @param name The name of the effect.
  142350. * @param kernelMatrix The matrix to be applied to the image
  142351. * @param options The required width/height ratio to downsize to before computing the render pass.
  142352. * @param camera The camera to apply the render pass to.
  142353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142354. * @param engine The engine which the post process will be applied. (default: current engine)
  142355. * @param reusable If the post process can be reused on the same frame. (default: false)
  142356. */
  142357. constructor(name: string,
  142358. /** The matrix to be applied to the image */
  142359. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142360. }
  142361. }
  142362. declare module BABYLON {
  142363. /** @hidden */
  142364. export var fxaaPixelShader: {
  142365. name: string;
  142366. shader: string;
  142367. };
  142368. }
  142369. declare module BABYLON {
  142370. /** @hidden */
  142371. export var fxaaVertexShader: {
  142372. name: string;
  142373. shader: string;
  142374. };
  142375. }
  142376. declare module BABYLON {
  142377. /**
  142378. * Fxaa post process
  142379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  142380. */
  142381. export class FxaaPostProcess extends PostProcess {
  142382. /** @hidden */
  142383. texelWidth: number;
  142384. /** @hidden */
  142385. texelHeight: number;
  142386. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142387. private _getDefines;
  142388. }
  142389. }
  142390. declare module BABYLON {
  142391. /** @hidden */
  142392. export var grainPixelShader: {
  142393. name: string;
  142394. shader: string;
  142395. };
  142396. }
  142397. declare module BABYLON {
  142398. /**
  142399. * The GrainPostProcess adds noise to the image at mid luminance levels
  142400. */
  142401. export class GrainPostProcess extends PostProcess {
  142402. /**
  142403. * The intensity of the grain added (default: 30)
  142404. */
  142405. intensity: number;
  142406. /**
  142407. * If the grain should be randomized on every frame
  142408. */
  142409. animated: boolean;
  142410. /**
  142411. * Creates a new instance of @see GrainPostProcess
  142412. * @param name The name of the effect.
  142413. * @param options The required width/height ratio to downsize to before computing the render pass.
  142414. * @param camera The camera to apply the render pass to.
  142415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142416. * @param engine The engine which the post process will be applied. (default: current engine)
  142417. * @param reusable If the post process can be reused on the same frame. (default: false)
  142418. * @param textureType Type of textures used when performing the post process. (default: 0)
  142419. * @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)
  142420. */
  142421. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142422. }
  142423. }
  142424. declare module BABYLON {
  142425. /** @hidden */
  142426. export var highlightsPixelShader: {
  142427. name: string;
  142428. shader: string;
  142429. };
  142430. }
  142431. declare module BABYLON {
  142432. /**
  142433. * Extracts highlights from the image
  142434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142435. */
  142436. export class HighlightsPostProcess extends PostProcess {
  142437. /**
  142438. * Extracts highlights from the image
  142439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  142440. * @param name The name of the effect.
  142441. * @param options The required width/height ratio to downsize to before computing the render pass.
  142442. * @param camera The camera to apply the render pass to.
  142443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142444. * @param engine The engine which the post process will be applied. (default: current engine)
  142445. * @param reusable If the post process can be reused on the same frame. (default: false)
  142446. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  142447. */
  142448. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  142449. }
  142450. }
  142451. declare module BABYLON {
  142452. /** @hidden */
  142453. export var mrtFragmentDeclaration: {
  142454. name: string;
  142455. shader: string;
  142456. };
  142457. }
  142458. declare module BABYLON {
  142459. /** @hidden */
  142460. export var geometryPixelShader: {
  142461. name: string;
  142462. shader: string;
  142463. };
  142464. }
  142465. declare module BABYLON {
  142466. /** @hidden */
  142467. export var geometryVertexShader: {
  142468. name: string;
  142469. shader: string;
  142470. };
  142471. }
  142472. declare module BABYLON {
  142473. /** @hidden */
  142474. interface ISavedTransformationMatrix {
  142475. world: Matrix;
  142476. viewProjection: Matrix;
  142477. }
  142478. /**
  142479. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  142480. */
  142481. export class GeometryBufferRenderer {
  142482. /**
  142483. * Constant used to retrieve the position texture index in the G-Buffer textures array
  142484. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  142485. */
  142486. static readonly POSITION_TEXTURE_TYPE: number;
  142487. /**
  142488. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  142489. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  142490. */
  142491. static readonly VELOCITY_TEXTURE_TYPE: number;
  142492. /**
  142493. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  142494. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  142495. */
  142496. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  142497. /**
  142498. * Dictionary used to store the previous transformation matrices of each rendered mesh
  142499. * in order to compute objects velocities when enableVelocity is set to "true"
  142500. * @hidden
  142501. */
  142502. _previousTransformationMatrices: {
  142503. [index: number]: ISavedTransformationMatrix;
  142504. };
  142505. /**
  142506. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  142507. * in order to compute objects velocities when enableVelocity is set to "true"
  142508. * @hidden
  142509. */
  142510. _previousBonesTransformationMatrices: {
  142511. [index: number]: Float32Array;
  142512. };
  142513. /**
  142514. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  142515. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  142516. */
  142517. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  142518. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  142519. renderTransparentMeshes: boolean;
  142520. private _scene;
  142521. private _multiRenderTarget;
  142522. private _ratio;
  142523. private _enablePosition;
  142524. private _enableVelocity;
  142525. private _enableReflectivity;
  142526. private _positionIndex;
  142527. private _velocityIndex;
  142528. private _reflectivityIndex;
  142529. protected _effect: Effect;
  142530. protected _cachedDefines: string;
  142531. /**
  142532. * Set the render list (meshes to be rendered) used in the G buffer.
  142533. */
  142534. set renderList(meshes: Mesh[]);
  142535. /**
  142536. * Gets wether or not G buffer are supported by the running hardware.
  142537. * This requires draw buffer supports
  142538. */
  142539. get isSupported(): boolean;
  142540. /**
  142541. * Returns the index of the given texture type in the G-Buffer textures array
  142542. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  142543. * @returns the index of the given texture type in the G-Buffer textures array
  142544. */
  142545. getTextureIndex(textureType: number): number;
  142546. /**
  142547. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  142548. */
  142549. get enablePosition(): boolean;
  142550. /**
  142551. * Sets whether or not objects positions are enabled for the G buffer.
  142552. */
  142553. set enablePosition(enable: boolean);
  142554. /**
  142555. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  142556. */
  142557. get enableVelocity(): boolean;
  142558. /**
  142559. * Sets wether or not objects velocities are enabled for the G buffer.
  142560. */
  142561. set enableVelocity(enable: boolean);
  142562. /**
  142563. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  142564. */
  142565. get enableReflectivity(): boolean;
  142566. /**
  142567. * Sets wether or not objects roughness are enabled for the G buffer.
  142568. */
  142569. set enableReflectivity(enable: boolean);
  142570. /**
  142571. * Gets the scene associated with the buffer.
  142572. */
  142573. get scene(): Scene;
  142574. /**
  142575. * Gets the ratio used by the buffer during its creation.
  142576. * How big is the buffer related to the main canvas.
  142577. */
  142578. get ratio(): number;
  142579. /** @hidden */
  142580. static _SceneComponentInitialization: (scene: Scene) => void;
  142581. /**
  142582. * Creates a new G Buffer for the scene
  142583. * @param scene The scene the buffer belongs to
  142584. * @param ratio How big is the buffer related to the main canvas.
  142585. */
  142586. constructor(scene: Scene, ratio?: number);
  142587. /**
  142588. * Checks wether everything is ready to render a submesh to the G buffer.
  142589. * @param subMesh the submesh to check readiness for
  142590. * @param useInstances is the mesh drawn using instance or not
  142591. * @returns true if ready otherwise false
  142592. */
  142593. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142594. /**
  142595. * Gets the current underlying G Buffer.
  142596. * @returns the buffer
  142597. */
  142598. getGBuffer(): MultiRenderTarget;
  142599. /**
  142600. * Gets the number of samples used to render the buffer (anti aliasing).
  142601. */
  142602. get samples(): number;
  142603. /**
  142604. * Sets the number of samples used to render the buffer (anti aliasing).
  142605. */
  142606. set samples(value: number);
  142607. /**
  142608. * Disposes the renderer and frees up associated resources.
  142609. */
  142610. dispose(): void;
  142611. protected _createRenderTargets(): void;
  142612. private _copyBonesTransformationMatrices;
  142613. }
  142614. }
  142615. declare module BABYLON {
  142616. interface Scene {
  142617. /** @hidden (Backing field) */
  142618. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  142619. /**
  142620. * Gets or Sets the current geometry buffer associated to the scene.
  142621. */
  142622. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  142623. /**
  142624. * Enables a GeometryBufferRender and associates it with the scene
  142625. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  142626. * @returns the GeometryBufferRenderer
  142627. */
  142628. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  142629. /**
  142630. * Disables the GeometryBufferRender associated with the scene
  142631. */
  142632. disableGeometryBufferRenderer(): void;
  142633. }
  142634. /**
  142635. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  142636. * in several rendering techniques.
  142637. */
  142638. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  142639. /**
  142640. * The component name helpful to identify the component in the list of scene components.
  142641. */
  142642. readonly name: string;
  142643. /**
  142644. * The scene the component belongs to.
  142645. */
  142646. scene: Scene;
  142647. /**
  142648. * Creates a new instance of the component for the given scene
  142649. * @param scene Defines the scene to register the component in
  142650. */
  142651. constructor(scene: Scene);
  142652. /**
  142653. * Registers the component in a given scene
  142654. */
  142655. register(): void;
  142656. /**
  142657. * Rebuilds the elements related to this component in case of
  142658. * context lost for instance.
  142659. */
  142660. rebuild(): void;
  142661. /**
  142662. * Disposes the component and the associated ressources
  142663. */
  142664. dispose(): void;
  142665. private _gatherRenderTargets;
  142666. }
  142667. }
  142668. declare module BABYLON {
  142669. /** @hidden */
  142670. export var motionBlurPixelShader: {
  142671. name: string;
  142672. shader: string;
  142673. };
  142674. }
  142675. declare module BABYLON {
  142676. /**
  142677. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  142678. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  142679. * As an example, all you have to do is to create the post-process:
  142680. * var mb = new BABYLON.MotionBlurPostProcess(
  142681. * 'mb', // The name of the effect.
  142682. * scene, // The scene containing the objects to blur according to their velocity.
  142683. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  142684. * camera // The camera to apply the render pass to.
  142685. * );
  142686. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  142687. */
  142688. export class MotionBlurPostProcess extends PostProcess {
  142689. /**
  142690. * Defines how much the image is blurred by the movement. Default value is equal to 1
  142691. */
  142692. motionStrength: number;
  142693. /**
  142694. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  142695. */
  142696. get motionBlurSamples(): number;
  142697. /**
  142698. * Sets the number of iterations to be used for motion blur quality
  142699. */
  142700. set motionBlurSamples(samples: number);
  142701. private _motionBlurSamples;
  142702. private _geometryBufferRenderer;
  142703. /**
  142704. * Creates a new instance MotionBlurPostProcess
  142705. * @param name The name of the effect.
  142706. * @param scene The scene containing the objects to blur according to their velocity.
  142707. * @param options The required width/height ratio to downsize to before computing the render pass.
  142708. * @param camera The camera to apply the render pass to.
  142709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142710. * @param engine The engine which the post process will be applied. (default: current engine)
  142711. * @param reusable If the post process can be reused on the same frame. (default: false)
  142712. * @param textureType Type of textures used when performing the post process. (default: 0)
  142713. * @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)
  142714. */
  142715. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142716. /**
  142717. * Excludes the given skinned mesh from computing bones velocities.
  142718. * 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.
  142719. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  142720. */
  142721. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  142722. /**
  142723. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  142724. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  142725. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  142726. */
  142727. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  142728. /**
  142729. * Disposes the post process.
  142730. * @param camera The camera to dispose the post process on.
  142731. */
  142732. dispose(camera?: Camera): void;
  142733. }
  142734. }
  142735. declare module BABYLON {
  142736. /** @hidden */
  142737. export var refractionPixelShader: {
  142738. name: string;
  142739. shader: string;
  142740. };
  142741. }
  142742. declare module BABYLON {
  142743. /**
  142744. * Post process which applies a refractin texture
  142745. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  142746. */
  142747. export class RefractionPostProcess extends PostProcess {
  142748. /** the base color of the refraction (used to taint the rendering) */
  142749. color: Color3;
  142750. /** simulated refraction depth */
  142751. depth: number;
  142752. /** the coefficient of the base color (0 to remove base color tainting) */
  142753. colorLevel: number;
  142754. private _refTexture;
  142755. private _ownRefractionTexture;
  142756. /**
  142757. * Gets or sets the refraction texture
  142758. * Please note that you are responsible for disposing the texture if you set it manually
  142759. */
  142760. get refractionTexture(): Texture;
  142761. set refractionTexture(value: Texture);
  142762. /**
  142763. * Initializes the RefractionPostProcess
  142764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  142765. * @param name The name of the effect.
  142766. * @param refractionTextureUrl Url of the refraction texture to use
  142767. * @param color the base color of the refraction (used to taint the rendering)
  142768. * @param depth simulated refraction depth
  142769. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  142770. * @param camera The camera to apply the render pass to.
  142771. * @param options The required width/height ratio to downsize to before computing the render pass.
  142772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142773. * @param engine The engine which the post process will be applied. (default: current engine)
  142774. * @param reusable If the post process can be reused on the same frame. (default: false)
  142775. */
  142776. constructor(name: string, refractionTextureUrl: string,
  142777. /** the base color of the refraction (used to taint the rendering) */
  142778. color: Color3,
  142779. /** simulated refraction depth */
  142780. depth: number,
  142781. /** the coefficient of the base color (0 to remove base color tainting) */
  142782. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  142783. /**
  142784. * Disposes of the post process
  142785. * @param camera Camera to dispose post process on
  142786. */
  142787. dispose(camera: Camera): void;
  142788. }
  142789. }
  142790. declare module BABYLON {
  142791. /** @hidden */
  142792. export var sharpenPixelShader: {
  142793. name: string;
  142794. shader: string;
  142795. };
  142796. }
  142797. declare module BABYLON {
  142798. /**
  142799. * The SharpenPostProcess applies a sharpen kernel to every pixel
  142800. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  142801. */
  142802. export class SharpenPostProcess extends PostProcess {
  142803. /**
  142804. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  142805. */
  142806. colorAmount: number;
  142807. /**
  142808. * How much sharpness should be applied (default: 0.3)
  142809. */
  142810. edgeAmount: number;
  142811. /**
  142812. * Creates a new instance ConvolutionPostProcess
  142813. * @param name The name of the effect.
  142814. * @param options The required width/height ratio to downsize to before computing the render pass.
  142815. * @param camera The camera to apply the render pass to.
  142816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  142817. * @param engine The engine which the post process will be applied. (default: current engine)
  142818. * @param reusable If the post process can be reused on the same frame. (default: false)
  142819. * @param textureType Type of textures used when performing the post process. (default: 0)
  142820. * @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)
  142821. */
  142822. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  142823. }
  142824. }
  142825. declare module BABYLON {
  142826. /**
  142827. * PostProcessRenderPipeline
  142828. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142829. */
  142830. export class PostProcessRenderPipeline {
  142831. private engine;
  142832. private _renderEffects;
  142833. private _renderEffectsForIsolatedPass;
  142834. /**
  142835. * List of inspectable custom properties (used by the Inspector)
  142836. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  142837. */
  142838. inspectableCustomProperties: IInspectable[];
  142839. /**
  142840. * @hidden
  142841. */
  142842. protected _cameras: Camera[];
  142843. /** @hidden */
  142844. _name: string;
  142845. /**
  142846. * Gets pipeline name
  142847. */
  142848. get name(): string;
  142849. /** Gets the list of attached cameras */
  142850. get cameras(): Camera[];
  142851. /**
  142852. * Initializes a PostProcessRenderPipeline
  142853. * @param engine engine to add the pipeline to
  142854. * @param name name of the pipeline
  142855. */
  142856. constructor(engine: Engine, name: string);
  142857. /**
  142858. * Gets the class name
  142859. * @returns "PostProcessRenderPipeline"
  142860. */
  142861. getClassName(): string;
  142862. /**
  142863. * If all the render effects in the pipeline are supported
  142864. */
  142865. get isSupported(): boolean;
  142866. /**
  142867. * Adds an effect to the pipeline
  142868. * @param renderEffect the effect to add
  142869. */
  142870. addEffect(renderEffect: PostProcessRenderEffect): void;
  142871. /** @hidden */
  142872. _rebuild(): void;
  142873. /** @hidden */
  142874. _enableEffect(renderEffectName: string, cameras: Camera): void;
  142875. /** @hidden */
  142876. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  142877. /** @hidden */
  142878. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  142879. /** @hidden */
  142880. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  142881. /** @hidden */
  142882. _attachCameras(cameras: Camera, unique: boolean): void;
  142883. /** @hidden */
  142884. _attachCameras(cameras: Camera[], unique: boolean): void;
  142885. /** @hidden */
  142886. _detachCameras(cameras: Camera): void;
  142887. /** @hidden */
  142888. _detachCameras(cameras: Nullable<Camera[]>): void;
  142889. /** @hidden */
  142890. _update(): void;
  142891. /** @hidden */
  142892. _reset(): void;
  142893. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  142894. /**
  142895. * Disposes of the pipeline
  142896. */
  142897. dispose(): void;
  142898. }
  142899. }
  142900. declare module BABYLON {
  142901. /**
  142902. * PostProcessRenderPipelineManager class
  142903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142904. */
  142905. export class PostProcessRenderPipelineManager {
  142906. private _renderPipelines;
  142907. /**
  142908. * Initializes a PostProcessRenderPipelineManager
  142909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142910. */
  142911. constructor();
  142912. /**
  142913. * Gets the list of supported render pipelines
  142914. */
  142915. get supportedPipelines(): PostProcessRenderPipeline[];
  142916. /**
  142917. * Adds a pipeline to the manager
  142918. * @param renderPipeline The pipeline to add
  142919. */
  142920. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  142921. /**
  142922. * Attaches a camera to the pipeline
  142923. * @param renderPipelineName The name of the pipeline to attach to
  142924. * @param cameras the camera to attach
  142925. * @param unique if the camera can be attached multiple times to the pipeline
  142926. */
  142927. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  142928. /**
  142929. * Detaches a camera from the pipeline
  142930. * @param renderPipelineName The name of the pipeline to detach from
  142931. * @param cameras the camera to detach
  142932. */
  142933. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  142934. /**
  142935. * Enables an effect by name on a pipeline
  142936. * @param renderPipelineName the name of the pipeline to enable the effect in
  142937. * @param renderEffectName the name of the effect to enable
  142938. * @param cameras the cameras that the effect should be enabled on
  142939. */
  142940. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  142941. /**
  142942. * Disables an effect by name on a pipeline
  142943. * @param renderPipelineName the name of the pipeline to disable the effect in
  142944. * @param renderEffectName the name of the effect to disable
  142945. * @param cameras the cameras that the effect should be disabled on
  142946. */
  142947. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  142948. /**
  142949. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  142950. */
  142951. update(): void;
  142952. /** @hidden */
  142953. _rebuild(): void;
  142954. /**
  142955. * Disposes of the manager and pipelines
  142956. */
  142957. dispose(): void;
  142958. }
  142959. }
  142960. declare module BABYLON {
  142961. interface Scene {
  142962. /** @hidden (Backing field) */
  142963. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  142964. /**
  142965. * Gets the postprocess render pipeline manager
  142966. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  142967. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  142968. */
  142969. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  142970. }
  142971. /**
  142972. * Defines the Render Pipeline scene component responsible to rendering pipelines
  142973. */
  142974. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  142975. /**
  142976. * The component name helpfull to identify the component in the list of scene components.
  142977. */
  142978. readonly name: string;
  142979. /**
  142980. * The scene the component belongs to.
  142981. */
  142982. scene: Scene;
  142983. /**
  142984. * Creates a new instance of the component for the given scene
  142985. * @param scene Defines the scene to register the component in
  142986. */
  142987. constructor(scene: Scene);
  142988. /**
  142989. * Registers the component in a given scene
  142990. */
  142991. register(): void;
  142992. /**
  142993. * Rebuilds the elements related to this component in case of
  142994. * context lost for instance.
  142995. */
  142996. rebuild(): void;
  142997. /**
  142998. * Disposes the component and the associated ressources
  142999. */
  143000. dispose(): void;
  143001. private _gatherRenderTargets;
  143002. }
  143003. }
  143004. declare module BABYLON {
  143005. /**
  143006. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  143007. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  143008. */
  143009. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  143010. private _scene;
  143011. private _camerasToBeAttached;
  143012. /**
  143013. * ID of the sharpen post process,
  143014. */
  143015. private readonly SharpenPostProcessId;
  143016. /**
  143017. * @ignore
  143018. * ID of the image processing post process;
  143019. */
  143020. readonly ImageProcessingPostProcessId: string;
  143021. /**
  143022. * @ignore
  143023. * ID of the Fast Approximate Anti-Aliasing post process;
  143024. */
  143025. readonly FxaaPostProcessId: string;
  143026. /**
  143027. * ID of the chromatic aberration post process,
  143028. */
  143029. private readonly ChromaticAberrationPostProcessId;
  143030. /**
  143031. * ID of the grain post process
  143032. */
  143033. private readonly GrainPostProcessId;
  143034. /**
  143035. * Sharpen post process which will apply a sharpen convolution to enhance edges
  143036. */
  143037. sharpen: SharpenPostProcess;
  143038. private _sharpenEffect;
  143039. private bloom;
  143040. /**
  143041. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  143042. */
  143043. depthOfField: DepthOfFieldEffect;
  143044. /**
  143045. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  143046. */
  143047. fxaa: FxaaPostProcess;
  143048. /**
  143049. * Image post processing pass used to perform operations such as tone mapping or color grading.
  143050. */
  143051. imageProcessing: ImageProcessingPostProcess;
  143052. /**
  143053. * Chromatic aberration post process which will shift rgb colors in the image
  143054. */
  143055. chromaticAberration: ChromaticAberrationPostProcess;
  143056. private _chromaticAberrationEffect;
  143057. /**
  143058. * Grain post process which add noise to the image
  143059. */
  143060. grain: GrainPostProcess;
  143061. private _grainEffect;
  143062. /**
  143063. * Glow post process which adds a glow to emissive areas of the image
  143064. */
  143065. private _glowLayer;
  143066. /**
  143067. * Animations which can be used to tweak settings over a period of time
  143068. */
  143069. animations: Animation[];
  143070. private _imageProcessingConfigurationObserver;
  143071. private _sharpenEnabled;
  143072. private _bloomEnabled;
  143073. private _depthOfFieldEnabled;
  143074. private _depthOfFieldBlurLevel;
  143075. private _fxaaEnabled;
  143076. private _imageProcessingEnabled;
  143077. private _defaultPipelineTextureType;
  143078. private _bloomScale;
  143079. private _chromaticAberrationEnabled;
  143080. private _grainEnabled;
  143081. private _buildAllowed;
  143082. /**
  143083. * Gets active scene
  143084. */
  143085. get scene(): Scene;
  143086. /**
  143087. * Enable or disable the sharpen process from the pipeline
  143088. */
  143089. set sharpenEnabled(enabled: boolean);
  143090. get sharpenEnabled(): boolean;
  143091. private _resizeObserver;
  143092. private _hardwareScaleLevel;
  143093. private _bloomKernel;
  143094. /**
  143095. * Specifies the size of the bloom blur kernel, relative to the final output size
  143096. */
  143097. get bloomKernel(): number;
  143098. set bloomKernel(value: number);
  143099. /**
  143100. * Specifies the weight of the bloom in the final rendering
  143101. */
  143102. private _bloomWeight;
  143103. /**
  143104. * Specifies the luma threshold for the area that will be blurred by the bloom
  143105. */
  143106. private _bloomThreshold;
  143107. private _hdr;
  143108. /**
  143109. * The strength of the bloom.
  143110. */
  143111. set bloomWeight(value: number);
  143112. get bloomWeight(): number;
  143113. /**
  143114. * The strength of the bloom.
  143115. */
  143116. set bloomThreshold(value: number);
  143117. get bloomThreshold(): number;
  143118. /**
  143119. * The scale of the bloom, lower value will provide better performance.
  143120. */
  143121. set bloomScale(value: number);
  143122. get bloomScale(): number;
  143123. /**
  143124. * Enable or disable the bloom from the pipeline
  143125. */
  143126. set bloomEnabled(enabled: boolean);
  143127. get bloomEnabled(): boolean;
  143128. private _rebuildBloom;
  143129. /**
  143130. * If the depth of field is enabled.
  143131. */
  143132. get depthOfFieldEnabled(): boolean;
  143133. set depthOfFieldEnabled(enabled: boolean);
  143134. /**
  143135. * Blur level of the depth of field effect. (Higher blur will effect performance)
  143136. */
  143137. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  143138. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  143139. /**
  143140. * If the anti aliasing is enabled.
  143141. */
  143142. set fxaaEnabled(enabled: boolean);
  143143. get fxaaEnabled(): boolean;
  143144. private _samples;
  143145. /**
  143146. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  143147. */
  143148. set samples(sampleCount: number);
  143149. get samples(): number;
  143150. /**
  143151. * If image processing is enabled.
  143152. */
  143153. set imageProcessingEnabled(enabled: boolean);
  143154. get imageProcessingEnabled(): boolean;
  143155. /**
  143156. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  143157. */
  143158. set glowLayerEnabled(enabled: boolean);
  143159. get glowLayerEnabled(): boolean;
  143160. /**
  143161. * Gets the glow layer (or null if not defined)
  143162. */
  143163. get glowLayer(): Nullable<GlowLayer>;
  143164. /**
  143165. * Enable or disable the chromaticAberration process from the pipeline
  143166. */
  143167. set chromaticAberrationEnabled(enabled: boolean);
  143168. get chromaticAberrationEnabled(): boolean;
  143169. /**
  143170. * Enable or disable the grain process from the pipeline
  143171. */
  143172. set grainEnabled(enabled: boolean);
  143173. get grainEnabled(): boolean;
  143174. /**
  143175. * @constructor
  143176. * @param name - The rendering pipeline name (default: "")
  143177. * @param hdr - If high dynamic range textures should be used (default: true)
  143178. * @param scene - The scene linked to this pipeline (default: the last created scene)
  143179. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  143180. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  143181. */
  143182. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  143183. /**
  143184. * Get the class name
  143185. * @returns "DefaultRenderingPipeline"
  143186. */
  143187. getClassName(): string;
  143188. /**
  143189. * Force the compilation of the entire pipeline.
  143190. */
  143191. prepare(): void;
  143192. private _hasCleared;
  143193. private _prevPostProcess;
  143194. private _prevPrevPostProcess;
  143195. private _setAutoClearAndTextureSharing;
  143196. private _depthOfFieldSceneObserver;
  143197. private _buildPipeline;
  143198. private _disposePostProcesses;
  143199. /**
  143200. * Adds a camera to the pipeline
  143201. * @param camera the camera to be added
  143202. */
  143203. addCamera(camera: Camera): void;
  143204. /**
  143205. * Removes a camera from the pipeline
  143206. * @param camera the camera to remove
  143207. */
  143208. removeCamera(camera: Camera): void;
  143209. /**
  143210. * Dispose of the pipeline and stop all post processes
  143211. */
  143212. dispose(): void;
  143213. /**
  143214. * Serialize the rendering pipeline (Used when exporting)
  143215. * @returns the serialized object
  143216. */
  143217. serialize(): any;
  143218. /**
  143219. * Parse the serialized pipeline
  143220. * @param source Source pipeline.
  143221. * @param scene The scene to load the pipeline to.
  143222. * @param rootUrl The URL of the serialized pipeline.
  143223. * @returns An instantiated pipeline from the serialized object.
  143224. */
  143225. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  143226. }
  143227. }
  143228. declare module BABYLON {
  143229. /** @hidden */
  143230. export var lensHighlightsPixelShader: {
  143231. name: string;
  143232. shader: string;
  143233. };
  143234. }
  143235. declare module BABYLON {
  143236. /** @hidden */
  143237. export var depthOfFieldPixelShader: {
  143238. name: string;
  143239. shader: string;
  143240. };
  143241. }
  143242. declare module BABYLON {
  143243. /**
  143244. * BABYLON.JS Chromatic Aberration GLSL Shader
  143245. * Author: Olivier Guyot
  143246. * Separates very slightly R, G and B colors on the edges of the screen
  143247. * Inspired by Francois Tarlier & Martins Upitis
  143248. */
  143249. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  143250. /**
  143251. * @ignore
  143252. * The chromatic aberration PostProcess id in the pipeline
  143253. */
  143254. LensChromaticAberrationEffect: string;
  143255. /**
  143256. * @ignore
  143257. * The highlights enhancing PostProcess id in the pipeline
  143258. */
  143259. HighlightsEnhancingEffect: string;
  143260. /**
  143261. * @ignore
  143262. * The depth-of-field PostProcess id in the pipeline
  143263. */
  143264. LensDepthOfFieldEffect: string;
  143265. private _scene;
  143266. private _depthTexture;
  143267. private _grainTexture;
  143268. private _chromaticAberrationPostProcess;
  143269. private _highlightsPostProcess;
  143270. private _depthOfFieldPostProcess;
  143271. private _edgeBlur;
  143272. private _grainAmount;
  143273. private _chromaticAberration;
  143274. private _distortion;
  143275. private _highlightsGain;
  143276. private _highlightsThreshold;
  143277. private _dofDistance;
  143278. private _dofAperture;
  143279. private _dofDarken;
  143280. private _dofPentagon;
  143281. private _blurNoise;
  143282. /**
  143283. * @constructor
  143284. *
  143285. * Effect parameters are as follow:
  143286. * {
  143287. * chromatic_aberration: number; // from 0 to x (1 for realism)
  143288. * edge_blur: number; // from 0 to x (1 for realism)
  143289. * distortion: number; // from 0 to x (1 for realism)
  143290. * grain_amount: number; // from 0 to 1
  143291. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  143292. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  143293. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  143294. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  143295. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  143296. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  143297. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  143298. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  143299. * }
  143300. * Note: if an effect parameter is unset, effect is disabled
  143301. *
  143302. * @param name The rendering pipeline name
  143303. * @param parameters - An object containing all parameters (see above)
  143304. * @param scene The scene linked to this pipeline
  143305. * @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)
  143306. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143307. */
  143308. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  143309. /**
  143310. * Get the class name
  143311. * @returns "LensRenderingPipeline"
  143312. */
  143313. getClassName(): string;
  143314. /**
  143315. * Gets associated scene
  143316. */
  143317. get scene(): Scene;
  143318. /**
  143319. * Gets or sets the edge blur
  143320. */
  143321. get edgeBlur(): number;
  143322. set edgeBlur(value: number);
  143323. /**
  143324. * Gets or sets the grain amount
  143325. */
  143326. get grainAmount(): number;
  143327. set grainAmount(value: number);
  143328. /**
  143329. * Gets or sets the chromatic aberration amount
  143330. */
  143331. get chromaticAberration(): number;
  143332. set chromaticAberration(value: number);
  143333. /**
  143334. * Gets or sets the depth of field aperture
  143335. */
  143336. get dofAperture(): number;
  143337. set dofAperture(value: number);
  143338. /**
  143339. * Gets or sets the edge distortion
  143340. */
  143341. get edgeDistortion(): number;
  143342. set edgeDistortion(value: number);
  143343. /**
  143344. * Gets or sets the depth of field distortion
  143345. */
  143346. get dofDistortion(): number;
  143347. set dofDistortion(value: number);
  143348. /**
  143349. * Gets or sets the darken out of focus amount
  143350. */
  143351. get darkenOutOfFocus(): number;
  143352. set darkenOutOfFocus(value: number);
  143353. /**
  143354. * Gets or sets a boolean indicating if blur noise is enabled
  143355. */
  143356. get blurNoise(): boolean;
  143357. set blurNoise(value: boolean);
  143358. /**
  143359. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  143360. */
  143361. get pentagonBokeh(): boolean;
  143362. set pentagonBokeh(value: boolean);
  143363. /**
  143364. * Gets or sets the highlight grain amount
  143365. */
  143366. get highlightsGain(): number;
  143367. set highlightsGain(value: number);
  143368. /**
  143369. * Gets or sets the highlight threshold
  143370. */
  143371. get highlightsThreshold(): number;
  143372. set highlightsThreshold(value: number);
  143373. /**
  143374. * Sets the amount of blur at the edges
  143375. * @param amount blur amount
  143376. */
  143377. setEdgeBlur(amount: number): void;
  143378. /**
  143379. * Sets edge blur to 0
  143380. */
  143381. disableEdgeBlur(): void;
  143382. /**
  143383. * Sets the amout of grain
  143384. * @param amount Amount of grain
  143385. */
  143386. setGrainAmount(amount: number): void;
  143387. /**
  143388. * Set grain amount to 0
  143389. */
  143390. disableGrain(): void;
  143391. /**
  143392. * Sets the chromatic aberration amount
  143393. * @param amount amount of chromatic aberration
  143394. */
  143395. setChromaticAberration(amount: number): void;
  143396. /**
  143397. * Sets chromatic aberration amount to 0
  143398. */
  143399. disableChromaticAberration(): void;
  143400. /**
  143401. * Sets the EdgeDistortion amount
  143402. * @param amount amount of EdgeDistortion
  143403. */
  143404. setEdgeDistortion(amount: number): void;
  143405. /**
  143406. * Sets edge distortion to 0
  143407. */
  143408. disableEdgeDistortion(): void;
  143409. /**
  143410. * Sets the FocusDistance amount
  143411. * @param amount amount of FocusDistance
  143412. */
  143413. setFocusDistance(amount: number): void;
  143414. /**
  143415. * Disables depth of field
  143416. */
  143417. disableDepthOfField(): void;
  143418. /**
  143419. * Sets the Aperture amount
  143420. * @param amount amount of Aperture
  143421. */
  143422. setAperture(amount: number): void;
  143423. /**
  143424. * Sets the DarkenOutOfFocus amount
  143425. * @param amount amount of DarkenOutOfFocus
  143426. */
  143427. setDarkenOutOfFocus(amount: number): void;
  143428. private _pentagonBokehIsEnabled;
  143429. /**
  143430. * Creates a pentagon bokeh effect
  143431. */
  143432. enablePentagonBokeh(): void;
  143433. /**
  143434. * Disables the pentagon bokeh effect
  143435. */
  143436. disablePentagonBokeh(): void;
  143437. /**
  143438. * Enables noise blur
  143439. */
  143440. enableNoiseBlur(): void;
  143441. /**
  143442. * Disables noise blur
  143443. */
  143444. disableNoiseBlur(): void;
  143445. /**
  143446. * Sets the HighlightsGain amount
  143447. * @param amount amount of HighlightsGain
  143448. */
  143449. setHighlightsGain(amount: number): void;
  143450. /**
  143451. * Sets the HighlightsThreshold amount
  143452. * @param amount amount of HighlightsThreshold
  143453. */
  143454. setHighlightsThreshold(amount: number): void;
  143455. /**
  143456. * Disables highlights
  143457. */
  143458. disableHighlights(): void;
  143459. /**
  143460. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  143461. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  143462. */
  143463. dispose(disableDepthRender?: boolean): void;
  143464. private _createChromaticAberrationPostProcess;
  143465. private _createHighlightsPostProcess;
  143466. private _createDepthOfFieldPostProcess;
  143467. private _createGrainTexture;
  143468. }
  143469. }
  143470. declare module BABYLON {
  143471. /** @hidden */
  143472. export var ssao2PixelShader: {
  143473. name: string;
  143474. shader: string;
  143475. };
  143476. }
  143477. declare module BABYLON {
  143478. /** @hidden */
  143479. export var ssaoCombinePixelShader: {
  143480. name: string;
  143481. shader: string;
  143482. };
  143483. }
  143484. declare module BABYLON {
  143485. /**
  143486. * Render pipeline to produce ssao effect
  143487. */
  143488. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  143489. /**
  143490. * @ignore
  143491. * The PassPostProcess id in the pipeline that contains the original scene color
  143492. */
  143493. SSAOOriginalSceneColorEffect: string;
  143494. /**
  143495. * @ignore
  143496. * The SSAO PostProcess id in the pipeline
  143497. */
  143498. SSAORenderEffect: string;
  143499. /**
  143500. * @ignore
  143501. * The horizontal blur PostProcess id in the pipeline
  143502. */
  143503. SSAOBlurHRenderEffect: string;
  143504. /**
  143505. * @ignore
  143506. * The vertical blur PostProcess id in the pipeline
  143507. */
  143508. SSAOBlurVRenderEffect: string;
  143509. /**
  143510. * @ignore
  143511. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143512. */
  143513. SSAOCombineRenderEffect: string;
  143514. /**
  143515. * The output strength of the SSAO post-process. Default value is 1.0.
  143516. */
  143517. totalStrength: number;
  143518. /**
  143519. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  143520. */
  143521. maxZ: number;
  143522. /**
  143523. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  143524. */
  143525. minZAspect: number;
  143526. private _samples;
  143527. /**
  143528. * Number of samples used for the SSAO calculations. Default value is 8
  143529. */
  143530. set samples(n: number);
  143531. get samples(): number;
  143532. private _textureSamples;
  143533. /**
  143534. * Number of samples to use for antialiasing
  143535. */
  143536. set textureSamples(n: number);
  143537. get textureSamples(): number;
  143538. /**
  143539. * Ratio object used for SSAO ratio and blur ratio
  143540. */
  143541. private _ratio;
  143542. /**
  143543. * Dynamically generated sphere sampler.
  143544. */
  143545. private _sampleSphere;
  143546. /**
  143547. * Blur filter offsets
  143548. */
  143549. private _samplerOffsets;
  143550. private _expensiveBlur;
  143551. /**
  143552. * If bilateral blur should be used
  143553. */
  143554. set expensiveBlur(b: boolean);
  143555. get expensiveBlur(): boolean;
  143556. /**
  143557. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  143558. */
  143559. radius: number;
  143560. /**
  143561. * The base color of the SSAO post-process
  143562. * The final result is "base + ssao" between [0, 1]
  143563. */
  143564. base: number;
  143565. /**
  143566. * Support test.
  143567. */
  143568. static get IsSupported(): boolean;
  143569. private _scene;
  143570. private _depthTexture;
  143571. private _normalTexture;
  143572. private _randomTexture;
  143573. private _originalColorPostProcess;
  143574. private _ssaoPostProcess;
  143575. private _blurHPostProcess;
  143576. private _blurVPostProcess;
  143577. private _ssaoCombinePostProcess;
  143578. /**
  143579. * Gets active scene
  143580. */
  143581. get scene(): Scene;
  143582. /**
  143583. * @constructor
  143584. * @param name The rendering pipeline name
  143585. * @param scene The scene linked to this pipeline
  143586. * @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 }
  143587. * @param cameras The array of cameras that the rendering pipeline will be attached to
  143588. */
  143589. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  143590. /**
  143591. * Get the class name
  143592. * @returns "SSAO2RenderingPipeline"
  143593. */
  143594. getClassName(): string;
  143595. /**
  143596. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  143597. */
  143598. dispose(disableGeometryBufferRenderer?: boolean): void;
  143599. private _createBlurPostProcess;
  143600. /** @hidden */
  143601. _rebuild(): void;
  143602. private _bits;
  143603. private _radicalInverse_VdC;
  143604. private _hammersley;
  143605. private _hemisphereSample_uniform;
  143606. private _generateHemisphere;
  143607. private _createSSAOPostProcess;
  143608. private _createSSAOCombinePostProcess;
  143609. private _createRandomTexture;
  143610. /**
  143611. * Serialize the rendering pipeline (Used when exporting)
  143612. * @returns the serialized object
  143613. */
  143614. serialize(): any;
  143615. /**
  143616. * Parse the serialized pipeline
  143617. * @param source Source pipeline.
  143618. * @param scene The scene to load the pipeline to.
  143619. * @param rootUrl The URL of the serialized pipeline.
  143620. * @returns An instantiated pipeline from the serialized object.
  143621. */
  143622. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  143623. }
  143624. }
  143625. declare module BABYLON {
  143626. /** @hidden */
  143627. export var ssaoPixelShader: {
  143628. name: string;
  143629. shader: string;
  143630. };
  143631. }
  143632. declare module BABYLON {
  143633. /**
  143634. * Render pipeline to produce ssao effect
  143635. */
  143636. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  143637. /**
  143638. * @ignore
  143639. * The PassPostProcess id in the pipeline that contains the original scene color
  143640. */
  143641. SSAOOriginalSceneColorEffect: string;
  143642. /**
  143643. * @ignore
  143644. * The SSAO PostProcess id in the pipeline
  143645. */
  143646. SSAORenderEffect: string;
  143647. /**
  143648. * @ignore
  143649. * The horizontal blur PostProcess id in the pipeline
  143650. */
  143651. SSAOBlurHRenderEffect: string;
  143652. /**
  143653. * @ignore
  143654. * The vertical blur PostProcess id in the pipeline
  143655. */
  143656. SSAOBlurVRenderEffect: string;
  143657. /**
  143658. * @ignore
  143659. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  143660. */
  143661. SSAOCombineRenderEffect: string;
  143662. /**
  143663. * The output strength of the SSAO post-process. Default value is 1.0.
  143664. */
  143665. totalStrength: number;
  143666. /**
  143667. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  143668. */
  143669. radius: number;
  143670. /**
  143671. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  143672. * Must not be equal to fallOff and superior to fallOff.
  143673. * Default value is 0.0075
  143674. */
  143675. area: number;
  143676. /**
  143677. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  143678. * Must not be equal to area and inferior to area.
  143679. * Default value is 0.000001
  143680. */
  143681. fallOff: number;
  143682. /**
  143683. * The base color of the SSAO post-process
  143684. * The final result is "base + ssao" between [0, 1]
  143685. */
  143686. base: number;
  143687. private _scene;
  143688. private _depthTexture;
  143689. private _randomTexture;
  143690. private _originalColorPostProcess;
  143691. private _ssaoPostProcess;
  143692. private _blurHPostProcess;
  143693. private _blurVPostProcess;
  143694. private _ssaoCombinePostProcess;
  143695. private _firstUpdate;
  143696. /**
  143697. * Gets active scene
  143698. */
  143699. get scene(): Scene;
  143700. /**
  143701. * @constructor
  143702. * @param name - The rendering pipeline name
  143703. * @param scene - The scene linked to this pipeline
  143704. * @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 }
  143705. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  143706. */
  143707. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  143708. /**
  143709. * Get the class name
  143710. * @returns "SSAORenderingPipeline"
  143711. */
  143712. getClassName(): string;
  143713. /**
  143714. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  143715. */
  143716. dispose(disableDepthRender?: boolean): void;
  143717. private _createBlurPostProcess;
  143718. /** @hidden */
  143719. _rebuild(): void;
  143720. private _createSSAOPostProcess;
  143721. private _createSSAOCombinePostProcess;
  143722. private _createRandomTexture;
  143723. }
  143724. }
  143725. declare module BABYLON {
  143726. /** @hidden */
  143727. export var screenSpaceReflectionPixelShader: {
  143728. name: string;
  143729. shader: string;
  143730. };
  143731. }
  143732. declare module BABYLON {
  143733. /**
  143734. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  143735. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  143736. */
  143737. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  143738. /**
  143739. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  143740. */
  143741. threshold: number;
  143742. /**
  143743. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  143744. */
  143745. strength: number;
  143746. /**
  143747. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  143748. */
  143749. reflectionSpecularFalloffExponent: number;
  143750. /**
  143751. * 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]
  143752. */
  143753. step: number;
  143754. /**
  143755. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  143756. */
  143757. roughnessFactor: number;
  143758. private _geometryBufferRenderer;
  143759. private _enableSmoothReflections;
  143760. private _reflectionSamples;
  143761. private _smoothSteps;
  143762. /**
  143763. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  143764. * @param name The name of the effect.
  143765. * @param scene The scene containing the objects to calculate reflections.
  143766. * @param options The required width/height ratio to downsize to before computing the render pass.
  143767. * @param camera The camera to apply the render pass to.
  143768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  143769. * @param engine The engine which the post process will be applied. (default: current engine)
  143770. * @param reusable If the post process can be reused on the same frame. (default: false)
  143771. * @param textureType Type of textures used when performing the post process. (default: 0)
  143772. * @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)
  143773. */
  143774. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  143775. /**
  143776. * Gets wether or not smoothing reflections is enabled.
  143777. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  143778. */
  143779. get enableSmoothReflections(): boolean;
  143780. /**
  143781. * Sets wether or not smoothing reflections is enabled.
  143782. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  143783. */
  143784. set enableSmoothReflections(enabled: boolean);
  143785. /**
  143786. * Gets the number of samples taken while computing reflections. More samples count is high,
  143787. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  143788. */
  143789. get reflectionSamples(): number;
  143790. /**
  143791. * Sets the number of samples taken while computing reflections. More samples count is high,
  143792. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  143793. */
  143794. set reflectionSamples(samples: number);
  143795. /**
  143796. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  143797. * more the post-process will require GPU power and can generate a drop in FPS.
  143798. * Default value (5.0) work pretty well in all cases but can be adjusted.
  143799. */
  143800. get smoothSteps(): number;
  143801. set smoothSteps(steps: number);
  143802. private _updateEffectDefines;
  143803. }
  143804. }
  143805. declare module BABYLON {
  143806. /** @hidden */
  143807. export var standardPixelShader: {
  143808. name: string;
  143809. shader: string;
  143810. };
  143811. }
  143812. declare module BABYLON {
  143813. /**
  143814. * Standard rendering pipeline
  143815. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  143816. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  143817. */
  143818. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  143819. /**
  143820. * Public members
  143821. */
  143822. /**
  143823. * Post-process which contains the original scene color before the pipeline applies all the effects
  143824. */
  143825. originalPostProcess: Nullable<PostProcess>;
  143826. /**
  143827. * Post-process used to down scale an image x4
  143828. */
  143829. downSampleX4PostProcess: Nullable<PostProcess>;
  143830. /**
  143831. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  143832. */
  143833. brightPassPostProcess: Nullable<PostProcess>;
  143834. /**
  143835. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  143836. */
  143837. blurHPostProcesses: PostProcess[];
  143838. /**
  143839. * Post-process array storing all the vertical blur post-processes used by the pipeline
  143840. */
  143841. blurVPostProcesses: PostProcess[];
  143842. /**
  143843. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  143844. */
  143845. textureAdderPostProcess: Nullable<PostProcess>;
  143846. /**
  143847. * Post-process used to create volumetric lighting effect
  143848. */
  143849. volumetricLightPostProcess: Nullable<PostProcess>;
  143850. /**
  143851. * Post-process used to smooth the previous volumetric light post-process on the X axis
  143852. */
  143853. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  143854. /**
  143855. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  143856. */
  143857. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  143858. /**
  143859. * Post-process used to merge the volumetric light effect and the real scene color
  143860. */
  143861. volumetricLightMergePostProces: Nullable<PostProcess>;
  143862. /**
  143863. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  143864. */
  143865. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  143866. /**
  143867. * Base post-process used to calculate the average luminance of the final image for HDR
  143868. */
  143869. luminancePostProcess: Nullable<PostProcess>;
  143870. /**
  143871. * Post-processes used to create down sample post-processes in order to get
  143872. * the average luminance of the final image for HDR
  143873. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  143874. */
  143875. luminanceDownSamplePostProcesses: PostProcess[];
  143876. /**
  143877. * Post-process used to create a HDR effect (light adaptation)
  143878. */
  143879. hdrPostProcess: Nullable<PostProcess>;
  143880. /**
  143881. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  143882. */
  143883. textureAdderFinalPostProcess: Nullable<PostProcess>;
  143884. /**
  143885. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  143886. */
  143887. lensFlareFinalPostProcess: Nullable<PostProcess>;
  143888. /**
  143889. * Post-process used to merge the final HDR post-process and the real scene color
  143890. */
  143891. hdrFinalPostProcess: Nullable<PostProcess>;
  143892. /**
  143893. * Post-process used to create a lens flare effect
  143894. */
  143895. lensFlarePostProcess: Nullable<PostProcess>;
  143896. /**
  143897. * Post-process that merges the result of the lens flare post-process and the real scene color
  143898. */
  143899. lensFlareComposePostProcess: Nullable<PostProcess>;
  143900. /**
  143901. * Post-process used to create a motion blur effect
  143902. */
  143903. motionBlurPostProcess: Nullable<PostProcess>;
  143904. /**
  143905. * Post-process used to create a depth of field effect
  143906. */
  143907. depthOfFieldPostProcess: Nullable<PostProcess>;
  143908. /**
  143909. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  143910. */
  143911. fxaaPostProcess: Nullable<FxaaPostProcess>;
  143912. /**
  143913. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  143914. */
  143915. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  143916. /**
  143917. * Represents the brightness threshold in order to configure the illuminated surfaces
  143918. */
  143919. brightThreshold: number;
  143920. /**
  143921. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  143922. */
  143923. blurWidth: number;
  143924. /**
  143925. * Sets if the blur for highlighted surfaces must be only horizontal
  143926. */
  143927. horizontalBlur: boolean;
  143928. /**
  143929. * Gets the overall exposure used by the pipeline
  143930. */
  143931. get exposure(): number;
  143932. /**
  143933. * Sets the overall exposure used by the pipeline
  143934. */
  143935. set exposure(value: number);
  143936. /**
  143937. * Texture used typically to simulate "dirty" on camera lens
  143938. */
  143939. lensTexture: Nullable<Texture>;
  143940. /**
  143941. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  143942. */
  143943. volumetricLightCoefficient: number;
  143944. /**
  143945. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  143946. */
  143947. volumetricLightPower: number;
  143948. /**
  143949. * Used the set the blur intensity to smooth the volumetric lights
  143950. */
  143951. volumetricLightBlurScale: number;
  143952. /**
  143953. * Light (spot or directional) used to generate the volumetric lights rays
  143954. * The source light must have a shadow generate so the pipeline can get its
  143955. * depth map
  143956. */
  143957. sourceLight: Nullable<SpotLight | DirectionalLight>;
  143958. /**
  143959. * For eye adaptation, represents the minimum luminance the eye can see
  143960. */
  143961. hdrMinimumLuminance: number;
  143962. /**
  143963. * For eye adaptation, represents the decrease luminance speed
  143964. */
  143965. hdrDecreaseRate: number;
  143966. /**
  143967. * For eye adaptation, represents the increase luminance speed
  143968. */
  143969. hdrIncreaseRate: number;
  143970. /**
  143971. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  143972. */
  143973. get hdrAutoExposure(): boolean;
  143974. /**
  143975. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  143976. */
  143977. set hdrAutoExposure(value: boolean);
  143978. /**
  143979. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  143980. */
  143981. lensColorTexture: Nullable<Texture>;
  143982. /**
  143983. * The overall strengh for the lens flare effect
  143984. */
  143985. lensFlareStrength: number;
  143986. /**
  143987. * Dispersion coefficient for lens flare ghosts
  143988. */
  143989. lensFlareGhostDispersal: number;
  143990. /**
  143991. * Main lens flare halo width
  143992. */
  143993. lensFlareHaloWidth: number;
  143994. /**
  143995. * Based on the lens distortion effect, defines how much the lens flare result
  143996. * is distorted
  143997. */
  143998. lensFlareDistortionStrength: number;
  143999. /**
  144000. * Configures the blur intensity used for for lens flare (halo)
  144001. */
  144002. lensFlareBlurWidth: number;
  144003. /**
  144004. * Lens star texture must be used to simulate rays on the flares and is available
  144005. * in the documentation
  144006. */
  144007. lensStarTexture: Nullable<Texture>;
  144008. /**
  144009. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  144010. * flare effect by taking account of the dirt texture
  144011. */
  144012. lensFlareDirtTexture: Nullable<Texture>;
  144013. /**
  144014. * Represents the focal length for the depth of field effect
  144015. */
  144016. depthOfFieldDistance: number;
  144017. /**
  144018. * Represents the blur intensity for the blurred part of the depth of field effect
  144019. */
  144020. depthOfFieldBlurWidth: number;
  144021. /**
  144022. * Gets how much the image is blurred by the movement while using the motion blur post-process
  144023. */
  144024. get motionStrength(): number;
  144025. /**
  144026. * Sets how much the image is blurred by the movement while using the motion blur post-process
  144027. */
  144028. set motionStrength(strength: number);
  144029. /**
  144030. * Gets wether or not the motion blur post-process is object based or screen based.
  144031. */
  144032. get objectBasedMotionBlur(): boolean;
  144033. /**
  144034. * Sets wether or not the motion blur post-process should be object based or screen based
  144035. */
  144036. set objectBasedMotionBlur(value: boolean);
  144037. /**
  144038. * List of animations for the pipeline (IAnimatable implementation)
  144039. */
  144040. animations: Animation[];
  144041. /**
  144042. * Private members
  144043. */
  144044. private _scene;
  144045. private _currentDepthOfFieldSource;
  144046. private _basePostProcess;
  144047. private _fixedExposure;
  144048. private _currentExposure;
  144049. private _hdrAutoExposure;
  144050. private _hdrCurrentLuminance;
  144051. private _motionStrength;
  144052. private _isObjectBasedMotionBlur;
  144053. private _floatTextureType;
  144054. private _camerasToBeAttached;
  144055. private _ratio;
  144056. private _bloomEnabled;
  144057. private _depthOfFieldEnabled;
  144058. private _vlsEnabled;
  144059. private _lensFlareEnabled;
  144060. private _hdrEnabled;
  144061. private _motionBlurEnabled;
  144062. private _fxaaEnabled;
  144063. private _screenSpaceReflectionsEnabled;
  144064. private _motionBlurSamples;
  144065. private _volumetricLightStepsCount;
  144066. private _samples;
  144067. /**
  144068. * @ignore
  144069. * Specifies if the bloom pipeline is enabled
  144070. */
  144071. get BloomEnabled(): boolean;
  144072. set BloomEnabled(enabled: boolean);
  144073. /**
  144074. * @ignore
  144075. * Specifies if the depth of field pipeline is enabed
  144076. */
  144077. get DepthOfFieldEnabled(): boolean;
  144078. set DepthOfFieldEnabled(enabled: boolean);
  144079. /**
  144080. * @ignore
  144081. * Specifies if the lens flare pipeline is enabed
  144082. */
  144083. get LensFlareEnabled(): boolean;
  144084. set LensFlareEnabled(enabled: boolean);
  144085. /**
  144086. * @ignore
  144087. * Specifies if the HDR pipeline is enabled
  144088. */
  144089. get HDREnabled(): boolean;
  144090. set HDREnabled(enabled: boolean);
  144091. /**
  144092. * @ignore
  144093. * Specifies if the volumetric lights scattering effect is enabled
  144094. */
  144095. get VLSEnabled(): boolean;
  144096. set VLSEnabled(enabled: boolean);
  144097. /**
  144098. * @ignore
  144099. * Specifies if the motion blur effect is enabled
  144100. */
  144101. get MotionBlurEnabled(): boolean;
  144102. set MotionBlurEnabled(enabled: boolean);
  144103. /**
  144104. * Specifies if anti-aliasing is enabled
  144105. */
  144106. get fxaaEnabled(): boolean;
  144107. set fxaaEnabled(enabled: boolean);
  144108. /**
  144109. * Specifies if screen space reflections are enabled.
  144110. */
  144111. get screenSpaceReflectionsEnabled(): boolean;
  144112. set screenSpaceReflectionsEnabled(enabled: boolean);
  144113. /**
  144114. * Specifies the number of steps used to calculate the volumetric lights
  144115. * Typically in interval [50, 200]
  144116. */
  144117. get volumetricLightStepsCount(): number;
  144118. set volumetricLightStepsCount(count: number);
  144119. /**
  144120. * Specifies the number of samples used for the motion blur effect
  144121. * Typically in interval [16, 64]
  144122. */
  144123. get motionBlurSamples(): number;
  144124. set motionBlurSamples(samples: number);
  144125. /**
  144126. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  144127. */
  144128. get samples(): number;
  144129. set samples(sampleCount: number);
  144130. /**
  144131. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  144132. * @constructor
  144133. * @param name The rendering pipeline name
  144134. * @param scene The scene linked to this pipeline
  144135. * @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)
  144136. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  144137. * @param cameras The array of cameras that the rendering pipeline will be attached to
  144138. */
  144139. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  144140. private _buildPipeline;
  144141. private _createDownSampleX4PostProcess;
  144142. private _createBrightPassPostProcess;
  144143. private _createBlurPostProcesses;
  144144. private _createTextureAdderPostProcess;
  144145. private _createVolumetricLightPostProcess;
  144146. private _createLuminancePostProcesses;
  144147. private _createHdrPostProcess;
  144148. private _createLensFlarePostProcess;
  144149. private _createDepthOfFieldPostProcess;
  144150. private _createMotionBlurPostProcess;
  144151. private _getDepthTexture;
  144152. private _disposePostProcesses;
  144153. /**
  144154. * Dispose of the pipeline and stop all post processes
  144155. */
  144156. dispose(): void;
  144157. /**
  144158. * Serialize the rendering pipeline (Used when exporting)
  144159. * @returns the serialized object
  144160. */
  144161. serialize(): any;
  144162. /**
  144163. * Parse the serialized pipeline
  144164. * @param source Source pipeline.
  144165. * @param scene The scene to load the pipeline to.
  144166. * @param rootUrl The URL of the serialized pipeline.
  144167. * @returns An instantiated pipeline from the serialized object.
  144168. */
  144169. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  144170. /**
  144171. * Luminance steps
  144172. */
  144173. static LuminanceSteps: number;
  144174. }
  144175. }
  144176. declare module BABYLON {
  144177. /** @hidden */
  144178. export var stereoscopicInterlacePixelShader: {
  144179. name: string;
  144180. shader: string;
  144181. };
  144182. }
  144183. declare module BABYLON {
  144184. /**
  144185. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  144186. */
  144187. export class StereoscopicInterlacePostProcessI extends PostProcess {
  144188. private _stepSize;
  144189. private _passedProcess;
  144190. /**
  144191. * Initializes a StereoscopicInterlacePostProcessI
  144192. * @param name The name of the effect.
  144193. * @param rigCameras The rig cameras to be appled to the post process
  144194. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  144195. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  144196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144197. * @param engine The engine which the post process will be applied. (default: current engine)
  144198. * @param reusable If the post process can be reused on the same frame. (default: false)
  144199. */
  144200. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144201. }
  144202. /**
  144203. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  144204. */
  144205. export class StereoscopicInterlacePostProcess extends PostProcess {
  144206. private _stepSize;
  144207. private _passedProcess;
  144208. /**
  144209. * Initializes a StereoscopicInterlacePostProcess
  144210. * @param name The name of the effect.
  144211. * @param rigCameras The rig cameras to be appled to the post process
  144212. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  144213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  144214. * @param engine The engine which the post process will be applied. (default: current engine)
  144215. * @param reusable If the post process can be reused on the same frame. (default: false)
  144216. */
  144217. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  144218. }
  144219. }
  144220. declare module BABYLON {
  144221. /** @hidden */
  144222. export var tonemapPixelShader: {
  144223. name: string;
  144224. shader: string;
  144225. };
  144226. }
  144227. declare module BABYLON {
  144228. /** Defines operator used for tonemapping */
  144229. export enum TonemappingOperator {
  144230. /** Hable */
  144231. Hable = 0,
  144232. /** Reinhard */
  144233. Reinhard = 1,
  144234. /** HejiDawson */
  144235. HejiDawson = 2,
  144236. /** Photographic */
  144237. Photographic = 3
  144238. }
  144239. /**
  144240. * Defines a post process to apply tone mapping
  144241. */
  144242. export class TonemapPostProcess extends PostProcess {
  144243. private _operator;
  144244. /** Defines the required exposure adjustement */
  144245. exposureAdjustment: number;
  144246. /**
  144247. * Creates a new TonemapPostProcess
  144248. * @param name defines the name of the postprocess
  144249. * @param _operator defines the operator to use
  144250. * @param exposureAdjustment defines the required exposure adjustement
  144251. * @param camera defines the camera to use (can be null)
  144252. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  144253. * @param engine defines the hosting engine (can be ignore if camera is set)
  144254. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144255. */
  144256. constructor(name: string, _operator: TonemappingOperator,
  144257. /** Defines the required exposure adjustement */
  144258. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  144259. }
  144260. }
  144261. declare module BABYLON {
  144262. /** @hidden */
  144263. export var volumetricLightScatteringPixelShader: {
  144264. name: string;
  144265. shader: string;
  144266. };
  144267. }
  144268. declare module BABYLON {
  144269. /** @hidden */
  144270. export var volumetricLightScatteringPassVertexShader: {
  144271. name: string;
  144272. shader: string;
  144273. };
  144274. }
  144275. declare module BABYLON {
  144276. /** @hidden */
  144277. export var volumetricLightScatteringPassPixelShader: {
  144278. name: string;
  144279. shader: string;
  144280. };
  144281. }
  144282. declare module BABYLON {
  144283. /**
  144284. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  144285. */
  144286. export class VolumetricLightScatteringPostProcess extends PostProcess {
  144287. private _volumetricLightScatteringPass;
  144288. private _volumetricLightScatteringRTT;
  144289. private _viewPort;
  144290. private _screenCoordinates;
  144291. private _cachedDefines;
  144292. /**
  144293. * If not undefined, the mesh position is computed from the attached node position
  144294. */
  144295. attachedNode: {
  144296. position: Vector3;
  144297. };
  144298. /**
  144299. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  144300. */
  144301. customMeshPosition: Vector3;
  144302. /**
  144303. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  144304. */
  144305. useCustomMeshPosition: boolean;
  144306. /**
  144307. * If the post-process should inverse the light scattering direction
  144308. */
  144309. invert: boolean;
  144310. /**
  144311. * The internal mesh used by the post-process
  144312. */
  144313. mesh: Mesh;
  144314. /**
  144315. * @hidden
  144316. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  144317. */
  144318. get useDiffuseColor(): boolean;
  144319. set useDiffuseColor(useDiffuseColor: boolean);
  144320. /**
  144321. * Array containing the excluded meshes not rendered in the internal pass
  144322. */
  144323. excludedMeshes: AbstractMesh[];
  144324. /**
  144325. * Controls the overall intensity of the post-process
  144326. */
  144327. exposure: number;
  144328. /**
  144329. * Dissipates each sample's contribution in range [0, 1]
  144330. */
  144331. decay: number;
  144332. /**
  144333. * Controls the overall intensity of each sample
  144334. */
  144335. weight: number;
  144336. /**
  144337. * Controls the density of each sample
  144338. */
  144339. density: number;
  144340. /**
  144341. * @constructor
  144342. * @param name The post-process name
  144343. * @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)
  144344. * @param camera The camera that the post-process will be attached to
  144345. * @param mesh The mesh used to create the light scattering
  144346. * @param samples The post-process quality, default 100
  144347. * @param samplingModeThe post-process filtering mode
  144348. * @param engine The babylon engine
  144349. * @param reusable If the post-process is reusable
  144350. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  144351. */
  144352. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  144353. /**
  144354. * Returns the string "VolumetricLightScatteringPostProcess"
  144355. * @returns "VolumetricLightScatteringPostProcess"
  144356. */
  144357. getClassName(): string;
  144358. private _isReady;
  144359. /**
  144360. * Sets the new light position for light scattering effect
  144361. * @param position The new custom light position
  144362. */
  144363. setCustomMeshPosition(position: Vector3): void;
  144364. /**
  144365. * Returns the light position for light scattering effect
  144366. * @return Vector3 The custom light position
  144367. */
  144368. getCustomMeshPosition(): Vector3;
  144369. /**
  144370. * Disposes the internal assets and detaches the post-process from the camera
  144371. */
  144372. dispose(camera: Camera): void;
  144373. /**
  144374. * Returns the render target texture used by the post-process
  144375. * @return the render target texture used by the post-process
  144376. */
  144377. getPass(): RenderTargetTexture;
  144378. private _meshExcluded;
  144379. private _createPass;
  144380. private _updateMeshScreenCoordinates;
  144381. /**
  144382. * Creates a default mesh for the Volumeric Light Scattering post-process
  144383. * @param name The mesh name
  144384. * @param scene The scene where to create the mesh
  144385. * @return the default mesh
  144386. */
  144387. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  144388. }
  144389. }
  144390. declare module BABYLON {
  144391. interface Scene {
  144392. /** @hidden (Backing field) */
  144393. _boundingBoxRenderer: BoundingBoxRenderer;
  144394. /** @hidden (Backing field) */
  144395. _forceShowBoundingBoxes: boolean;
  144396. /**
  144397. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  144398. */
  144399. forceShowBoundingBoxes: boolean;
  144400. /**
  144401. * Gets the bounding box renderer associated with the scene
  144402. * @returns a BoundingBoxRenderer
  144403. */
  144404. getBoundingBoxRenderer(): BoundingBoxRenderer;
  144405. }
  144406. interface AbstractMesh {
  144407. /** @hidden (Backing field) */
  144408. _showBoundingBox: boolean;
  144409. /**
  144410. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  144411. */
  144412. showBoundingBox: boolean;
  144413. }
  144414. /**
  144415. * Component responsible of rendering the bounding box of the meshes in a scene.
  144416. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  144417. */
  144418. export class BoundingBoxRenderer implements ISceneComponent {
  144419. /**
  144420. * The component name helpfull to identify the component in the list of scene components.
  144421. */
  144422. readonly name: string;
  144423. /**
  144424. * The scene the component belongs to.
  144425. */
  144426. scene: Scene;
  144427. /**
  144428. * Color of the bounding box lines placed in front of an object
  144429. */
  144430. frontColor: Color3;
  144431. /**
  144432. * Color of the bounding box lines placed behind an object
  144433. */
  144434. backColor: Color3;
  144435. /**
  144436. * Defines if the renderer should show the back lines or not
  144437. */
  144438. showBackLines: boolean;
  144439. /**
  144440. * @hidden
  144441. */
  144442. renderList: SmartArray<BoundingBox>;
  144443. private _colorShader;
  144444. private _vertexBuffers;
  144445. private _indexBuffer;
  144446. private _fillIndexBuffer;
  144447. private _fillIndexData;
  144448. /**
  144449. * Instantiates a new bounding box renderer in a scene.
  144450. * @param scene the scene the renderer renders in
  144451. */
  144452. constructor(scene: Scene);
  144453. /**
  144454. * Registers the component in a given scene
  144455. */
  144456. register(): void;
  144457. private _evaluateSubMesh;
  144458. private _activeMesh;
  144459. private _prepareRessources;
  144460. private _createIndexBuffer;
  144461. /**
  144462. * Rebuilds the elements related to this component in case of
  144463. * context lost for instance.
  144464. */
  144465. rebuild(): void;
  144466. /**
  144467. * @hidden
  144468. */
  144469. reset(): void;
  144470. /**
  144471. * Render the bounding boxes of a specific rendering group
  144472. * @param renderingGroupId defines the rendering group to render
  144473. */
  144474. render(renderingGroupId: number): void;
  144475. /**
  144476. * In case of occlusion queries, we can render the occlusion bounding box through this method
  144477. * @param mesh Define the mesh to render the occlusion bounding box for
  144478. */
  144479. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  144480. /**
  144481. * Dispose and release the resources attached to this renderer.
  144482. */
  144483. dispose(): void;
  144484. }
  144485. }
  144486. declare module BABYLON {
  144487. interface Scene {
  144488. /** @hidden (Backing field) */
  144489. _depthRenderer: {
  144490. [id: string]: DepthRenderer;
  144491. };
  144492. /**
  144493. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  144494. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  144495. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  144496. * @returns the created depth renderer
  144497. */
  144498. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  144499. /**
  144500. * Disables a depth renderer for a given camera
  144501. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  144502. */
  144503. disableDepthRenderer(camera?: Nullable<Camera>): void;
  144504. }
  144505. /**
  144506. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  144507. * in several rendering techniques.
  144508. */
  144509. export class DepthRendererSceneComponent implements ISceneComponent {
  144510. /**
  144511. * The component name helpfull to identify the component in the list of scene components.
  144512. */
  144513. readonly name: string;
  144514. /**
  144515. * The scene the component belongs to.
  144516. */
  144517. scene: Scene;
  144518. /**
  144519. * Creates a new instance of the component for the given scene
  144520. * @param scene Defines the scene to register the component in
  144521. */
  144522. constructor(scene: Scene);
  144523. /**
  144524. * Registers the component in a given scene
  144525. */
  144526. register(): void;
  144527. /**
  144528. * Rebuilds the elements related to this component in case of
  144529. * context lost for instance.
  144530. */
  144531. rebuild(): void;
  144532. /**
  144533. * Disposes the component and the associated ressources
  144534. */
  144535. dispose(): void;
  144536. private _gatherRenderTargets;
  144537. private _gatherActiveCameraRenderTargets;
  144538. }
  144539. }
  144540. declare module BABYLON {
  144541. /** @hidden */
  144542. export var outlinePixelShader: {
  144543. name: string;
  144544. shader: string;
  144545. };
  144546. }
  144547. declare module BABYLON {
  144548. /** @hidden */
  144549. export var outlineVertexShader: {
  144550. name: string;
  144551. shader: string;
  144552. };
  144553. }
  144554. declare module BABYLON {
  144555. interface Scene {
  144556. /** @hidden */
  144557. _outlineRenderer: OutlineRenderer;
  144558. /**
  144559. * Gets the outline renderer associated with the scene
  144560. * @returns a OutlineRenderer
  144561. */
  144562. getOutlineRenderer(): OutlineRenderer;
  144563. }
  144564. interface AbstractMesh {
  144565. /** @hidden (Backing field) */
  144566. _renderOutline: boolean;
  144567. /**
  144568. * Gets or sets a boolean indicating if the outline must be rendered as well
  144569. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  144570. */
  144571. renderOutline: boolean;
  144572. /** @hidden (Backing field) */
  144573. _renderOverlay: boolean;
  144574. /**
  144575. * Gets or sets a boolean indicating if the overlay must be rendered as well
  144576. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  144577. */
  144578. renderOverlay: boolean;
  144579. }
  144580. /**
  144581. * This class is responsible to draw bothe outline/overlay of meshes.
  144582. * It should not be used directly but through the available method on mesh.
  144583. */
  144584. export class OutlineRenderer implements ISceneComponent {
  144585. /**
  144586. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  144587. */
  144588. private static _StencilReference;
  144589. /**
  144590. * The name of the component. Each component must have a unique name.
  144591. */
  144592. name: string;
  144593. /**
  144594. * The scene the component belongs to.
  144595. */
  144596. scene: Scene;
  144597. /**
  144598. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  144599. */
  144600. zOffset: number;
  144601. private _engine;
  144602. private _effect;
  144603. private _cachedDefines;
  144604. private _savedDepthWrite;
  144605. /**
  144606. * Instantiates a new outline renderer. (There could be only one per scene).
  144607. * @param scene Defines the scene it belongs to
  144608. */
  144609. constructor(scene: Scene);
  144610. /**
  144611. * Register the component to one instance of a scene.
  144612. */
  144613. register(): void;
  144614. /**
  144615. * Rebuilds the elements related to this component in case of
  144616. * context lost for instance.
  144617. */
  144618. rebuild(): void;
  144619. /**
  144620. * Disposes the component and the associated ressources.
  144621. */
  144622. dispose(): void;
  144623. /**
  144624. * Renders the outline in the canvas.
  144625. * @param subMesh Defines the sumesh to render
  144626. * @param batch Defines the batch of meshes in case of instances
  144627. * @param useOverlay Defines if the rendering is for the overlay or the outline
  144628. */
  144629. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  144630. /**
  144631. * Returns whether or not the outline renderer is ready for a given submesh.
  144632. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  144633. * @param subMesh Defines the submesh to check readyness for
  144634. * @param useInstances Defines wheter wee are trying to render instances or not
  144635. * @returns true if ready otherwise false
  144636. */
  144637. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  144638. private _beforeRenderingMesh;
  144639. private _afterRenderingMesh;
  144640. }
  144641. }
  144642. declare module BABYLON {
  144643. /**
  144644. * Defines the basic options interface of a Sprite Frame Source Size.
  144645. */
  144646. export interface ISpriteJSONSpriteSourceSize {
  144647. /**
  144648. * number of the original width of the Frame
  144649. */
  144650. w: number;
  144651. /**
  144652. * number of the original height of the Frame
  144653. */
  144654. h: number;
  144655. }
  144656. /**
  144657. * Defines the basic options interface of a Sprite Frame Data.
  144658. */
  144659. export interface ISpriteJSONSpriteFrameData {
  144660. /**
  144661. * number of the x offset of the Frame
  144662. */
  144663. x: number;
  144664. /**
  144665. * number of the y offset of the Frame
  144666. */
  144667. y: number;
  144668. /**
  144669. * number of the width of the Frame
  144670. */
  144671. w: number;
  144672. /**
  144673. * number of the height of the Frame
  144674. */
  144675. h: number;
  144676. }
  144677. /**
  144678. * Defines the basic options interface of a JSON Sprite.
  144679. */
  144680. export interface ISpriteJSONSprite {
  144681. /**
  144682. * string name of the Frame
  144683. */
  144684. filename: string;
  144685. /**
  144686. * ISpriteJSONSpriteFrame basic object of the frame data
  144687. */
  144688. frame: ISpriteJSONSpriteFrameData;
  144689. /**
  144690. * boolean to flag is the frame was rotated.
  144691. */
  144692. rotated: boolean;
  144693. /**
  144694. * boolean to flag is the frame was trimmed.
  144695. */
  144696. trimmed: boolean;
  144697. /**
  144698. * ISpriteJSONSpriteFrame basic object of the source data
  144699. */
  144700. spriteSourceSize: ISpriteJSONSpriteFrameData;
  144701. /**
  144702. * ISpriteJSONSpriteFrame basic object of the source data
  144703. */
  144704. sourceSize: ISpriteJSONSpriteSourceSize;
  144705. }
  144706. /**
  144707. * Defines the basic options interface of a JSON atlas.
  144708. */
  144709. export interface ISpriteJSONAtlas {
  144710. /**
  144711. * Array of objects that contain the frame data.
  144712. */
  144713. frames: Array<ISpriteJSONSprite>;
  144714. /**
  144715. * object basic object containing the sprite meta data.
  144716. */
  144717. meta?: object;
  144718. }
  144719. }
  144720. declare module BABYLON {
  144721. /** @hidden */
  144722. export var spriteMapPixelShader: {
  144723. name: string;
  144724. shader: string;
  144725. };
  144726. }
  144727. declare module BABYLON {
  144728. /** @hidden */
  144729. export var spriteMapVertexShader: {
  144730. name: string;
  144731. shader: string;
  144732. };
  144733. }
  144734. declare module BABYLON {
  144735. /**
  144736. * Defines the basic options interface of a SpriteMap
  144737. */
  144738. export interface ISpriteMapOptions {
  144739. /**
  144740. * Vector2 of the number of cells in the grid.
  144741. */
  144742. stageSize?: Vector2;
  144743. /**
  144744. * Vector2 of the size of the output plane in World Units.
  144745. */
  144746. outputSize?: Vector2;
  144747. /**
  144748. * Vector3 of the position of the output plane in World Units.
  144749. */
  144750. outputPosition?: Vector3;
  144751. /**
  144752. * Vector3 of the rotation of the output plane.
  144753. */
  144754. outputRotation?: Vector3;
  144755. /**
  144756. * number of layers that the system will reserve in resources.
  144757. */
  144758. layerCount?: number;
  144759. /**
  144760. * number of max animation frames a single cell will reserve in resources.
  144761. */
  144762. maxAnimationFrames?: number;
  144763. /**
  144764. * number cell index of the base tile when the system compiles.
  144765. */
  144766. baseTile?: number;
  144767. /**
  144768. * boolean flip the sprite after its been repositioned by the framing data.
  144769. */
  144770. flipU?: boolean;
  144771. /**
  144772. * Vector3 scalar of the global RGB values of the SpriteMap.
  144773. */
  144774. colorMultiply?: Vector3;
  144775. }
  144776. /**
  144777. * Defines the IDisposable interface in order to be cleanable from resources.
  144778. */
  144779. export interface ISpriteMap extends IDisposable {
  144780. /**
  144781. * String name of the SpriteMap.
  144782. */
  144783. name: string;
  144784. /**
  144785. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  144786. */
  144787. atlasJSON: ISpriteJSONAtlas;
  144788. /**
  144789. * Texture of the SpriteMap.
  144790. */
  144791. spriteSheet: Texture;
  144792. /**
  144793. * The parameters to initialize the SpriteMap with.
  144794. */
  144795. options: ISpriteMapOptions;
  144796. }
  144797. /**
  144798. * Class used to manage a grid restricted sprite deployment on an Output plane.
  144799. */
  144800. export class SpriteMap implements ISpriteMap {
  144801. /** The Name of the spriteMap */
  144802. name: string;
  144803. /** The JSON file with the frame and meta data */
  144804. atlasJSON: ISpriteJSONAtlas;
  144805. /** The systems Sprite Sheet Texture */
  144806. spriteSheet: Texture;
  144807. /** Arguments passed with the Constructor */
  144808. options: ISpriteMapOptions;
  144809. /** Public Sprite Storage array, parsed from atlasJSON */
  144810. sprites: Array<ISpriteJSONSprite>;
  144811. /** Returns the Number of Sprites in the System */
  144812. get spriteCount(): number;
  144813. /** Returns the Position of Output Plane*/
  144814. get position(): Vector3;
  144815. /** Returns the Position of Output Plane*/
  144816. set position(v: Vector3);
  144817. /** Returns the Rotation of Output Plane*/
  144818. get rotation(): Vector3;
  144819. /** Returns the Rotation of Output Plane*/
  144820. set rotation(v: Vector3);
  144821. /** Sets the AnimationMap*/
  144822. get animationMap(): RawTexture;
  144823. /** Sets the AnimationMap*/
  144824. set animationMap(v: RawTexture);
  144825. /** Scene that the SpriteMap was created in */
  144826. private _scene;
  144827. /** Texture Buffer of Float32 that holds tile frame data*/
  144828. private _frameMap;
  144829. /** Texture Buffers of Float32 that holds tileMap data*/
  144830. private _tileMaps;
  144831. /** Texture Buffer of Float32 that holds Animation Data*/
  144832. private _animationMap;
  144833. /** Custom ShaderMaterial Central to the System*/
  144834. private _material;
  144835. /** Custom ShaderMaterial Central to the System*/
  144836. private _output;
  144837. /** Systems Time Ticker*/
  144838. private _time;
  144839. /**
  144840. * Creates a new SpriteMap
  144841. * @param name defines the SpriteMaps Name
  144842. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  144843. * @param spriteSheet is the Texture that the Sprites are on.
  144844. * @param options a basic deployment configuration
  144845. * @param scene The Scene that the map is deployed on
  144846. */
  144847. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  144848. /**
  144849. * Returns tileID location
  144850. * @returns Vector2 the cell position ID
  144851. */
  144852. getTileID(): Vector2;
  144853. /**
  144854. * Gets the UV location of the mouse over the SpriteMap.
  144855. * @returns Vector2 the UV position of the mouse interaction
  144856. */
  144857. getMousePosition(): Vector2;
  144858. /**
  144859. * Creates the "frame" texture Buffer
  144860. * -------------------------------------
  144861. * Structure of frames
  144862. * "filename": "Falling-Water-2.png",
  144863. * "frame": {"x":69,"y":103,"w":24,"h":32},
  144864. * "rotated": true,
  144865. * "trimmed": true,
  144866. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  144867. * "sourceSize": {"w":32,"h":32}
  144868. * @returns RawTexture of the frameMap
  144869. */
  144870. private _createFrameBuffer;
  144871. /**
  144872. * Creates the tileMap texture Buffer
  144873. * @param buffer normally and array of numbers, or a false to generate from scratch
  144874. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  144875. * @returns RawTexture of the tileMap
  144876. */
  144877. private _createTileBuffer;
  144878. /**
  144879. * Modifies the data of the tileMaps
  144880. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  144881. * @param pos is the iVector2 Coordinates of the Tile
  144882. * @param tile The SpriteIndex of the new Tile
  144883. */
  144884. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  144885. /**
  144886. * Creates the animationMap texture Buffer
  144887. * @param buffer normally and array of numbers, or a false to generate from scratch
  144888. * @returns RawTexture of the animationMap
  144889. */
  144890. private _createTileAnimationBuffer;
  144891. /**
  144892. * Modifies the data of the animationMap
  144893. * @param cellID is the Index of the Sprite
  144894. * @param _frame is the target Animation frame
  144895. * @param toCell is the Target Index of the next frame of the animation
  144896. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  144897. * @param speed is a global scalar of the time variable on the map.
  144898. */
  144899. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  144900. /**
  144901. * Exports the .tilemaps file
  144902. */
  144903. saveTileMaps(): void;
  144904. /**
  144905. * Imports the .tilemaps file
  144906. * @param url of the .tilemaps file
  144907. */
  144908. loadTileMaps(url: string): void;
  144909. /**
  144910. * Release associated resources
  144911. */
  144912. dispose(): void;
  144913. }
  144914. }
  144915. declare module BABYLON {
  144916. /**
  144917. * Class used to manage multiple sprites of different sizes on the same spritesheet
  144918. * @see http://doc.babylonjs.com/babylon101/sprites
  144919. */
  144920. export class SpritePackedManager extends SpriteManager {
  144921. /** defines the packed manager's name */
  144922. name: string;
  144923. /**
  144924. * Creates a new sprite manager from a packed sprite sheet
  144925. * @param name defines the manager's name
  144926. * @param imgUrl defines the sprite sheet url
  144927. * @param capacity defines the maximum allowed number of sprites
  144928. * @param scene defines the hosting scene
  144929. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  144930. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  144931. * @param samplingMode defines the smapling mode to use with spritesheet
  144932. * @param fromPacked set to true; do not alter
  144933. */
  144934. constructor(
  144935. /** defines the packed manager's name */
  144936. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  144937. }
  144938. }
  144939. declare module BABYLON {
  144940. /**
  144941. * Defines the list of states available for a task inside a AssetsManager
  144942. */
  144943. export enum AssetTaskState {
  144944. /**
  144945. * Initialization
  144946. */
  144947. INIT = 0,
  144948. /**
  144949. * Running
  144950. */
  144951. RUNNING = 1,
  144952. /**
  144953. * Done
  144954. */
  144955. DONE = 2,
  144956. /**
  144957. * Error
  144958. */
  144959. ERROR = 3
  144960. }
  144961. /**
  144962. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  144963. */
  144964. export abstract class AbstractAssetTask {
  144965. /**
  144966. * Task name
  144967. */ name: string;
  144968. /**
  144969. * Callback called when the task is successful
  144970. */
  144971. onSuccess: (task: any) => void;
  144972. /**
  144973. * Callback called when the task is not successful
  144974. */
  144975. onError: (task: any, message?: string, exception?: any) => void;
  144976. /**
  144977. * Creates a new AssetsManager
  144978. * @param name defines the name of the task
  144979. */
  144980. constructor(
  144981. /**
  144982. * Task name
  144983. */ name: string);
  144984. private _isCompleted;
  144985. private _taskState;
  144986. private _errorObject;
  144987. /**
  144988. * Get if the task is completed
  144989. */
  144990. get isCompleted(): boolean;
  144991. /**
  144992. * Gets the current state of the task
  144993. */
  144994. get taskState(): AssetTaskState;
  144995. /**
  144996. * Gets the current error object (if task is in error)
  144997. */
  144998. get errorObject(): {
  144999. message?: string;
  145000. exception?: any;
  145001. };
  145002. /**
  145003. * Internal only
  145004. * @hidden
  145005. */
  145006. _setErrorObject(message?: string, exception?: any): void;
  145007. /**
  145008. * Execute the current task
  145009. * @param scene defines the scene where you want your assets to be loaded
  145010. * @param onSuccess is a callback called when the task is successfully executed
  145011. * @param onError is a callback called if an error occurs
  145012. */
  145013. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145014. /**
  145015. * Execute the current task
  145016. * @param scene defines the scene where you want your assets to be loaded
  145017. * @param onSuccess is a callback called when the task is successfully executed
  145018. * @param onError is a callback called if an error occurs
  145019. */
  145020. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145021. /**
  145022. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  145023. * This can be used with failed tasks that have the reason for failure fixed.
  145024. */
  145025. reset(): void;
  145026. private onErrorCallback;
  145027. private onDoneCallback;
  145028. }
  145029. /**
  145030. * Define the interface used by progress events raised during assets loading
  145031. */
  145032. export interface IAssetsProgressEvent {
  145033. /**
  145034. * Defines the number of remaining tasks to process
  145035. */
  145036. remainingCount: number;
  145037. /**
  145038. * Defines the total number of tasks
  145039. */
  145040. totalCount: number;
  145041. /**
  145042. * Defines the task that was just processed
  145043. */
  145044. task: AbstractAssetTask;
  145045. }
  145046. /**
  145047. * Class used to share progress information about assets loading
  145048. */
  145049. export class AssetsProgressEvent implements IAssetsProgressEvent {
  145050. /**
  145051. * Defines the number of remaining tasks to process
  145052. */
  145053. remainingCount: number;
  145054. /**
  145055. * Defines the total number of tasks
  145056. */
  145057. totalCount: number;
  145058. /**
  145059. * Defines the task that was just processed
  145060. */
  145061. task: AbstractAssetTask;
  145062. /**
  145063. * Creates a AssetsProgressEvent
  145064. * @param remainingCount defines the number of remaining tasks to process
  145065. * @param totalCount defines the total number of tasks
  145066. * @param task defines the task that was just processed
  145067. */
  145068. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  145069. }
  145070. /**
  145071. * Define a task used by AssetsManager to load meshes
  145072. */
  145073. export class MeshAssetTask extends AbstractAssetTask {
  145074. /**
  145075. * Defines the name of the task
  145076. */
  145077. name: string;
  145078. /**
  145079. * Defines the list of mesh's names you want to load
  145080. */
  145081. meshesNames: any;
  145082. /**
  145083. * Defines the root url to use as a base to load your meshes and associated resources
  145084. */
  145085. rootUrl: string;
  145086. /**
  145087. * Defines the filename or File of the scene to load from
  145088. */
  145089. sceneFilename: string | File;
  145090. /**
  145091. * Gets the list of loaded meshes
  145092. */
  145093. loadedMeshes: Array<AbstractMesh>;
  145094. /**
  145095. * Gets the list of loaded particle systems
  145096. */
  145097. loadedParticleSystems: Array<IParticleSystem>;
  145098. /**
  145099. * Gets the list of loaded skeletons
  145100. */
  145101. loadedSkeletons: Array<Skeleton>;
  145102. /**
  145103. * Gets the list of loaded animation groups
  145104. */
  145105. loadedAnimationGroups: Array<AnimationGroup>;
  145106. /**
  145107. * Callback called when the task is successful
  145108. */
  145109. onSuccess: (task: MeshAssetTask) => void;
  145110. /**
  145111. * Callback called when the task is successful
  145112. */
  145113. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  145114. /**
  145115. * Creates a new MeshAssetTask
  145116. * @param name defines the name of the task
  145117. * @param meshesNames defines the list of mesh's names you want to load
  145118. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  145119. * @param sceneFilename defines the filename or File of the scene to load from
  145120. */
  145121. constructor(
  145122. /**
  145123. * Defines the name of the task
  145124. */
  145125. name: string,
  145126. /**
  145127. * Defines the list of mesh's names you want to load
  145128. */
  145129. meshesNames: any,
  145130. /**
  145131. * Defines the root url to use as a base to load your meshes and associated resources
  145132. */
  145133. rootUrl: string,
  145134. /**
  145135. * Defines the filename or File of the scene to load from
  145136. */
  145137. sceneFilename: string | File);
  145138. /**
  145139. * Execute the current task
  145140. * @param scene defines the scene where you want your assets to be loaded
  145141. * @param onSuccess is a callback called when the task is successfully executed
  145142. * @param onError is a callback called if an error occurs
  145143. */
  145144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145145. }
  145146. /**
  145147. * Define a task used by AssetsManager to load text content
  145148. */
  145149. export class TextFileAssetTask extends AbstractAssetTask {
  145150. /**
  145151. * Defines the name of the task
  145152. */
  145153. name: string;
  145154. /**
  145155. * Defines the location of the file to load
  145156. */
  145157. url: string;
  145158. /**
  145159. * Gets the loaded text string
  145160. */
  145161. text: string;
  145162. /**
  145163. * Callback called when the task is successful
  145164. */
  145165. onSuccess: (task: TextFileAssetTask) => void;
  145166. /**
  145167. * Callback called when the task is successful
  145168. */
  145169. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  145170. /**
  145171. * Creates a new TextFileAssetTask object
  145172. * @param name defines the name of the task
  145173. * @param url defines the location of the file to load
  145174. */
  145175. constructor(
  145176. /**
  145177. * Defines the name of the task
  145178. */
  145179. name: string,
  145180. /**
  145181. * Defines the location of the file to load
  145182. */
  145183. url: string);
  145184. /**
  145185. * Execute the current task
  145186. * @param scene defines the scene where you want your assets to be loaded
  145187. * @param onSuccess is a callback called when the task is successfully executed
  145188. * @param onError is a callback called if an error occurs
  145189. */
  145190. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145191. }
  145192. /**
  145193. * Define a task used by AssetsManager to load binary data
  145194. */
  145195. export class BinaryFileAssetTask extends AbstractAssetTask {
  145196. /**
  145197. * Defines the name of the task
  145198. */
  145199. name: string;
  145200. /**
  145201. * Defines the location of the file to load
  145202. */
  145203. url: string;
  145204. /**
  145205. * Gets the lodaded data (as an array buffer)
  145206. */
  145207. data: ArrayBuffer;
  145208. /**
  145209. * Callback called when the task is successful
  145210. */
  145211. onSuccess: (task: BinaryFileAssetTask) => void;
  145212. /**
  145213. * Callback called when the task is successful
  145214. */
  145215. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  145216. /**
  145217. * Creates a new BinaryFileAssetTask object
  145218. * @param name defines the name of the new task
  145219. * @param url defines the location of the file to load
  145220. */
  145221. constructor(
  145222. /**
  145223. * Defines the name of the task
  145224. */
  145225. name: string,
  145226. /**
  145227. * Defines the location of the file to load
  145228. */
  145229. url: string);
  145230. /**
  145231. * Execute the current task
  145232. * @param scene defines the scene where you want your assets to be loaded
  145233. * @param onSuccess is a callback called when the task is successfully executed
  145234. * @param onError is a callback called if an error occurs
  145235. */
  145236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145237. }
  145238. /**
  145239. * Define a task used by AssetsManager to load images
  145240. */
  145241. export class ImageAssetTask extends AbstractAssetTask {
  145242. /**
  145243. * Defines the name of the task
  145244. */
  145245. name: string;
  145246. /**
  145247. * Defines the location of the image to load
  145248. */
  145249. url: string;
  145250. /**
  145251. * Gets the loaded images
  145252. */
  145253. image: HTMLImageElement;
  145254. /**
  145255. * Callback called when the task is successful
  145256. */
  145257. onSuccess: (task: ImageAssetTask) => void;
  145258. /**
  145259. * Callback called when the task is successful
  145260. */
  145261. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  145262. /**
  145263. * Creates a new ImageAssetTask
  145264. * @param name defines the name of the task
  145265. * @param url defines the location of the image to load
  145266. */
  145267. constructor(
  145268. /**
  145269. * Defines the name of the task
  145270. */
  145271. name: string,
  145272. /**
  145273. * Defines the location of the image to load
  145274. */
  145275. url: string);
  145276. /**
  145277. * Execute the current task
  145278. * @param scene defines the scene where you want your assets to be loaded
  145279. * @param onSuccess is a callback called when the task is successfully executed
  145280. * @param onError is a callback called if an error occurs
  145281. */
  145282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145283. }
  145284. /**
  145285. * Defines the interface used by texture loading tasks
  145286. */
  145287. export interface ITextureAssetTask<TEX extends BaseTexture> {
  145288. /**
  145289. * Gets the loaded texture
  145290. */
  145291. texture: TEX;
  145292. }
  145293. /**
  145294. * Define a task used by AssetsManager to load 2D textures
  145295. */
  145296. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  145297. /**
  145298. * Defines the name of the task
  145299. */
  145300. name: string;
  145301. /**
  145302. * Defines the location of the file to load
  145303. */
  145304. url: string;
  145305. /**
  145306. * Defines if mipmap should not be generated (default is false)
  145307. */
  145308. noMipmap?: boolean | undefined;
  145309. /**
  145310. * Defines if texture must be inverted on Y axis (default is true)
  145311. */
  145312. invertY: boolean;
  145313. /**
  145314. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145315. */
  145316. samplingMode: number;
  145317. /**
  145318. * Gets the loaded texture
  145319. */
  145320. texture: Texture;
  145321. /**
  145322. * Callback called when the task is successful
  145323. */
  145324. onSuccess: (task: TextureAssetTask) => void;
  145325. /**
  145326. * Callback called when the task is successful
  145327. */
  145328. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  145329. /**
  145330. * Creates a new TextureAssetTask object
  145331. * @param name defines the name of the task
  145332. * @param url defines the location of the file to load
  145333. * @param noMipmap defines if mipmap should not be generated (default is false)
  145334. * @param invertY defines if texture must be inverted on Y axis (default is true)
  145335. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145336. */
  145337. constructor(
  145338. /**
  145339. * Defines the name of the task
  145340. */
  145341. name: string,
  145342. /**
  145343. * Defines the location of the file to load
  145344. */
  145345. url: string,
  145346. /**
  145347. * Defines if mipmap should not be generated (default is false)
  145348. */
  145349. noMipmap?: boolean | undefined,
  145350. /**
  145351. * Defines if texture must be inverted on Y axis (default is true)
  145352. */
  145353. invertY?: boolean,
  145354. /**
  145355. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  145356. */
  145357. samplingMode?: number);
  145358. /**
  145359. * Execute the current task
  145360. * @param scene defines the scene where you want your assets to be loaded
  145361. * @param onSuccess is a callback called when the task is successfully executed
  145362. * @param onError is a callback called if an error occurs
  145363. */
  145364. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145365. }
  145366. /**
  145367. * Define a task used by AssetsManager to load cube textures
  145368. */
  145369. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  145370. /**
  145371. * Defines the name of the task
  145372. */
  145373. name: string;
  145374. /**
  145375. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145376. */
  145377. url: string;
  145378. /**
  145379. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145380. */
  145381. extensions?: string[] | undefined;
  145382. /**
  145383. * Defines if mipmaps should not be generated (default is false)
  145384. */
  145385. noMipmap?: boolean | undefined;
  145386. /**
  145387. * Defines the explicit list of files (undefined by default)
  145388. */
  145389. files?: string[] | undefined;
  145390. /**
  145391. * Gets the loaded texture
  145392. */
  145393. texture: CubeTexture;
  145394. /**
  145395. * Callback called when the task is successful
  145396. */
  145397. onSuccess: (task: CubeTextureAssetTask) => void;
  145398. /**
  145399. * Callback called when the task is successful
  145400. */
  145401. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  145402. /**
  145403. * Creates a new CubeTextureAssetTask
  145404. * @param name defines the name of the task
  145405. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145406. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145407. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145408. * @param files defines the explicit list of files (undefined by default)
  145409. */
  145410. constructor(
  145411. /**
  145412. * Defines the name of the task
  145413. */
  145414. name: string,
  145415. /**
  145416. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  145417. */
  145418. url: string,
  145419. /**
  145420. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  145421. */
  145422. extensions?: string[] | undefined,
  145423. /**
  145424. * Defines if mipmaps should not be generated (default is false)
  145425. */
  145426. noMipmap?: boolean | undefined,
  145427. /**
  145428. * Defines the explicit list of files (undefined by default)
  145429. */
  145430. files?: string[] | undefined);
  145431. /**
  145432. * Execute the current task
  145433. * @param scene defines the scene where you want your assets to be loaded
  145434. * @param onSuccess is a callback called when the task is successfully executed
  145435. * @param onError is a callback called if an error occurs
  145436. */
  145437. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145438. }
  145439. /**
  145440. * Define a task used by AssetsManager to load HDR cube textures
  145441. */
  145442. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  145443. /**
  145444. * Defines the name of the task
  145445. */
  145446. name: string;
  145447. /**
  145448. * Defines the location of the file to load
  145449. */
  145450. url: string;
  145451. /**
  145452. * Defines the desired size (the more it increases the longer the generation will be)
  145453. */
  145454. size: number;
  145455. /**
  145456. * Defines if mipmaps should not be generated (default is false)
  145457. */
  145458. noMipmap: boolean;
  145459. /**
  145460. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145461. */
  145462. generateHarmonics: boolean;
  145463. /**
  145464. * 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)
  145465. */
  145466. gammaSpace: boolean;
  145467. /**
  145468. * Internal Use Only
  145469. */
  145470. reserved: boolean;
  145471. /**
  145472. * Gets the loaded texture
  145473. */
  145474. texture: HDRCubeTexture;
  145475. /**
  145476. * Callback called when the task is successful
  145477. */
  145478. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  145479. /**
  145480. * Callback called when the task is successful
  145481. */
  145482. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  145483. /**
  145484. * Creates a new HDRCubeTextureAssetTask object
  145485. * @param name defines the name of the task
  145486. * @param url defines the location of the file to load
  145487. * @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.
  145488. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145489. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145490. * @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)
  145491. * @param reserved Internal use only
  145492. */
  145493. constructor(
  145494. /**
  145495. * Defines the name of the task
  145496. */
  145497. name: string,
  145498. /**
  145499. * Defines the location of the file to load
  145500. */
  145501. url: string,
  145502. /**
  145503. * Defines the desired size (the more it increases the longer the generation will be)
  145504. */
  145505. size: number,
  145506. /**
  145507. * Defines if mipmaps should not be generated (default is false)
  145508. */
  145509. noMipmap?: boolean,
  145510. /**
  145511. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  145512. */
  145513. generateHarmonics?: boolean,
  145514. /**
  145515. * 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)
  145516. */
  145517. gammaSpace?: boolean,
  145518. /**
  145519. * Internal Use Only
  145520. */
  145521. reserved?: boolean);
  145522. /**
  145523. * Execute the current task
  145524. * @param scene defines the scene where you want your assets to be loaded
  145525. * @param onSuccess is a callback called when the task is successfully executed
  145526. * @param onError is a callback called if an error occurs
  145527. */
  145528. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145529. }
  145530. /**
  145531. * Define a task used by AssetsManager to load Equirectangular cube textures
  145532. */
  145533. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  145534. /**
  145535. * Defines the name of the task
  145536. */
  145537. name: string;
  145538. /**
  145539. * Defines the location of the file to load
  145540. */
  145541. url: string;
  145542. /**
  145543. * Defines the desired size (the more it increases the longer the generation will be)
  145544. */
  145545. size: number;
  145546. /**
  145547. * Defines if mipmaps should not be generated (default is false)
  145548. */
  145549. noMipmap: boolean;
  145550. /**
  145551. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145552. * but the standard material would require them in Gamma space) (default is true)
  145553. */
  145554. gammaSpace: boolean;
  145555. /**
  145556. * Gets the loaded texture
  145557. */
  145558. texture: EquiRectangularCubeTexture;
  145559. /**
  145560. * Callback called when the task is successful
  145561. */
  145562. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  145563. /**
  145564. * Callback called when the task is successful
  145565. */
  145566. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  145567. /**
  145568. * Creates a new EquiRectangularCubeTextureAssetTask object
  145569. * @param name defines the name of the task
  145570. * @param url defines the location of the file to load
  145571. * @param size defines the desired size (the more it increases the longer the generation will be)
  145572. * If the size is omitted this implies you are using a preprocessed cubemap.
  145573. * @param noMipmap defines if mipmaps should not be generated (default is false)
  145574. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  145575. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  145576. * (default is true)
  145577. */
  145578. constructor(
  145579. /**
  145580. * Defines the name of the task
  145581. */
  145582. name: string,
  145583. /**
  145584. * Defines the location of the file to load
  145585. */
  145586. url: string,
  145587. /**
  145588. * Defines the desired size (the more it increases the longer the generation will be)
  145589. */
  145590. size: number,
  145591. /**
  145592. * Defines if mipmaps should not be generated (default is false)
  145593. */
  145594. noMipmap?: boolean,
  145595. /**
  145596. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  145597. * but the standard material would require them in Gamma space) (default is true)
  145598. */
  145599. gammaSpace?: boolean);
  145600. /**
  145601. * Execute the current task
  145602. * @param scene defines the scene where you want your assets to be loaded
  145603. * @param onSuccess is a callback called when the task is successfully executed
  145604. * @param onError is a callback called if an error occurs
  145605. */
  145606. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  145607. }
  145608. /**
  145609. * This class can be used to easily import assets into a scene
  145610. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  145611. */
  145612. export class AssetsManager {
  145613. private _scene;
  145614. private _isLoading;
  145615. protected _tasks: AbstractAssetTask[];
  145616. protected _waitingTasksCount: number;
  145617. protected _totalTasksCount: number;
  145618. /**
  145619. * Callback called when all tasks are processed
  145620. */
  145621. onFinish: (tasks: AbstractAssetTask[]) => void;
  145622. /**
  145623. * Callback called when a task is successful
  145624. */
  145625. onTaskSuccess: (task: AbstractAssetTask) => void;
  145626. /**
  145627. * Callback called when a task had an error
  145628. */
  145629. onTaskError: (task: AbstractAssetTask) => void;
  145630. /**
  145631. * Callback called when a task is done (whatever the result is)
  145632. */
  145633. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  145634. /**
  145635. * Observable called when all tasks are processed
  145636. */
  145637. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  145638. /**
  145639. * Observable called when a task had an error
  145640. */
  145641. onTaskErrorObservable: Observable<AbstractAssetTask>;
  145642. /**
  145643. * Observable called when all tasks were executed
  145644. */
  145645. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  145646. /**
  145647. * Observable called when a task is done (whatever the result is)
  145648. */
  145649. onProgressObservable: Observable<IAssetsProgressEvent>;
  145650. /**
  145651. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  145652. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  145653. */
  145654. useDefaultLoadingScreen: boolean;
  145655. /**
  145656. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  145657. * when all assets have been downloaded.
  145658. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  145659. */
  145660. autoHideLoadingUI: boolean;
  145661. /**
  145662. * Creates a new AssetsManager
  145663. * @param scene defines the scene to work on
  145664. */
  145665. constructor(scene: Scene);
  145666. /**
  145667. * Add a MeshAssetTask to the list of active tasks
  145668. * @param taskName defines the name of the new task
  145669. * @param meshesNames defines the name of meshes to load
  145670. * @param rootUrl defines the root url to use to locate files
  145671. * @param sceneFilename defines the filename of the scene file
  145672. * @returns a new MeshAssetTask object
  145673. */
  145674. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  145675. /**
  145676. * Add a TextFileAssetTask to the list of active tasks
  145677. * @param taskName defines the name of the new task
  145678. * @param url defines the url of the file to load
  145679. * @returns a new TextFileAssetTask object
  145680. */
  145681. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  145682. /**
  145683. * Add a BinaryFileAssetTask to the list of active tasks
  145684. * @param taskName defines the name of the new task
  145685. * @param url defines the url of the file to load
  145686. * @returns a new BinaryFileAssetTask object
  145687. */
  145688. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  145689. /**
  145690. * Add a ImageAssetTask to the list of active tasks
  145691. * @param taskName defines the name of the new task
  145692. * @param url defines the url of the file to load
  145693. * @returns a new ImageAssetTask object
  145694. */
  145695. addImageTask(taskName: string, url: string): ImageAssetTask;
  145696. /**
  145697. * Add a TextureAssetTask to the list of active tasks
  145698. * @param taskName defines the name of the new task
  145699. * @param url defines the url of the file to load
  145700. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145701. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  145702. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145703. * @returns a new TextureAssetTask object
  145704. */
  145705. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  145706. /**
  145707. * Add a CubeTextureAssetTask to the list of active tasks
  145708. * @param taskName defines the name of the new task
  145709. * @param url defines the url of the file to load
  145710. * @param extensions defines the extension to use to load the cube map (can be null)
  145711. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145712. * @param files defines the list of files to load (can be null)
  145713. * @returns a new CubeTextureAssetTask object
  145714. */
  145715. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  145716. /**
  145717. *
  145718. * Add a HDRCubeTextureAssetTask to the list of active tasks
  145719. * @param taskName defines the name of the new task
  145720. * @param url defines the url of the file to load
  145721. * @param size defines the size you want for the cubemap (can be null)
  145722. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145723. * @param generateHarmonics defines if you want to automatically generate (true by default)
  145724. * @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)
  145725. * @param reserved Internal use only
  145726. * @returns a new HDRCubeTextureAssetTask object
  145727. */
  145728. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  145729. /**
  145730. *
  145731. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  145732. * @param taskName defines the name of the new task
  145733. * @param url defines the url of the file to load
  145734. * @param size defines the size you want for the cubemap (can be null)
  145735. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  145736. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  145737. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  145738. * @returns a new EquiRectangularCubeTextureAssetTask object
  145739. */
  145740. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  145741. /**
  145742. * Remove a task from the assets manager.
  145743. * @param task the task to remove
  145744. */
  145745. removeTask(task: AbstractAssetTask): void;
  145746. private _decreaseWaitingTasksCount;
  145747. private _runTask;
  145748. /**
  145749. * Reset the AssetsManager and remove all tasks
  145750. * @return the current instance of the AssetsManager
  145751. */
  145752. reset(): AssetsManager;
  145753. /**
  145754. * Start the loading process
  145755. * @return the current instance of the AssetsManager
  145756. */
  145757. load(): AssetsManager;
  145758. /**
  145759. * Start the loading process as an async operation
  145760. * @return a promise returning the list of failed tasks
  145761. */
  145762. loadAsync(): Promise<void>;
  145763. }
  145764. }
  145765. declare module BABYLON {
  145766. /**
  145767. * Wrapper class for promise with external resolve and reject.
  145768. */
  145769. export class Deferred<T> {
  145770. /**
  145771. * The promise associated with this deferred object.
  145772. */
  145773. readonly promise: Promise<T>;
  145774. private _resolve;
  145775. private _reject;
  145776. /**
  145777. * The resolve method of the promise associated with this deferred object.
  145778. */
  145779. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  145780. /**
  145781. * The reject method of the promise associated with this deferred object.
  145782. */
  145783. get reject(): (reason?: any) => void;
  145784. /**
  145785. * Constructor for this deferred object.
  145786. */
  145787. constructor();
  145788. }
  145789. }
  145790. declare module BABYLON {
  145791. /**
  145792. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  145793. */
  145794. export class MeshExploder {
  145795. private _centerMesh;
  145796. private _meshes;
  145797. private _meshesOrigins;
  145798. private _toCenterVectors;
  145799. private _scaledDirection;
  145800. private _newPosition;
  145801. private _centerPosition;
  145802. /**
  145803. * Explodes meshes from a center mesh.
  145804. * @param meshes The meshes to explode.
  145805. * @param centerMesh The mesh to be center of explosion.
  145806. */
  145807. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  145808. private _setCenterMesh;
  145809. /**
  145810. * Get class name
  145811. * @returns "MeshExploder"
  145812. */
  145813. getClassName(): string;
  145814. /**
  145815. * "Exploded meshes"
  145816. * @returns Array of meshes with the centerMesh at index 0.
  145817. */
  145818. getMeshes(): Array<Mesh>;
  145819. /**
  145820. * Explodes meshes giving a specific direction
  145821. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  145822. */
  145823. explode(direction?: number): void;
  145824. }
  145825. }
  145826. declare module BABYLON {
  145827. /**
  145828. * Class used to help managing file picking and drag'n'drop
  145829. */
  145830. export class FilesInput {
  145831. /**
  145832. * List of files ready to be loaded
  145833. */
  145834. static get FilesToLoad(): {
  145835. [key: string]: File;
  145836. };
  145837. /**
  145838. * Callback called when a file is processed
  145839. */
  145840. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  145841. private _engine;
  145842. private _currentScene;
  145843. private _sceneLoadedCallback;
  145844. private _progressCallback;
  145845. private _additionalRenderLoopLogicCallback;
  145846. private _textureLoadingCallback;
  145847. private _startingProcessingFilesCallback;
  145848. private _onReloadCallback;
  145849. private _errorCallback;
  145850. private _elementToMonitor;
  145851. private _sceneFileToLoad;
  145852. private _filesToLoad;
  145853. /**
  145854. * Creates a new FilesInput
  145855. * @param engine defines the rendering engine
  145856. * @param scene defines the hosting scene
  145857. * @param sceneLoadedCallback callback called when scene is loaded
  145858. * @param progressCallback callback called to track progress
  145859. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  145860. * @param textureLoadingCallback callback called when a texture is loading
  145861. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  145862. * @param onReloadCallback callback called when a reload is requested
  145863. * @param errorCallback callback call if an error occurs
  145864. */
  145865. 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);
  145866. private _dragEnterHandler;
  145867. private _dragOverHandler;
  145868. private _dropHandler;
  145869. /**
  145870. * Calls this function to listen to drag'n'drop events on a specific DOM element
  145871. * @param elementToMonitor defines the DOM element to track
  145872. */
  145873. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  145874. /**
  145875. * Release all associated resources
  145876. */
  145877. dispose(): void;
  145878. private renderFunction;
  145879. private drag;
  145880. private drop;
  145881. private _traverseFolder;
  145882. private _processFiles;
  145883. /**
  145884. * Load files from a drop event
  145885. * @param event defines the drop event to use as source
  145886. */
  145887. loadFiles(event: any): void;
  145888. private _processReload;
  145889. /**
  145890. * Reload the current scene from the loaded files
  145891. */
  145892. reload(): void;
  145893. }
  145894. }
  145895. declare module BABYLON {
  145896. /**
  145897. * Defines the root class used to create scene optimization to use with SceneOptimizer
  145898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145899. */
  145900. export class SceneOptimization {
  145901. /**
  145902. * Defines the priority of this optimization (0 by default which means first in the list)
  145903. */
  145904. priority: number;
  145905. /**
  145906. * Gets a string describing the action executed by the current optimization
  145907. * @returns description string
  145908. */
  145909. getDescription(): string;
  145910. /**
  145911. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145912. * @param scene defines the current scene where to apply this optimization
  145913. * @param optimizer defines the current optimizer
  145914. * @returns true if everything that can be done was applied
  145915. */
  145916. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145917. /**
  145918. * Creates the SceneOptimization object
  145919. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  145920. * @param desc defines the description associated with the optimization
  145921. */
  145922. constructor(
  145923. /**
  145924. * Defines the priority of this optimization (0 by default which means first in the list)
  145925. */
  145926. priority?: number);
  145927. }
  145928. /**
  145929. * Defines an optimization used to reduce the size of render target textures
  145930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145931. */
  145932. export class TextureOptimization extends SceneOptimization {
  145933. /**
  145934. * Defines the priority of this optimization (0 by default which means first in the list)
  145935. */
  145936. priority: number;
  145937. /**
  145938. * 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
  145939. */
  145940. maximumSize: number;
  145941. /**
  145942. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  145943. */
  145944. step: number;
  145945. /**
  145946. * Gets a string describing the action executed by the current optimization
  145947. * @returns description string
  145948. */
  145949. getDescription(): string;
  145950. /**
  145951. * Creates the TextureOptimization object
  145952. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  145953. * @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
  145954. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  145955. */
  145956. constructor(
  145957. /**
  145958. * Defines the priority of this optimization (0 by default which means first in the list)
  145959. */
  145960. priority?: number,
  145961. /**
  145962. * 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
  145963. */
  145964. maximumSize?: number,
  145965. /**
  145966. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  145967. */
  145968. step?: number);
  145969. /**
  145970. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  145971. * @param scene defines the current scene where to apply this optimization
  145972. * @param optimizer defines the current optimizer
  145973. * @returns true if everything that can be done was applied
  145974. */
  145975. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  145976. }
  145977. /**
  145978. * Defines an optimization used to increase or decrease the rendering resolution
  145979. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  145980. */
  145981. export class HardwareScalingOptimization extends SceneOptimization {
  145982. /**
  145983. * Defines the priority of this optimization (0 by default which means first in the list)
  145984. */
  145985. priority: number;
  145986. /**
  145987. * Defines the maximum scale to use (2 by default)
  145988. */
  145989. maximumScale: number;
  145990. /**
  145991. * Defines the step to use between two passes (0.5 by default)
  145992. */
  145993. step: number;
  145994. private _currentScale;
  145995. private _directionOffset;
  145996. /**
  145997. * Gets a string describing the action executed by the current optimization
  145998. * @return description string
  145999. */
  146000. getDescription(): string;
  146001. /**
  146002. * Creates the HardwareScalingOptimization object
  146003. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146004. * @param maximumScale defines the maximum scale to use (2 by default)
  146005. * @param step defines the step to use between two passes (0.5 by default)
  146006. */
  146007. constructor(
  146008. /**
  146009. * Defines the priority of this optimization (0 by default which means first in the list)
  146010. */
  146011. priority?: number,
  146012. /**
  146013. * Defines the maximum scale to use (2 by default)
  146014. */
  146015. maximumScale?: number,
  146016. /**
  146017. * Defines the step to use between two passes (0.5 by default)
  146018. */
  146019. step?: number);
  146020. /**
  146021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146022. * @param scene defines the current scene where to apply this optimization
  146023. * @param optimizer defines the current optimizer
  146024. * @returns true if everything that can be done was applied
  146025. */
  146026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146027. }
  146028. /**
  146029. * Defines an optimization used to remove shadows
  146030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146031. */
  146032. export class ShadowsOptimization extends SceneOptimization {
  146033. /**
  146034. * Gets a string describing the action executed by the current optimization
  146035. * @return description string
  146036. */
  146037. getDescription(): string;
  146038. /**
  146039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146040. * @param scene defines the current scene where to apply this optimization
  146041. * @param optimizer defines the current optimizer
  146042. * @returns true if everything that can be done was applied
  146043. */
  146044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146045. }
  146046. /**
  146047. * Defines an optimization used to turn post-processes off
  146048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146049. */
  146050. export class PostProcessesOptimization extends SceneOptimization {
  146051. /**
  146052. * Gets a string describing the action executed by the current optimization
  146053. * @return description string
  146054. */
  146055. getDescription(): string;
  146056. /**
  146057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146058. * @param scene defines the current scene where to apply this optimization
  146059. * @param optimizer defines the current optimizer
  146060. * @returns true if everything that can be done was applied
  146061. */
  146062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146063. }
  146064. /**
  146065. * Defines an optimization used to turn lens flares off
  146066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146067. */
  146068. export class LensFlaresOptimization extends SceneOptimization {
  146069. /**
  146070. * Gets a string describing the action executed by the current optimization
  146071. * @return description string
  146072. */
  146073. getDescription(): string;
  146074. /**
  146075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146076. * @param scene defines the current scene where to apply this optimization
  146077. * @param optimizer defines the current optimizer
  146078. * @returns true if everything that can be done was applied
  146079. */
  146080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146081. }
  146082. /**
  146083. * Defines an optimization based on user defined callback.
  146084. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146085. */
  146086. export class CustomOptimization extends SceneOptimization {
  146087. /**
  146088. * Callback called to apply the custom optimization.
  146089. */
  146090. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  146091. /**
  146092. * Callback called to get custom description
  146093. */
  146094. onGetDescription: () => string;
  146095. /**
  146096. * Gets a string describing the action executed by the current optimization
  146097. * @returns description string
  146098. */
  146099. getDescription(): string;
  146100. /**
  146101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146102. * @param scene defines the current scene where to apply this optimization
  146103. * @param optimizer defines the current optimizer
  146104. * @returns true if everything that can be done was applied
  146105. */
  146106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146107. }
  146108. /**
  146109. * Defines an optimization used to turn particles off
  146110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146111. */
  146112. export class ParticlesOptimization extends SceneOptimization {
  146113. /**
  146114. * Gets a string describing the action executed by the current optimization
  146115. * @return description string
  146116. */
  146117. getDescription(): string;
  146118. /**
  146119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146120. * @param scene defines the current scene where to apply this optimization
  146121. * @param optimizer defines the current optimizer
  146122. * @returns true if everything that can be done was applied
  146123. */
  146124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146125. }
  146126. /**
  146127. * Defines an optimization used to turn render targets off
  146128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146129. */
  146130. export class RenderTargetsOptimization extends SceneOptimization {
  146131. /**
  146132. * Gets a string describing the action executed by the current optimization
  146133. * @return description string
  146134. */
  146135. getDescription(): string;
  146136. /**
  146137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146138. * @param scene defines the current scene where to apply this optimization
  146139. * @param optimizer defines the current optimizer
  146140. * @returns true if everything that can be done was applied
  146141. */
  146142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  146143. }
  146144. /**
  146145. * Defines an optimization used to merge meshes with compatible materials
  146146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146147. */
  146148. export class MergeMeshesOptimization extends SceneOptimization {
  146149. private static _UpdateSelectionTree;
  146150. /**
  146151. * Gets or sets a boolean which defines if optimization octree has to be updated
  146152. */
  146153. static get UpdateSelectionTree(): boolean;
  146154. /**
  146155. * Gets or sets a boolean which defines if optimization octree has to be updated
  146156. */
  146157. static set UpdateSelectionTree(value: boolean);
  146158. /**
  146159. * Gets a string describing the action executed by the current optimization
  146160. * @return description string
  146161. */
  146162. getDescription(): string;
  146163. private _canBeMerged;
  146164. /**
  146165. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  146166. * @param scene defines the current scene where to apply this optimization
  146167. * @param optimizer defines the current optimizer
  146168. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  146169. * @returns true if everything that can be done was applied
  146170. */
  146171. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  146172. }
  146173. /**
  146174. * Defines a list of options used by SceneOptimizer
  146175. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146176. */
  146177. export class SceneOptimizerOptions {
  146178. /**
  146179. * Defines the target frame rate to reach (60 by default)
  146180. */
  146181. targetFrameRate: number;
  146182. /**
  146183. * Defines the interval between two checkes (2000ms by default)
  146184. */
  146185. trackerDuration: number;
  146186. /**
  146187. * Gets the list of optimizations to apply
  146188. */
  146189. optimizations: SceneOptimization[];
  146190. /**
  146191. * Creates a new list of options used by SceneOptimizer
  146192. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  146193. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  146194. */
  146195. constructor(
  146196. /**
  146197. * Defines the target frame rate to reach (60 by default)
  146198. */
  146199. targetFrameRate?: number,
  146200. /**
  146201. * Defines the interval between two checkes (2000ms by default)
  146202. */
  146203. trackerDuration?: number);
  146204. /**
  146205. * Add a new optimization
  146206. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  146207. * @returns the current SceneOptimizerOptions
  146208. */
  146209. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  146210. /**
  146211. * Add a new custom optimization
  146212. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  146213. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  146214. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  146215. * @returns the current SceneOptimizerOptions
  146216. */
  146217. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  146218. /**
  146219. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  146220. * @param targetFrameRate defines the target frame rate (60 by default)
  146221. * @returns a SceneOptimizerOptions object
  146222. */
  146223. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146224. /**
  146225. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  146226. * @param targetFrameRate defines the target frame rate (60 by default)
  146227. * @returns a SceneOptimizerOptions object
  146228. */
  146229. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146230. /**
  146231. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  146232. * @param targetFrameRate defines the target frame rate (60 by default)
  146233. * @returns a SceneOptimizerOptions object
  146234. */
  146235. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  146236. }
  146237. /**
  146238. * Class used to run optimizations in order to reach a target frame rate
  146239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  146240. */
  146241. export class SceneOptimizer implements IDisposable {
  146242. private _isRunning;
  146243. private _options;
  146244. private _scene;
  146245. private _currentPriorityLevel;
  146246. private _targetFrameRate;
  146247. private _trackerDuration;
  146248. private _currentFrameRate;
  146249. private _sceneDisposeObserver;
  146250. private _improvementMode;
  146251. /**
  146252. * Defines an observable called when the optimizer reaches the target frame rate
  146253. */
  146254. onSuccessObservable: Observable<SceneOptimizer>;
  146255. /**
  146256. * Defines an observable called when the optimizer enables an optimization
  146257. */
  146258. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  146259. /**
  146260. * Defines an observable called when the optimizer is not able to reach the target frame rate
  146261. */
  146262. onFailureObservable: Observable<SceneOptimizer>;
  146263. /**
  146264. * Gets a boolean indicating if the optimizer is in improvement mode
  146265. */
  146266. get isInImprovementMode(): boolean;
  146267. /**
  146268. * Gets the current priority level (0 at start)
  146269. */
  146270. get currentPriorityLevel(): number;
  146271. /**
  146272. * Gets the current frame rate checked by the SceneOptimizer
  146273. */
  146274. get currentFrameRate(): number;
  146275. /**
  146276. * Gets or sets the current target frame rate (60 by default)
  146277. */
  146278. get targetFrameRate(): number;
  146279. /**
  146280. * Gets or sets the current target frame rate (60 by default)
  146281. */
  146282. set targetFrameRate(value: number);
  146283. /**
  146284. * Gets or sets the current interval between two checks (every 2000ms by default)
  146285. */
  146286. get trackerDuration(): number;
  146287. /**
  146288. * Gets or sets the current interval between two checks (every 2000ms by default)
  146289. */
  146290. set trackerDuration(value: number);
  146291. /**
  146292. * Gets the list of active optimizations
  146293. */
  146294. get optimizations(): SceneOptimization[];
  146295. /**
  146296. * Creates a new SceneOptimizer
  146297. * @param scene defines the scene to work on
  146298. * @param options defines the options to use with the SceneOptimizer
  146299. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  146300. * @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)
  146301. */
  146302. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  146303. /**
  146304. * Stops the current optimizer
  146305. */
  146306. stop(): void;
  146307. /**
  146308. * Reset the optimizer to initial step (current priority level = 0)
  146309. */
  146310. reset(): void;
  146311. /**
  146312. * Start the optimizer. By default it will try to reach a specific framerate
  146313. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  146314. */
  146315. start(): void;
  146316. private _checkCurrentState;
  146317. /**
  146318. * Release all resources
  146319. */
  146320. dispose(): void;
  146321. /**
  146322. * Helper function to create a SceneOptimizer with one single line of code
  146323. * @param scene defines the scene to work on
  146324. * @param options defines the options to use with the SceneOptimizer
  146325. * @param onSuccess defines a callback to call on success
  146326. * @param onFailure defines a callback to call on failure
  146327. * @returns the new SceneOptimizer object
  146328. */
  146329. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  146330. }
  146331. }
  146332. declare module BABYLON {
  146333. /**
  146334. * Class used to serialize a scene into a string
  146335. */
  146336. export class SceneSerializer {
  146337. /**
  146338. * Clear cache used by a previous serialization
  146339. */
  146340. static ClearCache(): void;
  146341. /**
  146342. * Serialize a scene into a JSON compatible object
  146343. * @param scene defines the scene to serialize
  146344. * @returns a JSON compatible object
  146345. */
  146346. static Serialize(scene: Scene): any;
  146347. /**
  146348. * Serialize a mesh into a JSON compatible object
  146349. * @param toSerialize defines the mesh to serialize
  146350. * @param withParents defines if parents must be serialized as well
  146351. * @param withChildren defines if children must be serialized as well
  146352. * @returns a JSON compatible object
  146353. */
  146354. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  146355. }
  146356. }
  146357. declare module BABYLON {
  146358. /**
  146359. * Class used to host texture specific utilities
  146360. */
  146361. export class TextureTools {
  146362. /**
  146363. * Uses the GPU to create a copy texture rescaled at a given size
  146364. * @param texture Texture to copy from
  146365. * @param width defines the desired width
  146366. * @param height defines the desired height
  146367. * @param useBilinearMode defines if bilinear mode has to be used
  146368. * @return the generated texture
  146369. */
  146370. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  146371. }
  146372. }
  146373. declare module BABYLON {
  146374. /**
  146375. * This represents the different options available for the video capture.
  146376. */
  146377. export interface VideoRecorderOptions {
  146378. /** Defines the mime type of the video. */
  146379. mimeType: string;
  146380. /** Defines the FPS the video should be recorded at. */
  146381. fps: number;
  146382. /** Defines the chunk size for the recording data. */
  146383. recordChunckSize: number;
  146384. /** The audio tracks to attach to the recording. */
  146385. audioTracks?: MediaStreamTrack[];
  146386. }
  146387. /**
  146388. * This can help with recording videos from BabylonJS.
  146389. * This is based on the available WebRTC functionalities of the browser.
  146390. *
  146391. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  146392. */
  146393. export class VideoRecorder {
  146394. private static readonly _defaultOptions;
  146395. /**
  146396. * Returns whether or not the VideoRecorder is available in your browser.
  146397. * @param engine Defines the Babylon Engine.
  146398. * @returns true if supported otherwise false.
  146399. */
  146400. static IsSupported(engine: Engine): boolean;
  146401. private readonly _options;
  146402. private _canvas;
  146403. private _mediaRecorder;
  146404. private _recordedChunks;
  146405. private _fileName;
  146406. private _resolve;
  146407. private _reject;
  146408. /**
  146409. * True when a recording is already in progress.
  146410. */
  146411. get isRecording(): boolean;
  146412. /**
  146413. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  146414. * @param engine Defines the BabylonJS Engine you wish to record.
  146415. * @param options Defines options that can be used to customize the capture.
  146416. */
  146417. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  146418. /**
  146419. * Stops the current recording before the default capture timeout passed in the startRecording function.
  146420. */
  146421. stopRecording(): void;
  146422. /**
  146423. * Starts recording the canvas for a max duration specified in parameters.
  146424. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  146425. * If null no automatic download will start and you can rely on the promise to get the data back.
  146426. * @param maxDuration Defines the maximum recording time in seconds.
  146427. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  146428. * @return A promise callback at the end of the recording with the video data in Blob.
  146429. */
  146430. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  146431. /**
  146432. * Releases internal resources used during the recording.
  146433. */
  146434. dispose(): void;
  146435. private _handleDataAvailable;
  146436. private _handleError;
  146437. private _handleStop;
  146438. }
  146439. }
  146440. declare module BABYLON {
  146441. /**
  146442. * Class containing a set of static utilities functions for screenshots
  146443. */
  146444. export class ScreenshotTools {
  146445. /**
  146446. * Captures a screenshot of the current rendering
  146447. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146448. * @param engine defines the rendering engine
  146449. * @param camera defines the source camera
  146450. * @param size This parameter can be set to a single number or to an object with the
  146451. * following (optional) properties: precision, width, height. If a single number is passed,
  146452. * it will be used for both width and height. If an object is passed, the screenshot size
  146453. * will be derived from the parameters. The precision property is a multiplier allowing
  146454. * rendering at a higher or lower resolution
  146455. * @param successCallback defines the callback receives a single parameter which contains the
  146456. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146457. * src parameter of an <img> to display it
  146458. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146459. * Check your browser for supported MIME types
  146460. */
  146461. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  146462. /**
  146463. * Captures a screenshot of the current rendering
  146464. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146465. * @param engine defines the rendering engine
  146466. * @param camera defines the source camera
  146467. * @param size This parameter can be set to a single number or to an object with the
  146468. * following (optional) properties: precision, width, height. If a single number is passed,
  146469. * it will be used for both width and height. If an object is passed, the screenshot size
  146470. * will be derived from the parameters. The precision property is a multiplier allowing
  146471. * rendering at a higher or lower resolution
  146472. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  146473. * Check your browser for supported MIME types
  146474. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146475. * to the src parameter of an <img> to display it
  146476. */
  146477. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  146478. /**
  146479. * Generates an image screenshot from the specified camera.
  146480. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146481. * @param engine The engine to use for rendering
  146482. * @param camera The camera to use for rendering
  146483. * @param size This parameter can be set to a single number or to an object with the
  146484. * following (optional) properties: precision, width, height. If a single number is passed,
  146485. * it will be used for both width and height. If an object is passed, the screenshot size
  146486. * will be derived from the parameters. The precision property is a multiplier allowing
  146487. * rendering at a higher or lower resolution
  146488. * @param successCallback The callback receives a single parameter which contains the
  146489. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  146490. * src parameter of an <img> to display it
  146491. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146492. * Check your browser for supported MIME types
  146493. * @param samples Texture samples (default: 1)
  146494. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146495. * @param fileName A name for for the downloaded file.
  146496. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146497. */
  146498. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  146499. /**
  146500. * Generates an image screenshot from the specified camera.
  146501. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  146502. * @param engine The engine to use for rendering
  146503. * @param camera The camera to use for rendering
  146504. * @param size This parameter can be set to a single number or to an object with the
  146505. * following (optional) properties: precision, width, height. If a single number is passed,
  146506. * it will be used for both width and height. If an object is passed, the screenshot size
  146507. * will be derived from the parameters. The precision property is a multiplier allowing
  146508. * rendering at a higher or lower resolution
  146509. * @param mimeType The MIME type of the screenshot image (default: image/png).
  146510. * Check your browser for supported MIME types
  146511. * @param samples Texture samples (default: 1)
  146512. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  146513. * @param fileName A name for for the downloaded file.
  146514. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  146515. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  146516. * to the src parameter of an <img> to display it
  146517. */
  146518. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  146519. /**
  146520. * Gets height and width for screenshot size
  146521. * @private
  146522. */
  146523. private static _getScreenshotSize;
  146524. }
  146525. }
  146526. declare module BABYLON {
  146527. /**
  146528. * Interface for a data buffer
  146529. */
  146530. export interface IDataBuffer {
  146531. /**
  146532. * Reads bytes from the data buffer.
  146533. * @param byteOffset The byte offset to read
  146534. * @param byteLength The byte length to read
  146535. * @returns A promise that resolves when the bytes are read
  146536. */
  146537. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  146538. /**
  146539. * The byte length of the buffer.
  146540. */
  146541. readonly byteLength: number;
  146542. }
  146543. /**
  146544. * Utility class for reading from a data buffer
  146545. */
  146546. export class DataReader {
  146547. /**
  146548. * The data buffer associated with this data reader.
  146549. */
  146550. readonly buffer: IDataBuffer;
  146551. /**
  146552. * The current byte offset from the beginning of the data buffer.
  146553. */
  146554. byteOffset: number;
  146555. private _dataView;
  146556. private _dataByteOffset;
  146557. /**
  146558. * Constructor
  146559. * @param buffer The buffer to read
  146560. */
  146561. constructor(buffer: IDataBuffer);
  146562. /**
  146563. * Loads the given byte length.
  146564. * @param byteLength The byte length to load
  146565. * @returns A promise that resolves when the load is complete
  146566. */
  146567. loadAsync(byteLength: number): Promise<void>;
  146568. /**
  146569. * Read a unsigned 32-bit integer from the currently loaded data range.
  146570. * @returns The 32-bit integer read
  146571. */
  146572. readUint32(): number;
  146573. /**
  146574. * Read a byte array from the currently loaded data range.
  146575. * @param byteLength The byte length to read
  146576. * @returns The byte array read
  146577. */
  146578. readUint8Array(byteLength: number): Uint8Array;
  146579. /**
  146580. * Read a string from the currently loaded data range.
  146581. * @param byteLength The byte length to read
  146582. * @returns The string read
  146583. */
  146584. readString(byteLength: number): string;
  146585. /**
  146586. * Skips the given byte length the currently loaded data range.
  146587. * @param byteLength The byte length to skip
  146588. */
  146589. skipBytes(byteLength: number): void;
  146590. }
  146591. }
  146592. declare module BABYLON {
  146593. /**
  146594. * Class for storing data to local storage if available or in-memory storage otherwise
  146595. */
  146596. export class DataStorage {
  146597. private static _Storage;
  146598. private static _GetStorage;
  146599. /**
  146600. * Reads a string from the data storage
  146601. * @param key The key to read
  146602. * @param defaultValue The value if the key doesn't exist
  146603. * @returns The string value
  146604. */
  146605. static ReadString(key: string, defaultValue: string): string;
  146606. /**
  146607. * Writes a string to the data storage
  146608. * @param key The key to write
  146609. * @param value The value to write
  146610. */
  146611. static WriteString(key: string, value: string): void;
  146612. /**
  146613. * Reads a boolean from the data storage
  146614. * @param key The key to read
  146615. * @param defaultValue The value if the key doesn't exist
  146616. * @returns The boolean value
  146617. */
  146618. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  146619. /**
  146620. * Writes a boolean to the data storage
  146621. * @param key The key to write
  146622. * @param value The value to write
  146623. */
  146624. static WriteBoolean(key: string, value: boolean): void;
  146625. /**
  146626. * Reads a number from the data storage
  146627. * @param key The key to read
  146628. * @param defaultValue The value if the key doesn't exist
  146629. * @returns The number value
  146630. */
  146631. static ReadNumber(key: string, defaultValue: number): number;
  146632. /**
  146633. * Writes a number to the data storage
  146634. * @param key The key to write
  146635. * @param value The value to write
  146636. */
  146637. static WriteNumber(key: string, value: number): void;
  146638. }
  146639. }
  146640. declare module BABYLON {
  146641. /**
  146642. * Options used for hit testing
  146643. */
  146644. export interface IWebXRLegacyHitTestOptions {
  146645. /**
  146646. * Only test when user interacted with the scene. Default - hit test every frame
  146647. */
  146648. testOnPointerDownOnly?: boolean;
  146649. /**
  146650. * The node to use to transform the local results to world coordinates
  146651. */
  146652. worldParentNode?: TransformNode;
  146653. }
  146654. /**
  146655. * Interface defining the babylon result of raycasting/hit-test
  146656. */
  146657. export interface IWebXRLegacyHitResult {
  146658. /**
  146659. * Transformation matrix that can be applied to a node that will put it in the hit point location
  146660. */
  146661. transformationMatrix: Matrix;
  146662. /**
  146663. * The native hit test result
  146664. */
  146665. xrHitResult: XRHitResult | XRHitTestResult;
  146666. }
  146667. /**
  146668. * The currently-working hit-test module.
  146669. * Hit test (or Ray-casting) is used to interact with the real world.
  146670. * For further information read here - https://github.com/immersive-web/hit-test
  146671. */
  146672. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  146673. /**
  146674. * options to use when constructing this feature
  146675. */
  146676. readonly options: IWebXRLegacyHitTestOptions;
  146677. private _direction;
  146678. private _mat;
  146679. private _onSelectEnabled;
  146680. private _origin;
  146681. /**
  146682. * The module's name
  146683. */
  146684. static readonly Name: string;
  146685. /**
  146686. * The (Babylon) version of this module.
  146687. * This is an integer representing the implementation version.
  146688. * This number does not correspond to the WebXR specs version
  146689. */
  146690. static readonly Version: number;
  146691. /**
  146692. * Populated with the last native XR Hit Results
  146693. */
  146694. lastNativeXRHitResults: XRHitResult[];
  146695. /**
  146696. * Triggered when new babylon (transformed) hit test results are available
  146697. */
  146698. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  146699. /**
  146700. * Creates a new instance of the (legacy version) hit test feature
  146701. * @param _xrSessionManager an instance of WebXRSessionManager
  146702. * @param options options to use when constructing this feature
  146703. */
  146704. constructor(_xrSessionManager: WebXRSessionManager,
  146705. /**
  146706. * options to use when constructing this feature
  146707. */
  146708. options?: IWebXRLegacyHitTestOptions);
  146709. /**
  146710. * execute a hit test with an XR Ray
  146711. *
  146712. * @param xrSession a native xrSession that will execute this hit test
  146713. * @param xrRay the ray (position and direction) to use for ray-casting
  146714. * @param referenceSpace native XR reference space to use for the hit-test
  146715. * @param filter filter function that will filter the results
  146716. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  146717. */
  146718. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  146719. /**
  146720. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  146721. * @param event the (select) event to use to select with
  146722. * @param referenceSpace the reference space to use for this hit test
  146723. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  146724. */
  146725. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  146726. /**
  146727. * attach this feature
  146728. * Will usually be called by the features manager
  146729. *
  146730. * @returns true if successful.
  146731. */
  146732. attach(): boolean;
  146733. /**
  146734. * detach this feature.
  146735. * Will usually be called by the features manager
  146736. *
  146737. * @returns true if successful.
  146738. */
  146739. detach(): boolean;
  146740. /**
  146741. * Dispose this feature and all of the resources attached
  146742. */
  146743. dispose(): void;
  146744. protected _onXRFrame(frame: XRFrame): void;
  146745. private _onHitTestResults;
  146746. private _onSelect;
  146747. }
  146748. }
  146749. declare module BABYLON {
  146750. /**
  146751. * Options used in the plane detector module
  146752. */
  146753. export interface IWebXRPlaneDetectorOptions {
  146754. /**
  146755. * The node to use to transform the local results to world coordinates
  146756. */
  146757. worldParentNode?: TransformNode;
  146758. }
  146759. /**
  146760. * A babylon interface for a WebXR plane.
  146761. * A Plane is actually a polygon, built from N points in space
  146762. *
  146763. * Supported in chrome 79, not supported in canary 81 ATM
  146764. */
  146765. export interface IWebXRPlane {
  146766. /**
  146767. * a babylon-assigned ID for this polygon
  146768. */
  146769. id: number;
  146770. /**
  146771. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  146772. */
  146773. polygonDefinition: Array<Vector3>;
  146774. /**
  146775. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  146776. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  146777. */
  146778. transformationMatrix: Matrix;
  146779. /**
  146780. * the native xr-plane object
  146781. */
  146782. xrPlane: XRPlane;
  146783. }
  146784. /**
  146785. * The plane detector is used to detect planes in the real world when in AR
  146786. * For more information see https://github.com/immersive-web/real-world-geometry/
  146787. */
  146788. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  146789. private _options;
  146790. private _detectedPlanes;
  146791. private _enabled;
  146792. private _lastFrameDetected;
  146793. /**
  146794. * The module's name
  146795. */
  146796. static readonly Name: string;
  146797. /**
  146798. * The (Babylon) version of this module.
  146799. * This is an integer representing the implementation version.
  146800. * This number does not correspond to the WebXR specs version
  146801. */
  146802. static readonly Version: number;
  146803. /**
  146804. * Observers registered here will be executed when a new plane was added to the session
  146805. */
  146806. onPlaneAddedObservable: Observable<IWebXRPlane>;
  146807. /**
  146808. * Observers registered here will be executed when a plane is no longer detected in the session
  146809. */
  146810. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  146811. /**
  146812. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  146813. * This can execute N times every frame
  146814. */
  146815. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  146816. /**
  146817. * construct a new Plane Detector
  146818. * @param _xrSessionManager an instance of xr Session manager
  146819. * @param _options configuration to use when constructing this feature
  146820. */
  146821. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  146822. /**
  146823. * Dispose this feature and all of the resources attached
  146824. */
  146825. dispose(): void;
  146826. protected _onXRFrame(frame: XRFrame): void;
  146827. private _init;
  146828. private _updatePlaneWithXRPlane;
  146829. /**
  146830. * avoiding using Array.find for global support.
  146831. * @param xrPlane the plane to find in the array
  146832. */
  146833. private findIndexInPlaneArray;
  146834. }
  146835. }
  146836. declare module BABYLON {
  146837. /**
  146838. * Configuration options of the anchor system
  146839. */
  146840. export interface IWebXRAnchorSystemOptions {
  146841. /**
  146842. * Should a new anchor be added every time a select event is triggered
  146843. */
  146844. addAnchorOnSelect?: boolean;
  146845. /**
  146846. * should the anchor system use plane detection.
  146847. * If set to true, the plane-detection feature should be set using setPlaneDetector
  146848. */
  146849. usePlaneDetection?: boolean;
  146850. /**
  146851. * a node that will be used to convert local to world coordinates
  146852. */
  146853. worldParentNode?: TransformNode;
  146854. }
  146855. /**
  146856. * A babylon container for an XR Anchor
  146857. */
  146858. export interface IWebXRAnchor {
  146859. /**
  146860. * A babylon-assigned ID for this anchor
  146861. */
  146862. id: number;
  146863. /**
  146864. * Transformation matrix to apply to an object attached to this anchor
  146865. */
  146866. transformationMatrix: Matrix;
  146867. /**
  146868. * The native anchor object
  146869. */
  146870. xrAnchor: XRAnchor;
  146871. }
  146872. /**
  146873. * An implementation of the anchor system of WebXR.
  146874. * Note that the current documented implementation is not available in any browser. Future implementations
  146875. * will use the frame to create an anchor and not the session or a detected plane
  146876. * For further information see https://github.com/immersive-web/anchors/
  146877. */
  146878. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  146879. private _options;
  146880. private _enabled;
  146881. private _hitTestModule;
  146882. private _lastFrameDetected;
  146883. private _onSelect;
  146884. private _planeDetector;
  146885. private _trackedAnchors;
  146886. /**
  146887. * The module's name
  146888. */
  146889. static readonly Name: string;
  146890. /**
  146891. * The (Babylon) version of this module.
  146892. * This is an integer representing the implementation version.
  146893. * This number does not correspond to the WebXR specs version
  146894. */
  146895. static readonly Version: number;
  146896. /**
  146897. * Observers registered here will be executed when a new anchor was added to the session
  146898. */
  146899. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  146900. /**
  146901. * Observers registered here will be executed when an anchor was removed from the session
  146902. */
  146903. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  146904. /**
  146905. * Observers registered here will be executed when an existing anchor updates
  146906. * This can execute N times every frame
  146907. */
  146908. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  146909. /**
  146910. * constructs a new anchor system
  146911. * @param _xrSessionManager an instance of WebXRSessionManager
  146912. * @param _options configuration object for this feature
  146913. */
  146914. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  146915. /**
  146916. * Add anchor at a specific XR point.
  146917. *
  146918. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  146919. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  146920. * @returns a promise the fulfills when the anchor was created
  146921. */
  146922. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  146923. /**
  146924. * attach this feature
  146925. * Will usually be called by the features manager
  146926. *
  146927. * @returns true if successful.
  146928. */
  146929. attach(): boolean;
  146930. /**
  146931. * detach this feature.
  146932. * Will usually be called by the features manager
  146933. *
  146934. * @returns true if successful.
  146935. */
  146936. detach(): boolean;
  146937. /**
  146938. * Dispose this feature and all of the resources attached
  146939. */
  146940. dispose(): void;
  146941. /**
  146942. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  146943. * @param hitTestModule the hit-test module to use.
  146944. */
  146945. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  146946. /**
  146947. * set the plane detector to use in order to create anchors from frames
  146948. * @param planeDetector the plane-detector module to use
  146949. * @param enable enable plane-anchors. default is true
  146950. */
  146951. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  146952. protected _onXRFrame(frame: XRFrame): void;
  146953. /**
  146954. * avoiding using Array.find for global support.
  146955. * @param xrAnchor the plane to find in the array
  146956. */
  146957. private _findIndexInAnchorArray;
  146958. private _updateAnchorWithXRFrame;
  146959. }
  146960. }
  146961. declare module BABYLON {
  146962. /**
  146963. * Options interface for the background remover plugin
  146964. */
  146965. export interface IWebXRBackgroundRemoverOptions {
  146966. /**
  146967. * Further background meshes to disable when entering AR
  146968. */
  146969. backgroundMeshes?: AbstractMesh[];
  146970. /**
  146971. * flags to configure the removal of the environment helper.
  146972. * If not set, the entire background will be removed. If set, flags should be set as well.
  146973. */
  146974. environmentHelperRemovalFlags?: {
  146975. /**
  146976. * Should the skybox be removed (default false)
  146977. */
  146978. skyBox?: boolean;
  146979. /**
  146980. * Should the ground be removed (default false)
  146981. */
  146982. ground?: boolean;
  146983. };
  146984. /**
  146985. * don't disable the environment helper
  146986. */
  146987. ignoreEnvironmentHelper?: boolean;
  146988. }
  146989. /**
  146990. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  146991. */
  146992. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  146993. /**
  146994. * read-only options to be used in this module
  146995. */
  146996. readonly options: IWebXRBackgroundRemoverOptions;
  146997. /**
  146998. * The module's name
  146999. */
  147000. static readonly Name: string;
  147001. /**
  147002. * The (Babylon) version of this module.
  147003. * This is an integer representing the implementation version.
  147004. * This number does not correspond to the WebXR specs version
  147005. */
  147006. static readonly Version: number;
  147007. /**
  147008. * registered observers will be triggered when the background state changes
  147009. */
  147010. onBackgroundStateChangedObservable: Observable<boolean>;
  147011. /**
  147012. * constructs a new background remover module
  147013. * @param _xrSessionManager the session manager for this module
  147014. * @param options read-only options to be used in this module
  147015. */
  147016. constructor(_xrSessionManager: WebXRSessionManager,
  147017. /**
  147018. * read-only options to be used in this module
  147019. */
  147020. options?: IWebXRBackgroundRemoverOptions);
  147021. /**
  147022. * attach this feature
  147023. * Will usually be called by the features manager
  147024. *
  147025. * @returns true if successful.
  147026. */
  147027. attach(): boolean;
  147028. /**
  147029. * detach this feature.
  147030. * Will usually be called by the features manager
  147031. *
  147032. * @returns true if successful.
  147033. */
  147034. detach(): boolean;
  147035. /**
  147036. * Dispose this feature and all of the resources attached
  147037. */
  147038. dispose(): void;
  147039. protected _onXRFrame(_xrFrame: XRFrame): void;
  147040. private _setBackgroundState;
  147041. }
  147042. }
  147043. declare module BABYLON {
  147044. /**
  147045. * Options for the controller physics feature
  147046. */
  147047. export class IWebXRControllerPhysicsOptions {
  147048. /**
  147049. * Should the headset get its own impostor
  147050. */
  147051. enableHeadsetImpostor?: boolean;
  147052. /**
  147053. * Optional parameters for the headset impostor
  147054. */
  147055. headsetImpostorParams?: {
  147056. /**
  147057. * The type of impostor to create. Default is sphere
  147058. */
  147059. impostorType: number;
  147060. /**
  147061. * the size of the impostor. Defaults to 10cm
  147062. */
  147063. impostorSize?: number | {
  147064. width: number;
  147065. height: number;
  147066. depth: number;
  147067. };
  147068. /**
  147069. * Friction definitions
  147070. */
  147071. friction?: number;
  147072. /**
  147073. * Restitution
  147074. */
  147075. restitution?: number;
  147076. };
  147077. /**
  147078. * The physics properties of the future impostors
  147079. */
  147080. physicsProperties?: {
  147081. /**
  147082. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  147083. * Note that this requires a physics engine that supports mesh impostors!
  147084. */
  147085. useControllerMesh?: boolean;
  147086. /**
  147087. * The type of impostor to create. Default is sphere
  147088. */
  147089. impostorType?: number;
  147090. /**
  147091. * the size of the impostor. Defaults to 10cm
  147092. */
  147093. impostorSize?: number | {
  147094. width: number;
  147095. height: number;
  147096. depth: number;
  147097. };
  147098. /**
  147099. * Friction definitions
  147100. */
  147101. friction?: number;
  147102. /**
  147103. * Restitution
  147104. */
  147105. restitution?: number;
  147106. };
  147107. /**
  147108. * the xr input to use with this pointer selection
  147109. */
  147110. xrInput: WebXRInput;
  147111. }
  147112. /**
  147113. * Add physics impostor to your webxr controllers,
  147114. * including naive calculation of their linear and angular velocity
  147115. */
  147116. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  147117. private readonly _options;
  147118. private _attachController;
  147119. private _controllers;
  147120. private _debugMode;
  147121. private _delta;
  147122. private _headsetImpostor?;
  147123. private _headsetMesh?;
  147124. private _lastTimestamp;
  147125. private _tmpQuaternion;
  147126. private _tmpVector;
  147127. /**
  147128. * The module's name
  147129. */
  147130. static readonly Name: string;
  147131. /**
  147132. * The (Babylon) version of this module.
  147133. * This is an integer representing the implementation version.
  147134. * This number does not correspond to the webxr specs version
  147135. */
  147136. static readonly Version: number;
  147137. /**
  147138. * Construct a new Controller Physics Feature
  147139. * @param _xrSessionManager the corresponding xr session manager
  147140. * @param _options options to create this feature with
  147141. */
  147142. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  147143. /**
  147144. * @hidden
  147145. * enable debugging - will show console outputs and the impostor mesh
  147146. */
  147147. _enablePhysicsDebug(): void;
  147148. /**
  147149. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  147150. * @param xrController the controller to add
  147151. */
  147152. addController(xrController: WebXRInputSource): void;
  147153. /**
  147154. * attach this feature
  147155. * Will usually be called by the features manager
  147156. *
  147157. * @returns true if successful.
  147158. */
  147159. attach(): boolean;
  147160. /**
  147161. * detach this feature.
  147162. * Will usually be called by the features manager
  147163. *
  147164. * @returns true if successful.
  147165. */
  147166. detach(): boolean;
  147167. /**
  147168. * Get the headset impostor, if enabled
  147169. * @returns the impostor
  147170. */
  147171. getHeadsetImpostor(): PhysicsImpostor | undefined;
  147172. /**
  147173. * Get the physics impostor of a specific controller.
  147174. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  147175. * @param controller the controller or the controller id of which to get the impostor
  147176. * @returns the impostor or null
  147177. */
  147178. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  147179. /**
  147180. * Update the physics properties provided in the constructor
  147181. * @param newProperties the new properties object
  147182. */
  147183. setPhysicsProperties(newProperties: {
  147184. impostorType?: number;
  147185. impostorSize?: number | {
  147186. width: number;
  147187. height: number;
  147188. depth: number;
  147189. };
  147190. friction?: number;
  147191. restitution?: number;
  147192. }): void;
  147193. protected _onXRFrame(_xrFrame: any): void;
  147194. private _detachController;
  147195. }
  147196. }
  147197. declare module BABYLON {
  147198. /**
  147199. * Options used for hit testing (version 2)
  147200. */
  147201. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  147202. /**
  147203. * Do not create a permanent hit test. Will usually be used when only
  147204. * transient inputs are needed.
  147205. */
  147206. disablePermanentHitTest?: boolean;
  147207. /**
  147208. * Enable transient (for example touch-based) hit test inspections
  147209. */
  147210. enableTransientHitTest?: boolean;
  147211. /**
  147212. * Offset ray for the permanent hit test
  147213. */
  147214. offsetRay?: Vector3;
  147215. /**
  147216. * Offset ray for the transient hit test
  147217. */
  147218. transientOffsetRay?: Vector3;
  147219. /**
  147220. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  147221. */
  147222. useReferenceSpace?: boolean;
  147223. }
  147224. /**
  147225. * Interface defining the babylon result of hit-test
  147226. */
  147227. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  147228. /**
  147229. * The input source that generated this hit test (if transient)
  147230. */
  147231. inputSource?: XRInputSource;
  147232. /**
  147233. * Is this a transient hit test
  147234. */
  147235. isTransient?: boolean;
  147236. /**
  147237. * Position of the hit test result
  147238. */
  147239. position: Vector3;
  147240. /**
  147241. * Rotation of the hit test result
  147242. */
  147243. rotationQuaternion: Quaternion;
  147244. }
  147245. /**
  147246. * The currently-working hit-test module.
  147247. * Hit test (or Ray-casting) is used to interact with the real world.
  147248. * For further information read here - https://github.com/immersive-web/hit-test
  147249. *
  147250. * Tested on chrome (mobile) 80.
  147251. */
  147252. export class WebXRHitTest extends WebXRAbstractFeature {
  147253. /**
  147254. * options to use when constructing this feature
  147255. */
  147256. readonly options: IWebXRHitTestOptions;
  147257. private _tmpMat;
  147258. private _tmpPos;
  147259. private _tmpQuat;
  147260. private _transientXrHitTestSource;
  147261. private _xrHitTestSource;
  147262. private initHitTestSource;
  147263. /**
  147264. * The module's name
  147265. */
  147266. static readonly Name: string;
  147267. /**
  147268. * The (Babylon) version of this module.
  147269. * This is an integer representing the implementation version.
  147270. * This number does not correspond to the WebXR specs version
  147271. */
  147272. static readonly Version: number;
  147273. /**
  147274. * When set to true, each hit test will have its own position/rotation objects
  147275. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  147276. * the developers will clone them or copy them as they see fit.
  147277. */
  147278. autoCloneTransformation: boolean;
  147279. /**
  147280. * Populated with the last native XR Hit Results
  147281. */
  147282. lastNativeXRHitResults: XRHitResult[];
  147283. /**
  147284. * Triggered when new babylon (transformed) hit test results are available
  147285. */
  147286. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  147287. /**
  147288. * Use this to temporarily pause hit test checks.
  147289. */
  147290. paused: boolean;
  147291. /**
  147292. * Creates a new instance of the hit test feature
  147293. * @param _xrSessionManager an instance of WebXRSessionManager
  147294. * @param options options to use when constructing this feature
  147295. */
  147296. constructor(_xrSessionManager: WebXRSessionManager,
  147297. /**
  147298. * options to use when constructing this feature
  147299. */
  147300. options?: IWebXRHitTestOptions);
  147301. /**
  147302. * attach this feature
  147303. * Will usually be called by the features manager
  147304. *
  147305. * @returns true if successful.
  147306. */
  147307. attach(): boolean;
  147308. /**
  147309. * detach this feature.
  147310. * Will usually be called by the features manager
  147311. *
  147312. * @returns true if successful.
  147313. */
  147314. detach(): boolean;
  147315. /**
  147316. * Dispose this feature and all of the resources attached
  147317. */
  147318. dispose(): void;
  147319. protected _onXRFrame(frame: XRFrame): void;
  147320. private _processWebXRHitTestResult;
  147321. }
  147322. }
  147323. declare module BABYLON {
  147324. /**
  147325. * The motion controller class for all microsoft mixed reality controllers
  147326. */
  147327. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  147328. protected readonly _mapping: {
  147329. defaultButton: {
  147330. valueNodeName: string;
  147331. unpressedNodeName: string;
  147332. pressedNodeName: string;
  147333. };
  147334. defaultAxis: {
  147335. valueNodeName: string;
  147336. minNodeName: string;
  147337. maxNodeName: string;
  147338. };
  147339. buttons: {
  147340. "xr-standard-trigger": {
  147341. rootNodeName: string;
  147342. componentProperty: string;
  147343. states: string[];
  147344. };
  147345. "xr-standard-squeeze": {
  147346. rootNodeName: string;
  147347. componentProperty: string;
  147348. states: string[];
  147349. };
  147350. "xr-standard-touchpad": {
  147351. rootNodeName: string;
  147352. labelAnchorNodeName: string;
  147353. touchPointNodeName: string;
  147354. };
  147355. "xr-standard-thumbstick": {
  147356. rootNodeName: string;
  147357. componentProperty: string;
  147358. states: string[];
  147359. };
  147360. };
  147361. axes: {
  147362. "xr-standard-touchpad": {
  147363. "x-axis": {
  147364. rootNodeName: string;
  147365. };
  147366. "y-axis": {
  147367. rootNodeName: string;
  147368. };
  147369. };
  147370. "xr-standard-thumbstick": {
  147371. "x-axis": {
  147372. rootNodeName: string;
  147373. };
  147374. "y-axis": {
  147375. rootNodeName: string;
  147376. };
  147377. };
  147378. };
  147379. };
  147380. /**
  147381. * The base url used to load the left and right controller models
  147382. */
  147383. static MODEL_BASE_URL: string;
  147384. /**
  147385. * The name of the left controller model file
  147386. */
  147387. static MODEL_LEFT_FILENAME: string;
  147388. /**
  147389. * The name of the right controller model file
  147390. */
  147391. static MODEL_RIGHT_FILENAME: string;
  147392. profileId: string;
  147393. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147394. protected _getFilenameAndPath(): {
  147395. filename: string;
  147396. path: string;
  147397. };
  147398. protected _getModelLoadingConstraints(): boolean;
  147399. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147400. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147401. protected _updateModel(): void;
  147402. }
  147403. }
  147404. declare module BABYLON {
  147405. /**
  147406. * The motion controller class for oculus touch (quest, rift).
  147407. * This class supports legacy mapping as well the standard xr mapping
  147408. */
  147409. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  147410. private _forceLegacyControllers;
  147411. private _modelRootNode;
  147412. /**
  147413. * The base url used to load the left and right controller models
  147414. */
  147415. static MODEL_BASE_URL: string;
  147416. /**
  147417. * The name of the left controller model file
  147418. */
  147419. static MODEL_LEFT_FILENAME: string;
  147420. /**
  147421. * The name of the right controller model file
  147422. */
  147423. static MODEL_RIGHT_FILENAME: string;
  147424. /**
  147425. * Base Url for the Quest controller model.
  147426. */
  147427. static QUEST_MODEL_BASE_URL: string;
  147428. profileId: string;
  147429. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  147430. protected _getFilenameAndPath(): {
  147431. filename: string;
  147432. path: string;
  147433. };
  147434. protected _getModelLoadingConstraints(): boolean;
  147435. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147436. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147437. protected _updateModel(): void;
  147438. /**
  147439. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  147440. * between the touch and touch 2.
  147441. */
  147442. private _isQuest;
  147443. }
  147444. }
  147445. declare module BABYLON {
  147446. /**
  147447. * The motion controller class for the standard HTC-Vive controllers
  147448. */
  147449. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  147450. private _modelRootNode;
  147451. /**
  147452. * The base url used to load the left and right controller models
  147453. */
  147454. static MODEL_BASE_URL: string;
  147455. /**
  147456. * File name for the controller model.
  147457. */
  147458. static MODEL_FILENAME: string;
  147459. profileId: string;
  147460. /**
  147461. * Create a new Vive motion controller object
  147462. * @param scene the scene to use to create this controller
  147463. * @param gamepadObject the corresponding gamepad object
  147464. * @param handedness the handedness of the controller
  147465. */
  147466. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  147467. protected _getFilenameAndPath(): {
  147468. filename: string;
  147469. path: string;
  147470. };
  147471. protected _getModelLoadingConstraints(): boolean;
  147472. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  147473. protected _setRootMesh(meshes: AbstractMesh[]): void;
  147474. protected _updateModel(): void;
  147475. }
  147476. }
  147477. declare module BABYLON {
  147478. /**
  147479. * A cursor which tracks a point on a path
  147480. */
  147481. export class PathCursor {
  147482. private path;
  147483. /**
  147484. * Stores path cursor callbacks for when an onchange event is triggered
  147485. */
  147486. private _onchange;
  147487. /**
  147488. * The value of the path cursor
  147489. */
  147490. value: number;
  147491. /**
  147492. * The animation array of the path cursor
  147493. */
  147494. animations: Animation[];
  147495. /**
  147496. * Initializes the path cursor
  147497. * @param path The path to track
  147498. */
  147499. constructor(path: Path2);
  147500. /**
  147501. * Gets the cursor point on the path
  147502. * @returns A point on the path cursor at the cursor location
  147503. */
  147504. getPoint(): Vector3;
  147505. /**
  147506. * Moves the cursor ahead by the step amount
  147507. * @param step The amount to move the cursor forward
  147508. * @returns This path cursor
  147509. */
  147510. moveAhead(step?: number): PathCursor;
  147511. /**
  147512. * Moves the cursor behind by the step amount
  147513. * @param step The amount to move the cursor back
  147514. * @returns This path cursor
  147515. */
  147516. moveBack(step?: number): PathCursor;
  147517. /**
  147518. * Moves the cursor by the step amount
  147519. * If the step amount is greater than one, an exception is thrown
  147520. * @param step The amount to move the cursor
  147521. * @returns This path cursor
  147522. */
  147523. move(step: number): PathCursor;
  147524. /**
  147525. * Ensures that the value is limited between zero and one
  147526. * @returns This path cursor
  147527. */
  147528. private ensureLimits;
  147529. /**
  147530. * Runs onchange callbacks on change (used by the animation engine)
  147531. * @returns This path cursor
  147532. */
  147533. private raiseOnChange;
  147534. /**
  147535. * Executes a function on change
  147536. * @param f A path cursor onchange callback
  147537. * @returns This path cursor
  147538. */
  147539. onchange(f: (cursor: PathCursor) => void): PathCursor;
  147540. }
  147541. }
  147542. declare module BABYLON {
  147543. /** @hidden */
  147544. export var blurPixelShader: {
  147545. name: string;
  147546. shader: string;
  147547. };
  147548. }
  147549. declare module BABYLON {
  147550. /** @hidden */
  147551. export var pointCloudVertexDeclaration: {
  147552. name: string;
  147553. shader: string;
  147554. };
  147555. }
  147556. // Mixins
  147557. interface Window {
  147558. mozIndexedDB: IDBFactory;
  147559. webkitIndexedDB: IDBFactory;
  147560. msIndexedDB: IDBFactory;
  147561. webkitURL: typeof URL;
  147562. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  147563. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  147564. WebGLRenderingContext: WebGLRenderingContext;
  147565. MSGesture: MSGesture;
  147566. CANNON: any;
  147567. AudioContext: AudioContext;
  147568. webkitAudioContext: AudioContext;
  147569. PointerEvent: any;
  147570. Math: Math;
  147571. Uint8Array: Uint8ArrayConstructor;
  147572. Float32Array: Float32ArrayConstructor;
  147573. mozURL: typeof URL;
  147574. msURL: typeof URL;
  147575. VRFrameData: any; // WebVR, from specs 1.1
  147576. DracoDecoderModule: any;
  147577. setImmediate(handler: (...args: any[]) => void): number;
  147578. }
  147579. interface HTMLCanvasElement {
  147580. requestPointerLock(): void;
  147581. msRequestPointerLock?(): void;
  147582. mozRequestPointerLock?(): void;
  147583. webkitRequestPointerLock?(): void;
  147584. /** Track wether a record is in progress */
  147585. isRecording: boolean;
  147586. /** Capture Stream method defined by some browsers */
  147587. captureStream(fps?: number): MediaStream;
  147588. }
  147589. interface CanvasRenderingContext2D {
  147590. msImageSmoothingEnabled: boolean;
  147591. }
  147592. interface MouseEvent {
  147593. mozMovementX: number;
  147594. mozMovementY: number;
  147595. webkitMovementX: number;
  147596. webkitMovementY: number;
  147597. msMovementX: number;
  147598. msMovementY: number;
  147599. }
  147600. interface Navigator {
  147601. mozGetVRDevices: (any: any) => any;
  147602. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147603. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147604. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  147605. webkitGetGamepads(): Gamepad[];
  147606. msGetGamepads(): Gamepad[];
  147607. webkitGamepads(): Gamepad[];
  147608. }
  147609. interface HTMLVideoElement {
  147610. mozSrcObject: any;
  147611. }
  147612. interface Math {
  147613. fround(x: number): number;
  147614. imul(a: number, b: number): number;
  147615. }
  147616. interface WebGLRenderingContext {
  147617. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  147618. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  147619. vertexAttribDivisor(index: number, divisor: number): void;
  147620. createVertexArray(): any;
  147621. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  147622. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  147623. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  147624. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  147625. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  147626. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  147627. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  147628. // Queries
  147629. createQuery(): WebGLQuery;
  147630. deleteQuery(query: WebGLQuery): void;
  147631. beginQuery(target: number, query: WebGLQuery): void;
  147632. endQuery(target: number): void;
  147633. getQueryParameter(query: WebGLQuery, pname: number): any;
  147634. getQuery(target: number, pname: number): any;
  147635. MAX_SAMPLES: number;
  147636. RGBA8: number;
  147637. READ_FRAMEBUFFER: number;
  147638. DRAW_FRAMEBUFFER: number;
  147639. UNIFORM_BUFFER: number;
  147640. HALF_FLOAT_OES: number;
  147641. RGBA16F: number;
  147642. RGBA32F: number;
  147643. R32F: number;
  147644. RG32F: number;
  147645. RGB32F: number;
  147646. R16F: number;
  147647. RG16F: number;
  147648. RGB16F: number;
  147649. RED: number;
  147650. RG: number;
  147651. R8: number;
  147652. RG8: number;
  147653. UNSIGNED_INT_24_8: number;
  147654. DEPTH24_STENCIL8: number;
  147655. MIN: number;
  147656. MAX: number;
  147657. /* Multiple Render Targets */
  147658. drawBuffers(buffers: number[]): void;
  147659. readBuffer(src: number): void;
  147660. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  147661. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  147662. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  147663. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  147664. // Occlusion Query
  147665. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  147666. ANY_SAMPLES_PASSED: number;
  147667. QUERY_RESULT_AVAILABLE: number;
  147668. QUERY_RESULT: number;
  147669. }
  147670. interface WebGLProgram {
  147671. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  147672. }
  147673. interface EXT_disjoint_timer_query {
  147674. QUERY_COUNTER_BITS_EXT: number;
  147675. TIME_ELAPSED_EXT: number;
  147676. TIMESTAMP_EXT: number;
  147677. GPU_DISJOINT_EXT: number;
  147678. QUERY_RESULT_EXT: number;
  147679. QUERY_RESULT_AVAILABLE_EXT: number;
  147680. queryCounterEXT(query: WebGLQuery, target: number): void;
  147681. createQueryEXT(): WebGLQuery;
  147682. beginQueryEXT(target: number, query: WebGLQuery): void;
  147683. endQueryEXT(target: number): void;
  147684. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  147685. deleteQueryEXT(query: WebGLQuery): void;
  147686. }
  147687. interface WebGLUniformLocation {
  147688. _currentState: any;
  147689. }
  147690. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  147691. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  147692. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  147693. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  147694. interface WebGLRenderingContext {
  147695. readonly RASTERIZER_DISCARD: number;
  147696. readonly DEPTH_COMPONENT24: number;
  147697. readonly TEXTURE_3D: number;
  147698. readonly TEXTURE_2D_ARRAY: number;
  147699. readonly TEXTURE_COMPARE_FUNC: number;
  147700. readonly TEXTURE_COMPARE_MODE: number;
  147701. readonly COMPARE_REF_TO_TEXTURE: number;
  147702. readonly TEXTURE_WRAP_R: number;
  147703. readonly HALF_FLOAT: number;
  147704. readonly RGB8: number;
  147705. readonly RED_INTEGER: number;
  147706. readonly RG_INTEGER: number;
  147707. readonly RGB_INTEGER: number;
  147708. readonly RGBA_INTEGER: number;
  147709. readonly R8_SNORM: number;
  147710. readonly RG8_SNORM: number;
  147711. readonly RGB8_SNORM: number;
  147712. readonly RGBA8_SNORM: number;
  147713. readonly R8I: number;
  147714. readonly RG8I: number;
  147715. readonly RGB8I: number;
  147716. readonly RGBA8I: number;
  147717. readonly R8UI: number;
  147718. readonly RG8UI: number;
  147719. readonly RGB8UI: number;
  147720. readonly RGBA8UI: number;
  147721. readonly R16I: number;
  147722. readonly RG16I: number;
  147723. readonly RGB16I: number;
  147724. readonly RGBA16I: number;
  147725. readonly R16UI: number;
  147726. readonly RG16UI: number;
  147727. readonly RGB16UI: number;
  147728. readonly RGBA16UI: number;
  147729. readonly R32I: number;
  147730. readonly RG32I: number;
  147731. readonly RGB32I: number;
  147732. readonly RGBA32I: number;
  147733. readonly R32UI: number;
  147734. readonly RG32UI: number;
  147735. readonly RGB32UI: number;
  147736. readonly RGBA32UI: number;
  147737. readonly RGB10_A2UI: number;
  147738. readonly R11F_G11F_B10F: number;
  147739. readonly RGB9_E5: number;
  147740. readonly RGB10_A2: number;
  147741. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  147742. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  147743. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  147744. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  147745. readonly DEPTH_COMPONENT32F: number;
  147746. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  147747. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  147748. 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;
  147749. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  147750. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  147751. readonly TRANSFORM_FEEDBACK: number;
  147752. readonly INTERLEAVED_ATTRIBS: number;
  147753. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  147754. createTransformFeedback(): WebGLTransformFeedback;
  147755. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  147756. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  147757. beginTransformFeedback(primitiveMode: number): void;
  147758. endTransformFeedback(): void;
  147759. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  147760. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  147761. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  147762. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  147763. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  147764. }
  147765. interface ImageBitmap {
  147766. readonly width: number;
  147767. readonly height: number;
  147768. close(): void;
  147769. }
  147770. interface WebGLQuery extends WebGLObject {
  147771. }
  147772. declare var WebGLQuery: {
  147773. prototype: WebGLQuery;
  147774. new(): WebGLQuery;
  147775. };
  147776. interface WebGLSampler extends WebGLObject {
  147777. }
  147778. declare var WebGLSampler: {
  147779. prototype: WebGLSampler;
  147780. new(): WebGLSampler;
  147781. };
  147782. interface WebGLSync extends WebGLObject {
  147783. }
  147784. declare var WebGLSync: {
  147785. prototype: WebGLSync;
  147786. new(): WebGLSync;
  147787. };
  147788. interface WebGLTransformFeedback extends WebGLObject {
  147789. }
  147790. declare var WebGLTransformFeedback: {
  147791. prototype: WebGLTransformFeedback;
  147792. new(): WebGLTransformFeedback;
  147793. };
  147794. interface WebGLVertexArrayObject extends WebGLObject {
  147795. }
  147796. declare var WebGLVertexArrayObject: {
  147797. prototype: WebGLVertexArrayObject;
  147798. new(): WebGLVertexArrayObject;
  147799. };
  147800. // Type definitions for WebVR API
  147801. // Project: https://w3c.github.io/webvr/
  147802. // Definitions by: six a <https://github.com/lostfictions>
  147803. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  147804. interface VRDisplay extends EventTarget {
  147805. /**
  147806. * Dictionary of capabilities describing the VRDisplay.
  147807. */
  147808. readonly capabilities: VRDisplayCapabilities;
  147809. /**
  147810. * z-depth defining the far plane of the eye view frustum
  147811. * enables mapping of values in the render target depth
  147812. * attachment to scene coordinates. Initially set to 10000.0.
  147813. */
  147814. depthFar: number;
  147815. /**
  147816. * z-depth defining the near plane of the eye view frustum
  147817. * enables mapping of values in the render target depth
  147818. * attachment to scene coordinates. Initially set to 0.01.
  147819. */
  147820. depthNear: number;
  147821. /**
  147822. * An identifier for this distinct VRDisplay. Used as an
  147823. * association point in the Gamepad API.
  147824. */
  147825. readonly displayId: number;
  147826. /**
  147827. * A display name, a user-readable name identifying it.
  147828. */
  147829. readonly displayName: string;
  147830. readonly isConnected: boolean;
  147831. readonly isPresenting: boolean;
  147832. /**
  147833. * If this VRDisplay supports room-scale experiences, the optional
  147834. * stage attribute contains details on the room-scale parameters.
  147835. */
  147836. readonly stageParameters: VRStageParameters | null;
  147837. /**
  147838. * Passing the value returned by `requestAnimationFrame` to
  147839. * `cancelAnimationFrame` will unregister the callback.
  147840. * @param handle Define the hanle of the request to cancel
  147841. */
  147842. cancelAnimationFrame(handle: number): void;
  147843. /**
  147844. * Stops presenting to the VRDisplay.
  147845. * @returns a promise to know when it stopped
  147846. */
  147847. exitPresent(): Promise<void>;
  147848. /**
  147849. * Return the current VREyeParameters for the given eye.
  147850. * @param whichEye Define the eye we want the parameter for
  147851. * @returns the eye parameters
  147852. */
  147853. getEyeParameters(whichEye: string): VREyeParameters;
  147854. /**
  147855. * Populates the passed VRFrameData with the information required to render
  147856. * the current frame.
  147857. * @param frameData Define the data structure to populate
  147858. * @returns true if ok otherwise false
  147859. */
  147860. getFrameData(frameData: VRFrameData): boolean;
  147861. /**
  147862. * Get the layers currently being presented.
  147863. * @returns the list of VR layers
  147864. */
  147865. getLayers(): VRLayer[];
  147866. /**
  147867. * Return a VRPose containing the future predicted pose of the VRDisplay
  147868. * when the current frame will be presented. The value returned will not
  147869. * change until JavaScript has returned control to the browser.
  147870. *
  147871. * The VRPose will contain the position, orientation, velocity,
  147872. * and acceleration of each of these properties.
  147873. * @returns the pose object
  147874. */
  147875. getPose(): VRPose;
  147876. /**
  147877. * Return the current instantaneous pose of the VRDisplay, with no
  147878. * prediction applied.
  147879. * @returns the current instantaneous pose
  147880. */
  147881. getImmediatePose(): VRPose;
  147882. /**
  147883. * The callback passed to `requestAnimationFrame` will be called
  147884. * any time a new frame should be rendered. When the VRDisplay is
  147885. * presenting the callback will be called at the native refresh
  147886. * rate of the HMD. When not presenting this function acts
  147887. * identically to how window.requestAnimationFrame acts. Content should
  147888. * make no assumptions of frame rate or vsync behavior as the HMD runs
  147889. * asynchronously from other displays and at differing refresh rates.
  147890. * @param callback Define the eaction to run next frame
  147891. * @returns the request handle it
  147892. */
  147893. requestAnimationFrame(callback: FrameRequestCallback): number;
  147894. /**
  147895. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  147896. * Repeat calls while already presenting will update the VRLayers being displayed.
  147897. * @param layers Define the list of layer to present
  147898. * @returns a promise to know when the request has been fulfilled
  147899. */
  147900. requestPresent(layers: VRLayer[]): Promise<void>;
  147901. /**
  147902. * Reset the pose for this display, treating its current position and
  147903. * orientation as the "origin/zero" values. VRPose.position,
  147904. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  147905. * updated when calling resetPose(). This should be called in only
  147906. * sitting-space experiences.
  147907. */
  147908. resetPose(): void;
  147909. /**
  147910. * The VRLayer provided to the VRDisplay will be captured and presented
  147911. * in the HMD. Calling this function has the same effect on the source
  147912. * canvas as any other operation that uses its source image, and canvases
  147913. * created without preserveDrawingBuffer set to true will be cleared.
  147914. * @param pose Define the pose to submit
  147915. */
  147916. submitFrame(pose?: VRPose): void;
  147917. }
  147918. declare var VRDisplay: {
  147919. prototype: VRDisplay;
  147920. new(): VRDisplay;
  147921. };
  147922. interface VRLayer {
  147923. leftBounds?: number[] | Float32Array | null;
  147924. rightBounds?: number[] | Float32Array | null;
  147925. source?: HTMLCanvasElement | null;
  147926. }
  147927. interface VRDisplayCapabilities {
  147928. readonly canPresent: boolean;
  147929. readonly hasExternalDisplay: boolean;
  147930. readonly hasOrientation: boolean;
  147931. readonly hasPosition: boolean;
  147932. readonly maxLayers: number;
  147933. }
  147934. interface VREyeParameters {
  147935. /** @deprecated */
  147936. readonly fieldOfView: VRFieldOfView;
  147937. readonly offset: Float32Array;
  147938. readonly renderHeight: number;
  147939. readonly renderWidth: number;
  147940. }
  147941. interface VRFieldOfView {
  147942. readonly downDegrees: number;
  147943. readonly leftDegrees: number;
  147944. readonly rightDegrees: number;
  147945. readonly upDegrees: number;
  147946. }
  147947. interface VRFrameData {
  147948. readonly leftProjectionMatrix: Float32Array;
  147949. readonly leftViewMatrix: Float32Array;
  147950. readonly pose: VRPose;
  147951. readonly rightProjectionMatrix: Float32Array;
  147952. readonly rightViewMatrix: Float32Array;
  147953. readonly timestamp: number;
  147954. }
  147955. interface VRPose {
  147956. readonly angularAcceleration: Float32Array | null;
  147957. readonly angularVelocity: Float32Array | null;
  147958. readonly linearAcceleration: Float32Array | null;
  147959. readonly linearVelocity: Float32Array | null;
  147960. readonly orientation: Float32Array | null;
  147961. readonly position: Float32Array | null;
  147962. readonly timestamp: number;
  147963. }
  147964. interface VRStageParameters {
  147965. sittingToStandingTransform?: Float32Array;
  147966. sizeX?: number;
  147967. sizeY?: number;
  147968. }
  147969. interface Navigator {
  147970. getVRDisplays(): Promise<VRDisplay[]>;
  147971. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  147972. }
  147973. interface Window {
  147974. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  147975. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  147976. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  147977. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  147978. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  147979. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  147980. }
  147981. interface Gamepad {
  147982. readonly displayId: number;
  147983. }
  147984. type XRSessionMode =
  147985. | "inline"
  147986. | "immersive-vr"
  147987. | "immersive-ar";
  147988. type XRReferenceSpaceType =
  147989. | "viewer"
  147990. | "local"
  147991. | "local-floor"
  147992. | "bounded-floor"
  147993. | "unbounded";
  147994. type XREnvironmentBlendMode =
  147995. | "opaque"
  147996. | "additive"
  147997. | "alpha-blend";
  147998. type XRVisibilityState =
  147999. | "visible"
  148000. | "visible-blurred"
  148001. | "hidden";
  148002. type XRHandedness =
  148003. | "none"
  148004. | "left"
  148005. | "right";
  148006. type XRTargetRayMode =
  148007. | "gaze"
  148008. | "tracked-pointer"
  148009. | "screen";
  148010. type XREye =
  148011. | "none"
  148012. | "left"
  148013. | "right";
  148014. type XREventType =
  148015. | "devicechange"
  148016. | "visibilitychange"
  148017. | "end"
  148018. | "inputsourceschange"
  148019. | "select"
  148020. | "selectstart"
  148021. | "selectend"
  148022. | "squeeze"
  148023. | "squeezestart"
  148024. | "squeezeend"
  148025. | "reset";
  148026. interface XRSpace extends EventTarget {
  148027. }
  148028. interface XRRenderState {
  148029. depthNear?: number;
  148030. depthFar?: number;
  148031. inlineVerticalFieldOfView?: number;
  148032. baseLayer?: XRWebGLLayer;
  148033. }
  148034. interface XRInputSource {
  148035. handedness: XRHandedness;
  148036. targetRayMode: XRTargetRayMode;
  148037. targetRaySpace: XRSpace;
  148038. gripSpace: XRSpace | undefined;
  148039. gamepad: Gamepad | undefined;
  148040. profiles: Array<string>;
  148041. }
  148042. interface XRSessionInit {
  148043. optionalFeatures?: XRReferenceSpaceType[];
  148044. requiredFeatures?: XRReferenceSpaceType[];
  148045. }
  148046. interface XRSession extends XRAnchorCreator {
  148047. addEventListener: Function;
  148048. removeEventListener: Function;
  148049. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  148050. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  148051. requestAnimationFrame: Function;
  148052. end(): Promise<void>;
  148053. renderState: XRRenderState;
  148054. inputSources: Array<XRInputSource>;
  148055. // hit test
  148056. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  148057. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  148058. // legacy AR hit test
  148059. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  148060. // legacy plane detection
  148061. updateWorldTrackingState(options: {
  148062. planeDetectionState?: { enabled: boolean; }
  148063. }): void;
  148064. }
  148065. interface XRReferenceSpace extends XRSpace {
  148066. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  148067. onreset: any;
  148068. }
  148069. type XRPlaneSet = Set<XRPlane>;
  148070. type XRAnchorSet = Set<XRAnchor>;
  148071. interface XRFrame {
  148072. session: XRSession;
  148073. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  148074. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  148075. // AR
  148076. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  148077. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  148078. // Anchors
  148079. trackedAnchors?: XRAnchorSet;
  148080. // Planes
  148081. worldInformation: {
  148082. detectedPlanes?: XRPlaneSet;
  148083. };
  148084. }
  148085. interface XRViewerPose extends XRPose {
  148086. views: Array<XRView>;
  148087. }
  148088. interface XRPose {
  148089. transform: XRRigidTransform;
  148090. emulatedPosition: boolean;
  148091. }
  148092. interface XRWebGLLayerOptions {
  148093. antialias?: boolean;
  148094. depth?: boolean;
  148095. stencil?: boolean;
  148096. alpha?: boolean;
  148097. multiview?: boolean;
  148098. framebufferScaleFactor?: number;
  148099. }
  148100. declare var XRWebGLLayer: {
  148101. prototype: XRWebGLLayer;
  148102. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  148103. };
  148104. interface XRWebGLLayer {
  148105. framebuffer: WebGLFramebuffer;
  148106. framebufferWidth: number;
  148107. framebufferHeight: number;
  148108. getViewport: Function;
  148109. }
  148110. declare class XRRigidTransform {
  148111. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  148112. position: DOMPointReadOnly;
  148113. orientation: DOMPointReadOnly;
  148114. matrix: Float32Array;
  148115. inverse: XRRigidTransform;
  148116. }
  148117. interface XRView {
  148118. eye: XREye;
  148119. projectionMatrix: Float32Array;
  148120. transform: XRRigidTransform;
  148121. }
  148122. interface XRInputSourceChangeEvent {
  148123. session: XRSession;
  148124. removed: Array<XRInputSource>;
  148125. added: Array<XRInputSource>;
  148126. }
  148127. interface XRInputSourceEvent extends Event {
  148128. readonly frame: XRFrame;
  148129. readonly inputSource: XRInputSource;
  148130. }
  148131. // Experimental(er) features
  148132. declare class XRRay {
  148133. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  148134. origin: DOMPointReadOnly;
  148135. direction: DOMPointReadOnly;
  148136. matrix: Float32Array;
  148137. }
  148138. declare enum XRHitTestTrackableType {
  148139. "point",
  148140. "plane"
  148141. }
  148142. interface XRHitResult {
  148143. hitMatrix: Float32Array;
  148144. }
  148145. interface XRTransientInputHitTestResult {
  148146. readonly inputSource: XRInputSource;
  148147. readonly results: Array<XRHitTestResult>;
  148148. }
  148149. interface XRHitTestResult {
  148150. getPose(baseSpace: XRSpace): XRPose | undefined;
  148151. }
  148152. interface XRHitTestSource {
  148153. cancel(): void;
  148154. }
  148155. interface XRTransientInputHitTestSource {
  148156. cancel(): void;
  148157. }
  148158. interface XRHitTestOptionsInit {
  148159. space: XRSpace;
  148160. entityTypes?: Array<XRHitTestTrackableType>;
  148161. offsetRay?: XRRay;
  148162. }
  148163. interface XRTransientInputHitTestOptionsInit {
  148164. profile: string;
  148165. entityTypes?: Array<XRHitTestTrackableType>;
  148166. offsetRay?: XRRay;
  148167. }
  148168. interface XRAnchor {
  148169. // remove?
  148170. id?: string;
  148171. anchorSpace: XRSpace;
  148172. lastChangedTime: number;
  148173. detach(): void;
  148174. }
  148175. interface XRPlane extends XRAnchorCreator {
  148176. orientation: "Horizontal" | "Vertical";
  148177. planeSpace: XRSpace;
  148178. polygon: Array<DOMPointReadOnly>;
  148179. lastChangedTime: number;
  148180. }
  148181. interface XRAnchorCreator {
  148182. // AR Anchors
  148183. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  148184. }